mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-22 18:32:17 -07:00
Support multiple <set> tags per card within the database
This will allow us to show off all different printings for cards that might appear multiple times in a set (alt arts, Secret Lairs, etc.)
This commit is contained in:
parent
7ae1349ac8
commit
db53066d89
12 changed files with 159 additions and 152 deletions
|
|
@ -32,20 +32,24 @@ PictureToLoad::PictureToLoad(CardInfoPtr _card)
|
|||
: card(std::move(_card)), urlTemplates(SettingsCache::instance().downloads().getAllURLs())
|
||||
{
|
||||
if (card) {
|
||||
for (const auto &set : card->getSets()) {
|
||||
sortedSets << set.getPtr();
|
||||
for (const auto &x : card->getSets()) {
|
||||
for (const auto &set : x) {
|
||||
sortedSets << set.getPtr();
|
||||
}
|
||||
}
|
||||
if (sortedSets.empty()) {
|
||||
sortedSets << CardSet::newInstance("", "", "", QDate());
|
||||
}
|
||||
std::sort(sortedSets.begin(), sortedSets.end(), SetDownloadPriorityComparator());
|
||||
// If the pixmapCacheKey corresponds to a specific set, we have to try to load it first.
|
||||
for (const auto &set : card->getSets()) {
|
||||
if (QLatin1String("card_") + card->getName() + QString("_") + QString(set.getProperty("uuid")) ==
|
||||
card->getPixmapCacheKey()) {
|
||||
long long setIndex = sortedSets.indexOf(set.getPtr());
|
||||
CardSetPtr setForCardProviderID = sortedSets.takeAt(setIndex);
|
||||
sortedSets.prepend(setForCardProviderID);
|
||||
for (const auto &x : card->getSets()) {
|
||||
for (const auto &set : x) {
|
||||
if (QLatin1String("card_") + card->getName() + QString("_") + QString(set.getProperty("uuid")) ==
|
||||
card->getPixmapCacheKey()) {
|
||||
long long setIndex = sortedSets.indexOf(set.getPtr());
|
||||
CardSetPtr setForCardProviderID = sortedSets.takeAt(setIndex);
|
||||
sortedSets.prepend(setForCardProviderID);
|
||||
}
|
||||
}
|
||||
}
|
||||
// The first time called, nextSet will also populate the Urls for the first set.
|
||||
|
|
|
|||
|
|
@ -167,9 +167,11 @@ CardInfoPerSet PrintingSelector::getSetForUUID(const QString &uuid)
|
|||
{
|
||||
CardInfoPerSetMap cardInfoPerSets = selectedCard->getSets();
|
||||
|
||||
for (const auto &cardInfoPerSet : cardInfoPerSets) {
|
||||
if (cardInfoPerSet.getProperty("uuid") == uuid) {
|
||||
return cardInfoPerSet;
|
||||
for (const auto &x : cardInfoPerSets) {
|
||||
for (const auto &cardInfoPerSet : x) {
|
||||
if (cardInfoPerSet.getProperty("uuid") == uuid) {
|
||||
return cardInfoPerSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,15 +184,18 @@ QList<CardInfoPerSet> PrintingSelector::prependPrintingsInDeck(const QList<CardI
|
|||
QList<QPair<CardInfoPerSet, int>> countList;
|
||||
|
||||
// Collect sets with their counts
|
||||
for (const auto &cardInfoPerSet : cardInfoPerSets) {
|
||||
QModelIndex find_card =
|
||||
deckModel->findCard(selectedCard->getName(), DECK_ZONE_MAIN, cardInfoPerSet.getProperty("uuid"));
|
||||
if (find_card.isValid()) {
|
||||
int count =
|
||||
deckModel->data(find_card, Qt::DisplayRole).toInt(); // Ensure the count is treated as an integer
|
||||
if (count > 0) {
|
||||
countList.append(qMakePair(cardInfoPerSet, count));
|
||||
for (const auto &x : cardInfoPerSets) {
|
||||
for (const auto &cardInfoPerSet : x) {
|
||||
QModelIndex find_card =
|
||||
deckModel->findCard(selectedCard->getName(), DECK_ZONE_MAIN, cardInfoPerSet.getProperty("uuid"));
|
||||
if (find_card.isValid()) {
|
||||
int count =
|
||||
deckModel->data(find_card, Qt::DisplayRole).toInt(); // Ensure the count is treated as an integer
|
||||
if (count > 0) {
|
||||
countList.append(qMakePair(cardInfoPerSet, count));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -226,8 +231,11 @@ QList<CardInfoPerSet> PrintingSelector::sortSets()
|
|||
|
||||
QList<CardSetPtr> sortedSets;
|
||||
|
||||
for (const auto &set : cardInfoPerSets) {
|
||||
sortedSets << set.getPtr();
|
||||
for (const auto &x : cardInfoPerSets) {
|
||||
for (const auto &set : x) {
|
||||
sortedSets << set.getPtr();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sortedSets.empty()) {
|
||||
|
|
@ -244,8 +252,11 @@ QList<CardInfoPerSet> PrintingSelector::sortSets()
|
|||
// Reconstruct sorted list of CardInfoPerSet
|
||||
for (const auto &set : sortedSets) {
|
||||
for (auto it = cardInfoPerSets.begin(); it != cardInfoPerSets.end(); ++it) {
|
||||
if (it.value().getPtr() == set) {
|
||||
sortedCardInfoPerSets << it.value();
|
||||
for (const auto &x : it.value()) {
|
||||
if (x.getPtr() == set) {
|
||||
sortedCardInfoPerSets << it.value();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue