update pixmap cache
This commit is contained in:
parent
dfaa6b1d95
commit
d6ec869c23
2 changed files with 18 additions and 10 deletions
|
@ -169,15 +169,22 @@ void CardInfo::clearPixmapCache()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardInfo::updatePixmapCache()
|
||||||
|
{
|
||||||
|
qDebug(QString("Updating pixmap cache for %1").arg(name).toLatin1());
|
||||||
|
clearPixmapCache();
|
||||||
|
loadPixmap();
|
||||||
|
}
|
||||||
|
|
||||||
QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
||||||
{
|
{
|
||||||
xml.writeStartElement("card");
|
xml.writeStartElement("card");
|
||||||
xml.writeTextElement("name", info->getName());
|
xml.writeTextElement("name", info->getName());
|
||||||
|
|
||||||
SetList sets = info->getSets();
|
SetList sets = info->getSets();
|
||||||
for (int i = 0; i < sets.size(); i++)
|
for (int i = 0; i < sets.size(); i++)
|
||||||
xml.writeTextElement("set", sets[i]->getShortName());
|
xml.writeTextElement("set", sets[i]->getShortName());
|
||||||
|
|
||||||
xml.writeTextElement("manacost", info->getManaCost());
|
xml.writeTextElement("manacost", info->getManaCost());
|
||||||
xml.writeTextElement("type", info->getCardType());
|
xml.writeTextElement("type", info->getCardType());
|
||||||
if (!info->getPowTough().isEmpty())
|
if (!info->getPowTough().isEmpty())
|
||||||
|
@ -185,7 +192,7 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
||||||
xml.writeTextElement("tablerow", QString::number(info->getTableRow()));
|
xml.writeTextElement("tablerow", QString::number(info->getTableRow()));
|
||||||
xml.writeTextElement("text", info->getText());
|
xml.writeTextElement("text", info->getText());
|
||||||
xml.writeEndElement(); // card
|
xml.writeEndElement(); // card
|
||||||
|
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +201,7 @@ CardDatabase::CardDatabase(QObject *parent)
|
||||||
{
|
{
|
||||||
updateDatabasePath();
|
updateDatabasePath();
|
||||||
updatePicsPath();
|
updatePicsPath();
|
||||||
|
|
||||||
noCard = new CardInfo(this);
|
noCard = new CardInfo(this);
|
||||||
noCard->loadPixmap(); // cache pixmap for card back
|
noCard->loadPixmap(); // cache pixmap for card back
|
||||||
}
|
}
|
||||||
|
@ -305,7 +312,7 @@ void CardDatabase::importOracleFile(const QString &fileName, CardSet *set)
|
||||||
card = cardHash.value(cardname);
|
card = cardHash.value(cardname);
|
||||||
else {
|
else {
|
||||||
card = new CardInfo(this, cardname, manacost, cardtype, powtough, text.join("\n"));
|
card = new CardInfo(this, cardname, manacost, cardtype, powtough, text.join("\n"));
|
||||||
|
|
||||||
int tableRow = 1;
|
int tableRow = 1;
|
||||||
QString mainCardType = card->getMainCardType();
|
QString mainCardType = card->getMainCardType();
|
||||||
if (mainCardType == "Land")
|
if (mainCardType == "Land")
|
||||||
|
@ -315,7 +322,7 @@ void CardDatabase::importOracleFile(const QString &fileName, CardSet *set)
|
||||||
else if (mainCardType == "Creature")
|
else if (mainCardType == "Creature")
|
||||||
tableRow = 3;
|
tableRow = 3;
|
||||||
card->setTableRow(tableRow);
|
card->setTableRow(tableRow);
|
||||||
|
|
||||||
cardHash.insert(cardname, card);
|
cardHash.insert(cardname, card);
|
||||||
}
|
}
|
||||||
card->addToSet(set);
|
card->addToSet(set);
|
||||||
|
@ -424,7 +431,7 @@ bool CardDatabase::saveToFile(const QString &fileName)
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
QXmlStreamWriter xml(&file);
|
QXmlStreamWriter xml(&file);
|
||||||
|
|
||||||
xml.setAutoFormatting(true);
|
xml.setAutoFormatting(true);
|
||||||
xml.writeStartDocument();
|
xml.writeStartDocument();
|
||||||
xml.writeStartElement("cockatrice_carddatabase");
|
xml.writeStartElement("cockatrice_carddatabase");
|
||||||
|
@ -435,13 +442,13 @@ bool CardDatabase::saveToFile(const QString &fileName)
|
||||||
while (setIterator.hasNext())
|
while (setIterator.hasNext())
|
||||||
xml << setIterator.next().value();
|
xml << setIterator.next().value();
|
||||||
xml.writeEndElement(); // sets
|
xml.writeEndElement(); // sets
|
||||||
|
|
||||||
xml.writeStartElement("cards");
|
xml.writeStartElement("cards");
|
||||||
QHashIterator<QString, CardInfo *> cardIterator(cardHash);
|
QHashIterator<QString, CardInfo *> cardIterator(cardHash);
|
||||||
while (cardIterator.hasNext())
|
while (cardIterator.hasNext())
|
||||||
xml << cardIterator.next().value();
|
xml << cardIterator.next().value();
|
||||||
xml.writeEndElement(); // cards
|
xml.writeEndElement(); // cards
|
||||||
|
|
||||||
xml.writeEndElement(); // cockatrice_carddatabase
|
xml.writeEndElement(); // cockatrice_carddatabase
|
||||||
xml.writeEndDocument();
|
xml.writeEndDocument();
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ public:
|
||||||
QPixmap *loadPixmap();
|
QPixmap *loadPixmap();
|
||||||
QPixmap *getPixmap(QSize size);
|
QPixmap *getPixmap(QSize size);
|
||||||
void clearPixmapCache();
|
void clearPixmapCache();
|
||||||
|
void updatePixmapCache();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CardDatabase : public QObject {
|
class CardDatabase : public QObject {
|
||||||
|
@ -76,7 +77,7 @@ private:
|
||||||
QHash<QString, CardSet *> setHash;
|
QHash<QString, CardSet *> setHash;
|
||||||
CardInfo *noCard;
|
CardInfo *noCard;
|
||||||
QString picsPath, cardDatabasePath;
|
QString picsPath, cardDatabasePath;
|
||||||
|
|
||||||
void loadCardsFromXml(QXmlStreamReader &xml);
|
void loadCardsFromXml(QXmlStreamReader &xml);
|
||||||
void loadSetsFromXml(QXmlStreamReader &xml);
|
void loadSetsFromXml(QXmlStreamReader &xml);
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue