[CardInfo] refactor some fields into a UiAttributes struct (#6322)

* refactor CardInfo

* refactor everything else
This commit is contained in:
RickyRister 2025-11-16 08:56:57 -08:00 committed by GitHub
parent 722344967f
commit 9a3104c5ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 73 additions and 87 deletions

View file

@ -262,9 +262,12 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
continue;
}
CardInfoPtr newCard =
CardInfo::newInstance(name, text, isToken, properties, relatedCards, reverseRelatedCards, _sets, cipt,
landscapeOrientation, tableRow, upsideDown);
CardInfo::UiAttributes attributes = {.cipt = cipt,
.landscapeOrientation = landscapeOrientation,
.tableRow = tableRow,
.upsideDownArt = upsideDown};
CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards,
reverseRelatedCards, _sets, attributes);
emit addCard(newCard);
}
}
@ -379,14 +382,15 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
}
// positioning
xml.writeTextElement("tablerow", QString::number(info->getTableRow()));
if (info->getCipt()) {
const CardInfo::UiAttributes &attributes = info->getUiAttributes();
xml.writeTextElement("tablerow", QString::number(attributes.tableRow));
if (attributes.cipt) {
xml.writeTextElement("cipt", "1");
}
if (info->getLandscapeOrientation()) {
if (attributes.landscapeOrientation) {
xml.writeTextElement("landscapeOrientation", "1");
}
if (info->getUpsideDownArt()) {
if (attributes.upsideDownArt) {
xml.writeTextElement("upsidedown", "1");
}