diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2008-02-22 01:39:13 +0000 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2008-02-22 01:39:13 +0000 |
commit | 8082fda92a86b34a37fe386266efbde5e30bca16 (patch) | |
tree | 85713a913062b8c851de806e2ad0fe26adaa7e03 /pokemod | |
parent | 88b11f136c7a4b287ac44e3ec8e671cf17ab8319 (diff) | |
download | sigen-8082fda92a86b34a37fe386266efbde5e30bca16.tar.gz sigen-8082fda92a86b34a37fe386266efbde5e30bca16.tar.xz sigen-8082fda92a86b34a37fe386266efbde5e30bca16.zip |
[FIX] Frac now makes sure that the denominator is positive
[FIX] Sprite-containing classes less repetative with determining paths
[FIX] More include cleanup in pokemodr
[FIX] Precision of Frac decimal equivalents now use a define
[FIX] Species UI form is now more compact and complete
[ADD] SpeciesUI.{h, cpp} (again; wasn't actually included last time and got lost)
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@68 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod')
-rw-r--r-- | pokemod/Badge.cpp | 12 | ||||
-rw-r--r-- | pokemod/Species.cpp | 59 | ||||
-rw-r--r-- | pokemod/Species.h | 10 | ||||
-rw-r--r-- | pokemod/Tile.cpp | 21 | ||||
-rw-r--r-- | pokemod/Tile.h | 3 |
5 files changed, 63 insertions, 42 deletions
diff --git a/pokemod/Badge.cpp b/pokemod/Badge.cpp index 2f444cef..cdc150d1 100644 --- a/pokemod/Badge.cpp +++ b/pokemod/Badge.cpp @@ -61,12 +61,12 @@ bool Badge::validate() const pokemod->validationMsg("Obey level out of range"); valid = false; } - if (!QFile(QString("%1/badge/%2/face.png").arg(pokemod->getPath()).arg(name)).exists()) + if (!QFile(getFace()).exists()) { pokemod->validationMsg("Cannot find the face sprite"); valid = false; } - if (!QFile(QString("%1/badge/%2/badge.png").arg(pokemod->getPath()).arg(name)).exists()) + if (!QFile(getBadge()).exists()) { pokemod->validationMsg("Cannot find the badge sprite"); valid = false; @@ -118,19 +118,19 @@ void Badge::setName(const QString& n) void Badge::setFace(const QString& f) throw(Exception) { - QFile file(QString("%1/badge/%2/face.png").arg(pokemod->getPath()).arg(name)); + QFile file(getFace()); if (file.exists() && !file.remove()) throw(ReplaceException(className, file.fileName())); - if (!QFile::copy(f, QString("%1/badge/%2/face.png").arg(pokemod->getPath()).arg(name))) + if (!QFile::copy(f, getFace())) throw(SaveException(className, file.fileName())); } void Badge::setBadge(const QString& b) throw(Exception) { - QFile file(QString("%1/badge/%2/badge.png").arg(pokemod->getPath()).arg(name)); + QFile file(getBadge()); if (file.exists() && !file.remove()) throw(ReplaceException(className, file.fileName())); - if (!QFile::copy(b, QString("%1/badge/%2/badge.png").arg(pokemod->getPath()).arg(name))) + if (!QFile::copy(b, getBadge())) throw(SaveException(className, file.fileName())); } diff --git a/pokemod/Species.cpp b/pokemod/Species.cpp index 2cb92749..14433c5f 100644 --- a/pokemod/Species.cpp +++ b/pokemod/Species.cpp @@ -43,7 +43,7 @@ Species::Species(const Pokemod* par, const int _id) : heightFeet(0), heightInches(0), pokedexEntry(""), - genderFactor(1, 1, true), + genderFactor(1, 1), eggSpecies(-1), eggSteps(0), nidoranGroup(-1) @@ -101,30 +101,30 @@ bool Species::validate() const pokemod->validationMsg("Invalid height inches"); valid = false; } - if (!QFile::exists(QString("%1/species/%2/front%3.png").arg(pokemod->getPath()).arg(name).arg(pokemod->getRules()->getGenderAllowed() ? "-male" : ""))) + if (!QFile::exists(getFrontMaleSprite())) { pokemod->validationMsg(QString("Cannot find the front%1 image").arg(pokemod->getRules()->getGenderAllowed() ? " male" : "")); valid = false; } - if (!QFile::exists(QString("%1/species/%2/back%3.png").arg(pokemod->getPath()).arg(name).arg(pokemod->getRules()->getGenderAllowed() ? "-male" : ""))) + if (!QFile::exists(getBackMaleSprite())) { pokemod->validationMsg(QString("Cannot find the back%1 image").arg(pokemod->getRules()->getGenderAllowed() ? " male" : "")); valid = false; } if (pokemod->getRules()->getGenderAllowed()) { - if (!QFile::exists(QString("%1/species/%2/front-female.png").arg(pokemod->getPath()).arg(name))) + if (!QFile::exists(getFrontFemaleSprite())) { pokemod->validationMsg("Cannot find the front female image"); valid = false; } - if (!QFile::exists(QString("%1/species/%2/back-female.png").arg(pokemod->getPath()).arg(name))) + if (!QFile::exists(getBackFemaleSprite())) { pokemod->validationMsg("Cannot find the back female image"); valid = false; } } - if (!QFile::exists(QString("%1/species/%2/list.png").arg(pokemod->getPath()).arg(name))) + if (!QFile::exists(getListSprite())) { pokemod->validationMsg("Cannot find the list sprite"); valid = false; @@ -230,7 +230,7 @@ bool Species::validate() const { if (1 < i.value()) { - pokemod->validationMsg(QString("There are %1 evoltions with the speices %2").arg(i.value()).arg(i.key())); + pokemod->validationMsg(QString("There are %1 evolutions with the speices %2").arg(i.value()).arg(i.key())); valid = false; } } @@ -553,19 +553,19 @@ void Species::setPokedexEntry(const QString& p) void Species::setFrontMaleSprite(const QString& fname) throw(Exception) { - QFile file(QString("%1/species/%2/front%3.png").arg(pokemod->getPath()).arg(name).arg(pokemod->getRules()->getGenderAllowed() ? "-male" : "")); + QFile file(getFrontMaleSprite()); if (file.exists() && !file.remove()) throw(RemoveException(className, file.fileName())); - if (!QFile::copy(fname, QString("%1/species/%2/front%3.png").arg(pokemod->getPath()).arg(name).arg(pokemod->getRules()->getGenderAllowed() ? "-male" : ""))) + if (!QFile::copy(fname, getFrontMaleSprite())) throw(SaveException(className, file.fileName())); } void Species::setBackMaleSprite(const QString& fname) throw(Exception) { - QFile file(QString("%1/species/%2/back%3.png").arg(pokemod->getPath()).arg(name).arg(pokemod->getRules()->getGenderAllowed() ? "-male" : "")); + QFile file(getBackMaleSprite()); if (file.exists() && !file.remove()) throw(RemoveException(className, file.fileName())); - if (!QFile::copy(fname, QString("%1/species/%2/back%3.png").arg(pokemod->getPath()).arg(name).arg(pokemod->getRules()->getGenderAllowed() ? "-male" : ""))) + if (!QFile::copy(fname, getBackMaleSprite())) throw(SaveException(className, file.fileName())); } @@ -573,10 +573,10 @@ void Species::setFrontFemaleSprite(const QString& fname) throw(Exception) { if (!pokemod->getRules()->getGenderAllowed()) throw(Exception(className, "gender is not allowed")); - QFile file(QString("%1/species/%2/front-female.png").arg(pokemod->getPath()).arg(name)); + QFile file(getFrontFemaleSprite()); if (file.exists() && !file.remove()) throw(RemoveException(className, file.fileName())); - if (!QFile::copy(fname, QString("%1/species/%2/front-female.png").arg(pokemod->getPath()).arg(name))) + if (!QFile::copy(fname, getFrontFemaleSprite())) throw(SaveException(className, file.fileName())); } @@ -584,19 +584,19 @@ void Species::setBackFemaleSprite(const QString& fname) throw(Exception) { if (!pokemod->getRules()->getGenderAllowed()) throw(Exception(className, "gender is not allowed")); - QFile file(QString("%1/species/%2/back-female.png").arg(pokemod->getPath()).arg(name)); + QFile file(getBackFemaleSprite()); if (file.exists() && !file.remove()) throw(RemoveException(className, file.fileName())); - if (!QFile::copy(fname, QString("%1/species/%2/back-female.png").arg(pokemod->getPath()).arg(name))) + if (!QFile::copy(fname, getBackFemaleSprite())) throw(SaveException(className, file.fileName())); } void Species::setListSprite(const QString& fname) throw(Exception) { - QFile file(QString("%1/species/%2/list.png").arg(pokemod->getPath()).arg(name)); + QFile file(getListSprite()); if (file.exists() && !file.remove()) throw(RemoveException(className, file.fileName())); - if (!QFile::copy(fname, QString("%1/species/%2/list.png").arg(pokemod->getPath()).arg(name))) + if (!QFile::copy(fname, getListSprite())) throw(SaveException(className, file.fileName())); } @@ -739,6 +739,31 @@ QString Species::getPokedexEntry() const return pokedexEntry; } +QString Species::getFrontMaleSprite() const +{ + return QString("%1/species/%2/front-male.png").arg(pokemod->getPath()).arg(name); +} + +QString Species::getBackMaleSprite() const +{ + return QString("%1/species/%2/back-male.png").arg(pokemod->getPath()).arg(name); +} + +QString Species::getFrontFemaleSprite() const +{ + return QString("%1/species/%2/front-female.png").arg(pokemod->getPath()).arg(name); +} + +QString Species::getBackFemaleSprite() const +{ + return QString("%1/species/%2/back-female.png").arg(pokemod->getPath()).arg(name); +} + +QString Species::getListSprite() const +{ + return QString("%1/species/%2/list.png").arg(pokemod->getPath()).arg(name); +} + Frac Species::getGenderFactor() const { return genderFactor; diff --git a/pokemod/Species.h b/pokemod/Species.h index 13e48ec6..11410b9e 100644 --- a/pokemod/Species.h +++ b/pokemod/Species.h @@ -105,11 +105,11 @@ class Species : public Object int getHeightFeet() const; int getHeightInches() const; QString getPokedexEntry() const; - bool getFrontMaleSprite() const; - bool getBackMaleSprite() const; - bool getFrontFemaleSprite() const; - bool getBackFemaleSprite() const; - bool getListSprite() const; + QString getFrontMaleSprite() const; + QString getBackMaleSprite() const; + QString getFrontFemaleSprite() const; + QString getBackFemaleSprite() const; + QString getListSprite() const; Frac getGenderFactor() const; int getEggSpecies() const; int getEggSteps() const; diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp index 7f9e319e..11043882 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -28,7 +28,6 @@ const QStringList Tile::ForceStr = QStringList() << "Slip" << "Stop" << "Force" Tile::Tile(const Pokemod* par, const int _id) : Object("Tile", par, _id), name(""), - pic(""), wildChance(1, 1), hmType(-1), under(-1), @@ -46,8 +45,7 @@ Tile::Tile(const Pokemod* par, const Tile& t, const int _id) : } Tile::Tile(const Pokemod* par, const QString& fname, const int _id) : - Object("Tile", par, _id), - pic("") + Object("Tile", par, _id) { load(fname, _id); } @@ -61,7 +59,7 @@ bool Tile::validate() const pokemod->validationMsg("Name is not defined"); valid = false; } - if (!QFile::exists(QString("%1/image/tile/%2.png").arg(pokemod->getPath()).arg(pic))) + if (!QFile::exists(getPic())) { pokemod->validationMsg("Cannot find tile image"); valid = false; @@ -112,7 +110,6 @@ void Tile::load(const QString& fname, const int _id) throw(Exception) int i; int j; ini.getValue("name", name); - ini.getValue("pic", pic); ini.getValue("from-up", from[D_Up], false); ini.getValue("from-down", from[D_Down], false); ini.getValue("from-left", from[D_Left], false); @@ -131,7 +128,6 @@ void Tile::save() const throw(Exception) Ini ini; ini.addField("id", id); ini.addField("name", name); - ini.addField("pic", pic); ini.addField("from-up", from[D_Up]); ini.addField("from-down", from[D_Down]); ini.addField("from-left", from[D_Left]); @@ -150,11 +146,13 @@ void Tile::setName(const QString& n) name = n; } -void Tile::setPic(const QString& p) throw(OpenException) +void Tile::setPic(const QString& fname) throw(Exception) { - if (!QFile::exists(QString("%1/image/tile/%2.png").arg(pokemod->getPath()).arg(p))) - throw(OpenException(className, QString("%1/image/tile/%2.png").arg(pokemod->getPath()).arg(p))); - pic = p; + QFile file(getPic()); + if (file.exists() && !file.remove()) + throw(RemoveException(className, file.fileName())); + if (!QFile::copy(fname, getPic())) + throw(SaveException(className, file.fileName())); } void Tile::setFrom(const int d, const bool f) throw(BoundsException) @@ -225,7 +223,7 @@ QString Tile::getName() const QString Tile::getPic() const { - return pic; + return QString("%1/tile/%2.png").arg(pokemod->getPath()).arg(name); } bool Tile::getFrom(const int d) const throw(BoundsException) @@ -265,7 +263,6 @@ Tile& Tile::operator=(const Tile& rhs) if (this == &rhs) return *this; name = rhs.name; - pic = rhs.pic; for (int i = 0; i < D_End; ++i) from[i] = rhs.from[i]; wildChance = rhs.wildChance; diff --git a/pokemod/Tile.h b/pokemod/Tile.h index f2825be2..32441e92 100644 --- a/pokemod/Tile.h +++ b/pokemod/Tile.h @@ -55,7 +55,7 @@ class Tile : public Object void save() const throw(Exception); void setName(const QString& n); - void setPic(const QString& p) throw(OpenException); + void setPic(const QString& p) throw(Exception); void setFrom(const int d, const bool f) throw(BoundsException); void setWildChance(const int n, const int d) throw(Exception); void setWildChanceNum(const int n) throw(Exception); @@ -79,7 +79,6 @@ class Tile : public Object bool validate() const; QString name; - QString pic; bool from[D_End]; Frac wildChance; int hmType; |