Rotate 180 degrees the art of flipped cards
This commit is contained in:
parent
8826908923
commit
518bda8c09
4 changed files with 34 additions and 7 deletions
|
@ -483,6 +483,7 @@ CardInfo::CardInfo(CardDatabase *_db,
|
||||||
const QString &_text,
|
const QString &_text,
|
||||||
const QStringList &_colors,
|
const QStringList &_colors,
|
||||||
const QStringList &_relatedCards,
|
const QStringList &_relatedCards,
|
||||||
|
bool _upsideDownArt,
|
||||||
int _loyalty,
|
int _loyalty,
|
||||||
bool _cipt,
|
bool _cipt,
|
||||||
int _tableRow,
|
int _tableRow,
|
||||||
|
@ -502,6 +503,7 @@ CardInfo::CardInfo(CardDatabase *_db,
|
||||||
text(_text),
|
text(_text),
|
||||||
colors(_colors),
|
colors(_colors),
|
||||||
relatedCards(_relatedCards),
|
relatedCards(_relatedCards),
|
||||||
|
upsideDownArt(_upsideDownArt),
|
||||||
loyalty(_loyalty),
|
loyalty(_loyalty),
|
||||||
customPicURLs(_customPicURLs),
|
customPicURLs(_customPicURLs),
|
||||||
customPicURLsHq(_customPicURLsHq),
|
customPicURLsHq(_customPicURLsHq),
|
||||||
|
@ -583,7 +585,13 @@ void CardInfo::loadPixmap(QPixmap &pixmap)
|
||||||
void CardInfo::imageLoaded(const QImage &image)
|
void CardInfo::imageLoaded(const QImage &image)
|
||||||
{
|
{
|
||||||
if (!image.isNull()) {
|
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();
|
emit pixmapUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,6 +713,8 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
||||||
xml.writeTextElement("cipt", "1");
|
xml.writeTextElement("cipt", "1");
|
||||||
if (info->getIsToken())
|
if (info->getIsToken())
|
||||||
xml.writeTextElement("token", "1");
|
xml.writeTextElement("token", "1");
|
||||||
|
if (info->getUpsideDownArt())
|
||||||
|
xml.writeTextElement("upsidedown", "1");
|
||||||
xml.writeEndElement(); // card
|
xml.writeEndElement(); // card
|
||||||
|
|
||||||
return xml;
|
return xml;
|
||||||
|
@ -867,6 +877,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
|
||||||
int loyalty = 0;
|
int loyalty = 0;
|
||||||
bool cipt = false;
|
bool cipt = false;
|
||||||
bool isToken = false;
|
bool isToken = false;
|
||||||
|
bool upsideDown = false;
|
||||||
while (!xml.atEnd()) {
|
while (!xml.atEnd()) {
|
||||||
if (xml.readNext() == QXmlStreamReader::EndElement)
|
if (xml.readNext() == QXmlStreamReader::EndElement)
|
||||||
break;
|
break;
|
||||||
|
@ -903,6 +914,8 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
|
||||||
tableRow = xml.readElementText().toInt();
|
tableRow = xml.readElementText().toInt();
|
||||||
else if (xml.name() == "cipt")
|
else if (xml.name() == "cipt")
|
||||||
cipt = (xml.readElementText() == "1");
|
cipt = (xml.readElementText() == "1");
|
||||||
|
else if (xml.name() == "upsidedown")
|
||||||
|
upsideDown = (xml.readElementText() == "1");
|
||||||
else if (xml.name() == "loyalty")
|
else if (xml.name() == "loyalty")
|
||||||
loyalty = xml.readElementText().toInt();
|
loyalty = xml.readElementText().toInt();
|
||||||
else if (xml.name() == "token")
|
else if (xml.name() == "token")
|
||||||
|
@ -910,7 +923,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isToken == tokens) {
|
if (isToken == tokens) {
|
||||||
addCard(new CardInfo(this, name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,7 @@ private:
|
||||||
QString text;
|
QString text;
|
||||||
QStringList colors;
|
QStringList colors;
|
||||||
QStringList relatedCards;
|
QStringList relatedCards;
|
||||||
|
bool upsideDownArt;
|
||||||
int loyalty;
|
int loyalty;
|
||||||
QStringMap customPicURLs, customPicURLsHq;
|
QStringMap customPicURLs, customPicURLsHq;
|
||||||
MuidMap muIds;
|
MuidMap muIds;
|
||||||
|
@ -150,6 +151,7 @@ public:
|
||||||
const QString &_text = QString(),
|
const QString &_text = QString(),
|
||||||
const QStringList &_colors = QStringList(),
|
const QStringList &_colors = QStringList(),
|
||||||
const QStringList &_relatedCards = QStringList(),
|
const QStringList &_relatedCards = QStringList(),
|
||||||
|
bool _upsideDownArt = false,
|
||||||
int _loyalty = 0,
|
int _loyalty = 0,
|
||||||
bool _cipt = false,
|
bool _cipt = false,
|
||||||
int _tableRow = 0,
|
int _tableRow = 0,
|
||||||
|
@ -178,6 +180,7 @@ public:
|
||||||
void setColors(const QStringList &_colors) { colors = _colors; emit cardInfoChanged(this); }
|
void setColors(const QStringList &_colors) { colors = _colors; emit cardInfoChanged(this); }
|
||||||
const QStringList &getColors() const { return colors; }
|
const QStringList &getColors() const { return colors; }
|
||||||
const QStringList &getRelatedCards() const { return relatedCards; }
|
const QStringList &getRelatedCards() const { return relatedCards; }
|
||||||
|
bool getUpsideDownArt() const { return upsideDownArt; }
|
||||||
QString getCustomPicURL(const QString &set) const { return customPicURLs.value(set); }
|
QString getCustomPicURL(const QString &set) const { return customPicURLs.value(set); }
|
||||||
QString getCustomPicURLHq(const QString &set) const { return customPicURLsHq.value(set); }
|
QString getCustomPicURLHq(const QString &set) const { return customPicURLsHq.value(set); }
|
||||||
int getMuId(const QString &set) const { return muIds.value(set); }
|
int getMuId(const QString &set) const { return muIds.value(set); }
|
||||||
|
|
|
@ -66,7 +66,8 @@ CardInfo *OracleImporter::addCard(const QString &setName,
|
||||||
int cardLoyalty,
|
int cardLoyalty,
|
||||||
const QString &cardText,
|
const QString &cardText,
|
||||||
const QStringList & colors,
|
const QStringList & colors,
|
||||||
const QStringList & relatedCards
|
const QStringList & relatedCards,
|
||||||
|
bool upsideDown
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
QStringList cardTextRows = cardText.split("\n");
|
QStringList cardTextRows = cardText.split("\n");
|
||||||
|
@ -99,7 +100,7 @@ CardInfo *OracleImporter::addCard(const QString &setName,
|
||||||
|
|
||||||
bool cipt = cardText.contains("Hideaway") || (cardText.contains(cardName + " enters the battlefield tapped") && !cardText.contains(cardName + " enters the battlefield tapped unless"));
|
bool cipt = cardText.contains("Hideaway") || (cardText.contains(cardName + " enters the battlefield tapped") && !cardText.contains(cardName + " enters the battlefield tapped unless"));
|
||||||
|
|
||||||
card = new CardInfo(this, cardName, isToken, cardCost, cmc, cardType, cardPT, cardText, colors, relatedCards, cardLoyalty, cipt);
|
card = new CardInfo(this, cardName, isToken, cardCost, cmc, cardType, cardPT, cardText, colors, relatedCards, upsideDown, cardLoyalty, cipt);
|
||||||
int tableRow = 1;
|
int tableRow = 1;
|
||||||
QString mainCardType = card->getMainCardType();
|
QString mainCardType = card->getMainCardType();
|
||||||
if ((mainCardType == "Land") || mArtifact)
|
if ((mainCardType == "Land") || mArtifact)
|
||||||
|
@ -153,6 +154,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
int cardId;
|
int cardId;
|
||||||
int cardLoyalty;
|
int cardLoyalty;
|
||||||
bool cardIsToken = false;
|
bool cardIsToken = false;
|
||||||
|
bool upsideDown = false;
|
||||||
QMap<int, QVariantMap> splitCards;
|
QMap<int, QVariantMap> splitCards;
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
@ -208,6 +210,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
colors.removeDuplicates();
|
colors.removeDuplicates();
|
||||||
|
|
||||||
relatedCards = QStringList();
|
relatedCards = QStringList();
|
||||||
|
upsideDown = false;
|
||||||
} else {
|
} else {
|
||||||
// first card of a pair; enqueue for later merging
|
// first card of a pair; enqueue for later merging
|
||||||
// Conditional on cardId because promo prints have no muid - see #640
|
// Conditional on cardId because promo prints have no muid - see #640
|
||||||
|
@ -227,7 +230,15 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
cardLoyalty = map.contains("loyalty") ? map.value("loyalty").toInt() : 0;
|
cardLoyalty = map.contains("loyalty") ? map.value("loyalty").toInt() : 0;
|
||||||
cardIsToken = map.value("layout") == "token";
|
cardIsToken = map.value("layout") == "token";
|
||||||
relatedCards = map.contains("names") ? map.value("names").toStringList() : QStringList();
|
relatedCards = map.contains("names") ? map.value("names").toStringList() : QStringList();
|
||||||
relatedCards.removeAll(cardName);
|
relatedCards.removeAll(cardName);
|
||||||
|
|
||||||
|
if(0 == QString::compare(map.value("layout").toString(), QString("flip"), Qt::CaseInsensitive))
|
||||||
|
{
|
||||||
|
QStringList cardNames = map.contains("names") ? map.value("names").toStringList() : QStringList();
|
||||||
|
upsideDown = (cardNames.indexOf(cardName) > 0);
|
||||||
|
} else {
|
||||||
|
upsideDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
colors.clear();
|
colors.clear();
|
||||||
extractColors(map.value("colors").toStringList(), colors);
|
extractColors(map.value("colors").toStringList(), colors);
|
||||||
|
@ -239,7 +250,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cardIsToken) {
|
if (!cardIsToken) {
|
||||||
CardInfo *card = addCard(set->getShortName(), cardName, cardIsToken, cardId, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards);
|
CardInfo *card = addCard(set->getShortName(), cardName, cardIsToken, cardId, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, upsideDown);
|
||||||
|
|
||||||
if (!set->contains(card)) {
|
if (!set->contains(card)) {
|
||||||
card->addToSet(set);
|
card->addToSet(set);
|
||||||
|
|
|
@ -29,7 +29,7 @@ private:
|
||||||
QVariantMap setsMap;
|
QVariantMap setsMap;
|
||||||
QString dataDir;
|
QString dataDir;
|
||||||
|
|
||||||
CardInfo *addCard(const QString &setName, QString cardName, bool isToken, int cardId, QString &cardCost, QString &cmc, const QString &cardType, const QString &cardPT, int cardLoyalty, const QString &cardText, const QStringList & colors, const QStringList & relatedCards);
|
CardInfo *addCard(const QString &setName, QString cardName, bool isToken, int cardId, QString &cardCost, QString &cmc, const QString &cardType, const QString &cardPT, int cardLoyalty, const QString &cardText, const QStringList & colors, const QStringList & relatedCards, bool upsideDown);
|
||||||
signals:
|
signals:
|
||||||
void setIndexChanged(int cardsImported, int setIndex, const QString &setName);
|
void setIndexChanged(int cardsImported, int setIndex, const QString &setName);
|
||||||
void dataReadProgress(int bytesRead, int totalBytes);
|
void dataReadProgress(int bytesRead, int totalBytes);
|
||||||
|
|
Loading…
Reference in a new issue