mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-22 09:35:08 -07:00
Localization wiring now runs end to end: the oracle importer collects
foreignData for the configured language and the client renders it.
- [Oracle] Import localized names and rules texts for the selected cardLang
- single-face cards store their foreignData name and full text
- multi-face (split/adventure/aftermath/prepare) cards collect the joined
name once and join each face's translated text with the same separator
as the English merge; an incomplete translation falls back to English;
the joined text follows the same highest-priority-set policy as the
single-face path and is only collected when localization is enabled
- the wizard switching languages re-imports the card database
- [Client] Display localized card info throughout the client
- card info text/picture widgets and the game board re-render on language
change
- pictures resolve cardLang art through Scryfall's named endpoint using the
localized name, falling back to id-based art when no match exists
- deck editor keeps canonical English names as card identity (EditRole)
while showing localized names (DisplayRole), so decks and wire names
stay stable
- [Card] Add CardLocalization-backed name/text lookup and cards.xml v4
localization elements with a bounded-size translation cache
- [Tests] Cover oracle foreignData import (incl. multi-face joins, priority
and fallback paths), XML v4 localization parsing, deck model localized
display and the language-aware settings default
Existing installations need to re-run Oracle to see translations: localized
data only lands in cards.xml when the Oracle app is started with the
preferred language selected — launch the separate "Oracle" program that
ships with Cockatrice, pick the language in the wizard and let it re-import
the card database.
The client's database cache (cards.xml.cache) is invalidated by the cache
format bump and the source-hash checks, but a cache written before the
re-import can still hold English-only entries (the hash uses file size and
mtime, so a same-size/same-timestamp rewrite may be served as-is); delete
cards.xml.cache and relaunch if no localized names/texts show up after
re-importing.
244 lines
7.4 KiB
C++
244 lines
7.4 KiB
C++
#include "cards_display_settings.h"
|
|
|
|
CardsDisplaySettings::CardsDisplaySettings(const QString &settingPath, QObject *parent)
|
|
: SettingsManager(settingPath + "cards_display.ini", "cards", QString(), parent)
|
|
{
|
|
}
|
|
|
|
bool CardsDisplaySettings::getDisplayCardNames() const
|
|
{
|
|
return getValue("displayCardNames", QString(), QString(), true).toBool();
|
|
}
|
|
|
|
bool CardsDisplaySettings::getRoundCardCorners() const
|
|
{
|
|
return getValue("roundCardCorners", QString(), QString(), true).toBool();
|
|
}
|
|
|
|
bool CardsDisplaySettings::getOverrideAllCardArtWithPersonalPreference() const
|
|
{
|
|
return getValue("overrideAllCardArtWithPersonalPreference", QString(), QString(), false).toBool();
|
|
}
|
|
|
|
bool CardsDisplaySettings::getBumpSetsWithCardsInDeckToTop() const
|
|
{
|
|
return getValue("bumpSetsWithCardsInDeckToTop", QString(), QString(), true).toBool();
|
|
}
|
|
|
|
int CardsDisplaySettings::getPrintingSelectorSortOrder() const
|
|
{
|
|
return getValue("sortOrder", "cards", "printingSelector", 1).toInt();
|
|
}
|
|
|
|
int CardsDisplaySettings::getPrintingSelectorCardSize() const
|
|
{
|
|
return getValue("printingSelector", "cards", "cardSize", 100).toInt();
|
|
}
|
|
|
|
bool CardsDisplaySettings::getIncludeRebalancedCards() const
|
|
{
|
|
return getValue("includerebalancedcards", QString(), QString(), true).toBool();
|
|
}
|
|
|
|
bool CardsDisplaySettings::getPrintingSelectorNavigationButtonsVisible() const
|
|
{
|
|
return getValue("navigationButtonsVisible", "cards", "printingSelector", true).toBool();
|
|
}
|
|
|
|
bool CardsDisplaySettings::getTapAnimation() const
|
|
{
|
|
return getValue("tapAnimation", QString(), QString(), true).toBool();
|
|
}
|
|
|
|
bool CardsDisplaySettings::getArrowDrawAnimation() const
|
|
{
|
|
return getValue("arrowDrawAnimation", QString(), QString(), true).toBool();
|
|
}
|
|
|
|
bool CardsDisplaySettings::getAutoRotateSidewaysLayoutCards() const
|
|
{
|
|
return getValue("autoRotateSidewaysLayoutCards", QString(), QString(), true).toBool();
|
|
}
|
|
|
|
bool CardsDisplaySettings::getScaleCards() const
|
|
{
|
|
return getValue("scaleCards", QString(), QString(), true).toBool();
|
|
}
|
|
|
|
int CardsDisplaySettings::getStackCardOverlapPercent() const
|
|
{
|
|
return getValue("verticalCardOverlapPercent", QString(), QString(), 33).toInt();
|
|
}
|
|
|
|
int CardsDisplaySettings::getCardInfoViewMode() const
|
|
{
|
|
return getValue("cardInfoViewMode", QString(), QString(), 0).toInt();
|
|
}
|
|
|
|
int CardsDisplaySettings::getVisualDeckStorageCardSize() const
|
|
{
|
|
return getValue("visualDeckStorage", "cards", "cardSize", 100).toInt();
|
|
}
|
|
|
|
int CardsDisplaySettings::getVisualDatabaseDisplayCardSize() const
|
|
{
|
|
return getValue("visualDatabaseDisplay", "cards", "cardSize", 100).toInt();
|
|
}
|
|
|
|
int CardsDisplaySettings::getVisualDeckEditorCardSize() const
|
|
{
|
|
return getValue("visualDeckEditor", "cards", "cardSize", 100).toInt();
|
|
}
|
|
|
|
int CardsDisplaySettings::getEDHRecCardSize() const
|
|
{
|
|
return getValue("edhrec", "cards", "cardSize", 100).toInt();
|
|
}
|
|
|
|
int CardsDisplaySettings::getArchidektPreviewSize() const
|
|
{
|
|
return getValue("archidektPreview", "cards", "cardSize", 100).toInt();
|
|
}
|
|
|
|
int CardsDisplaySettings::getSampleHandSize() const
|
|
{
|
|
return getValue("sampleHandSize", "cards", "cardSize", 7).toInt();
|
|
}
|
|
|
|
QString CardsDisplaySettings::getCardLang() const
|
|
{
|
|
return getValue("cardLang", QString(), QString(), "en").toString();
|
|
}
|
|
|
|
void CardsDisplaySettings::setDisplayCardNames(bool _displayCardNames)
|
|
{
|
|
setValue(_displayCardNames, "displayCardNames");
|
|
emit displayCardNamesChanged();
|
|
}
|
|
|
|
void CardsDisplaySettings::setRoundCardCorners(bool _roundCardCorners)
|
|
{
|
|
if (_roundCardCorners == getRoundCardCorners()) {
|
|
return;
|
|
}
|
|
setValue(_roundCardCorners, "roundCardCorners");
|
|
emit roundCardCornersChanged(_roundCardCorners);
|
|
}
|
|
|
|
void CardsDisplaySettings::setOverrideAllCardArtWithPersonalPreference(bool _overrideAllCardArt)
|
|
{
|
|
setValue(_overrideAllCardArt, "overrideAllCardArtWithPersonalPreference");
|
|
emit overrideAllCardArtWithPersonalPreferenceChanged(_overrideAllCardArt);
|
|
}
|
|
|
|
void CardsDisplaySettings::setBumpSetsWithCardsInDeckToTop(bool _bumpSetsWithCardsInDeckToTop)
|
|
{
|
|
setValue(_bumpSetsWithCardsInDeckToTop, "bumpSetsWithCardsInDeckToTop");
|
|
emit bumpSetsWithCardsInDeckToTopChanged();
|
|
}
|
|
|
|
void CardsDisplaySettings::setPrintingSelectorSortOrder(int _printingSelectorSortOrder)
|
|
{
|
|
setValue(_printingSelectorSortOrder, "sortOrder", "cards", "printingSelector");
|
|
emit printingSelectorSortOrderChanged();
|
|
}
|
|
|
|
void CardsDisplaySettings::setPrintingSelectorCardSize(int _printingSelectorCardSize)
|
|
{
|
|
setValue(_printingSelectorCardSize, "printingSelector", "cards", "cardSize");
|
|
emit printingSelectorCardSizeChanged();
|
|
}
|
|
|
|
void CardsDisplaySettings::setIncludeRebalancedCards(bool _includeRebalancedCards)
|
|
{
|
|
if (_includeRebalancedCards == getIncludeRebalancedCards()) {
|
|
return;
|
|
}
|
|
setValue(_includeRebalancedCards, "includerebalancedcards");
|
|
emit includeRebalancedCardsChanged(_includeRebalancedCards);
|
|
}
|
|
|
|
void CardsDisplaySettings::setPrintingSelectorNavigationButtonsVisible(bool _navigationButtonsVisible)
|
|
{
|
|
setValue(_navigationButtonsVisible, "navigationButtonsVisible", "cards", "printingSelector");
|
|
emit printingSelectorNavigationButtonsVisibleChanged();
|
|
}
|
|
|
|
void CardsDisplaySettings::setTapAnimation(bool _tapAnimation)
|
|
{
|
|
setValue(_tapAnimation, "tapAnimation");
|
|
}
|
|
|
|
void CardsDisplaySettings::setArrowDrawAnimation(bool _arrowDrawAnimation)
|
|
{
|
|
setValue(_arrowDrawAnimation, "arrowDrawAnimation");
|
|
}
|
|
|
|
void CardsDisplaySettings::setAutoRotateSidewaysLayoutCards(bool _autoRotateSidewaysLayoutCards)
|
|
{
|
|
setValue(_autoRotateSidewaysLayoutCards, "autoRotateSidewaysLayoutCards");
|
|
}
|
|
|
|
void CardsDisplaySettings::setCardScaling(bool _scaleCards)
|
|
{
|
|
setValue(_scaleCards, "scaleCards");
|
|
}
|
|
|
|
void CardsDisplaySettings::setStackCardOverlapPercent(int _verticalCardOverlapPercent)
|
|
{
|
|
setValue(_verticalCardOverlapPercent, "verticalCardOverlapPercent");
|
|
}
|
|
|
|
void CardsDisplaySettings::setCardInfoViewMode(int _viewMode)
|
|
{
|
|
setValue(_viewMode, "cardInfoViewMode");
|
|
}
|
|
|
|
void CardsDisplaySettings::setVisualDeckStorageCardSize(int _cardSize)
|
|
{
|
|
setValue(_cardSize, "visualDeckStorage", "cards", "cardSize");
|
|
emit visualDeckStorageCardSizeChanged();
|
|
}
|
|
|
|
void CardsDisplaySettings::setVisualDatabaseDisplayCardSize(int _cardSize)
|
|
{
|
|
setValue(_cardSize, "visualDatabaseDisplay", "cards", "cardSize");
|
|
emit visualDatabaseDisplayCardSizeChanged();
|
|
}
|
|
|
|
void CardsDisplaySettings::setVisualDeckEditorCardSize(int _cardSize)
|
|
{
|
|
setValue(_cardSize, "visualDeckEditor", "cards", "cardSize");
|
|
emit visualDeckEditorCardSizeChanged();
|
|
}
|
|
|
|
void CardsDisplaySettings::setEDHRecCardSize(int _edhrecCardSize)
|
|
{
|
|
setValue(_edhrecCardSize, "edhrec", "cards", "cardSize");
|
|
emit edhRecCardSizeChanged();
|
|
}
|
|
|
|
void CardsDisplaySettings::setArchidektPreviewCardSize(int _archidektPreviewCardSize)
|
|
{
|
|
setValue(_archidektPreviewCardSize, "archidektPreview", "cards", "cardSize");
|
|
emit archidektPreviewSizeChanged();
|
|
}
|
|
|
|
void CardsDisplaySettings::setSampleHandSize(int _sampleHandSize)
|
|
{
|
|
setValue(_sampleHandSize, "sampleHandSize", "cards", "cardSize");
|
|
emit sampleHandSizeChanged(_sampleHandSize);
|
|
}
|
|
|
|
void CardsDisplaySettings::setCardLang(const QString &_cardLang)
|
|
{
|
|
if (_cardLang == getCardLang()) {
|
|
return;
|
|
}
|
|
setValue(_cardLang, "cardLang");
|
|
// Flush to disk immediately: the Oracle tool is a separate process that
|
|
// reads this value to decide which foreignData to import, so it must not
|
|
// observe a stale (pre-change) value.
|
|
sync();
|
|
emit cardLangChanged(_cardLang);
|
|
}
|