From 2b653821cc31f18adb5d50bb0bc19048939670dc Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 21 Jan 2008 00:44:23 +0000 Subject: [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) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@35 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/MapTrainer.cpp | 135 +++++++++++++++++++++++-------------------------- 1 file changed, 63 insertions(+), 72 deletions(-) (limited to 'pokemod/MapTrainer.cpp') diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp index 6ce711eb..ad287393 100644 --- a/pokemod/MapTrainer.cpp +++ b/pokemod/MapTrainer.cpp @@ -35,7 +35,7 @@ PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const unsigned _id) : overworldDialog(UINT_MAX), winDialog(UINT_MAX), loseDialog(UINT_MAX), - leadPokemon(UINT_MAX) + leadTeamMember(UINT_MAX) { } @@ -80,30 +80,30 @@ bool PokeMod::MapTrainer::validate() const pokemod.validationMsg("AI file couldn\'t be found"); valid = false; } - if (pokemod.getDialogByID(overworldDialog) == UINT_MAX) + if (pokemod.getDialogIndex(overworldDialog) == UINT_MAX) { pokemod.validationMsg("Invalid overworld dialog"); valid = false; } - if (pokemod.getDialogByID(winDialog) == UINT_MAX) + if (pokemod.getDialogIndex(winDialog) == UINT_MAX) { pokemod.validationMsg("Invalid win dialog"); valid = false; } - if (pokemod.getDialogByID(loseDialog) == UINT_MAX) + if (pokemod.getDialogIndex(loseDialog) == UINT_MAX) { pokemod.validationMsg("Invalid lose dialog"); valid = false; } - if (getPokemonCount() <= leadPokemon) + if (getTeamMemberCount() <= leadTeamMember) { - pokemod.validationMsg("Invalid lead Pokémon"); + pokemod.validationMsg("Invalid lead member"); valid = false; } - if (getPokemonCount()) + if (getTeamMemberCount()) { QMap idChecker; - for (QListIterator i(team); i.hasNext(); i.next()) + for (QListIterator i(teamMembers); i.hasNext(); i.next()) { if (!i.peekNext().isValid()) valid = false; @@ -113,14 +113,14 @@ bool PokeMod::MapTrainer::validate() const { if (1 < i.value()) { - pokemod.validationMsg(QString("There are %1 Pokémon with id %2").arg(i.value()).arg(i.key())); + pokemod.validationMsg(QString("There are %1 team members with id %2").arg(i.value()).arg(i.key())); valid = false; } } } else { - pokemod.validationMsg("There are no Pokémon"); + pokemod.validationMsg("There are no team members"); valid = false; } return valid; @@ -129,9 +129,9 @@ bool PokeMod::MapTrainer::validate() const unsigned PokeMod::MapTrainer::getNewId() const { unsigned i = 0; - for (; i < getPokemonCount(); ++i) + for (; i < getTeamMemberCount(); ++i) { - if (getPokemonByID(i) == UINT_MAX) + if (getTeamMemberIndex(i) == UINT_MAX) return i; } return UINT_MAX; @@ -161,15 +161,15 @@ void PokeMod::MapTrainer::load(const QString& fname, const unsigned _id) throw(E ini.getValue("overworldDialog", overworldDialog); ini.getValue("winDialog", winDialog); ini.getValue("loseDialog", loseDialog); - ini.getValue("leadPokemon", leadPokemon); + ini.getValue("leadTeamMember", leadTeamMember); QStringList path = pokemod.getPath().split('/'); path.removeLast(); QDir fdir(path.join("/")); - team.clear(); + teamMembers.clear(); if (fdir.cd("team")) { for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); ) - newPokemon(i.next()); + newTeamMember(i.next()); } } @@ -191,9 +191,9 @@ void PokeMod::MapTrainer::save(const QString& map) const throw(Exception) ini.addField("overworldDialog", overworldDialog); ini.addField("winDialog", winDialog); ini.addField("loseDialog", loseDialog); - ini.addField("leadPokemon", leadPokemon); + ini.addField("leadTeamMember", leadTeamMember); ini.save(QString("%1/map/%2/trainer/%3/data.pini").arg(pokemod.getPath()).arg(map).arg(name)); - for (QListIterator i(team); i.hasNext(); ) + for (QListIterator i(teamMembers); i.hasNext(); ) i.next().save(map, name); } @@ -267,30 +267,30 @@ void PokeMod::MapTrainer::setAppearFlagStatus(const unsigned s) void PokeMod::MapTrainer::setOverworldDialog(const unsigned o) throw(BoundsException) { - if (pokemod.getDialogByID(o) == UINT_MAX) + if (pokemod.getDialogIndex(o) == UINT_MAX) throw(BoundsException("MapTrainer", "overworldDialog")); overworldDialog = o; } void PokeMod::MapTrainer::setWinDialog(const unsigned w) throw(BoundsException) { - if (pokemod.getDialogByID(w) == UINT_MAX) + if (pokemod.getDialogIndex(w) == UINT_MAX) throw(BoundsException("MapTrainer", "winDialog")); winDialog = w; } void PokeMod::MapTrainer::setLoseDialog(const unsigned l) throw(BoundsException) { - if (pokemod.getDialogByID(l) == UINT_MAX) + if (pokemod.getDialogIndex(l) == UINT_MAX) throw(BoundsException("MapTrainer", "loseDialog")); loseDialog = l; } -void PokeMod::MapTrainer::setLeadPokemon(const unsigned l) throw(BoundsException) +void PokeMod::MapTrainer::setLeadTeamMember(const unsigned l) throw(BoundsException) { - if (getPokemonCount() <= l) - throw(BoundsException("MapTrainer", "leadPokemon")); - leadPokemon = l; + if (getTeamMemberCount() <= l) + throw(BoundsException("MapTrainer", "leadTeamMember")); + leadTeamMember = l; } QString PokeMod::MapTrainer::getName() const @@ -303,16 +303,6 @@ Point PokeMod::MapTrainer::getCoordinate() const return coordinate; } -unsigned PokeMod::MapTrainer::getCoordinateX() const -{ - return coordinate.getX(); -} - -unsigned PokeMod::MapTrainer::getCoordinateY() const -{ - return coordinate.getY(); -} - QString PokeMod::MapTrainer::getSkin() const { return skin; @@ -343,16 +333,6 @@ Flag PokeMod::MapTrainer::getAppearFlag() const return appearFlag; } -unsigned PokeMod::MapTrainer::getAppearFlagFlag() const -{ - return appearFlag.getFlag(); -} - -unsigned PokeMod::MapTrainer::getAppearFlagStatus() const -{ - return appearFlag.getStatus(); -} - unsigned PokeMod::MapTrainer::getOverworldDialog() const { return overworldDialog; @@ -368,63 +348,73 @@ unsigned PokeMod::MapTrainer::getLoseDialog() const return loseDialog; } -unsigned PokeMod::MapTrainer::getLeadPokemon() const +unsigned PokeMod::MapTrainer::getLeadTeamMember() const { - return leadPokemon; + return leadTeamMember; } -const PokeMod::MapTrainerPokemon& PokeMod::MapTrainer::getPokemon(const unsigned i) const throw(IndexException) +const PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::getTeamMember(const unsigned i) const throw(IndexException) { - if (getPokemonCount() <= i) + if (getTeamMemberCount() <= i) throw(IndexException("MapTrainer")); - return team.at(i); + return teamMembers.at(i); } -PokeMod::MapTrainerPokemon& PokeMod::MapTrainer::getPokemon(const unsigned i) throw(IndexException) +PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::getTeamMember(const unsigned i) throw(IndexException) { - if (getPokemonCount() <= i) + if (getTeamMemberCount() <= i) throw(IndexException("MapTrainer")); - return team[i]; + return teamMembers[i]; +} + +const PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::getTeamMemberByID(const unsigned i) const throw(IndexException) +{ + return getTeamMember(getTeamMemberIndex(i)); +} + +PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::getTeamMemberByID(const unsigned i) throw(IndexException) +{ + return getTeamMember(getTeamMemberIndex(i)); } -unsigned PokeMod::MapTrainer::getPokemonByID(const unsigned _id) const +unsigned PokeMod::MapTrainer::getTeamMemberIndex(const unsigned _id) const { - for (unsigned i = 0; i < getPokemonCount(); ++i) + for (unsigned i = 0; i < getTeamMemberCount(); ++i) { - if (team[i].getId() == _id) + if (teamMembers[i].getId() == _id) return i; } return UINT_MAX; } -unsigned PokeMod::MapTrainer::getPokemonCount() const +unsigned PokeMod::MapTrainer::getTeamMemberCount() const { - return team.size(); + return teamMembers.size(); } -PokeMod::MapTrainerPokemon& PokeMod::MapTrainer::newPokemon() +PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::newTeamMember() { - team.append(MapTrainerPokemon(pokemod, getNewId())); - return team[getPokemonCount() - 1]; + teamMembers.append(MapTrainerTeamMember(pokemod, getNewId())); + return teamMembers[getTeamMemberCount() - 1]; } -PokeMod::MapTrainerPokemon& PokeMod::MapTrainer::newPokemon(const QString& fname) +PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::newTeamMember(const QString& fname) { - team.append(MapTrainerPokemon(pokemod, fname, getNewId())); - return team[getPokemonCount() - 1]; + teamMembers.append(MapTrainerTeamMember(pokemod, fname, getNewId())); + return teamMembers[getTeamMemberCount() - 1]; } -PokeMod::MapTrainerPokemon& PokeMod::MapTrainer::newPokemon(const MapTrainerPokemon& p) +PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::newTeamMember(const MapTrainerTeamMember& p) { - team.append(MapTrainerPokemon(pokemod, p, getNewId())); - return team[getPokemonCount() - 1]; + teamMembers.append(MapTrainerTeamMember(pokemod, p, getNewId())); + return teamMembers[getTeamMemberCount() - 1]; } -void PokeMod::MapTrainer::deletePokemon(const unsigned i) throw(IndexException) +void PokeMod::MapTrainer::deleteTeamMember(const unsigned i) throw(IndexException) { - if (getPokemonCount() <= i) + if (getTeamMemberCount() <= i) throw(IndexException("MapTrainer")); - team.removeAt(i); + teamMembers.removeAt(i); } PokeMod::MapTrainer& PokeMod::MapTrainer::operator=(const MapTrainer& rhs) @@ -442,8 +432,9 @@ PokeMod::MapTrainer& PokeMod::MapTrainer::operator=(const MapTrainer& rhs) overworldDialog = rhs.overworldDialog; winDialog = rhs.winDialog; loseDialog = rhs.loseDialog; - team.clear(); - for (unsigned i = 0; i < rhs.getPokemonCount(); ++i) - newPokemon(rhs.getPokemon(i)); + leadTeamMember = rhs.leadTeamMember; + teamMembers.clear(); + for (unsigned i = 0; i < rhs.getTeamMemberCount(); ++i) + newTeamMember(rhs.getTeamMember(i)); return *this; } -- cgit