From 71b01e6110a6642d709a3dc38a24bdc458f49523 Mon Sep 17 00:00:00 2001 From: Zach H Date: Wed, 18 Dec 2024 22:52:34 -0500 Subject: [PATCH] ADD landscapeOrientation field (#5267) --- cockatrice/src/dialogs/dlg_edit_tokens.cpp | 2 +- cockatrice/src/game/cards/abstract_card_item.cpp | 2 +- cockatrice/src/game/cards/card_database.cpp | 8 +++++--- cockatrice/src/game/cards/card_database.h | 11 +++++++++-- .../cards/card_database_parser/cockatrice_xml_3.cpp | 11 +++++++++-- .../cards/card_database_parser/cockatrice_xml_4.cpp | 3 +++ oracle/src/oracleimporter.cpp | 6 +++++- 7 files changed, 33 insertions(+), 10 deletions(-) diff --git a/cockatrice/src/dialogs/dlg_edit_tokens.cpp b/cockatrice/src/dialogs/dlg_edit_tokens.cpp index 884c1c225..208e9fe80 100644 --- a/cockatrice/src/dialogs/dlg_edit_tokens.cpp +++ b/cockatrice/src/dialogs/dlg_edit_tokens.cpp @@ -165,7 +165,7 @@ void DlgEditTokens::actAddToken() CardInfoPerSetMap sets; sets[setName].append(CardInfoPerSet(databaseModel->getDatabase()->getSet(setName))); CardInfoPtr card = CardInfo::newInstance(name, "", true, QVariantHash(), QList(), - QList(), sets, false, -1, false); + QList(), sets, false, false, -1, false); card->setCardType("Token"); databaseModel->getDatabase()->addCard(card); diff --git a/cockatrice/src/game/cards/abstract_card_item.cpp b/cockatrice/src/game/cards/abstract_card_item.cpp index 80da703a7..a8a2375f3 100644 --- a/cockatrice/src/game/cards/abstract_card_item.cpp +++ b/cockatrice/src/game/cards/abstract_card_item.cpp @@ -59,7 +59,7 @@ void AbstractCardItem::cardInfoUpdated() QVariantHash properties = QVariantHash(); info = CardInfo::newInstance(name, "", true, QVariantHash(), QList(), QList(), - CardInfoPerSetMap(), false, -1, false); + CardInfoPerSetMap(), false, false, -1, false); } if (info.data()) { connect(info.data(), SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated())); diff --git a/cockatrice/src/game/cards/card_database.cpp b/cockatrice/src/game/cards/card_database.cpp index 3e58440fd..dd9173fdc 100644 --- a/cockatrice/src/game/cards/card_database.cpp +++ b/cockatrice/src/game/cards/card_database.cpp @@ -234,11 +234,12 @@ CardInfo::CardInfo(const QString &_name, const QList &_reverseRelatedCards, CardInfoPerSetMap _sets, bool _cipt, + bool _landscapeOrientation, int _tableRow, bool _upsideDownArt) : name(_name), text(_text), isToken(_isToken), properties(std::move(_properties)), relatedCards(_relatedCards), - reverseRelatedCards(_reverseRelatedCards), sets(std::move(_sets)), cipt(_cipt), tableRow(_tableRow), - upsideDownArt(_upsideDownArt) + reverseRelatedCards(_reverseRelatedCards), sets(std::move(_sets)), cipt(_cipt), + landscapeOrientation(_landscapeOrientation), tableRow(_tableRow), upsideDownArt(_upsideDownArt) { pixmapCacheKey = QLatin1String("card_") + name; simpleName = CardInfo::simplifyName(name); @@ -259,11 +260,12 @@ CardInfoPtr CardInfo::newInstance(const QString &_name, const QList &_reverseRelatedCards, CardInfoPerSetMap _sets, bool _cipt, + bool _landscapeOrientation, int _tableRow, bool _upsideDownArt) { CardInfoPtr ptr(new CardInfo(_name, _text, _isToken, std::move(_properties), _relatedCards, _reverseRelatedCards, - _sets, _cipt, _tableRow, _upsideDownArt)); + _sets, _cipt, _landscapeOrientation, _tableRow, _upsideDownArt)); ptr->setSmartPointer(ptr); for (const auto &cardInfoPerSetList : _sets) { diff --git a/cockatrice/src/game/cards/card_database.h b/cockatrice/src/game/cards/card_database.h index 78d573d99..018c30512 100644 --- a/cockatrice/src/game/cards/card_database.h +++ b/cockatrice/src/game/cards/card_database.h @@ -197,6 +197,7 @@ private: QString setsNames; // positioning properties; used by UI bool cipt; + bool landscapeOrientation; int tableRow; bool upsideDownArt; @@ -209,14 +210,15 @@ public: const QList &_reverseRelatedCards = QList(), CardInfoPerSetMap _sets = CardInfoPerSetMap(), bool _cipt = false, + bool _landscapeOrientation = false, int _tableRow = 0, bool _upsideDownArt = false); CardInfo(const CardInfo &other) : QObject(other.parent()), name(other.name), simpleName(other.simpleName), pixmapCacheKey(other.pixmapCacheKey), text(other.text), isToken(other.isToken), properties(other.properties), relatedCards(other.relatedCards), reverseRelatedCards(other.reverseRelatedCards), reverseRelatedCardsToMe(other.reverseRelatedCardsToMe), - sets(other.sets), setsNames(other.setsNames), cipt(other.cipt), tableRow(other.tableRow), - upsideDownArt(other.upsideDownArt) + sets(other.sets), setsNames(other.setsNames), cipt(other.cipt), + landscapeOrientation(other.landscapeOrientation), tableRow(other.tableRow), upsideDownArt(other.upsideDownArt) { } ~CardInfo() override; @@ -229,6 +231,7 @@ public: const QList &_reverseRelatedCards = QList(), CardInfoPerSetMap _sets = CardInfoPerSetMap(), bool _cipt = false, + bool _landscapeOrientation = false, int _tableRow = 0, bool _upsideDownArt = false); @@ -348,6 +351,10 @@ public: { return cipt; } + bool getLandscapeOrientation() const + { + return landscapeOrientation; + } int getTableRow() const { return tableRow; diff --git a/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_3.cpp b/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_3.cpp index 52f284cc2..c27ce732d 100644 --- a/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_3.cpp +++ b/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_3.cpp @@ -158,6 +158,7 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml) auto _sets = CardInfoPerSetMap(); int tableRow = 0; bool cipt = false; + bool landscapeOrientation = false; bool isToken = false; bool upsideDown = false; @@ -194,6 +195,8 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml) tableRow = xml.readElementText(QXmlStreamReader::IncludeChildElements).toInt(); } else if (xmlName == "cipt") { cipt = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1"); + } else if (xmlName == "landscapeOrientation") { + landscapeOrientation = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1"); } else if (xmlName == "upsidedown") { upsideDown = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1"); // sets @@ -267,8 +270,9 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml) } properties.insert("colors", colors); - CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards, - reverseRelatedCards, _sets, cipt, tableRow, upsideDown); + CardInfoPtr newCard = + CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards, _sets, cipt, + landscapeOrientation, tableRow, upsideDown); emit addCard(newCard); } } @@ -405,6 +409,9 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in if (info->getCipt()) { xml.writeTextElement("cipt", "1"); } + if (info->getLandscapeOrientation()) { + xml.writeTextElement("landscapeOrientation", "1"); + } if (info->getUpsideDownArt()) { xml.writeTextElement("upsidedown", "1"); } diff --git a/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_4.cpp b/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_4.cpp index c6c3921f7..b29ef1cb8 100644 --- a/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_4.cpp +++ b/cockatrice/src/game/cards/card_database_parser/cockatrice_xml_4.cpp @@ -353,6 +353,9 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in if (info->getCipt()) { xml.writeTextElement("cipt", "1"); } + if (info->getLandscapeOrientation()) { + xml.writeTextElement("landscapeOrientation", "1"); + } if (info->getUpsideDownArt()) { xml.writeTextElement("upsidedown", "1"); } diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index 1e1d41c14..26cd652c8 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -156,6 +156,10 @@ CardInfoPtr OracleImporter::addCard(QString name, ") enters( the battlefield)? tapped(?! unless)"); bool cipt = ciptRegex.match(text).hasMatch(); + bool landscapeOrientation = properties.value("maintype").toString() == "Battle" || + properties.value("layout").toString() == "split" || + properties.value("layout").toString() == "planar"; + // table row int tableRow = 1; QString mainCardType = properties.value("maintype").toString(); @@ -179,7 +183,7 @@ CardInfoPtr OracleImporter::addCard(QString name, CardInfoPerSetMap setsInfo; setsInfo[setInfo.getPtr()->getShortName()].append(setInfo); CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards, - setsInfo, cipt, tableRow, upsideDown); + setsInfo, cipt, landscapeOrientation, tableRow, upsideDown); if (name.isEmpty()) { qDebug() << "warning: an empty card was added to set" << setInfo.getPtr()->getShortName();