mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33: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();
|
||||
}
|
||||
|
||||
void CardState::setColor(const QString &_color)
|
||||
{
|
||||
color = _color;
|
||||
emit colorChanged();
|
||||
}
|
||||
|
||||
void CardState::deleteView()
|
||||
{
|
||||
emit viewDeleteRequested();
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ private:
|
|||
QString pt;
|
||||
bool doesntUntap = false;
|
||||
bool destroyOnZoneChange = false;
|
||||
QString color;
|
||||
|
||||
CardState *attachedTo = nullptr;
|
||||
QList<CardItem *> attachedCards;
|
||||
|
|
@ -46,6 +47,7 @@ signals:
|
|||
void tappedChanged(bool newTapped, bool canAnimate);
|
||||
void facedownChanged(bool newFaceDown);
|
||||
void stateReset();
|
||||
void colorChanged();
|
||||
|
||||
void attackingChanged(bool newValue);
|
||||
void countersChanged(const QMap<int, int> &newCounters);
|
||||
|
|
@ -92,6 +94,16 @@ public:
|
|||
|
||||
void setCardRef(const CardRef &_cardRef);
|
||||
|
||||
QString getName() const
|
||||
{
|
||||
return cardRef.name;
|
||||
}
|
||||
|
||||
QString getProviderId() const
|
||||
{
|
||||
return cardRef.providerId;
|
||||
}
|
||||
|
||||
ExactCard getCard() const
|
||||
{
|
||||
return exactCard;
|
||||
|
|
@ -186,6 +198,13 @@ public:
|
|||
*/
|
||||
static QVariantList parsePT(const QString &pt);
|
||||
|
||||
[[nodiscard]] QString getColor() const
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
void setColor(const QString &_color);
|
||||
|
||||
bool getDoesntUntap() const
|
||||
{
|
||||
return doesntUntap;
|
||||
|
|
|
|||
|
|
@ -54,6 +54,10 @@ AbstractCardItem::AbstractCardItem(QGraphicsItem *parent, const CardRef &cardRef
|
|||
connect(state, &CardState::cardRefChanged, this, &AbstractCardItem::onCardRefChanged);
|
||||
connect(state, &CardState::tappedChanged, this, &AbstractCardItem::onTappedChanged);
|
||||
connect(state, &CardState::facedownChanged, this, [this] { update(); });
|
||||
connect(state, &CardState::colorChanged, this, [this] {
|
||||
cacheBgColor();
|
||||
update();
|
||||
});
|
||||
|
||||
connect(&SettingsCache::instance().cardsDisplay(), &CardsDisplaySettings::displayCardNamesChanged, this,
|
||||
[this] { update(); });
|
||||
|
|
@ -265,18 +269,17 @@ void AbstractCardItem::setHovered(bool _hovered)
|
|||
|
||||
void AbstractCardItem::setColor(const QString &_color)
|
||||
{
|
||||
color = _color;
|
||||
cacheBgColor();
|
||||
update();
|
||||
state->setColor(_color);
|
||||
}
|
||||
|
||||
void AbstractCardItem::cacheBgColor()
|
||||
{
|
||||
QChar colorChar;
|
||||
if (color.isEmpty()) {
|
||||
const QString cardColor = state->getColor();
|
||||
if (cardColor.isEmpty()) {
|
||||
colorChar = state->getCardInfo().getColorChar();
|
||||
} else {
|
||||
colorChar = color.at(0);
|
||||
colorChar = cardColor.at(0);
|
||||
}
|
||||
|
||||
switch (colorChar.toLower().toLatin1()) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ class AbstractCardItem : public ArrowTarget, public IAnimatedItem
|
|||
protected:
|
||||
CardState *state;
|
||||
int tapAngle;
|
||||
QString color;
|
||||
QColor bgColor;
|
||||
|
||||
private:
|
||||
|
|
@ -114,9 +113,9 @@ public:
|
|||
{
|
||||
return isHovered;
|
||||
}
|
||||
QString getColor() const
|
||||
[[nodiscard]] QString getColor() const
|
||||
{
|
||||
return color;
|
||||
return state->getColor();
|
||||
}
|
||||
void setColor(const QString &_color);
|
||||
bool getTapped() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue