parent
948a5c62ef
commit
8c17e2d12a
6 changed files with 49 additions and 6 deletions
|
@ -172,7 +172,8 @@ CardInfo::CardInfo(const QString &_name,
|
||||||
int _tableRow,
|
int _tableRow,
|
||||||
const SetList &_sets,
|
const SetList &_sets,
|
||||||
const QStringMap &_customPicURLs,
|
const QStringMap &_customPicURLs,
|
||||||
MuidMap _muIds
|
MuidMap _muIds,
|
||||||
|
QStringMap _setNumbers
|
||||||
)
|
)
|
||||||
: name(_name),
|
: name(_name),
|
||||||
isToken(_isToken),
|
isToken(_isToken),
|
||||||
|
@ -190,6 +191,7 @@ CardInfo::CardInfo(const QString &_name,
|
||||||
loyalty(_loyalty),
|
loyalty(_loyalty),
|
||||||
customPicURLs(_customPicURLs),
|
customPicURLs(_customPicURLs),
|
||||||
muIds(_muIds),
|
muIds(_muIds),
|
||||||
|
setNumbers(_setNumbers),
|
||||||
cipt(_cipt),
|
cipt(_cipt),
|
||||||
tableRow(_tableRow)
|
tableRow(_tableRow)
|
||||||
{
|
{
|
||||||
|
@ -316,6 +318,10 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
||||||
tmpSet=sets[i]->getShortName();
|
tmpSet=sets[i]->getShortName();
|
||||||
xml.writeAttribute("muId", QString::number(info->getMuId(tmpSet)));
|
xml.writeAttribute("muId", QString::number(info->getMuId(tmpSet)));
|
||||||
|
|
||||||
|
tmpString = info->getSetNumber(tmpSet);
|
||||||
|
if(!tmpString.isEmpty())
|
||||||
|
xml.writeAttribute("num", info->getSetNumber(tmpSet));
|
||||||
|
|
||||||
tmpString = info->getCustomPicURL(tmpSet);
|
tmpString = info->getCustomPicURL(tmpSet);
|
||||||
if(!tmpString.isEmpty())
|
if(!tmpString.isEmpty())
|
||||||
xml.writeAttribute("picURL", tmpString);
|
xml.writeAttribute("picURL", tmpString);
|
||||||
|
@ -487,6 +493,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
QStringList colors, relatedCards, reverseRelatedCards;
|
QStringList colors, relatedCards, reverseRelatedCards;
|
||||||
QStringMap customPicURLs;
|
QStringMap customPicURLs;
|
||||||
MuidMap muids;
|
MuidMap muids;
|
||||||
|
QStringMap setNumbers;
|
||||||
SetList sets;
|
SetList sets;
|
||||||
int tableRow = 0;
|
int tableRow = 0;
|
||||||
int loyalty = 0;
|
int loyalty = 0;
|
||||||
|
@ -518,6 +525,9 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
if (attrs.hasAttribute("picURL")) {
|
if (attrs.hasAttribute("picURL")) {
|
||||||
customPicURLs[setName] = attrs.value("picURL").toString();
|
customPicURLs[setName] = attrs.value("picURL").toString();
|
||||||
}
|
}
|
||||||
|
if (attrs.hasAttribute("num")) {
|
||||||
|
setNumbers[setName] = attrs.value("num").toString();
|
||||||
|
}
|
||||||
} else if (xml.name() == "color")
|
} else if (xml.name() == "color")
|
||||||
colors << xml.readElementText();
|
colors << xml.readElementText();
|
||||||
else if (xml.name() == "related")
|
else if (xml.name() == "related")
|
||||||
|
@ -540,7 +550,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addCard(new CardInfo(name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, reverseRelatedCards, upsideDown, loyalty, cipt, tableRow, sets, customPicURLs, muids));
|
addCard(new CardInfo(name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, reverseRelatedCards, upsideDown, loyalty, cipt, tableRow, sets, customPicURLs, muids, setNumbers));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,7 @@ private:
|
||||||
int loyalty;
|
int loyalty;
|
||||||
QStringMap customPicURLs;
|
QStringMap customPicURLs;
|
||||||
MuidMap muIds;
|
MuidMap muIds;
|
||||||
|
QStringMap setNumbers;
|
||||||
bool cipt;
|
bool cipt;
|
||||||
int tableRow;
|
int tableRow;
|
||||||
QString pixmapCacheKey;
|
QString pixmapCacheKey;
|
||||||
|
@ -107,7 +108,8 @@ public:
|
||||||
int _tableRow = 0,
|
int _tableRow = 0,
|
||||||
const SetList &_sets = SetList(),
|
const SetList &_sets = SetList(),
|
||||||
const QStringMap &_customPicURLs = QStringMap(),
|
const QStringMap &_customPicURLs = QStringMap(),
|
||||||
MuidMap muids = MuidMap()
|
MuidMap muids = MuidMap(),
|
||||||
|
QStringMap _setNumbers = QStringMap()
|
||||||
);
|
);
|
||||||
~CardInfo();
|
~CardInfo();
|
||||||
inline const QString &getName() const { return name; }
|
inline const QString &getName() const { return name; }
|
||||||
|
@ -139,6 +141,7 @@ public:
|
||||||
bool getUpsideDownArt() const { return upsideDownArt; }
|
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); }
|
||||||
int getMuId(const QString &set) const { return muIds.value(set); }
|
int getMuId(const QString &set) const { return muIds.value(set); }
|
||||||
|
QString getSetNumber(const QString &set) const { return setNumbers.value(set); }
|
||||||
QString getMainCardType() const;
|
QString getMainCardType() const;
|
||||||
QString getCorrectedName() const;
|
QString getCorrectedName() const;
|
||||||
int getTableRow() const { return tableRow; }
|
int getTableRow() const { return tableRow; }
|
||||||
|
@ -146,6 +149,7 @@ public:
|
||||||
void setLoyalty(int _loyalty) { loyalty = _loyalty; emit cardInfoChanged(this); }
|
void setLoyalty(int _loyalty) { loyalty = _loyalty; emit cardInfoChanged(this); }
|
||||||
void setCustomPicURL(const QString &_set, const QString &_customPicURL) { customPicURLs.insert(_set, _customPicURL); }
|
void setCustomPicURL(const QString &_set, const QString &_customPicURL) { customPicURLs.insert(_set, _customPicURL); }
|
||||||
void setMuId(const QString &_set, const int &_muId) { muIds.insert(_set, _muId); }
|
void setMuId(const QString &_set, const int &_muId) { muIds.insert(_set, _muId); }
|
||||||
|
void setSetNumber(const QString &_set, const QString &_setNumber) { setNumbers.insert(_set, _setNumber); }
|
||||||
void addToSet(CardSet *set);
|
void addToSet(CardSet *set);
|
||||||
void emitPixmapUpdated() { emit pixmapUpdated(); }
|
void emitPixmapUpdated() { emit pixmapUpdated(); }
|
||||||
void refreshCachedSetNames();
|
void refreshCachedSetNames();
|
||||||
|
|
|
@ -220,6 +220,7 @@ QString PictureLoaderWorker::getPicUrl()
|
||||||
picUrl.replace("!cardid!", QUrl::toPercentEncoding(QString::number(muid)));
|
picUrl.replace("!cardid!", QUrl::toPercentEncoding(QString::number(muid)));
|
||||||
if (set)
|
if (set)
|
||||||
{
|
{
|
||||||
|
picUrl.replace("!setnumber!", QUrl::toPercentEncoding(card->getSetNumber(set->getShortName())));
|
||||||
picUrl.replace("!setcode!", QUrl::toPercentEncoding(set->getShortName()));
|
picUrl.replace("!setcode!", QUrl::toPercentEncoding(set->getShortName()));
|
||||||
picUrl.replace("!setcode_lower!", QUrl::toPercentEncoding(set->getShortName().toLower()));
|
picUrl.replace("!setcode_lower!", QUrl::toPercentEncoding(set->getShortName().toLower()));
|
||||||
picUrl.replace("!setname!", QUrl::toPercentEncoding(set->getLongName()));
|
picUrl.replace("!setname!", QUrl::toPercentEncoding(set->getLongName()));
|
||||||
|
@ -229,6 +230,7 @@ QString PictureLoaderWorker::getPicUrl()
|
||||||
if (
|
if (
|
||||||
picUrl.contains("!name!") ||
|
picUrl.contains("!name!") ||
|
||||||
picUrl.contains("!name_lower!") ||
|
picUrl.contains("!name_lower!") ||
|
||||||
|
picUrl.contains("!setnumber!") ||
|
||||||
picUrl.contains("!setcode!") ||
|
picUrl.contains("!setcode!") ||
|
||||||
picUrl.contains("!setcode_lower!") ||
|
picUrl.contains("!setcode_lower!") ||
|
||||||
picUrl.contains("!setname!") ||
|
picUrl.contains("!setname!") ||
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
<xs:extension base="xs:string">
|
<xs:extension base="xs:string">
|
||||||
<xs:attribute type="xs:int" name="muId" use="optional"/>
|
<xs:attribute type="xs:int" name="muId" use="optional"/>
|
||||||
<xs:attribute type="xs:anyURI" name="picUrl" use="optional"/>
|
<xs:attribute type="xs:anyURI" name="picUrl" use="optional"/>
|
||||||
|
<xs:attribute type="xs:string" name="num" use="optional"/>
|
||||||
</xs:extension>
|
</xs:extension>
|
||||||
</xs:simpleContent>
|
</xs:simpleContent>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
|
|
@ -59,6 +59,7 @@ CardInfo *OracleImporter::addCard(const QString &setName,
|
||||||
QString cardName,
|
QString cardName,
|
||||||
bool isToken,
|
bool isToken,
|
||||||
int cardId,
|
int cardId,
|
||||||
|
QString &setNumber,
|
||||||
QString &cardCost,
|
QString &cardCost,
|
||||||
QString &cmc,
|
QString &cmc,
|
||||||
const QString &cardType,
|
const QString &cardType,
|
||||||
|
@ -110,6 +111,7 @@ CardInfo *OracleImporter::addCard(const QString &setName,
|
||||||
cards.insert(cardName, card);
|
cards.insert(cardName, card);
|
||||||
}
|
}
|
||||||
card->setMuId(setName, cardId);
|
card->setMuId(setName, cardId);
|
||||||
|
card->setSetNumber(setName, setNumber);
|
||||||
|
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
@ -149,6 +151,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
QStringList relatedCards;
|
QStringList relatedCards;
|
||||||
QStringList reverseRelatedCards; // dummy
|
QStringList reverseRelatedCards; // dummy
|
||||||
int cardId;
|
int cardId;
|
||||||
|
QString setNumber;
|
||||||
int cardLoyalty;
|
int cardLoyalty;
|
||||||
bool upsideDown = false;
|
bool upsideDown = false;
|
||||||
QMap<int, QVariantMap> splitCards;
|
QMap<int, QVariantMap> splitCards;
|
||||||
|
@ -179,6 +182,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
cardPT = map.contains("power") || map.contains("toughness") ? map.value("power").toString() + QString('/') + map.value("toughness").toString() : QString("");
|
cardPT = map.contains("power") || map.contains("toughness") ? map.value("power").toString() + QString('/') + map.value("toughness").toString() : QString("");
|
||||||
cardText = map.contains("text") ? map.value("text").toString() : QString("");
|
cardText = map.contains("text") ? map.value("text").toString() : QString("");
|
||||||
cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0;
|
cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0;
|
||||||
|
setNumber = map.contains("number") ? map.value("number").toString() : QString("");
|
||||||
cardLoyalty = map.contains("loyalty") ? map.value("loyalty").toInt() : 0;
|
cardLoyalty = map.contains("loyalty") ? map.value("loyalty").toInt() : 0;
|
||||||
relatedCards = map.contains("names") ? map.value("names").toStringList() : QStringList();
|
relatedCards = map.contains("names") ? map.value("names").toStringList() : QStringList();
|
||||||
relatedCards.removeAll(cardName);
|
relatedCards.removeAll(cardName);
|
||||||
|
@ -194,7 +198,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
colors.clear();
|
colors.clear();
|
||||||
extractColors(map.value("colors").toStringList(), colors);
|
extractColors(map.value("colors").toStringList(), colors);
|
||||||
|
|
||||||
CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown);
|
CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, setNumber, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown);
|
||||||
|
|
||||||
if (!set->contains(card)) {
|
if (!set->contains(card)) {
|
||||||
card->addToSet(set);
|
card->addToSet(set);
|
||||||
|
@ -227,6 +231,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
cardType = "";
|
cardType = "";
|
||||||
cardPT = "";
|
cardPT = "";
|
||||||
cardText = "";
|
cardText = "";
|
||||||
|
setNumber = "";
|
||||||
colors.clear();
|
colors.clear();
|
||||||
// this is currently an integer; can't accept 2 values
|
// this is currently an integer; can't accept 2 values
|
||||||
cardLoyalty = 0;
|
cardLoyalty = 0;
|
||||||
|
@ -272,6 +277,11 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
cardText += prefix2;
|
cardText += prefix2;
|
||||||
cardText += map.value("text").toString();
|
cardText += map.value("text").toString();
|
||||||
}
|
}
|
||||||
|
if(map.contains("number"))
|
||||||
|
{
|
||||||
|
if(setNumber.isEmpty())
|
||||||
|
setNumber = map.value("number").toString();
|
||||||
|
}
|
||||||
|
|
||||||
extractColors(map.value("colors").toStringList(), colors);
|
extractColors(map.value("colors").toStringList(), colors);
|
||||||
}
|
}
|
||||||
|
@ -282,7 +292,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
|
||||||
upsideDown = false;
|
upsideDown = false;
|
||||||
|
|
||||||
// add the card
|
// add the card
|
||||||
CardInfo *card = addCard(set->getShortName(), cardName, false, muid, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown);
|
CardInfo *card = addCard(set->getShortName(), cardName, false, muid, setNumber, cardCost, cmc, cardType, cardPT, cardLoyalty, cardText, colors, relatedCards, reverseRelatedCards, upsideDown);
|
||||||
|
|
||||||
if (!set->contains(card)) {
|
if (!set->contains(card)) {
|
||||||
card->addToSet(set);
|
card->addToSet(set);
|
||||||
|
|
|
@ -30,7 +30,23 @@ 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, const QStringList & reverseRelatedCards, bool upsideDown);
|
CardInfo *addCard(
|
||||||
|
const QString &setName,
|
||||||
|
QString cardName,
|
||||||
|
bool isToken,
|
||||||
|
int cardId,
|
||||||
|
QString &setNumber,
|
||||||
|
QString &cardCost,
|
||||||
|
QString &cmc,
|
||||||
|
const QString &cardType,
|
||||||
|
const QString &cardPT,
|
||||||
|
int cardLoyalty,
|
||||||
|
const QString &cardText,
|
||||||
|
const QStringList & colors,
|
||||||
|
const QStringList & relatedCards,
|
||||||
|
const QStringList & reverseRelatedCards,
|
||||||
|
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