From 0ae7d01234d1d797d9427bb5644b9077b5f2a50a Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Sat, 22 Mar 2025 06:07:42 +0100 Subject: [PATCH] Hide arena only cards (#5759) * Add settings (default: true) to ignore online-only cards * Use QAbstractButton::toggled Also, fix dbconverter build * Mocks mocks mocks * Update dlg_manage_sets.cpp * translations * Update dlg_manage_sets.cpp --------- Co-authored-by: Zach H --- cockatrice/cockatrice_en@source.ts | 526 +++++++++--------- cockatrice/src/dialogs/dlg_manage_sets.cpp | 17 +- cockatrice/src/dialogs/dlg_manage_sets.h | 2 + cockatrice/src/game/cards/card_database.cpp | 2 +- .../card_database_parser/cockatrice_xml_4.cpp | 15 +- cockatrice/src/settings/cache_settings.cpp | 8 + cockatrice/src/settings/cache_settings.h | 7 + dbconverter/src/mocks.cpp | 3 + doc/carddatabase_v4/cards.xsd | 1 + oracle/oracle_en@source.ts | 2 +- oracle/src/oracleimporter.cpp | 3 +- tests/carddatabase/mocks.cpp | 3 + 12 files changed, 330 insertions(+), 259 deletions(-) diff --git a/cockatrice/cockatrice_en@source.ts b/cockatrice/cockatrice_en@source.ts index 8be7525f4..be95b2f58 100644 --- a/cockatrice/cockatrice_en@source.ts +++ b/cockatrice/cockatrice_en@source.ts @@ -59,8 +59,8 @@ Do you want to save the changes? - - + + Error @@ -92,13 +92,13 @@ Please check that the directory is writable and try again. - + There are no cards in your deck to be exported - - No deck was selected to be saved. + + No deck was selected to be exported. @@ -845,104 +845,109 @@ This is only saved for moderators and cannot be seen by the banned person. DeckEditorMenu - + &Deck Editor - + &New deck - + &Load deck... - + Load recent deck... - + Clear - + &Save deck - + Save deck &as... - + Load deck from cl&ipboard... - + Edit deck in clipboard - - + + Annotated - + Not Annotated - + Save deck to clipboard - + Annotated (No set info) - + Not Annotated (No set info) - + &Print deck... - + &Send deck to online service - + Create decklist (decklist.org) - + + Create decklist (decklist.xyz) + + + + Analyze deck (deckstats.net) - + Analyze deck (tappedout.net) - + &Close @@ -1179,8 +1184,7 @@ This is only saved for moderators and cannot be seen by the banned person. DeckPreviewDeckTagsDisplayWidget - - + Edit tags ... @@ -2344,37 +2348,37 @@ Make sure to enable the 'Token' set in the "Manage sets" dia DlgMoveTopCardsUntil - + Card name (or search expressions): - + Number of hits: - + Auto play hits - + Put top cards on stack until... - + No cards matching the search expression exists in the card database. Proceed anyways? - + Cockatrice - + Invalid filter @@ -4876,9 +4880,9 @@ Cockatrice will now reload the card database. - - - + + + Number of cards: (max. %1) @@ -5320,12 +5324,12 @@ Cockatrice will now reload the card database. - + Which position should this card be placed: - + (max. %1) @@ -5345,8 +5349,8 @@ Cockatrice will now reload the card database. - - + + Number: @@ -5441,78 +5445,78 @@ Cockatrice will now reload the card database. - + Move bottom cards to grave - + Move bottom cards to exile - + Draw bottom cards - - + + C&reate another %1 token - + Create tokens - + Place card X cards from top of library - + Change power/toughness - + Change stats to: - + Set annotation - + Please enter the new annotation: - + Set counters - + Re&veal to... - + View related cards - + Token: - + All tokens @@ -7882,128 +7886,133 @@ Please refrain from engaging in this activity or further actions may be taken ag WndSets - + Move selected set to the top - + Move selected set up - + Move selected set down - + Move selected set to the bottom - + Search by set name, code, or type - + Default order - + Restore original art priority order - + Enable all sets - + Disable all sets - + Enable selected set(s) - + Disable selected set(s) - + Deck Editor - + Use CTRL+A to select all sets in the view. - + Only cards in enabled sets will appear in the card list of the deck editor. - + Image priority is decided in the following order: - + first the CUSTOM Folder (%1), then the Enabled Sets in this dialog (Top to Bottom) %1 is a link to the wiki - + Card Art - + How to use custom card art - + Hints - + Note - + Sorting by column allows you to find a set while not changing set priority. - + To enable ordering again, click the column header until this message disappears. - + Use the current sorting as the set priority instead - + Sorts the set priority using the same column - + + Include online-only (Arena) cards [requires restart] + + + + Manage sets @@ -8106,7 +8115,7 @@ Please refrain from engaging in this activity or further actions may be taken ag - + Deck Editor @@ -8187,7 +8196,7 @@ Please refrain from engaging in this activity or further actions may be taken ag - + Replays @@ -8243,752 +8252,763 @@ Please refrain from engaging in this activity or further actions may be taken ag - Analyze Deck + Analyze Deck (deckstats.net) + Analyze Deck - + + Analyze Deck (tappedout.net) + + + + Clear All Filters - + Clear Selected Filter - + Close - + Remove Card - + Manage Sets... - + Edit Custom Tokens... - - Export Deck + + Export Deck (decklist.org) - + + Export Deck (decklist.xyz) + + + + Add Card - + Load Deck... - + Load Deck from Clipboard... - + Edit Deck in Clipboard, Annotated - + Edit Deck in Clipboard - + New Deck - + Open Custom Pictures Folder - + Print Deck... - + Delete Card - - + + Reset Layout - + Save Deck - + Save Deck as... - + Save Deck to Clipboard, Annotated - + Save Deck to Clipboard, Annotated (No Set Info) - + Save Deck to Clipboard - + Save Deck to Clipboard (No Set Info) - + Load Local Deck... - + Load Remote Deck... - + Set Ready to Start - + Toggle Sideboard Lock - - + + Add Green Counter - - + + Remove Green Counter - - + + Set Green Counters... - + Add Yellow Counter - + Remove Yellow Counter - + Set Yellow Counters... - - + + Add Red Counter - - + + Remove Red Counter - - + + Set Red Counters... - + Add Life Counter - + Remove Life Counter - + Set Life Counters... - + Add White Counter - + Remove White Counter - + Set White Counters... - + Add Blue Counter - + Remove Blue Counter - + Set Blue Counters... - + Add Black Counter - + Remove Black Counter - + Set Black Counters... - + Add Colorless Counter - + Remove Colorless Counter - + Set Colorless Counters... - + Add Other Counter - + Remove Other Counter - + Set Other Counters... - + Add Power (+1/+0) - + Remove Power (-1/-0) - + Move Toughness to Power (+1/-1) - + Add Toughness (+0/+1) - + Remove Toughness (-0/-1) - + Move Power to Toughness (-1/+1) - + Add Power and Toughness (+1/+1) - + Remove Power and Toughness (-1/-1) - + Set Power and Toughness... - + Reset Power and Toughness - + Untap - + Upkeep - + Draw - + First Main Phase - + Start Combat - + Attack - + Block - + Damage - + End Combat - + Second Main Phase - + End - + Next Phase - + Next Phase Action - + Next Turn - + Hide Card in Reveal Window - + Tap / Untap Card - + Untap All - + Toggle Untap - + Turn Card Over - + Peek Card - + Play Card - + Attach Card... - + Unattach Card - + Clone Card - + Create Token... - + Create All Related Tokens - + Create Another Token - + Set Annotation... - + Select All Cards in Zone - + Select All Cards in Row - + Select All Cards in Column - - + + Bottom of Library - - - - + + + + Exile - - - - + + + + Graveyard - - + + Hand - - + + Top of Library - - - + + + Battlefield, Face Down - + Battlefield - + Library - + Sideboard - + Top Cards of Library - + Bottom Cards of Library - + Close Recent View - - + + Stack - - + + Graveyard (Multiple) - - + + Exile (Multiple) - + Stack Until Found - + Draw Bottom Card - + Draw Multiple Cards from Bottom... - + Draw Arrow... - + Remove Local Arrows - + Leave Game - + Concede - + Roll Dice... - + Shuffle Library - + Shuffle Top Cards of Library - + Shuffle Bottom Cards of Library - + Mulligan - + Draw a Card - + Draw Multiple Cards... - + Undo Draw - + Always Reveal Top Card - + Always Look At Top Card - + Rotate View Clockwise - + Rotate View Counterclockwise - + Unfocus Text Box - + Focus Chat - + Clear Chat - + Refresh - + Skip Forward - + Skip Backward - + Skip Forward by a lot - + Skip Backward by a lot - + Play/Pause - + Toggle Fast Forward - + Visual Deck Storage - + Deck Storage - + Server - + Account - + Administration - + Logs diff --git a/cockatrice/src/dialogs/dlg_manage_sets.cpp b/cockatrice/src/dialogs/dlg_manage_sets.cpp index ab82b9b65..626abd43f 100644 --- a/cockatrice/src/dialogs/dlg_manage_sets.cpp +++ b/cockatrice/src/dialogs/dlg_manage_sets.cpp @@ -8,6 +8,7 @@ #include "../settings/cache_settings.h" #include +#include #include #include #include @@ -162,6 +163,11 @@ WndSets::WndSets(QWidget *parent) : QMainWindow(parent) sortWarning->setLayout(sortWarningLayout); sortWarning->setVisible(false); + includeOnlineOnlyCards = SettingsCache::instance().getIncludeOnlineOnlyCards(); + QCheckBox *onlineOnly = new QCheckBox(tr("Include online-only (Arena) cards [requires restart]")); + onlineOnly->setChecked(includeOnlineOnlyCards); + connect(onlineOnly, &QAbstractButton::toggled, this, &WndSets::includeOnlineOnlyCardsChanged); + buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), this, SLOT(actSave())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(actRestore())); @@ -175,8 +181,9 @@ WndSets::WndSets(QWidget *parent) : QMainWindow(parent) mainLayout->addWidget(enableSomeButton, 2, 1); mainLayout->addWidget(disableSomeButton, 2, 2); mainLayout->addWidget(sortWarning, 3, 1, 1, 2); - mainLayout->addWidget(hintsGroupBox, 4, 1, 1, 2); - mainLayout->addWidget(buttonBox, 5, 1, 1, 2); + mainLayout->addWidget(onlineOnly, 4, 1, 1, 2); + mainLayout->addWidget(hintsGroupBox, 5, 1, 1, 2); + mainLayout->addWidget(buttonBox, 6, 1, 1, 2); mainLayout->setColumnStretch(1, 1); mainLayout->setColumnStretch(2, 1); @@ -239,9 +246,15 @@ void WndSets::rebuildMainLayout(int actionToTake) } } +void WndSets::includeOnlineOnlyCardsChanged(bool _includeOnlineOnlyCards) +{ + includeOnlineOnlyCards = _includeOnlineOnlyCards; +} + void WndSets::actSave() { model->save(CardDatabaseManager::getInstance()); + SettingsCache::instance().setIncludeOnlineOnlyCards(includeOnlineOnlyCards); PictureLoader::clearPixmapCache(); close(); } diff --git a/cockatrice/src/dialogs/dlg_manage_sets.h b/cockatrice/src/dialogs/dlg_manage_sets.h index e974f67f9..13dea7fef 100644 --- a/cockatrice/src/dialogs/dlg_manage_sets.h +++ b/cockatrice/src/dialogs/dlg_manage_sets.h @@ -44,6 +44,7 @@ private: void saveHeaderState(); void rebuildMainLayout(int actionToTake); bool setOrderIsSorted; + bool includeOnlineOnlyCards; enum { NO_SETS_SELECTED, @@ -73,6 +74,7 @@ private slots: void actDisableResetButton(const QString &filterText); void actSort(int index); void actIgnoreWarning(); + void includeOnlineOnlyCardsChanged(bool _includeOnlineOnlyCardsChanged); }; #endif diff --git a/cockatrice/src/game/cards/card_database.cpp b/cockatrice/src/game/cards/card_database.cpp index b22bc2891..0fe43e20a 100644 --- a/cockatrice/src/game/cards/card_database.cpp +++ b/cockatrice/src/game/cards/card_database.cpp @@ -536,4 +536,4 @@ bool CardDatabase::saveCustomTokensToFile() availableParsers.first()->saveToFile(tmpSets, tmpCards, fileName); return true; -} \ No newline at end of file +} diff --git a/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_4.cpp b/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_4.cpp index e7f657b96..827b70fc3 100644 --- a/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_4.cpp +++ b/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_4.cpp @@ -1,5 +1,7 @@ #include "cockatrice_xml_4.h" +#include "../../../settings/cache_settings.h" + #include #include #include @@ -124,6 +126,7 @@ QVariantHash CockatriceXml4Parser::loadCardPropertiesFromXml(QXmlStreamReader &x void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml) { + bool includeOnlineOnlyCards = SettingsCache::instance().getIncludeOnlineOnlyCards(); while (!xml.atEnd()) { if (xml.readNext() == QXmlStreamReader::EndElement) { break; @@ -183,7 +186,17 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml) attrName = "picurl"; setInfo.setProperty(attrName, attr.value().toString()); } - _sets[setName].append(setInfo); + + // This is very much a hack and not the right place to + // put this check, as it requires a reload of Cockatrice + // to be apply. + // + // However, this is also true of the `set->getEnabled()` + // check above (which is currently bugged as well), so + // we'll fix both at the same time. + if (includeOnlineOnlyCards || setInfo.getProperty("isOnlineOnly") != "true") { + _sets[setName].append(setInfo); + } } // related cards } else if (xmlName == "related" || xmlName == "reverse-related") { diff --git a/cockatrice/src/settings/cache_settings.cpp b/cockatrice/src/settings/cache_settings.cpp index bd88a8a3f..52e6af104 100644 --- a/cockatrice/src/settings/cache_settings.cpp +++ b/cockatrice/src/settings/cache_settings.cpp @@ -259,6 +259,7 @@ SettingsCache::SettingsCache() bumpSetsWithCardsInDeckToTop = settings->value("cards/bumpsetswithcardsindecktotop", true).toBool(); printingSelectorSortOrder = settings->value("cards/printingselectorsortorder", 1).toInt(); printingSelectorCardSize = settings->value("cards/printingselectorcardsize", 100).toInt(); + includeOnlineOnlyCards = settings->value("cards/includeonlineonlycards", false).toBool(); printingSelectorNavigationButtonsVisible = settings->value("cards/printingselectornavigationbuttonsvisible", true).toBool(); visualDeckStorageCardSize = settings->value("interface/visualdeckstoragecardsize", 100).toInt(); @@ -654,6 +655,13 @@ void SettingsCache::setPrintingSelectorCardSize(int _printingSelectorCardSize) emit printingSelectorCardSizeChanged(); } +void SettingsCache::setIncludeOnlineOnlyCards(bool _includeOnlineOnlyCards) +{ + includeOnlineOnlyCards = _includeOnlineOnlyCards; + settings->setValue("cards/includeonlineonlycards", includeOnlineOnlyCards); + emit includeOnlineOnlyCardsChanged(includeOnlineOnlyCards); +} + void SettingsCache::setPrintingSelectorNavigationButtonsVisible(QT_STATE_CHANGED_T _navigationButtonsVisible) { printingSelectorNavigationButtonsVisible = _navigationButtonsVisible; diff --git a/cockatrice/src/settings/cache_settings.h b/cockatrice/src/settings/cache_settings.h index 771b2663c..5986b07a7 100644 --- a/cockatrice/src/settings/cache_settings.h +++ b/cockatrice/src/settings/cache_settings.h @@ -58,6 +58,7 @@ signals: void bumpSetsWithCardsInDeckToTopChanged(); void printingSelectorSortOrderChanged(); void printingSelectorCardSizeChanged(); + void includeOnlineOnlyCardsChanged(bool _includeOnlineOnlyCards); void printingSelectorNavigationButtonsVisibleChanged(); void visualDeckStorageShowTagFilterChanged(bool _visible); void visualDeckStorageShowBannerCardComboBoxChanged(bool _visible); @@ -128,6 +129,7 @@ private: bool bumpSetsWithCardsInDeckToTop; int printingSelectorSortOrder; int printingSelectorCardSize; + bool includeOnlineOnlyCards; bool printingSelectorNavigationButtonsVisible; int visualDeckStorageSortingOrder; bool visualDeckStorageShowFolders; @@ -401,6 +403,10 @@ public: { return printingSelectorCardSize; } + bool getIncludeOnlineOnlyCards() const + { + return includeOnlineOnlyCards; + } bool getPrintingSelectorNavigationButtonsVisible() const { return printingSelectorNavigationButtonsVisible; @@ -774,6 +780,7 @@ public slots: void setBumpSetsWithCardsInDeckToTop(QT_STATE_CHANGED_T _bumpSetsWithCardsInDeckToTop); void setPrintingSelectorSortOrder(int _printingSelectorSortOrder); void setPrintingSelectorCardSize(int _printingSelectorCardSize); + void setIncludeOnlineOnlyCards(bool _includeOnlineOnlyCards); void setPrintingSelectorNavigationButtonsVisible(QT_STATE_CHANGED_T _navigationButtonsVisible); void setVisualDeckStorageSortingOrder(int _visualDeckStorageSortingOrder); void setVisualDeckStorageShowFolders(QT_STATE_CHANGED_T value); diff --git a/dbconverter/src/mocks.cpp b/dbconverter/src/mocks.cpp index e2f6ed4df..06889d2b3 100644 --- a/dbconverter/src/mocks.cpp +++ b/dbconverter/src/mocks.cpp @@ -199,6 +199,9 @@ void SettingsCache::setPrintingSelectorSortOrder(int /* _printingSelectorSortOrd void SettingsCache::setPrintingSelectorCardSize(int /* _printingSelectorCardSize */) { } +void SettingsCache::setIncludeOnlineOnlyCards(bool /* _includeOnlineOnlyCards */) +{ +} void SettingsCache::setPrintingSelectorNavigationButtonsVisible(QT_STATE_CHANGED_T /* _navigationButtonsVisible */) { } diff --git a/doc/carddatabase_v4/cards.xsd b/doc/carddatabase_v4/cards.xsd index 00ed72555..6c5eb9bda 100644 --- a/doc/carddatabase_v4/cards.xsd +++ b/doc/carddatabase_v4/cards.xsd @@ -28,6 +28,7 @@ + diff --git a/oracle/oracle_en@source.ts b/oracle/oracle_en@source.ts index 7c085344a..301de42e3 100644 --- a/oracle/oracle_en@source.ts +++ b/oracle/oracle_en@source.ts @@ -271,7 +271,7 @@ OracleImporter - + Dummy set containing tokens diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index 360423394..4187c4c9f 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -212,7 +212,8 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet, const QList }; // mtgjson name => xml name - static const QMap setInfoProperties{{"number", "num"}, {"rarity", "rarity"}}; + static const QMap setInfoProperties{ + {"number", "num"}, {"rarity", "rarity"}, {"isOnlineOnly", "isOnlineOnly"}}; // mtgjson name => xml name static const QMap identifierProperties{{"multiverseId", "muid"}, {"scryfallId", "uuid"}}; diff --git a/tests/carddatabase/mocks.cpp b/tests/carddatabase/mocks.cpp index f399179c3..78b95cc1c 100644 --- a/tests/carddatabase/mocks.cpp +++ b/tests/carddatabase/mocks.cpp @@ -203,6 +203,9 @@ void SettingsCache::setPrintingSelectorSortOrder(int /* _printingSelectorSortOrd void SettingsCache::setPrintingSelectorCardSize(int /* _printingSelectorCardSize */) { } +void SettingsCache::setIncludeOnlineOnlyCards(bool /* _includeOnlineOnlyCards */) +{ +} void SettingsCache::setPrintingSelectorNavigationButtonsVisible(QT_STATE_CHANGED_T /* _navigationButtonsVisible */) { }