mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 03:53:56 -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);
|
setCacheMode(DeviceCoordinateCache);
|
||||||
|
|
||||||
connect(&SettingsCache::instance(), SIGNAL(displayCardNamesChanged()), this, SLOT(callUpdate()));
|
connect(&SettingsCache::instance(), SIGNAL(displayCardNamesChanged()), this, SLOT(callUpdate()));
|
||||||
cardInfoUpdated();
|
refreshCardInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractCardItem::~AbstractCardItem()
|
AbstractCardItem::~AbstractCardItem()
|
||||||
|
|
@ -51,7 +51,7 @@ void AbstractCardItem::pixmapUpdated()
|
||||||
emit sigPixmapUpdated();
|
emit sigPixmapUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractCardItem::cardInfoUpdated()
|
void AbstractCardItem::refreshCardInfo()
|
||||||
{
|
{
|
||||||
info = CardDatabaseManager::getInstance()->getCardByNameAndProviderId(name, providerId);
|
info = CardDatabaseManager::getInstance()->getCardByNameAndProviderId(name, providerId);
|
||||||
|
|
||||||
|
|
@ -185,7 +185,7 @@ void AbstractCardItem::setName(const QString &_name)
|
||||||
disconnect(info.data(), nullptr, this, nullptr);
|
disconnect(info.data(), nullptr, this, nullptr);
|
||||||
name = _name;
|
name = _name;
|
||||||
|
|
||||||
cardInfoUpdated();
|
refreshCardInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractCardItem::setProviderId(const QString &_providerId)
|
void AbstractCardItem::setProviderId(const QString &_providerId)
|
||||||
|
|
@ -200,7 +200,7 @@ void AbstractCardItem::setProviderId(const QString &_providerId)
|
||||||
}
|
}
|
||||||
providerId = _providerId;
|
providerId = _providerId;
|
||||||
|
|
||||||
cardInfoUpdated();
|
refreshCardInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractCardItem::setHovered(bool _hovered)
|
void AbstractCardItem::setHovered(bool _hovered)
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,14 @@ private:
|
||||||
qreal realZValue;
|
qreal realZValue;
|
||||||
private slots:
|
private slots:
|
||||||
void pixmapUpdated();
|
void pixmapUpdated();
|
||||||
void cardInfoUpdated();
|
|
||||||
void callUpdate()
|
void callUpdate()
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void refreshCardInfo();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void hovered(AbstractCardItem *card);
|
void hovered(AbstractCardItem *card);
|
||||||
void showCardInfoPopup(const QPoint &pos, const QString &cardName, const QString &providerId);
|
void showCardInfoPopup(const QPoint &pos, const QString &cardName, const QString &providerId);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "card_zone.h"
|
#include "card_zone.h"
|
||||||
|
|
||||||
|
#include "../cards/card_database_manager.h"
|
||||||
#include "../cards/card_item.h"
|
#include "../cards/card_item.h"
|
||||||
#include "../player/player.h"
|
#include "../player/player.h"
|
||||||
#include "pb/command_move_card.pb.h"
|
#include "pb/command_move_card.pb.h"
|
||||||
|
|
@ -31,6 +32,11 @@ CardZone::CardZone(Player *_p,
|
||||||
{
|
{
|
||||||
if (!isView)
|
if (!isView)
|
||||||
player->addZone(this);
|
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()
|
CardZone::~CardZone()
|
||||||
|
|
@ -119,6 +125,13 @@ bool CardZone::showContextMenu(const QPoint &screenPos)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardZone::refreshCardInfos()
|
||||||
|
{
|
||||||
|
for (const auto &cardItem : cards) {
|
||||||
|
cardItem->refreshCardInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CardZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void CardZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::RightButton) {
|
if (event->button() == Qt::RightButton) {
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,9 @@ public slots:
|
||||||
void moveAllToZone();
|
void moveAllToZone();
|
||||||
bool showContextMenu(const QPoint &screenPos);
|
bool showContextMenu(const QPoint &screenPos);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void refreshCardInfos();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue