added tablerow to cardinfo
This commit is contained in:
parent
b8bf18801f
commit
b12155f59c
2 changed files with 22 additions and 16 deletions
|
@ -54,8 +54,8 @@ void SetList::sortByKey()
|
||||||
qSort(begin(), end(), CompareFunctor());
|
qSort(begin(), end(), CompareFunctor());
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInfo::CardInfo(CardDatabase *_db, const QString &_name, const QString &_manacost, const QString &_cardtype, const QString &_powtough, const QString &_text, const SetList &_sets)
|
CardInfo::CardInfo(CardDatabase *_db, const QString &_name, const QString &_manacost, const QString &_cardtype, const QString &_powtough, const QString &_text, int _tableRow, const SetList &_sets)
|
||||||
: db(_db), name(_name), sets(_sets), manacost(_manacost), cardtype(_cardtype), powtough(_powtough), text(_text), pixmap(NULL)
|
: db(_db), name(_name), sets(_sets), manacost(_manacost), cardtype(_cardtype), powtough(_powtough), text(_text), tableRow(_tableRow), pixmap(NULL)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < sets.size(); i++)
|
for (int i = 0; i < sets.size(); i++)
|
||||||
sets[i]->append(this);
|
sets[i]->append(this);
|
||||||
|
@ -104,18 +104,6 @@ QString CardInfo::getMainCardType() const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CardInfo::getTableRow() const
|
|
||||||
{
|
|
||||||
QString mainCardType = getMainCardType();
|
|
||||||
if (mainCardType == "Land")
|
|
||||||
return 0;
|
|
||||||
if ((mainCardType == "Sorcery") || (mainCardType == "Instant"))
|
|
||||||
return 2;
|
|
||||||
if (mainCardType == "Creature")
|
|
||||||
return 3;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CardInfo::addToSet(CardSet *set)
|
void CardInfo::addToSet(CardSet *set)
|
||||||
{
|
{
|
||||||
set->append(this);
|
set->append(this);
|
||||||
|
@ -186,6 +174,7 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
||||||
xml.writeTextElement("type", info->getCardType());
|
xml.writeTextElement("type", info->getCardType());
|
||||||
if (!info->getPowTough().isEmpty())
|
if (!info->getPowTough().isEmpty())
|
||||||
xml.writeTextElement("pt", info->getPowTough());
|
xml.writeTextElement("pt", info->getPowTough());
|
||||||
|
xml.writeTextElement("tablerow", QString::number(info->getTableRow()));
|
||||||
xml.writeTextElement("text", info->getText());
|
xml.writeTextElement("text", info->getText());
|
||||||
xml.writeEndElement(); // card
|
xml.writeEndElement(); // card
|
||||||
|
|
||||||
|
@ -293,6 +282,17 @@ 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;
|
||||||
|
QString mainCardType = card->getMainCardType();
|
||||||
|
if (mainCardType == "Land")
|
||||||
|
tableRow = 0;
|
||||||
|
else if ((mainCardType == "Sorcery") || (mainCardType == "Instant"))
|
||||||
|
tableRow = 2;
|
||||||
|
else if (mainCardType == "Creature")
|
||||||
|
tableRow = 3;
|
||||||
|
card->setTableRow(tableRow);
|
||||||
|
|
||||||
cardHash.insert(cardname, card);
|
cardHash.insert(cardname, card);
|
||||||
}
|
}
|
||||||
card->addToSet(set);
|
card->addToSet(set);
|
||||||
|
@ -348,6 +348,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
if (xml.name() == "card") {
|
if (xml.name() == "card") {
|
||||||
QString name, manacost, type, pt, text;
|
QString name, manacost, type, pt, text;
|
||||||
SetList sets;
|
SetList sets;
|
||||||
|
int tableRow = 0;
|
||||||
while (!xml.atEnd()) {
|
while (!xml.atEnd()) {
|
||||||
if (xml.readNext() == QXmlStreamReader::EndElement)
|
if (xml.readNext() == QXmlStreamReader::EndElement)
|
||||||
break;
|
break;
|
||||||
|
@ -363,8 +364,10 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
text = xml.readElementText();
|
text = xml.readElementText();
|
||||||
else if (xml.name() == "set")
|
else if (xml.name() == "set")
|
||||||
sets << getSet(xml.readElementText());
|
sets << getSet(xml.readElementText());
|
||||||
|
else if (xml.name() == "tablerow")
|
||||||
|
tableRow = xml.readElementText().toInt();
|
||||||
}
|
}
|
||||||
cardHash.insert(name, new CardInfo(this, name, manacost, type, pt, text, sets));
|
cardHash.insert(name, new CardInfo(this, name, manacost, type, pt, text, tableRow, sets));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ private:
|
||||||
QString cardtype;
|
QString cardtype;
|
||||||
QString powtough;
|
QString powtough;
|
||||||
QString text;
|
QString text;
|
||||||
|
int tableRow;
|
||||||
QPixmap *pixmap;
|
QPixmap *pixmap;
|
||||||
QMap<int, QPixmap *> scaledPixmapCache;
|
QMap<int, QPixmap *> scaledPixmapCache;
|
||||||
public:
|
public:
|
||||||
|
@ -50,6 +51,7 @@ public:
|
||||||
const QString &_cardtype = QString(),
|
const QString &_cardtype = QString(),
|
||||||
const QString &_powtough = QString(),
|
const QString &_powtough = QString(),
|
||||||
const QString &_text = QString(),
|
const QString &_text = QString(),
|
||||||
|
int _tableRow = 0,
|
||||||
const SetList &_sets = SetList());
|
const SetList &_sets = SetList());
|
||||||
~CardInfo();
|
~CardInfo();
|
||||||
QString getName() const { return name; }
|
QString getName() const { return name; }
|
||||||
|
@ -59,7 +61,8 @@ public:
|
||||||
QString getPowTough() const { return powtough; }
|
QString getPowTough() const { return powtough; }
|
||||||
QString getText() const { return text; }
|
QString getText() const { return text; }
|
||||||
QString getMainCardType() const;
|
QString getMainCardType() const;
|
||||||
int getTableRow() const;
|
int getTableRow() const { return tableRow; }
|
||||||
|
void setTableRow(int _tableRow) { tableRow = _tableRow; }
|
||||||
void addToSet(CardSet *set);
|
void addToSet(CardSet *set);
|
||||||
QPixmap *loadPixmap();
|
QPixmap *loadPixmap();
|
||||||
QPixmap *getPixmap(QSize size);
|
QPixmap *getPixmap(QSize size);
|
||||||
|
|
Loading…
Reference in a new issue