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
|
|
@ -71,6 +71,10 @@ CardItem::CardItem(PlayerLogic *_owner,
|
|||
update();
|
||||
});
|
||||
|
||||
// The retyped logic layer drives CardState setters directly (bypassing the CardItem wrappers that called
|
||||
// update()), so repaint on every state change: attacking, annotation, doesntUntap, P/T and counters.
|
||||
connect(state, &CardState::stateChanged, this, [this] { update(); });
|
||||
|
||||
connect(state, &CardState::viewDeleteRequested, this, &CardItem::deleteLater);
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +237,7 @@ void CardItem::setAttachedTo(CardItem *_attachedTo)
|
|||
if (state->getAttachedTo()->getZone() == nullptr) {
|
||||
deleteLater();
|
||||
} else {
|
||||
emit state->getAttachedTo()->getZone()->cardAdded(this);
|
||||
emit state->getAttachedTo()->getZone()->cardAdded(state);
|
||||
state->getAttachedTo()->addAttachedCard(this);
|
||||
if (state->getZone() != state->getAttachedTo()->getZone()) {
|
||||
state->getAttachedTo()->getZone()->reorganizeCards();
|
||||
|
|
@ -245,7 +249,7 @@ void CardItem::setAttachedTo(CardItem *_attachedTo)
|
|||
if (state->getZone() == nullptr) {
|
||||
deleteLater();
|
||||
} else {
|
||||
emit state->getZone()->cardAdded(this);
|
||||
emit state->getZone()->cardAdded(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -467,7 +471,7 @@ void CardItem::handleClickedToPlay(bool shiftHeld)
|
|||
if (SettingsCache::instance().userInterface().getClickPlaysAllSelected()) {
|
||||
emit hideSelected(this);
|
||||
} else {
|
||||
state->getZone()->removeCard(this);
|
||||
state->getZone()->removeCard(state);
|
||||
}
|
||||
} else {
|
||||
playCard(shiftHeld);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue