Add option to disable bumping sets to the front of the list if the deck contains cards from the set.

This commit is contained in:
Lukas Brübach 2024-11-27 23:54:19 +01:00 committed by ZeldaZach
parent 3195a5ab68
commit 34bec790c7
No known key found for this signature in database
5 changed files with 39 additions and 10 deletions

View file

@ -2,6 +2,7 @@
#include "../../../../utility/card_set_comparator.h"
#include "printing_selector_card_display_widget.h"
#include "../../../../settings/cache_settings.h"
#include <QComboBox>
#include <QDebug>
@ -306,22 +307,28 @@ void PrintingSelector::getAllSetsForCurrentCard()
{
const QList<CardInfoPerSet> sortedSets = sortSets();
const QList<CardInfoPerSet> filteredSets = filterSets(sortedSets);
const QList<CardInfoPerSet> prependedSets = prependPrintingsInDeck(filteredSets);
QList<CardInfoPerSet> 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();
}
});

View file

@ -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"));

View file

@ -94,6 +94,7 @@ private:
QCheckBox showShortcutsCheckBox;
QCheckBox displayCardNamesCheckBox;
QCheckBox overrideAllCardArtWithPersonalPreferenceCheckBox;
QCheckBox bumpSetsWithCardsInDeckToTopCheckBox;
QCheckBox cardScalingCheckBox;
QLabel verticalCardOverlapPercentLabel;
QSpinBox verticalCardOverlapPercentBox;

View file

@ -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<bool>(_bumpSetsWithCardsInDeckToTop);
settings->setValue("cards/bumpsetswithcardsindecktotop", bumpSetsWithCardsInDeckToTop);
emit bumpSetsWithCardsInDeckToTopChanged();
}
void SettingsCache::setHorizontalHand(QT_STATE_CHANGED_T _horizontalHand)
{
horizontalHand = static_cast<bool>(_horizontalHand);

View file

@ -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);