fix cards having the wrong printing if rejoin game before card db finishes loading (#5390)

* rename cardInfoUpdated to refreshCardInfo and make it public

* refresh card infos when db finishes loading
This commit is contained in:
RickyRister 2024-12-29 19:25:11 -08:00 committed by GitHub
parent d231264a16
commit b6793a5e01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 5 deletions

View file

@ -1,5 +1,6 @@
#include "card_zone.h"
#include "../cards/card_database_manager.h"
#include "../cards/card_item.h"
#include "../player/player.h"
#include "pb/command_move_card.pb.h"
@ -31,6 +32,11 @@ CardZone::CardZone(Player *_p,
{
if (!isView)
player->addZone(this);
// If we join a game before the card db finishes loading, the cards might have the wrong printings.
// Force refresh all cards in the zone when db finishes loading to fix that.
connect(CardDatabaseManager::getInstance(), &CardDatabase::cardDatabaseLoadingFinished, this,
&CardZone::refreshCardInfos);
}
CardZone::~CardZone()
@ -119,6 +125,13 @@ bool CardZone::showContextMenu(const QPoint &screenPos)
return false;
}
void CardZone::refreshCardInfos()
{
for (const auto &cardItem : cards) {
cardItem->refreshCardInfo();
}
}
void CardZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::RightButton) {