ADD landscapeOrientation field (#5267)

This commit is contained in:
Zach H 2024-12-18 22:52:34 -05:00 committed by GitHub
parent c716f85962
commit 71b01e6110
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 33 additions and 10 deletions

View file

@ -165,7 +165,7 @@ void DlgEditTokens::actAddToken()
CardInfoPerSetMap sets; CardInfoPerSetMap sets;
sets[setName].append(CardInfoPerSet(databaseModel->getDatabase()->getSet(setName))); sets[setName].append(CardInfoPerSet(databaseModel->getDatabase()->getSet(setName)));
CardInfoPtr card = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(), CardInfoPtr card = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(),
QList<CardRelation *>(), sets, false, -1, false); QList<CardRelation *>(), sets, false, false, -1, false);
card->setCardType("Token"); card->setCardType("Token");
databaseModel->getDatabase()->addCard(card); databaseModel->getDatabase()->addCard(card);

View file

@ -59,7 +59,7 @@ void AbstractCardItem::cardInfoUpdated()
QVariantHash properties = QVariantHash(); QVariantHash properties = QVariantHash();
info = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(), QList<CardRelation *>(), info = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(), QList<CardRelation *>(),
CardInfoPerSetMap(), false, -1, false); CardInfoPerSetMap(), false, false, -1, false);
} }
if (info.data()) { if (info.data()) {
connect(info.data(), SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated())); connect(info.data(), SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated()));

View file

@ -234,11 +234,12 @@ CardInfo::CardInfo(const QString &_name,
const QList<CardRelation *> &_reverseRelatedCards, const QList<CardRelation *> &_reverseRelatedCards,
CardInfoPerSetMap _sets, CardInfoPerSetMap _sets,
bool _cipt, bool _cipt,
bool _landscapeOrientation,
int _tableRow, int _tableRow,
bool _upsideDownArt) bool _upsideDownArt)
: name(_name), text(_text), isToken(_isToken), properties(std::move(_properties)), relatedCards(_relatedCards), : name(_name), text(_text), isToken(_isToken), properties(std::move(_properties)), relatedCards(_relatedCards),
reverseRelatedCards(_reverseRelatedCards), sets(std::move(_sets)), cipt(_cipt), tableRow(_tableRow), reverseRelatedCards(_reverseRelatedCards), sets(std::move(_sets)), cipt(_cipt),
upsideDownArt(_upsideDownArt) landscapeOrientation(_landscapeOrientation), tableRow(_tableRow), upsideDownArt(_upsideDownArt)
{ {
pixmapCacheKey = QLatin1String("card_") + name; pixmapCacheKey = QLatin1String("card_") + name;
simpleName = CardInfo::simplifyName(name); simpleName = CardInfo::simplifyName(name);
@ -259,11 +260,12 @@ CardInfoPtr CardInfo::newInstance(const QString &_name,
const QList<CardRelation *> &_reverseRelatedCards, const QList<CardRelation *> &_reverseRelatedCards,
CardInfoPerSetMap _sets, CardInfoPerSetMap _sets,
bool _cipt, bool _cipt,
bool _landscapeOrientation,
int _tableRow, int _tableRow,
bool _upsideDownArt) bool _upsideDownArt)
{ {
CardInfoPtr ptr(new CardInfo(_name, _text, _isToken, std::move(_properties), _relatedCards, _reverseRelatedCards, CardInfoPtr ptr(new CardInfo(_name, _text, _isToken, std::move(_properties), _relatedCards, _reverseRelatedCards,
_sets, _cipt, _tableRow, _upsideDownArt)); _sets, _cipt, _landscapeOrientation, _tableRow, _upsideDownArt));
ptr->setSmartPointer(ptr); ptr->setSmartPointer(ptr);
for (const auto &cardInfoPerSetList : _sets) { for (const auto &cardInfoPerSetList : _sets) {

View file

@ -197,6 +197,7 @@ private:
QString setsNames; QString setsNames;
// positioning properties; used by UI // positioning properties; used by UI
bool cipt; bool cipt;
bool landscapeOrientation;
int tableRow; int tableRow;
bool upsideDownArt; bool upsideDownArt;
@ -209,14 +210,15 @@ public:
const QList<CardRelation *> &_reverseRelatedCards = QList<CardRelation *>(), const QList<CardRelation *> &_reverseRelatedCards = QList<CardRelation *>(),
CardInfoPerSetMap _sets = CardInfoPerSetMap(), CardInfoPerSetMap _sets = CardInfoPerSetMap(),
bool _cipt = false, bool _cipt = false,
bool _landscapeOrientation = false,
int _tableRow = 0, int _tableRow = 0,
bool _upsideDownArt = false); bool _upsideDownArt = false);
CardInfo(const CardInfo &other) CardInfo(const CardInfo &other)
: QObject(other.parent()), name(other.name), simpleName(other.simpleName), pixmapCacheKey(other.pixmapCacheKey), : QObject(other.parent()), name(other.name), simpleName(other.simpleName), pixmapCacheKey(other.pixmapCacheKey),
text(other.text), isToken(other.isToken), properties(other.properties), relatedCards(other.relatedCards), text(other.text), isToken(other.isToken), properties(other.properties), relatedCards(other.relatedCards),
reverseRelatedCards(other.reverseRelatedCards), reverseRelatedCardsToMe(other.reverseRelatedCardsToMe), reverseRelatedCards(other.reverseRelatedCards), reverseRelatedCardsToMe(other.reverseRelatedCardsToMe),
sets(other.sets), setsNames(other.setsNames), cipt(other.cipt), tableRow(other.tableRow), sets(other.sets), setsNames(other.setsNames), cipt(other.cipt),
upsideDownArt(other.upsideDownArt) landscapeOrientation(other.landscapeOrientation), tableRow(other.tableRow), upsideDownArt(other.upsideDownArt)
{ {
} }
~CardInfo() override; ~CardInfo() override;
@ -229,6 +231,7 @@ public:
const QList<CardRelation *> &_reverseRelatedCards = QList<CardRelation *>(), const QList<CardRelation *> &_reverseRelatedCards = QList<CardRelation *>(),
CardInfoPerSetMap _sets = CardInfoPerSetMap(), CardInfoPerSetMap _sets = CardInfoPerSetMap(),
bool _cipt = false, bool _cipt = false,
bool _landscapeOrientation = false,
int _tableRow = 0, int _tableRow = 0,
bool _upsideDownArt = false); bool _upsideDownArt = false);
@ -348,6 +351,10 @@ public:
{ {
return cipt; return cipt;
} }
bool getLandscapeOrientation() const
{
return landscapeOrientation;
}
int getTableRow() const int getTableRow() const
{ {
return tableRow; return tableRow;

View file

@ -158,6 +158,7 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
auto _sets = CardInfoPerSetMap(); auto _sets = CardInfoPerSetMap();
int tableRow = 0; int tableRow = 0;
bool cipt = false; bool cipt = false;
bool landscapeOrientation = false;
bool isToken = false; bool isToken = false;
bool upsideDown = false; bool upsideDown = false;
@ -194,6 +195,8 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
tableRow = xml.readElementText(QXmlStreamReader::IncludeChildElements).toInt(); tableRow = xml.readElementText(QXmlStreamReader::IncludeChildElements).toInt();
} else if (xmlName == "cipt") { } else if (xmlName == "cipt") {
cipt = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1"); cipt = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
} else if (xmlName == "landscapeOrientation") {
landscapeOrientation = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
} else if (xmlName == "upsidedown") { } else if (xmlName == "upsidedown") {
upsideDown = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1"); upsideDown = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
// sets // sets
@ -267,8 +270,9 @@ void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
} }
properties.insert("colors", colors); properties.insert("colors", colors);
CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards, CardInfoPtr newCard =
reverseRelatedCards, _sets, cipt, tableRow, upsideDown); CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards, _sets, cipt,
landscapeOrientation, tableRow, upsideDown);
emit addCard(newCard); emit addCard(newCard);
} }
} }
@ -405,6 +409,9 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
if (info->getCipt()) { if (info->getCipt()) {
xml.writeTextElement("cipt", "1"); xml.writeTextElement("cipt", "1");
} }
if (info->getLandscapeOrientation()) {
xml.writeTextElement("landscapeOrientation", "1");
}
if (info->getUpsideDownArt()) { if (info->getUpsideDownArt()) {
xml.writeTextElement("upsidedown", "1"); xml.writeTextElement("upsidedown", "1");
} }

View file

@ -353,6 +353,9 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
if (info->getCipt()) { if (info->getCipt()) {
xml.writeTextElement("cipt", "1"); xml.writeTextElement("cipt", "1");
} }
if (info->getLandscapeOrientation()) {
xml.writeTextElement("landscapeOrientation", "1");
}
if (info->getUpsideDownArt()) { if (info->getUpsideDownArt()) {
xml.writeTextElement("upsidedown", "1"); xml.writeTextElement("upsidedown", "1");
} }

View file

@ -156,6 +156,10 @@ CardInfoPtr OracleImporter::addCard(QString name,
") enters( the battlefield)? tapped(?! unless)"); ") enters( the battlefield)? tapped(?! unless)");
bool cipt = ciptRegex.match(text).hasMatch(); 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 // table row
int tableRow = 1; int tableRow = 1;
QString mainCardType = properties.value("maintype").toString(); QString mainCardType = properties.value("maintype").toString();
@ -179,7 +183,7 @@ CardInfoPtr OracleImporter::addCard(QString name,
CardInfoPerSetMap setsInfo; CardInfoPerSetMap setsInfo;
setsInfo[setInfo.getPtr()->getShortName()].append(setInfo); setsInfo[setInfo.getPtr()->getShortName()].append(setInfo);
CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards, CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards,
setsInfo, cipt, tableRow, upsideDown); setsInfo, cipt, landscapeOrientation, tableRow, upsideDown);
if (name.isEmpty()) { if (name.isEmpty()) {
qDebug() << "warning: an empty card was added to set" << setInfo.getPtr()->getShortName(); qDebug() << "warning: an empty card was added to set" << setInfo.getPtr()->getShortName();