refresh card infos when db finishes loading

This commit is contained in:
RickyRister 2024-12-29 18:00:03 -08:00
parent 53efa113ef
commit 3a9e5e7e4a
2 changed files with 16 additions and 0 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) {

View file

@ -43,6 +43,9 @@ public slots:
void moveAllToZone();
bool showContextMenu(const QPoint &screenPos);
private slots:
void refreshCardInfos();
public:
enum
{