mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 19:13:25 -08:00
[Refactor] Retype card containers and zone logic onto CardState (#7434)
* [Refactor] Retype card containers and zone logic onto CardState * [Game] Restore attach bookkeeping via CardItem and repaint on state change * [Refactor] Give custom zones a hidden graphics owner Custom PileZoneLogic zones had no CardZone, so moving a card into one left the CardItem drawn at its old spot. Create a hidden PileZone in onCustomZoneAdded so cards are reparented and hidden. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
5d0d466930
commit
65e9f1b370
33 changed files with 232 additions and 159 deletions
|
|
@ -37,17 +37,26 @@ void CardZone::invalidateItems()
|
|||
const QList<CardItem *> &CardZone::cardItems() const
|
||||
{
|
||||
if (itemsDirty) {
|
||||
items = getLogic()->getCards();
|
||||
items.clear();
|
||||
for (auto *cardState : getLogic()->getCards()) {
|
||||
if (auto *cardItem = qobject_cast<CardItem *>(cardState->parent())) {
|
||||
items.append(cardItem);
|
||||
}
|
||||
}
|
||||
itemsDirty = false;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
void CardZone::onCardAdded(CardItem *addedCard)
|
||||
void CardZone::onCardAdded(CardState *addedCard)
|
||||
{
|
||||
addedCard->setParentItem(this);
|
||||
addedCard->setVisible(true);
|
||||
addedCard->update();
|
||||
auto *addedItem = addedCard == nullptr ? nullptr : qobject_cast<CardItem *>(addedCard->parent());
|
||||
if (addedItem == nullptr) {
|
||||
return;
|
||||
}
|
||||
addedItem->setParentItem(this);
|
||||
addedItem->setVisible(true);
|
||||
addedItem->update();
|
||||
}
|
||||
|
||||
void CardZone::retranslateUi()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue