mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
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 <zahalpern+github@gmail.com>
This commit is contained in:
parent
345606846f
commit
0ae7d01234
12 changed files with 330 additions and 259 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -8,6 +8,7 @@
|
|||
#include "../settings/cache_settings.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGridLayout>
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -536,4 +536,4 @@ bool CardDatabase::saveCustomTokensToFile()
|
|||
|
||||
availableParsers.first()->saveToFile(tmpSets, tmpCards, fileName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "cockatrice_xml_4.h"
|
||||
|
||||
#include "../../../settings/cache_settings.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
|
@ -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") {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
<xs:attribute type="xs:anyURI" name="picURL" use="optional" />
|
||||
<xs:attribute type="xs:string" name="num" use="optional" />
|
||||
<xs:attribute type="xs:string" name="rarity" use="optional" />
|
||||
<xs:attribute type="xs:boolean" name="onlineOnly" use="optional" />
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@
|
|||
<context>
|
||||
<name>OracleImporter</name>
|
||||
<message>
|
||||
<location filename="src/oracleimporter.cpp" line="471"/>
|
||||
<location filename="src/oracleimporter.cpp" line="472"/>
|
||||
<source>Dummy set containing tokens</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
|||
|
|
@ -212,7 +212,8 @@ int OracleImporter::importCardsFromSet(const CardSetPtr ¤tSet, const QList
|
|||
};
|
||||
|
||||
// mtgjson name => xml name
|
||||
static const QMap<QString, QString> setInfoProperties{{"number", "num"}, {"rarity", "rarity"}};
|
||||
static const QMap<QString, QString> setInfoProperties{
|
||||
{"number", "num"}, {"rarity", "rarity"}, {"isOnlineOnly", "isOnlineOnly"}};
|
||||
|
||||
// mtgjson name => xml name
|
||||
static const QMap<QString, QString> identifierProperties{{"multiverseId", "muid"}, {"scryfallId", "uuid"}};
|
||||
|
|
|
|||
|
|
@ -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 */)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue