summaryrefslogtreecommitdiffstats
path: root/pokemod/Pokemod.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-01-21 00:44:23 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-01-21 00:44:23 +0000
commit2b653821cc31f18adb5d50bb0bc19048939670dc (patch)
treed333bbf0d1dde8fe0c1633bea60785b20ac07841 /pokemod/Pokemod.cpp
parente27ba66952a1e851bb417611e0ed7df1fbf5f945 (diff)
downloadsigen-2b653821cc31f18adb5d50bb0bc19048939670dc.tar.gz
sigen-2b653821cc31f18adb5d50bb0bc19048939670dc.tar.xz
sigen-2b653821cc31f18adb5d50bb0bc19048939670dc.zip
[ADD] More GUI classes (only MoveEffect left)
[FIX] Polished up GUI classes [FIX] renamed methods get*ByID -> get*Index instead for more logical get*ByID [FIX] Renaming in pokemod to remove mention of Pokémon [FIX] minor .pro fixes (aesthetic mainly) git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@35 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Pokemod.cpp')
-rw-r--r--pokemod/Pokemod.cpp309
1 files changed, 193 insertions, 116 deletions
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp
index da034a59..74b8b7c4 100644
--- a/pokemod/Pokemod.cpp
+++ b/pokemod/Pokemod.cpp
@@ -29,10 +29,7 @@ PokeMod::Pokemod::Pokemod(const QString& fname) :
version(""),
description(""),
startMap(UINT_MAX),
- startMoney(0),
- startCoordinate(0, 0),
- startDirection(UINT_MAX),
- startDialog(UINT_MAX),
+ startWarp(UINT_MAX),
superPCUname(""),
superPCPasswd(""),
typeChart(1, 1, Frac(1, 1, Frac::Improper)),
@@ -57,16 +54,11 @@ bool PokeMod::Pokemod::validate() const
}
if (description == "")
validationMsg("Description is not defined", V_Warn);
- if (getMapByID(startMap))
+ if (getMapIndex(startMap))
{
- if (getMap(getMapByID(startMap)).getWidth() <= startCoordinate.getX())
+ if (getMapByID(startMap).getWarpIndex(startWarp) == UINT_MAX)
{
- validationMsg("Invalid starting x coordinate");
- valid = false;
- }
- if (getMap(getMapByID(startMap)).getHeight() <= startCoordinate.getY())
- {
- validationMsg("Invalid starting y coordinate");
+ validationMsg("Invalid starting warp");
valid = false;
}
}
@@ -75,16 +67,6 @@ bool PokeMod::Pokemod::validate() const
validationMsg("Invalid starting map");
valid = false;
}
- if (D_End <= startDirection)
- {
- validationMsg("Invalid starting direction");
- valid = false;
- }
- if (getDialogByID(startDialog) == UINT_MAX)
- {
- validationMsg("Invalid starting dialog");
- valid = false;
- }
if (!QFile::exists(QString("%1/image/skin/walk.png").arg(getPath())))
{
validationMsg("Cannot find walking skin");
@@ -452,7 +434,7 @@ bool PokeMod::Pokemod::validate() const
}
if (!getSpeciesCount())
{
- validationMsg("There are no Pokémon");
+ validationMsg("There are no species");
valid = false;
}
for (QListIterator<Species> i(species); i.hasNext(); i.next())
@@ -466,7 +448,7 @@ bool PokeMod::Pokemod::validate() const
{
if (1 < i.value())
{
- validationMsg(QString("There are %1 Pokémon with id %2").arg(i.value()).arg(i.key()));
+ validationMsg(QString("There are %1 species with id %2").arg(i.value()).arg(i.key()));
valid = false;
}
}
@@ -474,7 +456,7 @@ bool PokeMod::Pokemod::validate() const
{
if (1 < i.value())
{
- validationMsg(QString("There are %1 Pokémon with the name \"%2\"").arg(i.value()).arg(i.key()));
+ validationMsg(QString("There are %1 species with the name \"%2\"").arg(i.value()).arg(i.key()));
valid = false;
}
}
@@ -621,18 +603,11 @@ void PokeMod::Pokemod::load(const QString& fname) throw(Exception)
QStringList fpath = fname.split('\\', QString::SkipEmptyParts).join("/").split('\\', QString::SkipEmptyParts);
fpath.removeLast();
path = fpath.join("/");
- unsigned i;
- unsigned j;
ini.getValue("title", title);
ini.getValue("version", version);
ini.getValue("description", description);
ini.getValue("startMap", startMap);
- ini.getValue("startMoney", startMoney, 0);
- ini.getValue("startCoordinate-x", i, 0);
- ini.getValue("startCoordinate-y", j, 0);
- startCoordinate.set(i, j);
- ini.getValue("startDirection", startDirection);
- ini.getValue("startDialog", startDialog);
+ ini.getValue("startWarp", startWarp);
ini.getValue("superPCUname", superPCUname);
ini.getValue("superPCPasswd", superPCPasswd);
for (unsigned i = 0; i < pokemod.getTypeCount(); ++i)
@@ -769,11 +744,7 @@ void PokeMod::Pokemod::save() const throw(Exception)
ini.addField("version", version);
ini.addField("description", description);
ini.addField("startMap", startMap);
- ini.addField("startMoney", startMoney);
- ini.addField("startCoordinate-x", startCoordinate.getX());
- ini.addField("startCoordinate-y", startCoordinate.getY());
- ini.addField("startDirection", startDirection);
- ini.addField("startDialog", startDialog);
+ ini.addField("startWarp", startWarp);
ini.addField("superPCUname", superPCUname);
ini.addField("superPCPasswd", superPCPasswd);
for (unsigned i = 1; i < typeChart.getWidth(); ++i)
@@ -842,57 +813,18 @@ void PokeMod::Pokemod::setDescription(const QString& d)
void PokeMod::Pokemod::setStartMap(const unsigned s) throw(BoundsException)
{
- if (getMapByID(s) == UINT_MAX)
+ if (getMapIndex(s) == UINT_MAX)
throw(BoundsException("Pokemod", "startMap"));
startMap = s;
}
-void PokeMod::Pokemod::setStartMoney(const unsigned s)
-{
- startMoney = s;
-}
-
-void PokeMod::Pokemod::setStartCoordinate(const unsigned x, const unsigned y) throw(BoundsException)
-{
- if (getMapByID(startMap) == UINT_MAX)
- throw(BoundsException("Pokemod", "startMap"));
- if (getMap(getMapByID(startMap)).getWidth() <= x)
- throw(BoundsException("Pokemod", "startX"));
- if (getMap(getMapByID(startMap)).getHeight() <= y)
- throw(BoundsException("Pokemod", "startY"));
- startCoordinate.set(x, y);
-}
-
-void PokeMod::Pokemod::setStartCoordinateX(const unsigned x) throw(BoundsException)
+void PokeMod::Pokemod::setStartWarp(const unsigned s) throw(BoundsException)
{
- if (getMapByID(startMap) == UINT_MAX)
+ if (getMapIndex(startMap) == UINT_MAX)
throw(BoundsException("Pokemod", "startMap"));
- if (getMap(getMapByID(startMap)).getWidth() <= x)
- throw(BoundsException("Pokemod", "startX"));
- startCoordinate.setX(x);
-}
-
-void PokeMod::Pokemod::setStartCoordinateY(const unsigned y) throw(BoundsException)
-{
- if (getMapByID(startMap) == UINT_MAX)
- throw(BoundsException("Pokemod", "startMap"));
- if (getMap(getMapByID(startMap)).getHeight() <= y)
- throw(BoundsException("Pokemod", "startY"));
- startCoordinate.setY(y);
-}
-
-void PokeMod::Pokemod::setStartDirection(const unsigned s) throw(BoundsException)
-{
- if (D_End <= s)
- throw(BoundsException("Pokemod", "startDirection"));
- startDirection = s;
-}
-
-void PokeMod::Pokemod::setStartDialog(const unsigned s) throw(BoundsException)
-{
- if (getDialogByID(s) == UINT_MAX)
- throw(BoundsException("Pokemod", "startDialog"));
- startDialog = s;
+ if (getMapByID(startMap).getWarpIndex(s) == UINT_MAX)
+ throw(BoundsException("Pokemod", "startWarp"));
+ startWarp = s;
}
void PokeMod::Pokemod::setWalkSkin(const QString& fname) throw(Exception)
@@ -1004,24 +936,9 @@ unsigned PokeMod::Pokemod::getStartMap() const
return startMap;
}
-unsigned PokeMod::Pokemod::getStartMoney() const
-{
- return startMoney;
-}
-
-Point PokeMod::Pokemod::getStartCoordinate() const
-{
- return startCoordinate;
-}
-
-unsigned PokeMod::Pokemod::getStartDirection() const
+unsigned PokeMod::Pokemod::getStartWarp() const
{
- return startDirection;
-}
-
-unsigned PokeMod::Pokemod::getStartDialog() const
-{
- return startDialog;
+ return startWarp;
}
QString PokeMod::Pokemod::getSuperPCUname() const
@@ -1073,7 +990,17 @@ PokeMod::Ability& PokeMod::Pokemod::getAbility(const unsigned i) throw(IndexExce
return abilities[i];
}
-unsigned PokeMod::Pokemod::getAbilityByID(const unsigned _id) const
+const PokeMod::Ability& PokeMod::Pokemod::getAbilityByID(const unsigned i) const throw(IndexException)
+{
+ return getAbility(getAbilityIndex(i));
+}
+
+PokeMod::Ability& PokeMod::Pokemod::getAbilityByID(const unsigned i) throw(IndexException)
+{
+ return getAbility(getAbilityIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getAbilityIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getAbilityCount(); ++i)
{
@@ -1127,7 +1054,17 @@ PokeMod::Author& PokeMod::Pokemod::getAuthor(const unsigned i) throw(IndexExcept
return authors[i];
}
-unsigned PokeMod::Pokemod::getAuthorByID(const unsigned _id) const
+const PokeMod::Author& PokeMod::Pokemod::getAuthorByID(const unsigned i) const throw(IndexException)
+{
+ return getAuthor(getAuthorIndex(i));
+}
+
+PokeMod::Author& PokeMod::Pokemod::getAuthorByID(const unsigned i) throw(IndexException)
+{
+ return getAuthor(getAuthorIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getAuthorIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getAuthorCount(); ++i)
{
@@ -1169,7 +1106,17 @@ PokeMod::Badge& PokeMod::Pokemod::getBadge(const unsigned i) throw(IndexExceptio
return badges[i];
}
-unsigned PokeMod::Pokemod::getBadgeByID(const unsigned _id) const
+const PokeMod::Badge& PokeMod::Pokemod::getBadgeByID(const unsigned i) const throw(IndexException)
+{
+ return getBadge(getBadgeIndex(i));
+}
+
+PokeMod::Badge& PokeMod::Pokemod::getBadgeByID(const unsigned i) throw(IndexException)
+{
+ return getBadge(getBadgeIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getBadgeIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getBadgeCount(); ++i)
{
@@ -1223,7 +1170,17 @@ PokeMod::CoinList& PokeMod::Pokemod::getCoinList(const unsigned i) throw(IndexEx
return coinLists[i];
}
-unsigned PokeMod::Pokemod::getCoinListByID(const unsigned _id) const
+const PokeMod::CoinList& PokeMod::Pokemod::getCoinListByID(const unsigned i) const throw(IndexException)
+{
+ return getCoinList(getCoinListIndex(i));
+}
+
+PokeMod::CoinList& PokeMod::Pokemod::getCoinListByID(const unsigned i) throw(IndexException)
+{
+ return getCoinList(getCoinListIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getCoinListIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getCoinListCount(); ++i)
{
@@ -1277,7 +1234,17 @@ PokeMod::Dialog& PokeMod::Pokemod::getDialog(const unsigned i) throw(IndexExcept
return dialogs[i];
}
-unsigned PokeMod::Pokemod::getDialogByID(const unsigned _id) const
+const PokeMod::Dialog& PokeMod::Pokemod::getDialogByID(const unsigned i) const throw(IndexException)
+{
+ return getDialog(getDialogIndex(i));
+}
+
+PokeMod::Dialog& PokeMod::Pokemod::getDialogByID(const unsigned i) throw(IndexException)
+{
+ return getDialog(getDialogIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getDialogIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getDialogCount(); ++i)
{
@@ -1331,7 +1298,17 @@ PokeMod::EggGroup& PokeMod::Pokemod::getEggGroup(const unsigned i) throw(IndexEx
return eggGroups[i];
}
-unsigned PokeMod::Pokemod::getEggGroupByID(const unsigned _id) const
+const PokeMod::EggGroup& PokeMod::Pokemod::getEggGroupByID(const unsigned i) const throw(IndexException)
+{
+ return getEggGroup(getEggGroupIndex(i));
+}
+
+PokeMod::EggGroup& PokeMod::Pokemod::getEggGroupByID(const unsigned i) throw(IndexException)
+{
+ return getEggGroup(getEggGroupIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getEggGroupIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getEggGroupCount(); ++i)
{
@@ -1385,7 +1362,17 @@ PokeMod::Item& PokeMod::Pokemod::getItem(const unsigned i) throw(IndexException)
return items[i];
}
-unsigned PokeMod::Pokemod::getItemByID(const unsigned _id) const
+const PokeMod::Item& PokeMod::Pokemod::getItemByID(const unsigned i) const throw(IndexException)
+{
+ return getItem(getItemIndex(i));
+}
+
+PokeMod::Item& PokeMod::Pokemod::getItemByID(const unsigned i) throw(IndexException)
+{
+ return getItem(getItemIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getItemIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getItemCount(); ++i)
{
@@ -1439,7 +1426,17 @@ PokeMod::ItemType& PokeMod::Pokemod::getItemType(const unsigned i) throw(IndexEx
return itemTypes[i];
}
-unsigned PokeMod::Pokemod::getItemTypeByID(const unsigned _id) const
+const PokeMod::ItemType& PokeMod::Pokemod::getItemTypeByID(const unsigned i) const throw(IndexException)
+{
+ return getItemType(getItemTypeIndex(i));
+}
+
+PokeMod::ItemType& PokeMod::Pokemod::getItemTypeByID(const unsigned i) throw(IndexException)
+{
+ return getItemType(getItemTypeIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getItemTypeIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getItemTypeCount(); ++i)
{
@@ -1493,7 +1490,17 @@ PokeMod::Map& PokeMod::Pokemod::getMap(const unsigned i) throw(IndexException)
return maps[i];
}
-unsigned PokeMod::Pokemod::getMapByID(const unsigned _id) const
+const PokeMod::Map& PokeMod::Pokemod::getMapByID(const unsigned i) const throw(IndexException)
+{
+ return getMap(getMapIndex(i));
+}
+
+PokeMod::Map& PokeMod::Pokemod::getMapByID(const unsigned i) throw(IndexException)
+{
+ return getMap(getMapIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getMapIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getMapCount(); ++i)
{
@@ -1547,7 +1554,17 @@ PokeMod::Move& PokeMod::Pokemod::getMove(const unsigned i) throw(IndexException)
return moves[i];
}
-unsigned PokeMod::Pokemod::getMoveByID(const unsigned _id) const
+const PokeMod::Move& PokeMod::Pokemod::getMoveByID(const unsigned i) const throw(IndexException)
+{
+ return getMove(getMoveIndex(i));
+}
+
+PokeMod::Move& PokeMod::Pokemod::getMoveByID(const unsigned i) throw(IndexException)
+{
+ return getMove(getMoveIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getMoveIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getMoveCount(); ++i)
{
@@ -1601,7 +1618,17 @@ PokeMod::Nature& PokeMod::Pokemod::getNature(const unsigned i) throw(IndexExcept
return natures[i];
}
-unsigned PokeMod::Pokemod::getNatureByID(const unsigned _id) const
+const PokeMod::Nature& PokeMod::Pokemod::getNatureByID(const unsigned i) const throw(IndexException)
+{
+ return getNature(getNatureIndex(i));
+}
+
+PokeMod::Nature& PokeMod::Pokemod::getNatureByID(const unsigned i) throw(IndexException)
+{
+ return getNature(getNatureIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getNatureIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getNatureCount(); ++i)
{
@@ -1655,7 +1682,17 @@ PokeMod::Species& PokeMod::Pokemod::getSpecies(const unsigned i) throw(IndexExce
return species[i];
}
-unsigned PokeMod::Pokemod::getSpeciesByID(const unsigned _id) const
+const PokeMod::Species& PokeMod::Pokemod::getSpeciesByID(const unsigned i) const throw(IndexException)
+{
+ return getSpecies(getSpeciesIndex(i));
+}
+
+PokeMod::Species& PokeMod::Pokemod::getSpeciesByID(const unsigned i) throw(IndexException)
+{
+ return getSpecies(getSpeciesIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getSpeciesIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getSpeciesCount(); ++i)
{
@@ -1709,7 +1746,17 @@ PokeMod::Store& PokeMod::Pokemod::getStore(const unsigned i) throw(IndexExceptio
return stores[i];
}
-unsigned PokeMod::Pokemod::getStoreByID(const unsigned _id) const
+const PokeMod::Store& PokeMod::Pokemod::getStoreByID(const unsigned i) const throw(IndexException)
+{
+ return getStore(getStoreIndex(i));
+}
+
+PokeMod::Store& PokeMod::Pokemod::getStoreByID(const unsigned i) throw(IndexException)
+{
+ return getStore(getStoreIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getStoreIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getStoreCount(); ++i)
{
@@ -1763,7 +1810,17 @@ PokeMod::Tile& PokeMod::Pokemod::getTile(const unsigned i) throw(IndexException)
return tiles[i];
}
-unsigned PokeMod::Pokemod::getTileByID(const unsigned _id) const
+const PokeMod::Tile& PokeMod::Pokemod::getTileByID(const unsigned i) const throw(IndexException)
+{
+ return getTile(getTileIndex(i));
+}
+
+PokeMod::Tile& PokeMod::Pokemod::getTileByID(const unsigned i) throw(IndexException)
+{
+ return getTile(getTileIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getTileIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getTileCount(); ++i)
{
@@ -1817,7 +1874,17 @@ PokeMod::Time& PokeMod::Pokemod::getTime(const unsigned i) throw(IndexException)
return times[i];
}
-unsigned PokeMod::Pokemod::getTimeByID(const unsigned _id) const
+const PokeMod::Time& PokeMod::Pokemod::getTimeByID(const unsigned i) const throw(IndexException)
+{
+ return getTime(getTimeIndex(i));
+}
+
+PokeMod::Time& PokeMod::Pokemod::getTimeByID(const unsigned i) throw(IndexException)
+{
+ return getTime(getTimeIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getTimeIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getTimeCount(); ++i)
{
@@ -1871,7 +1938,17 @@ PokeMod::Type& PokeMod::Pokemod::getType(const unsigned i) throw(IndexException)
return types[i];
}
-unsigned PokeMod::Pokemod::getTypeByID(const unsigned _id) const
+const PokeMod::Type& PokeMod::Pokemod::getTypeByID(const unsigned i) const throw(IndexException)
+{
+ return getType(getTypeIndex(i));
+}
+
+PokeMod::Type& PokeMod::Pokemod::getTypeByID(const unsigned i) throw(IndexException)
+{
+ return getType(getTypeIndex(i));
+}
+
+unsigned PokeMod::Pokemod::getTypeIndex(const unsigned _id) const
{
for (unsigned i = 0; i < getTypeCount(); ++i)
{