mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
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:
parent
d231264a16
commit
b6793a5e01
4 changed files with 24 additions and 5 deletions
|
|
@ -25,7 +25,7 @@ AbstractCardItem::AbstractCardItem(QGraphicsItem *parent,
|
|||
setCacheMode(DeviceCoordinateCache);
|
||||
|
||||
connect(&SettingsCache::instance(), SIGNAL(displayCardNamesChanged()), this, SLOT(callUpdate()));
|
||||
cardInfoUpdated();
|
||||
refreshCardInfo();
|
||||
}
|
||||
|
||||
AbstractCardItem::~AbstractCardItem()
|
||||
|
|
@ -51,7 +51,7 @@ void AbstractCardItem::pixmapUpdated()
|
|||
emit sigPixmapUpdated();
|
||||
}
|
||||
|
||||
void AbstractCardItem::cardInfoUpdated()
|
||||
void AbstractCardItem::refreshCardInfo()
|
||||
{
|
||||
info = CardDatabaseManager::getInstance()->getCardByNameAndProviderId(name, providerId);
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ void AbstractCardItem::setName(const QString &_name)
|
|||
disconnect(info.data(), nullptr, this, nullptr);
|
||||
name = _name;
|
||||
|
||||
cardInfoUpdated();
|
||||
refreshCardInfo();
|
||||
}
|
||||
|
||||
void AbstractCardItem::setProviderId(const QString &_providerId)
|
||||
|
|
@ -200,7 +200,7 @@ void AbstractCardItem::setProviderId(const QString &_providerId)
|
|||
}
|
||||
providerId = _providerId;
|
||||
|
||||
cardInfoUpdated();
|
||||
refreshCardInfo();
|
||||
}
|
||||
|
||||
void AbstractCardItem::setHovered(bool _hovered)
|
||||
|
|
|
|||
|
|
@ -28,11 +28,14 @@ private:
|
|||
qreal realZValue;
|
||||
private slots:
|
||||
void pixmapUpdated();
|
||||
void cardInfoUpdated();
|
||||
void callUpdate()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
public slots:
|
||||
void refreshCardInfo();
|
||||
|
||||
signals:
|
||||
void hovered(AbstractCardItem *card);
|
||||
void showCardInfoPopup(const QPoint &pos, const QString &cardName, const QString &providerId);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ public slots:
|
|||
void moveAllToZone();
|
||||
bool showContextMenu(const QPoint &screenPos);
|
||||
|
||||
private slots:
|
||||
void refreshCardInfos();
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue