mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[Refactor] Move the active card from AbstractGame into GameScene (#7416)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
94b91be5a2
commit
4972ebcb97
6 changed files with 26 additions and 20 deletions
|
|
@ -67,9 +67,10 @@ CardItem::CardItem(PlayerLogic *_owner,
|
|||
void CardItem::prepareDelete()
|
||||
{
|
||||
if (owner != nullptr) {
|
||||
if (owner->getGame()->getActiveCard() == this) {
|
||||
auto *gameScene = qobject_cast<GameScene *>(scene());
|
||||
if (gameScene && gameScene->getActiveCard() == this) {
|
||||
emit owner->requestCardMenuUpdate(nullptr);
|
||||
owner->getGame()->setActiveCard(nullptr);
|
||||
gameScene->setActiveCard(nullptr);
|
||||
}
|
||||
owner = nullptr;
|
||||
}
|
||||
|
|
@ -567,7 +568,9 @@ QVariant CardItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
|||
bool selected = value.toBool();
|
||||
|
||||
if (selected) {
|
||||
owner->getGame()->setActiveCard(this);
|
||||
if (auto *gameScene = qobject_cast<GameScene *>(scene())) {
|
||||
gameScene->setActiveCard(this);
|
||||
}
|
||||
}
|
||||
|
||||
emit selectionChanged(this, selected);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue