From 34bec790c7eb7469bbe704da9754d022de9b0625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Wed, 27 Nov 2024 23:54:19 +0100 Subject: [PATCH] Add option to disable bumping sets to the front of the list if the deck contains cards from the set. --- .../printing_selector/printing_selector.cpp | 15 +++++++++++---- cockatrice/src/dialogs/dlg_settings.cpp | 18 ++++++++++++------ cockatrice/src/dialogs/dlg_settings.h | 1 + cockatrice/src/settings/cache_settings.cpp | 8 ++++++++ cockatrice/src/settings/cache_settings.h | 7 +++++++ 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp b/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp index de0a808fb..e64dd002b 100644 --- a/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp +++ b/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp @@ -2,6 +2,7 @@ #include "../../../../utility/card_set_comparator.h" #include "printing_selector_card_display_widget.h" +#include "../../../../settings/cache_settings.h" #include #include @@ -306,22 +307,28 @@ void PrintingSelector::getAllSetsForCurrentCard() { const QList sortedSets = sortSets(); const QList filteredSets = filterSets(sortedSets); - const QList prependedSets = prependPrintingsInDeck(filteredSets); + QList setsToUse; + + if (SettingsCache::instance().getBumpSetsWithCardsInDeckToTop()) { + setsToUse = prependPrintingsInDeck(filteredSets); + } else { + setsToUse = filteredSets; + } // Defer widget creation currentIndex = 0; connect(timer, &QTimer::timeout, this, [=]() mutable { - for (int i = 0; i < BATCH_SIZE && currentIndex < prependedSets.size(); ++i, ++currentIndex) { + for (int i = 0; i < BATCH_SIZE && currentIndex < setsToUse.size(); ++i, ++currentIndex) { auto *cardDisplayWidget = new PrintingSelectorCardDisplayWidget(this, deckEditor, deckModel, deckView, cardSizeSlider, - selectedCard, prependedSets[currentIndex], currentZone); + selectedCard, setsToUse[currentIndex], currentZone); flowWidget->addWidget(cardDisplayWidget); cardDisplayWidget->clampSetNameToPicture(); } // Stop timer when done - if (currentIndex >= prependedSets.size()) { + if (currentIndex >= setsToUse.size()) { timer->stop(); } }); diff --git a/cockatrice/src/dialogs/dlg_settings.cpp b/cockatrice/src/dialogs/dlg_settings.cpp index 4ea78c236..7e72a5fab 100644 --- a/cockatrice/src/dialogs/dlg_settings.cpp +++ b/cockatrice/src/dialogs/dlg_settings.cpp @@ -339,8 +339,12 @@ AppearanceSettingsPage::AppearanceSettingsPage() connect(&displayCardNamesCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, &SettingsCache::setDisplayCardNames); overrideAllCardArtWithPersonalPreferenceCheckBox.setChecked(settings.getOverrideAllCardArtWithPersonalPreference()); - connect(&overrideAllCardArtWithPersonalPreferenceCheckBox, SIGNAL(QT_STATE_CHANGED(QT_STATE_CHANGED_T)), &settings, - SLOT(setOverrideAllCardArtWithPersonalPreference(QT_STATE_CHANGED_T))); + connect(&overrideAllCardArtWithPersonalPreferenceCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, + &SettingsCache::setOverrideAllCardArtWithPersonalPreference); + + bumpSetsWithCardsInDeckToTopCheckBox.setChecked(settings.getBumpSetsWithCardsInDeckToTop()); + connect(&bumpSetsWithCardsInDeckToTopCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, + &SettingsCache::setBumpSetsWithCardsInDeckToTop); cardScalingCheckBox.setChecked(settings.getScaleCards()); connect(&cardScalingCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, &SettingsCache::setCardScaling); @@ -359,10 +363,11 @@ AppearanceSettingsPage::AppearanceSettingsPage() cardsGrid->addWidget(&displayCardNamesCheckBox, 0, 0, 1, 2); cardsGrid->addWidget(&cardScalingCheckBox, 1, 0, 1, 2); cardsGrid->addWidget(&overrideAllCardArtWithPersonalPreferenceCheckBox, 2, 0, 1, 2); - cardsGrid->addWidget(&verticalCardOverlapPercentLabel, 2, 0, 1, 1); - cardsGrid->addWidget(&verticalCardOverlapPercentBox, 2, 1, 1, 1); - cardsGrid->addWidget(&cardViewInitialRowsMaxLabel, 3, 0); - cardsGrid->addWidget(&cardViewInitialRowsMaxBox, 3, 1); + cardsGrid->addWidget(&bumpSetsWithCardsInDeckToTopCheckBox, 3, 0, 1, 2); + cardsGrid->addWidget(&verticalCardOverlapPercentLabel, 4, 0, 1, 1); + cardsGrid->addWidget(&verticalCardOverlapPercentBox, 4, 1, 1, 1); + cardsGrid->addWidget(&cardViewInitialRowsMaxLabel, 5, 0); + cardsGrid->addWidget(&cardViewInitialRowsMaxBox, 5, 1); cardsGroupBox = new QGroupBox; cardsGroupBox->setLayout(cardsGrid); @@ -460,6 +465,7 @@ void AppearanceSettingsPage::retranslateUi() overrideAllCardArtWithPersonalPreferenceCheckBox.setText( tr("Override all card art with personal set preference (Pre-ProviderID change behavior) [Requires Client " "restart]")); + bumpSetsWithCardsInDeckToTopCheckBox.setText(tr("Bump sets that the deck contains cards from to the top in the printing selector")); cardScalingCheckBox.setText(tr("Scale cards on mouse over")); verticalCardOverlapPercentLabel.setText( tr("Minimum overlap percentage of cards on the stack and in vertical hand")); diff --git a/cockatrice/src/dialogs/dlg_settings.h b/cockatrice/src/dialogs/dlg_settings.h index ed15d4720..af05d956a 100644 --- a/cockatrice/src/dialogs/dlg_settings.h +++ b/cockatrice/src/dialogs/dlg_settings.h @@ -94,6 +94,7 @@ private: QCheckBox showShortcutsCheckBox; QCheckBox displayCardNamesCheckBox; QCheckBox overrideAllCardArtWithPersonalPreferenceCheckBox; + QCheckBox bumpSetsWithCardsInDeckToTopCheckBox; QCheckBox cardScalingCheckBox; QLabel verticalCardOverlapPercentLabel; QSpinBox verticalCardOverlapPercentBox; diff --git a/cockatrice/src/settings/cache_settings.cpp b/cockatrice/src/settings/cache_settings.cpp index 2f0bd19f9..2cb2d7334 100644 --- a/cockatrice/src/settings/cache_settings.cpp +++ b/cockatrice/src/settings/cache_settings.cpp @@ -244,6 +244,7 @@ SettingsCache::SettingsCache() displayCardNames = settings->value("cards/displaycardnames", true).toBool(); overrideAllCardArtWithPersonalPreference = settings->value("cards/overrideallcardartwithpersonalpreference", false).toBool(); + bumpSetsWithCardsInDeckToTop = settings->value("cards/bumpsetswithcardsindecktotop", true).toBool(); horizontalHand = settings->value("hand/horizontal", true).toBool(); invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool(); minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 4).toInt(); @@ -536,6 +537,13 @@ void SettingsCache::setOverrideAllCardArtWithPersonalPreference(QT_STATE_CHANGED emit overrideAllCardArtWithPersonalPreferenceChanged(); } +void SettingsCache::setBumpSetsWithCardsInDeckToTop(QT_STATE_CHANGED_T _bumpSetsWithCardsInDeckToTop) +{ + bumpSetsWithCardsInDeckToTop = static_cast(_bumpSetsWithCardsInDeckToTop); + settings->setValue("cards/bumpsetswithcardsindecktotop", bumpSetsWithCardsInDeckToTop); + emit bumpSetsWithCardsInDeckToTopChanged(); +} + void SettingsCache::setHorizontalHand(QT_STATE_CHANGED_T _horizontalHand) { horizontalHand = static_cast(_horizontalHand); diff --git a/cockatrice/src/settings/cache_settings.h b/cockatrice/src/settings/cache_settings.h index 1af6b372c..4274ace80 100644 --- a/cockatrice/src/settings/cache_settings.h +++ b/cockatrice/src/settings/cache_settings.h @@ -49,6 +49,7 @@ signals: void picDownloadChanged(); void displayCardNamesChanged(); void overrideAllCardArtWithPersonalPreferenceChanged(); + void bumpSetsWithCardsInDeckToTopChanged(); void horizontalHandChanged(); void handJustificationChanged(); void invertVerticalCoordinateChanged(); @@ -101,6 +102,7 @@ private: bool showShortcuts; bool displayCardNames; bool overrideAllCardArtWithPersonalPreference; + bool bumpSetsWithCardsInDeckToTop; bool horizontalHand; bool invertVerticalCoordinate; int minPlayersForMultiColumnLayout; @@ -305,6 +307,10 @@ public: { return overrideAllCardArtWithPersonalPreference; } + bool getBumpSetsWithCardsInDeckToTop() const + { + return bumpSetsWithCardsInDeckToTop; + } bool getHorizontalHand() const { return horizontalHand; @@ -585,6 +591,7 @@ public slots: void setShowShortcuts(QT_STATE_CHANGED_T _showShortcuts); void setDisplayCardNames(QT_STATE_CHANGED_T _displayCardNames); void setOverrideAllCardArtWithPersonalPreference(QT_STATE_CHANGED_T _overrideAllCardArt); + void setBumpSetsWithCardsInDeckToTop(QT_STATE_CHANGED_T _bumpSetsWithCardsInDeckToTop); void setHorizontalHand(QT_STATE_CHANGED_T _horizontalHand); void setInvertVerticalCoordinate(QT_STATE_CHANGED_T _invertVerticalCoordinate); void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);