summaryrefslogtreecommitdiffstats
path: root/pokemod/Pokemod.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/Pokemod.cpp')
-rw-r--r--pokemod/Pokemod.cpp307
1 files changed, 191 insertions, 116 deletions
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp
index 77ed6011..abb6f482 100644
--- a/pokemod/Pokemod.cpp
+++ b/pokemod/Pokemod.cpp
@@ -702,20 +702,23 @@ int Pokemod::abilityCount() const
Ability* Pokemod::newAbility()
{
- m_abilities.append(new Ability(this, newAbilityId()));
- return m_abilities[abilityCount() - 1];
+ return newAbility(new Ability(this, newAbilityId()));
}
Ability* Pokemod::newAbility(const QDomElement& xml)
{
- m_abilities.append(new Ability(xml, this, newAbilityId()));
- return m_abilities[abilityCount() - 1];
+ return newAbility(new Ability(xml, this, newAbilityId()));
}
Ability* Pokemod::newAbility(const Ability& ability)
{
- m_abilities.append(new Ability(ability, this, newAbilityId()));
- return m_abilities[abilityCount() - 1];
+ return newAbility(new Ability(ability, this, newAbilityId()));
+}
+
+Ability* Pokemod::newAbility(Ability* ability)
+{
+ m_abilities.append(ability);
+ return ability;
}
void Pokemod::deleteAbility(const int index) throw(IndexException)
@@ -780,20 +783,23 @@ int Pokemod::authorCount() const
Author* Pokemod::newAuthor()
{
- m_authors.append(new Author(this, newAuthorId()));
- return m_authors[authorCount() - 1];
+ return newAuthor(new Author(this, newAuthorId()));
}
Author* Pokemod::newAuthor(const QDomElement& xml)
{
- m_authors.append(new Author(xml, this, newAuthorId()));
- return m_authors[authorCount() - 1];
+ return newAuthor(new Author(xml, this, newAuthorId()));
}
Author* Pokemod::newAuthor(const Author& author)
{
- m_authors.append(new Author(author, this, newAuthorId()));
- return m_authors[authorCount() - 1];
+ return newAuthor(new Author(author, this, newAuthorId()));
+}
+
+Author* Pokemod::newAuthor(Author* author)
+{
+ m_authors.append(author);
+ return author;
}
void Pokemod::deleteAuthor(const int index) throw(IndexException)
@@ -858,20 +864,23 @@ int Pokemod::badgeCount() const
Badge* Pokemod::newBadge()
{
- m_badges.append(new Badge(this, newBadgeId()));
- return m_badges[badgeCount() - 1];
+ return newBadge(new Badge(this, newBadgeId()));
}
Badge* Pokemod::newBadge(const QDomElement& xml)
{
- m_badges.append(new Badge(xml, this, newBadgeId()));
- return m_badges[badgeCount() - 1];
+ return newBadge(new Badge(xml, this, newBadgeId()));
}
Badge* Pokemod::newBadge(const Badge& badge)
{
- m_badges.append(new Badge(badge, this, newBadgeId()));
- return m_badges[badgeCount() - 1];
+ return newBadge(new Badge(badge, this, newBadgeId()));
+}
+
+Badge* Pokemod::newBadge(Badge* badge)
+{
+ m_badges.append(badge);
+ return badge;
}
void Pokemod::deleteBadge(const int index) throw(IndexException)
@@ -936,20 +945,23 @@ int Pokemod::coinListCount() const
CoinList* Pokemod::newCoinList()
{
- m_coinLists.append(new CoinList(this, newCoinListId()));
- return m_coinLists[coinListCount() - 1];
+ return newCoinList(new CoinList(this, newCoinListId()));
}
CoinList* Pokemod::newCoinList(const QDomElement& xml)
{
- m_coinLists.append(new CoinList(xml, this, newCoinListId()));
- return m_coinLists[coinListCount() - 1];
+ return newCoinList(new CoinList(xml, this, newCoinListId()));
}
CoinList* Pokemod::newCoinList(const CoinList& coinList)
{
- m_coinLists.append(new CoinList(coinList, this, newCoinListId()));
- return m_coinLists[coinListCount() - 1];
+ return newCoinList(new CoinList(coinList, this, newCoinListId()));
+}
+
+CoinList* Pokemod::newCoinList(CoinList* coinList)
+{
+ m_coinLists.append(coinList);
+ return coinList;
}
void Pokemod::deleteCoinList(const int index) throw(IndexException)
@@ -1014,20 +1026,23 @@ int Pokemod::dialogCount() const
Dialog* Pokemod::newDialog()
{
- m_dialogs.append(new Dialog(this, newDialogId()));
- return m_dialogs[dialogCount() - 1];
+ return newDialog(new Dialog(this, newDialogId()));
}
Dialog* Pokemod::newDialog(const QDomElement& xml)
{
- m_dialogs.append(new Dialog(xml, this, newDialogId()));
- return m_dialogs[dialogCount() - 1];
+ return newDialog(new Dialog(xml, this, newDialogId()));
}
Dialog* Pokemod::newDialog(const Dialog& dialog)
{
- m_dialogs.append(new Dialog(dialog, this, newDialogId()));
- return m_dialogs[dialogCount() - 1];
+ return newDialog(new Dialog(dialog, this, newDialogId()));
+}
+
+Dialog* Pokemod::newDialog(Dialog* dialog)
+{
+ m_dialogs.append(dialog);
+ return dialog;
}
void Pokemod::deleteDialog(const int index) throw(IndexException)
@@ -1092,20 +1107,23 @@ int Pokemod::eggGroupCount() const
EggGroup* Pokemod::newEggGroup()
{
- m_eggGroups.append(new EggGroup(this, newEggGroupId()));
- return m_eggGroups[eggGroupCount() - 1];
+ return newEggGroup(new EggGroup(this, newEggGroupId()));
}
EggGroup* Pokemod::newEggGroup(const QDomElement& xml)
{
- m_eggGroups.append(new EggGroup(xml, this, newEggGroupId()));
- return m_eggGroups[eggGroupCount() - 1];
+ return newEggGroup(new EggGroup(xml, this, newEggGroupId()));
}
EggGroup* Pokemod::newEggGroup(const EggGroup& eggGroup)
{
- m_eggGroups.append(new EggGroup(eggGroup, this, newEggGroupId()));
- return m_eggGroups[eggGroupCount() - 1];
+ return newEggGroup(new EggGroup(eggGroup, this, newEggGroupId()));
+}
+
+EggGroup* Pokemod::newEggGroup(EggGroup* eggGroup)
+{
+ m_eggGroups.append(eggGroup);
+ return eggGroup;
}
void Pokemod::deleteEggGroup(const int index) throw(IndexException)
@@ -1170,20 +1188,23 @@ int Pokemod::itemCount() const
Item* Pokemod::newItem()
{
- m_items.append(new Item(this, newItemId()));
- return m_items[itemCount() - 1];
+ return newItem(new Item(this, newItemId()));
}
Item* Pokemod::newItem(const QDomElement& xml)
{
- m_items.append(new Item(xml, this, newItemId()));
- return m_items[itemCount() - 1];
+ return newItem(new Item(xml, this, newItemId()));
}
Item* Pokemod::newItem(const Item& item)
{
- m_items.append(new Item(item, this, newItemId()));
- return m_items[itemCount() - 1];
+ return newItem(new Item(item, this, newItemId()));
+}
+
+Item* Pokemod::newItem(Item* item)
+{
+ m_items.append(item);
+ return item;
}
void Pokemod::deleteItem(const int index) throw(IndexException)
@@ -1248,20 +1269,23 @@ int Pokemod::itemTypeCount() const
ItemType* Pokemod::newItemType()
{
- m_itemTypes.append(new ItemType(this, newItemTypeId()));
- return m_itemTypes[itemTypeCount() - 1];
+ return newItemType(new ItemType(this, newItemTypeId()));
}
ItemType* Pokemod::newItemType(const QDomElement& xml)
{
- m_itemTypes.append(new ItemType(xml, this, newItemTypeId()));
- return m_itemTypes[itemTypeCount() - 1];
+ return newItemType(new ItemType(xml, this, newItemTypeId()));
}
ItemType* Pokemod::newItemType(const ItemType& itemType)
{
- m_itemTypes.append(new ItemType(itemType, this, newItemTypeId()));
- return m_itemTypes[itemTypeCount() - 1];
+ return newItemType(new ItemType(itemType, this, newItemTypeId()));
+}
+
+ItemType* Pokemod::newItemType(ItemType* itemType)
+{
+ m_itemTypes.append(itemType);
+ return itemType;
}
void Pokemod::deleteItemType(const int index) throw(IndexException)
@@ -1326,20 +1350,23 @@ int Pokemod::mapCount() const
Map* Pokemod::newMap()
{
- m_maps.append(new Map(this, newMapId()));
- return m_maps[mapCount() - 1];
+ return newMap(new Map(this, newMapId()));
}
Map* Pokemod::newMap(const QDomElement& xml)
{
- m_maps.append(new Map(xml, this, newMapId()));
- return m_maps[mapCount() - 1];
+ return newMap(new Map(xml, this, newMapId()));
}
Map* Pokemod::newMap(const Map& map)
{
- m_maps.append(new Map(map, this, newMapId()));
- return m_maps[mapCount() - 1];
+ return newMap(new Map(map, this, newMapId()));
+}
+
+Map* Pokemod::newMap(Map* map)
+{
+ m_maps.append(map);
+ return map;
}
void Pokemod::deleteMap(const int index) throw(IndexException)
@@ -1404,20 +1431,23 @@ int Pokemod::moveCount() const
Move* Pokemod::newMove()
{
- m_moves.append(new Move(this, newMoveId()));
- return m_moves[moveCount() - 1];
+ return newMove(new Move(this, newMoveId()));
}
Move* Pokemod::newMove(const QDomElement& xml)
{
- m_moves.append(new Move(xml, this, newMoveId()));
- return m_moves[moveCount() - 1];
+ return newMove(new Move(xml, this, newMoveId()));
}
Move* Pokemod::newMove(const Move& move)
{
- m_moves.append(new Move(move, this, newMoveId()));
- return m_moves[moveCount() - 1];
+ return newMove(new Move(move, this, newMoveId()));
+}
+
+Move* Pokemod::newMove(Move* move)
+{
+ m_moves.append(move);
+ return move;
}
void Pokemod::deleteMove(const int index) throw(IndexException)
@@ -1482,20 +1512,23 @@ int Pokemod::natureCount() const
Nature* Pokemod::newNature()
{
- m_natures.append(new Nature(this, newNatureId()));
- return m_natures[natureCount() - 1];
+ return newNature(new Nature(this, newNatureId()));
}
Nature* Pokemod::newNature(const QDomElement& xml)
{
- m_natures.append(new Nature(xml, this, newNatureId()));
- return m_natures[natureCount() - 1];
+ return newNature(new Nature(xml, this, newNatureId()));
}
Nature* Pokemod::newNature(const Nature& nature)
{
- m_natures.append(new Nature(nature, this, newNatureId()));
- return m_natures[natureCount() - 1];
+ return newNature(new Nature(nature, this, newNatureId()));
+}
+
+Nature* Pokemod::newNature(Nature* nature)
+{
+ m_natures.append(nature);
+ return nature;
}
void Pokemod::deleteNature(const int index) throw(IndexException)
@@ -1560,20 +1593,23 @@ int Pokemod::speciesCount() const
Species* Pokemod::newSpecies()
{
- m_species.append(new Species(this, newSpeciesId()));
- return m_species[speciesCount() - 1];
+ return newSpecies(new Species(this, newSpeciesId()));
}
Species* Pokemod::newSpecies(const QDomElement& xml)
{
- m_species.append(new Species(xml, this, newSpeciesId()));
- return m_species[speciesCount() - 1];
+ return newSpecies(new Species(xml, this, newSpeciesId()));
}
Species* Pokemod::newSpecies(const Species& species)
{
- m_species.append(new Species(species, this, newSpeciesId()));
- return m_species[speciesCount() - 1];
+ return newSpecies(new Species(species, this, newSpeciesId()));
+}
+
+Species* Pokemod::newSpecies(Species* species)
+{
+ m_species.append(species);
+ return species;
}
void Pokemod::deleteSpecies(const int index) throw(IndexException)
@@ -1638,20 +1674,23 @@ int Pokemod::storeCount() const
Store* Pokemod::newStore()
{
- m_stores.append(new Store(this, newStoreId()));
- return m_stores[storeCount() - 1];
+ return newStore(new Store(this, newStoreId()));
}
Store* Pokemod::newStore(const QDomElement& xml)
{
- m_stores.append(new Store(xml, this, newStoreId()));
- return m_stores[storeCount() - 1];
+ return newStore(new Store(xml, this, newStoreId()));
}
Store* Pokemod::newStore(const Store& store)
{
- m_stores.append(new Store(store, this, newStoreId()));
- return m_stores[storeCount() - 1];
+ return newStore(new Store(store, this, newStoreId()));
+}
+
+Store* Pokemod::newStore(Store* store)
+{
+ m_stores.append(store);
+ return store;
}
void Pokemod::deleteStore(const int index) throw(IndexException)
@@ -1716,20 +1755,23 @@ int Pokemod::tileCount() const
Tile* Pokemod::newTile()
{
- m_tiles.append(new Tile(this, newTileId()));
- return m_tiles[tileCount() - 1];
+ return newTile(new Tile(this, newTileId()));
}
Tile* Pokemod::newTile(const QDomElement& xml)
{
- m_tiles.append(new Tile(xml, this, newTileId()));
- return m_tiles[tileCount() - 1];
+ return newTile(new Tile(xml, this, newTileId()));
}
Tile* Pokemod::newTile(const Tile& tile)
{
- m_tiles.append(new Tile(tile, this, newTileId()));
- return m_tiles[tileCount() - 1];
+ return newTile(new Tile(tile, this, newTileId()));
+}
+
+Tile* Pokemod::newTile(Tile* tile)
+{
+ m_tiles.append(tile);
+ return tile;
}
void Pokemod::deleteTile(const int index) throw(IndexException)
@@ -1794,20 +1836,23 @@ int Pokemod::timeCount() const
Time* Pokemod::newTime()
{
- m_times.append(new Time(this, newTimeId()));
- return m_times[timeCount() - 1];
+ return newTime(new Time(this, newTimeId()));
}
Time* Pokemod::newTime(const QDomElement& xml)
{
- m_times.append(new Time(xml, this, newTimeId()));
- return m_times[timeCount() - 1];
+ return newTime(new Time(xml, this, newTimeId()));
}
Time* Pokemod::newTime(const Time& time)
{
- m_times.append(new Time(time, this, newTimeId()));
- return m_times[timeCount() - 1];
+ return newTime(new Time(time, this, newTimeId()));
+}
+
+Time* Pokemod::newTime(Time* time)
+{
+ m_times.append(time);
+ return time;
}
void Pokemod::deleteTime(const int index) throw(IndexException)
@@ -1872,20 +1917,23 @@ int Pokemod::trainerCount() const
Trainer* Pokemod::newTrainer()
{
- m_trainers.append(new Trainer(this, newTrainerId()));
- return m_trainers[trainerCount() - 1];
+ return newTrainer(new Trainer(this, newTrainerId()));
}
Trainer* Pokemod::newTrainer(const QDomElement& xml)
{
- m_trainers.append(new Trainer(xml, this, newTrainerId()));
- return m_trainers[trainerCount() - 1];
+ return newTrainer(new Trainer(xml, this, newTrainerId()));
}
Trainer* Pokemod::newTrainer(const Trainer& trainer)
{
- m_trainers.append(new Trainer(trainer, this, newTrainerId()));
- return m_trainers[trainerCount() - 1];
+ return newTrainer(new Trainer(trainer, this, newTrainerId()));
+}
+
+Trainer* Pokemod::newTrainer(Trainer* trainer)
+{
+ m_trainers.append(trainer);
+ return trainer;
}
void Pokemod::deleteTrainer(const int index) throw(IndexException)
@@ -1950,32 +1998,21 @@ int Pokemod::typeCount() const
Type* Pokemod::newType()
{
- if (typeCount())
- {
- m_typeChart.addColumn(Fraction(1, 1));
- m_typeChart.addRow(Fraction(1, 1));
- }
- else
- m_typeChart.addColumn(Fraction(1, 1));
- m_types.append(new Type(this, newTypeId()));
- return m_types[typeCount() - 1];
+ return newType(new Type(this, newTypeId()));
}
Type* Pokemod::newType(const QDomElement& xml)
{
- if (typeCount())
- {
- m_typeChart.addColumn(Fraction(1, 1));
- m_typeChart.addRow(Fraction(1, 1));
- }
- else
- m_typeChart.addColumn(Fraction(1, 1));
- m_types.append(new Type(xml, this, newTypeId()));
- return m_types[typeCount() - 1];
+ return newType(new Type(xml, this, newTypeId()));
}
Type* Pokemod::newType(const Type& type)
{
+ return newType(new Type(type, this, newTypeId()));
+}
+
+Type* Pokemod::newType(Type* type)
+{
if (typeCount())
{
m_typeChart.addColumn(Fraction(1, 1));
@@ -1983,8 +2020,8 @@ Type* Pokemod::newType(const Type& type)
}
else
m_typeChart.addColumn(Fraction(1, 1));
- m_types.append(new Type(type, this, newTypeId()));
- return m_types[typeCount() - 1];
+ m_types.append(type);
+ return type;
}
void Pokemod::deleteType(const int index) throw(IndexException)
@@ -2048,3 +2085,41 @@ Pokemod& Pokemod::operator=(const Pokemod& rhs)
COPY_SUB(Type, types);
return *this;
}
+
+void Pokemod::clear()
+{
+ while (abilityCount())
+ deleteAbility(0);
+ while (authorCount())
+ deleteAuthor(0);
+ while (badgeCount())
+ deleteBadge(0);
+ while (coinListCount())
+ deleteCoinList(0);
+ while (dialogCount())
+ deleteDialog(0);
+ while (eggGroupCount())
+ deleteEggGroup(0);
+ while (itemCount())
+ deleteItem(0);
+ while (itemTypeCount())
+ deleteItemType(0);
+ while (mapCount())
+ deleteMap(0);
+ while (moveCount())
+ deleteMove(0);
+ while (natureCount())
+ deleteNature(0);
+ while (speciesCount())
+ deleteSpecies(0);
+ while (storeCount())
+ deleteStore(0);
+ while (tileCount())
+ deleteTile(0);
+ while (timeCount())
+ deleteTime(0);
+ while (trainerCount())
+ deleteTrainer(0);
+ while (typeCount())
+ deleteType(0);
+}