mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
[Refactor] Hold zone views and card view teardown outside game graphics (#7429)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
2335e064ac
commit
edb5caec8a
9 changed files with 84 additions and 39 deletions
|
|
@ -291,6 +291,8 @@ void GameScene::addPlayer(PlayerLogic *player)
|
|||
[this, id = player->getPlayerInfo()->getId()]() { clearArrowsForPlayerLocally(id); });
|
||||
|
||||
connect(player->getPlayerEventHandler(), &PlayerEventHandler::cardZoneChanged, this, &GameScene::onCardZoneChanged);
|
||||
connect(player->getPlayerEventHandler(), &PlayerEventHandler::cardViewRefreshRequested, this,
|
||||
&GameScene::onCardViewRefreshRequested);
|
||||
|
||||
rearrange();
|
||||
}
|
||||
|
|
@ -650,6 +652,25 @@ void GameScene::onCardZoneChanged(CardItem *card, bool sameZone)
|
|||
}
|
||||
}
|
||||
|
||||
void GameScene::onCardViewRefreshRequested(CardState *card, bool zoneChanged, PlayerLogic *newOwner)
|
||||
{
|
||||
auto *item = qobject_cast<CardItem *>(card->parent());
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
if (zoneChanged) {
|
||||
item->deleteCardInfoPopup();
|
||||
}
|
||||
item->deleteDragItem();
|
||||
if (zoneChanged) {
|
||||
item->setBeingPointedAt(false);
|
||||
item->setHovered(false);
|
||||
}
|
||||
if (newOwner) {
|
||||
item->setOwner(newOwner);
|
||||
}
|
||||
}
|
||||
|
||||
void GameScene::clearArrowsForPlayer(int playerId)
|
||||
{
|
||||
for (int arrowId : arrowRegistry.idsForPlayer(playerId)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue