mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 02:13:02 -07:00
[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:
parent
6e92d53c54
commit
987ebcaa35
1 changed files with 19 additions and 11 deletions
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue