mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 01:53:25 -08:00
[Refactor] Add card name, printing id, and color to CardState (#7433)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
edb5caec8a
commit
5d0d466930
4 changed files with 35 additions and 8 deletions
|
|
@ -20,6 +20,12 @@ void CardState::resetState(bool keepAnnotations)
|
||||||
emit stateReset();
|
emit stateReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardState::setColor(const QString &_color)
|
||||||
|
{
|
||||||
|
color = _color;
|
||||||
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void CardState::deleteView()
|
void CardState::deleteView()
|
||||||
{
|
{
|
||||||
emit viewDeleteRequested();
|
emit viewDeleteRequested();
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ private:
|
||||||
QString pt;
|
QString pt;
|
||||||
bool doesntUntap = false;
|
bool doesntUntap = false;
|
||||||
bool destroyOnZoneChange = false;
|
bool destroyOnZoneChange = false;
|
||||||
|
QString color;
|
||||||
|
|
||||||
CardState *attachedTo = nullptr;
|
CardState *attachedTo = nullptr;
|
||||||
QList<CardItem *> attachedCards;
|
QList<CardItem *> attachedCards;
|
||||||
|
|
@ -46,6 +47,7 @@ signals:
|
||||||
void tappedChanged(bool newTapped, bool canAnimate);
|
void tappedChanged(bool newTapped, bool canAnimate);
|
||||||
void facedownChanged(bool newFaceDown);
|
void facedownChanged(bool newFaceDown);
|
||||||
void stateReset();
|
void stateReset();
|
||||||
|
void colorChanged();
|
||||||
|
|
||||||
void attackingChanged(bool newValue);
|
void attackingChanged(bool newValue);
|
||||||
void countersChanged(const QMap<int, int> &newCounters);
|
void countersChanged(const QMap<int, int> &newCounters);
|
||||||
|
|
@ -92,6 +94,16 @@ public:
|
||||||
|
|
||||||
void setCardRef(const CardRef &_cardRef);
|
void setCardRef(const CardRef &_cardRef);
|
||||||
|
|
||||||
|
QString getName() const
|
||||||
|
{
|
||||||
|
return cardRef.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getProviderId() const
|
||||||
|
{
|
||||||
|
return cardRef.providerId;
|
||||||
|
}
|
||||||
|
|
||||||
ExactCard getCard() const
|
ExactCard getCard() const
|
||||||
{
|
{
|
||||||
return exactCard;
|
return exactCard;
|
||||||
|
|
@ -186,6 +198,13 @@ public:
|
||||||
*/
|
*/
|
||||||
static QVariantList parsePT(const QString &pt);
|
static QVariantList parsePT(const QString &pt);
|
||||||
|
|
||||||
|
[[nodiscard]] QString getColor() const
|
||||||
|
{
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setColor(const QString &_color);
|
||||||
|
|
||||||
bool getDoesntUntap() const
|
bool getDoesntUntap() const
|
||||||
{
|
{
|
||||||
return doesntUntap;
|
return doesntUntap;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,10 @@ AbstractCardItem::AbstractCardItem(QGraphicsItem *parent, const CardRef &cardRef
|
||||||
connect(state, &CardState::cardRefChanged, this, &AbstractCardItem::onCardRefChanged);
|
connect(state, &CardState::cardRefChanged, this, &AbstractCardItem::onCardRefChanged);
|
||||||
connect(state, &CardState::tappedChanged, this, &AbstractCardItem::onTappedChanged);
|
connect(state, &CardState::tappedChanged, this, &AbstractCardItem::onTappedChanged);
|
||||||
connect(state, &CardState::facedownChanged, this, [this] { update(); });
|
connect(state, &CardState::facedownChanged, this, [this] { update(); });
|
||||||
|
connect(state, &CardState::colorChanged, this, [this] {
|
||||||
|
cacheBgColor();
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
|
||||||
connect(&SettingsCache::instance().cardsDisplay(), &CardsDisplaySettings::displayCardNamesChanged, this,
|
connect(&SettingsCache::instance().cardsDisplay(), &CardsDisplaySettings::displayCardNamesChanged, this,
|
||||||
[this] { update(); });
|
[this] { update(); });
|
||||||
|
|
@ -265,18 +269,17 @@ void AbstractCardItem::setHovered(bool _hovered)
|
||||||
|
|
||||||
void AbstractCardItem::setColor(const QString &_color)
|
void AbstractCardItem::setColor(const QString &_color)
|
||||||
{
|
{
|
||||||
color = _color;
|
state->setColor(_color);
|
||||||
cacheBgColor();
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractCardItem::cacheBgColor()
|
void AbstractCardItem::cacheBgColor()
|
||||||
{
|
{
|
||||||
QChar colorChar;
|
QChar colorChar;
|
||||||
if (color.isEmpty()) {
|
const QString cardColor = state->getColor();
|
||||||
|
if (cardColor.isEmpty()) {
|
||||||
colorChar = state->getCardInfo().getColorChar();
|
colorChar = state->getCardInfo().getColorChar();
|
||||||
} else {
|
} else {
|
||||||
colorChar = color.at(0);
|
colorChar = cardColor.at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (colorChar.toLower().toLatin1()) {
|
switch (colorChar.toLower().toLatin1()) {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ class AbstractCardItem : public ArrowTarget, public IAnimatedItem
|
||||||
protected:
|
protected:
|
||||||
CardState *state;
|
CardState *state;
|
||||||
int tapAngle;
|
int tapAngle;
|
||||||
QString color;
|
|
||||||
QColor bgColor;
|
QColor bgColor;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -114,9 +113,9 @@ public:
|
||||||
{
|
{
|
||||||
return isHovered;
|
return isHovered;
|
||||||
}
|
}
|
||||||
QString getColor() const
|
[[nodiscard]] QString getColor() const
|
||||||
{
|
{
|
||||||
return color;
|
return state->getColor();
|
||||||
}
|
}
|
||||||
void setColor(const QString &_color);
|
void setColor(const QString &_color);
|
||||||
bool getTapped() const
|
bool getTapped() const
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue