mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Rework of the card database, xml format and oracle parser (#3511)
* CardDB: merge all card properties in a new structure * Pre Json parser changes * Cockatrice: use qt's builtin json support * Move qt-json src dir from cockatrice to oracle * Add dummy cockatricexml4 parser (yet to be implemented) * Implement a new parser and xml format * cockatricexml4: new xml parser following the "generic properties hash" pattern; * oracleimporter: refactor the parsing code to better adapt to cockatricexml4; rewrote split cards parsing * carddb: change "colors" from a stringlist to a string * carddb: move the getMainCardType() method to the cockatricexml3 parser * * CardInfo: show all properties (stil missing: nice name + translation) * Rework the "add related card" feature so that it doesn't change the card name in the carddb Also, fix token count display * Picture loader: Added support for transform cards * Fix side information for flip cards Mtgjson uses side a/b for flip cards, while scryfall doesn't * Pictureloader: dynamic tag resolution from card properties Examples old => new * !cardid! => !set:muid! * !uuid! => !set:uuid! * !collectornumber! => !set:num! New examples: * !prop:type! * !prop:manacost! * Start moving mtg-related property names to a specific file * Clangify * Fix tests * Make gcc an happy puppy * Revert "Make gcc an happy puppy" This reverts commit 446ec5f27516c4d3b32dbfc79557f4827c5c5bdf. * Some gcc fixes * Share set list between different db parsers, so they won't overwrite one each other * All glory to the hypnoclangifier! * Fix test compilation * Cleanup edited files in the prior PR. (#3519) * Cleanup edited files in the prior PR. Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com> * Fix includes Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com> * Update carddatabase.h
This commit is contained in:
parent
19180243aa
commit
ed70099e36
44 changed files with 1814 additions and 1360 deletions
|
|
@ -30,7 +30,9 @@ PictureToLoad::PictureToLoad(CardInfoPtr _card) : card(std::move(_card))
|
|||
urlTemplates = settingsCache->downloads().getAllURLs();
|
||||
|
||||
if (card) {
|
||||
sortedSets = card->getSets();
|
||||
for (const auto &set : card->getSets()) {
|
||||
sortedSets << set.getPtr();
|
||||
}
|
||||
qSort(sortedSets.begin(), sortedSets.end(), SetDownloadPriorityComparator());
|
||||
// The first time called, nextSet will also populate the Urls for the first set.
|
||||
nextSet();
|
||||
|
|
@ -240,28 +242,50 @@ QString PictureToLoad::transformUrl(const QString &urlTemplate) const
|
|||
CardSetPtr set = getCurrentSet();
|
||||
|
||||
QMap<QString, QString> transformMap = QMap<QString, QString>();
|
||||
|
||||
// name
|
||||
transformMap["!name!"] = card->getName();
|
||||
transformMap["!name_lower!"] = card->getName().toLower();
|
||||
transformMap["!corrected_name!"] = card->getCorrectedName();
|
||||
transformMap["!corrected_name_lower!"] = card->getCorrectedName().toLower();
|
||||
|
||||
// card properties
|
||||
QRegExp rxCardProp("!prop:([^!]+)!");
|
||||
int pos = 0;
|
||||
while ((pos = rxCardProp.indexIn(transformedUrl, pos)) != -1) {
|
||||
QString propertyName = rxCardProp.cap(1);
|
||||
pos += rxCardProp.matchedLength();
|
||||
QString propertyValue = card->getProperty(propertyName);
|
||||
if (propertyValue.isEmpty()) {
|
||||
qDebug() << "PictureLoader: [card: " << card->getName() << " set: " << getSetName()
|
||||
<< "]: Requested property (" << propertyName << ") for Url template (" << urlTemplate
|
||||
<< ") is not available";
|
||||
return QString();
|
||||
} else {
|
||||
transformMap["!prop:" + propertyName + "!"] = propertyValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (set) {
|
||||
transformMap["!cardid!"] = QString::number(card->getMuId(set->getShortName()));
|
||||
transformMap["!uuid!"] = card->getUuId(set->getShortName());
|
||||
transformMap["!collectornumber!"] = card->getCollectorNumber(set->getShortName());
|
||||
transformMap["!setcode!"] = set->getShortName();
|
||||
transformMap["!setcode_lower!"] = set->getShortName().toLower();
|
||||
transformMap["!setname!"] = set->getLongName();
|
||||
transformMap["!setname_lower!"] = set->getLongName().toLower();
|
||||
} else {
|
||||
transformMap["!cardid!"] = QString();
|
||||
transformMap["!uuid!"] = QString();
|
||||
transformMap["!collectornumber!"] = QString();
|
||||
transformMap["!setcode!"] = QString();
|
||||
transformMap["!setcode_lower!"] = QString();
|
||||
transformMap["!setname!"] = QString();
|
||||
transformMap["!setname_lower!"] = QString();
|
||||
|
||||
QRegExp rxSetProp("!set:([^!]+)!");
|
||||
pos = 0; // Defined above
|
||||
while ((pos = rxSetProp.indexIn(transformedUrl, pos)) != -1) {
|
||||
QString propertyName = rxSetProp.cap(1);
|
||||
pos += rxSetProp.matchedLength();
|
||||
QString propertyValue = card->getSetProperty(set->getShortName(), propertyName);
|
||||
if (propertyValue.isEmpty()) {
|
||||
qDebug() << "PictureLoader: [card: " << card->getName() << " set: " << getSetName()
|
||||
<< "]: Requested set property (" << propertyName << ") for Url template (" << urlTemplate
|
||||
<< ") is not available";
|
||||
return QString();
|
||||
} else {
|
||||
transformMap["!set:" + propertyName + "!"] = propertyValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const QString &prop : transformMap.keys()) {
|
||||
|
|
@ -483,7 +507,7 @@ void PictureLoader::getPixmap(QPixmap &pixmap, CardInfoPtr card, QSize size)
|
|||
return;
|
||||
}
|
||||
|
||||
// search for an exact size copy of the picure in cache
|
||||
// search for an exact size copy of the picture in cache
|
||||
QString key = card->getPixmapCacheKey();
|
||||
QString sizeKey = key + QLatin1Char('_') + QString::number(size.width()) + QString::number(size.height());
|
||||
if (QPixmapCache::find(sizeKey, &pixmap))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue