mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 01:53:25 -08:00
[Refactor] Move the attachment graph and card view teardown onto CardState (#7428)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
47c90cda10
commit
2335e064ac
7 changed files with 54 additions and 19 deletions
|
|
@ -65,12 +65,13 @@ CardItem::CardItem(PlayerLogic *_owner,
|
|||
});
|
||||
|
||||
connect(state, &CardState::stateReset, this, [this] {
|
||||
attachedCards.clear();
|
||||
if (scene()) {
|
||||
static_cast<GameScene *>(scene())->unregisterAnimationItem(this);
|
||||
}
|
||||
update();
|
||||
});
|
||||
|
||||
connect(state, &CardState::viewDeleteRequested, this, &CardItem::deleteLater);
|
||||
}
|
||||
|
||||
void CardItem::prepareDelete()
|
||||
|
|
@ -84,6 +85,7 @@ void CardItem::prepareDelete()
|
|||
owner = nullptr;
|
||||
}
|
||||
|
||||
const QList<CardItem *> &attachedCards = state->getAttachedCards();
|
||||
while (!attachedCards.isEmpty()) {
|
||||
attachedCards.first()->setZone(nullptr); // so that it won't try to call reorganizeCards()
|
||||
attachedCards.first()->setAttachedTo(nullptr);
|
||||
|
|
@ -224,7 +226,7 @@ void CardItem::setAttachedTo(CardItem *_attachedTo)
|
|||
}
|
||||
|
||||
state->setGridPoint(QPoint(-1, state->getGridPoint().y()));
|
||||
state->setAttachedTo(_attachedTo);
|
||||
state->setAttachedTo(_attachedTo == nullptr ? nullptr : _attachedTo->getState());
|
||||
if (state->getAttachedTo() != nullptr) {
|
||||
// If the zone is being torn down, it might already be null by the time a card tries to un-attach all its
|
||||
// attached cards
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue