[Game] Render custom deck zones in the deck view

The in-game deck view now walks custom zones like the standard
boards, so cards filed under a user-created zone show up in their
zone's card pile instead of disappearing from the view.
This commit is contained in:
Lukas Brübach 2026-08-24 07:29:58 +02:00 committed by GitHub
parent 334515b8ad
commit 9e6672c2b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QtMath> #include <QtMath>
#include <algorithm> #include <algorithm>
#include <functional>
#include <libcockatrice/card/card_info.h> #include <libcockatrice/card/card_info.h>
#include <libcockatrice/deck_list/deck_list.h> #include <libcockatrice/deck_list/deck_list.h>
#include <libcockatrice/deck_list/tree/deck_list_card_node.h> #include <libcockatrice/deck_list/tree/deck_list_card_node.h>
@ -381,18 +382,25 @@ void DeckViewScene::rebuildTree()
addItem(container); addItem(container);
} }
for (int j = 0; j < currentZone->size(); j++) { // Cards in custom zones nested under a board are regular board cards in-game.
auto *currentCard = dynamic_cast<DecklistCardNode *>(currentZone->at(j)); // They are collected recursively and reported with the top-level board zone
if (!currentCard) { // as their origin, so that sideboard plans keep working.
continue; std::function<void(const InnerDecklistNode *)> addZoneCards = [&addZoneCards, container, currentZone,
this](const InnerDecklistNode *zone) {
for (int j = 0; j < zone->size(); j++) {
auto *currentCard = dynamic_cast<DecklistCardNode *>(zone->at(j));
if (currentCard) {
for (int k = 0; k < currentCard->getNumber(); ++k) {
auto *newCard = new DeckViewCard(container, currentCard->toCardRef(), currentZone->getName());
container->addCard(newCard);
emit newCardAdded(newCard);
}
} else if (auto *innerZone = dynamic_cast<InnerDecklistNode *>(zone->at(j))) {
addZoneCards(innerZone);
}
} }
};
for (int k = 0; k < currentCard->getNumber(); ++k) { addZoneCards(currentZone);
auto *newCard = new DeckViewCard(container, currentCard->toCardRef(), currentZone->getName());
container->addCard(newCard);
emit newCardAdded(newCard);
}
}
} }
} }