Merge pull request #1134 from ctrlaltca/related_cards

Related cards
This commit is contained in:
ctrlaltca 2015-06-22 17:22:47 +02:00
commit 2415ba2605
8 changed files with 110 additions and 14 deletions

View file

@ -492,13 +492,16 @@ CardInfo::CardInfo(CardDatabase *_db,
const QString &_powtough,
const QString &_text,
const QStringList &_colors,
const QStringList &_relatedCards,
bool _upsideDownArt,
int _loyalty,
bool _cipt,
int _tableRow,
const SetList &_sets,
const QStringMap &_customPicURLs,
const QStringMap &_customPicURLsHq,
MuidMap _muIds)
MuidMap _muIds
)
: db(_db),
name(_name),
isToken(_isToken),
@ -509,6 +512,8 @@ CardInfo::CardInfo(CardDatabase *_db,
powtough(_powtough),
text(_text),
colors(_colors),
relatedCards(_relatedCards),
upsideDownArt(_upsideDownArt),
loyalty(_loyalty),
customPicURLs(_customPicURLs),
customPicURLsHq(_customPicURLsHq),
@ -590,7 +595,13 @@ void CardInfo::loadPixmap(QPixmap &pixmap)
void CardInfo::imageLoaded(const QImage &image)
{
if (!image.isNull()) {
QPixmapCache::insert(pixmapCacheKey, QPixmap::fromImage(image));
if(upsideDownArt)
{
QImage mirrorImage = image.mirrored(true, true);
QPixmapCache::insert(pixmapCacheKey, QPixmap::fromImage(mirrorImage));
} else {
QPixmapCache::insert(pixmapCacheKey, QPixmap::fromImage(image));
}
emit pixmapUpdated();
}
}
@ -695,6 +706,10 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
for (int i = 0; i < colors.size(); i++)
xml.writeTextElement("color", colors[i]);
const QStringList &related = info->getRelatedCards();
for (int i = 0; i < related.size(); i++)
xml.writeTextElement("related", related[i]);
xml.writeTextElement("manacost", info->getManaCost());
xml.writeTextElement("cmc", info->getCmc());
xml.writeTextElement("type", info->getCardType());
@ -708,6 +723,8 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
xml.writeTextElement("cipt", "1");
if (info->getIsToken())
xml.writeTextElement("token", "1");
if (info->getUpsideDownArt())
xml.writeTextElement("upsidedown", "1");
xml.writeEndElement(); // card
return xml;
@ -862,7 +879,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
break;
if (xml.name() == "card") {
QString name, manacost, cmc, type, pt, text;
QStringList colors;
QStringList colors, relatedCards;
QStringMap customPicURLs, customPicURLsHq;
MuidMap muids;
SetList sets;
@ -870,6 +887,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
int loyalty = 0;
bool cipt = false;
bool isToken = false;
bool upsideDown = false;
while (!xml.atEnd()) {
if (xml.readNext() == QXmlStreamReader::EndElement)
break;
@ -900,10 +918,14 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
}
} else if (xml.name() == "color")
colors << xml.readElementText();
else if (xml.name() == "related")
relatedCards << xml.readElementText();
else if (xml.name() == "tablerow")
tableRow = xml.readElementText().toInt();
else if (xml.name() == "cipt")
cipt = (xml.readElementText() == "1");
else if (xml.name() == "upsidedown")
upsideDown = (xml.readElementText() == "1");
else if (xml.name() == "loyalty")
loyalty = xml.readElementText().toInt();
else if (xml.name() == "token")
@ -911,7 +933,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
}
if (isToken == tokens) {
addCard(new CardInfo(this, name, isToken, manacost, cmc, type, pt, text, colors, loyalty, cipt, tableRow, sets, customPicURLs, customPicURLsHq, muids));
addCard(new CardInfo(this, name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, upsideDown, loyalty, cipt, tableRow, sets, customPicURLs, customPicURLsHq, muids));
}
}
}