summaryrefslogtreecommitdiffstats
path: root/pokemod/Pokemod.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-19 18:12:17 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-19 18:12:17 +0000
commitfe31331e2807634ae659e372358bac5781de9130 (patch)
tree6b208974e3f141e9b22152526e2d42e967bfd4ec /pokemod/Pokemod.cpp
parent6679f5cffa9d35a23b76605ddfbf3257f882b6ee (diff)
downloadsigen-fe31331e2807634ae659e372358bac5781de9130.tar.gz
sigen-fe31331e2807634ae659e372358bac5781de9130.tar.xz
sigen-fe31331e2807634ae659e372358bac5781de9130.zip
[FIX] IndexException is more explicit
[FIX] Added SizeException for image validation [FIX] QPixmaps are now verified [FIX] Classes now use error and warning rather than throwing [FIX] Deleted Object.cpp git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@100 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Pokemod.cpp')
-rw-r--r--pokemod/Pokemod.cpp87
1 files changed, 49 insertions, 38 deletions
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp
index b5cc1cc5..bed4f017 100644
--- a/pokemod/Pokemod.cpp
+++ b/pokemod/Pokemod.cpp
@@ -61,6 +61,12 @@ Pokemod::Pokemod() :
m_description(""),
m_startMap(INT_MAX),
m_startWarp(INT_MAX),
+ m_walkSkin(192, 128),
+ m_bikeSkin(192, 128),
+ m_surfSkin(192, 128),
+ m_flySkin(192, 128),
+ m_fishSkin(192, 128),
+ m_surfFishSkin(),
m_superPCUname(""),
m_superPCPasswd(""),
m_typeChart(0, 0),//, Fraction(1, 1, Fraction::Improper)),
@@ -409,8 +415,7 @@ void Pokemod::load(const QDomElement& xml, const int) throw(Exception)
QDomElement Pokemod::save() const
{
- QDomElement xml;
- xml.setTagName(className());
+ QDomElement xml = QDomDocument().createElement(className());
SAVE(QString, title);
SAVE(QString, version);
SAVE(QString, description);
@@ -451,13 +456,13 @@ int Pokemod::maxCompatability(const Pokemod& pokemod) const
// TODO: MaxCompatability between two versions
}
-void Pokemod::validationMsg(const QString& msg, Validation val) const throw(Exception)
+void Pokemod::validationMsg(const QString& message, const Validation level) const throw(Exception)
{
if (!valOutput)
throw(Exception(className(), "valOutput isn\'t set"));
- if (V_End < val)
- throw(BoundsException(className(), "val"));
- (*valOutput) << ValidationStr[val] << QDateTime::currentDateTime().toString(" (yyyyMMdd hh:mm:ss.zzz ddd): ") << msg;
+ if (V_End < level)
+ warning<BoundsException>("level");
+ (*valOutput) << ValidationStr[level] << QDateTime::currentDateTime().toString(" (yyyyMMdd hh:mm:ss.zzz ddd): ") << message;
}
void Pokemod::setValOutput(QStringList& s)
@@ -488,52 +493,58 @@ void Pokemod::setDescription(const QString& description)
void Pokemod::setStartMap(const int startMap) throw(BoundsException)
{
if (mapIndex(startMap) == INT_MAX)
- throw(BoundsException(className(), "startMap"));
+ error<BoundsException>("startMap");
m_startMap = startMap;
}
void Pokemod::setStartWarp(const int startWarp) throw(BoundsException)
{
if (mapIndex(m_startMap) == INT_MAX)
- throw(BoundsException(className(), "startMap"));
+ error<BoundsException>("startMap");
if (mapById(m_startMap)->warpIndex(startWarp) == INT_MAX)
- throw(BoundsException(className(), "startWarp"));
+ error<BoundsException>("startWarp");
m_startWarp = startWarp;
}
-void Pokemod::setWalkSkin(const QPixmap& walkSkin) throw(Exception)
+void Pokemod::setWalkSkin(const QPixmap& walkSkin) throw(SizeException)
{
- // TODO: check dimensions
+ if (walkSkin.size() != QSize(192, 128))
+ error<SizeException>("walkSkin");
m_walkSkin = walkSkin;
}
-void Pokemod::setBikeSkin(const QPixmap& bikeSkin) throw(Exception)
+void Pokemod::setBikeSkin(const QPixmap& bikeSkin) throw(SizeException)
{
- // TODO: check dimensions
+ if (bikeSkin.size() != QSize(192, 128))
+ error<SizeException>("bikeSkin");
m_bikeSkin = bikeSkin;
}
-void Pokemod::setSurfSkin(const QPixmap& surfSkin) throw(Exception)
+void Pokemod::setSurfSkin(const QPixmap& surfSkin) throw(SizeException)
{
- // TODO: check dimensions
+ if (surfSkin.size() != QSize(192, 128))
+ error<SizeException>("surfSkin");
m_surfSkin = surfSkin;
}
-void Pokemod::setFlySkin(const QPixmap& flySkin) throw(Exception)
+void Pokemod::setFlySkin(const QPixmap& flySkin) throw(SizeException)
{
- // TODO: check dimensions
+ if (flySkin.size() != QSize(192, 128))
+ error<SizeException>("flySkin");
m_flySkin = flySkin;
}
-void Pokemod::setFishSkin(const QPixmap& fishSkin) throw(Exception)
+void Pokemod::setFishSkin(const QPixmap& fishSkin) throw(SizeException)
{
- // TODO: check dimensions
+ if (fishSkin.size() != QSize(192, 128))
+ error<SizeException>("fishSkin");
m_fishSkin = fishSkin;
}
-void Pokemod::setSurfFishSkin(const QPixmap& surfFishSkin) throw(Exception)
+void Pokemod::setSurfFishSkin(const QPixmap& surfFishSkin) throw(SizeException)
{
- // TODO: check dimensions
+ if (surfFishSkin.size() != QSize(192, 128))
+ error<SizeException>("surfFishSkin");
m_surfFishSkin = surfFishSkin;
}
@@ -655,7 +666,7 @@ Rules* Pokemod::rules()
const Ability* Pokemod::ability(const int index) const throw(IndexException)
{
if (abilityCount() <= index)
- error<IndexException>("ability");
+ warning<IndexException>("ability");
return m_abilities.at(index);
}
@@ -733,7 +744,7 @@ int Pokemod::newAbilityId() const
const Author* Pokemod::author(const int index) const throw(IndexException)
{
if (authorCount() <= index)
- error<IndexException>("author");
+ warning<IndexException>("author");
return m_authors.at(index);
}
@@ -811,7 +822,7 @@ int Pokemod::newAuthorId() const
const Badge* Pokemod::badge(const int index) const throw(IndexException)
{
if (badgeCount() <= index)
- error<IndexException>("badge");
+ warning<IndexException>("badge");
return m_badges.at(index);
}
@@ -889,7 +900,7 @@ int Pokemod::newBadgeId() const
const CoinList* Pokemod::coinList(const int index) const throw(IndexException)
{
if (coinListCount() <= index)
- error<IndexException>("coin list");
+ warning<IndexException>("coin list");
return m_coinLists.at(index);
}
@@ -967,7 +978,7 @@ int Pokemod::newCoinListId() const
const Dialog* Pokemod::dialog(const int index) const throw(IndexException)
{
if (dialogCount() <= index)
- error<IndexException>("dialog");
+ warning<IndexException>("dialog");
return m_dialogs.at(index);
}
@@ -1045,7 +1056,7 @@ int Pokemod::newDialogId() const
const EggGroup* Pokemod::eggGroup(const int index) const throw(IndexException)
{
if (eggGroupCount() <= index)
- error<IndexException>("egg group");
+ warning<IndexException>("egg group");
return m_eggGroups.at(index);
}
@@ -1123,7 +1134,7 @@ int Pokemod::newEggGroupId() const
const Item* Pokemod::item(const int index) const throw(IndexException)
{
if (itemCount() <= index)
- error<IndexException>("item");
+ warning<IndexException>("item");
return m_items.at(index);
}
@@ -1201,7 +1212,7 @@ int Pokemod::newItemId() const
const ItemType* Pokemod::itemType(const int index) const throw(IndexException)
{
if (itemTypeCount() <= index)
- error<IndexException>("item type");
+ warning<IndexException>("item type");
return m_itemTypes.at(index);
}
@@ -1279,7 +1290,7 @@ int Pokemod::newItemTypeId() const
const Map* Pokemod::map(const int index) const throw(IndexException)
{
if (mapCount() <= index)
- error<IndexException>("map");
+ warning<IndexException>("map");
return m_maps.at(index);
}
@@ -1357,7 +1368,7 @@ int Pokemod::newMapId() const
const Move* Pokemod::move(const int index) const throw(IndexException)
{
if (moveCount() <= index)
- error<IndexException>("move");
+ warning<IndexException>("move");
return m_moves.at(index);
}
@@ -1435,7 +1446,7 @@ int Pokemod::newMoveId() const
const Nature* Pokemod::nature(const int index) const throw(IndexException)
{
if (natureCount() <= index)
- error<IndexException>("nature");
+ warning<IndexException>("nature");
return m_natures.at(index);
}
@@ -1513,7 +1524,7 @@ int Pokemod::newNatureId() const
const Species* Pokemod::species(const int index) const throw(IndexException)
{
if (speciesCount() <= index)
- error<IndexException>("species");
+ warning<IndexException>("species");
return m_species.at(index);
}
@@ -1591,7 +1602,7 @@ int Pokemod::newSpeciesId() const
const Store* Pokemod::store(const int index) const throw(IndexException)
{
if (storeCount() <= index)
- error<IndexException>("store");
+ warning<IndexException>("store");
return m_stores.at(index);
}
@@ -1669,7 +1680,7 @@ int Pokemod::newStoreId() const
const Tile* Pokemod::tile(const int index) const throw(IndexException)
{
if (tileCount() <= index)
- error<IndexException>("tile");
+ warning<IndexException>("tile");
return m_tiles.at(index);
}
@@ -1747,7 +1758,7 @@ int Pokemod::newTileId() const
const Time* Pokemod::time(const int index) const throw(IndexException)
{
if (timeCount() <= index)
- error<IndexException>("time");
+ warning<IndexException>("time");
return m_times.at(index);
}
@@ -1825,7 +1836,7 @@ int Pokemod::newTimeId() const
const Trainer* Pokemod::trainer(const int index) const throw(IndexException)
{
if (trainerCount() <= index)
- error<IndexException>("trainer");
+ warning<IndexException>("trainer");
return m_trainers.at(index);
}
@@ -1903,7 +1914,7 @@ int Pokemod::newTrainerId() const
const Type* Pokemod::type(const int index) const throw(IndexException)
{
if (typeCount() <= index)
- error<IndexException>("type");
+ warning<IndexException>("type");
return m_types.at(index);
}