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
7 changed files with 33 additions and 10 deletions

View File

@@ -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<CardRelation *>(),
QList<CardRelation *>(), sets, false, -1, false);
QList<CardRelation *>(), sets, false, false, -1, false);
card->setCardType("Token");
databaseModel->getDatabase()->addCard(card);

View File

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

View File

@@ -234,11 +234,12 @@ CardInfo::CardInfo(const QString &_name,
const QList<CardRelation *> &_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<CardRelation *> &_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) {

View File

@@ -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<CardRelation *> &_reverseRelatedCards = QList<CardRelation *>(),
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<CardRelation *> &_reverseRelatedCards = QList<CardRelation *>(),
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;

View File

@@ -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");
}

View File

@@ -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");
}

View File

@@ -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();