diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-08-04 03:27:13 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-08-04 03:27:13 +0000 |
| commit | 373e686bf4ecaaabcf80544e74f017eebe05213f (patch) | |
| tree | cddf7a223f16944b0380386e568f2606f634c366 /pokemod/Pokemod.cpp | |
| parent | 63417b1c5057d22bd853e92cd3a25aa812b8d917 (diff) | |
| download | sigen-373e686bf4ecaaabcf80544e74f017eebe05213f.tar.gz sigen-373e686bf4ecaaabcf80544e74f017eebe05213f.tar.xz sigen-373e686bf4ecaaabcf80544e74f017eebe05213f.zip | |
[FIX] Cleaned up the RC file
[FIX] Script editing is getting there (still a little weird...)
[FIX] Cleaned up the main file a bit
[FIX] Added the Skin class
[FIX] All sprites and skins are internally linked now
[FIX] No more image restraints (tiles are still enforced so that map editing works)
[FIX] Cleaned up checking for valid values when setting in pokemod
[FIX] Removed FileDialog files
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@233 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Pokemod.cpp')
| -rw-r--r-- | pokemod/Pokemod.cpp | 107 |
1 files changed, 95 insertions, 12 deletions
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index 04a6086e..843e0880 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -32,6 +32,7 @@ #include "Move.h" #include "Nature.h" #include "Rules.h" +#include "Skin.h" #include "Sound.h" #include "Species.h" #include "Sprite.h" @@ -188,6 +189,12 @@ void Pokemod::Pokemod::validate() TEST_SUB_END(); idChecker.clear(); nameChecker.clear(); + TEST_SUB_BEGIN(Skin, skins); + TEST_SUB("skin", id); + TEST_SUB("skin", name); + TEST_SUB_END(); + idChecker.clear(); + nameChecker.clear(); if (!soundCount()) emit(warning("There are no sounds")); TEST_SUB_BEGIN(Sound, sounds); @@ -284,6 +291,7 @@ void Pokemod::Pokemod::load(const QDomElement& xml) LOAD_SUB(newMap, Map); LOAD_SUB(newMove, Move); LOAD_SUB(newNature, Nature); + LOAD_SUB(newSkin, Skin); LOAD_SUB(newSound, Sound); LOAD_SUB(newSpecies, Species); LOAD_SUB(newSprite, Sprite); @@ -318,6 +326,7 @@ QDomElement Pokemod::Pokemod::save() const SAVE_SUB(Map, maps); SAVE_SUB(Move, moves); SAVE_SUB(Nature, natures); + SAVE_SUB(Skin, skins); SAVE_SUB(Sound, sounds); SAVE_SUB(Species, species); SAVE_SUB(Sprite, sprites); @@ -349,26 +358,19 @@ void Pokemod::Pokemod::setDescription(const QString& description) void Pokemod::Pokemod::setStartMap(const int startMap) { if (mapIndex(startMap) == INT_MAX) - { emit(error(bounds("startMap"))); - return; - } - CHECK(startMap); + else + CHECK(startMap); } void Pokemod::Pokemod::setStartWarp(const int startWarp) { if (mapIndex(m_startMap) == INT_MAX) - { emit(error(bounds("startMap"))); - return; - } - if (mapById(m_startMap)->warpIndex(startWarp) == INT_MAX) - { + else if (mapById(m_startMap)->warpIndex(startWarp) == INT_MAX) emit(error(bounds("startWarp"))); - return; - } - CHECK(startWarp); + else + CHECK(startWarp); } void Pokemod::Pokemod::setTypechart(const int attack, const int defense, const Fraction& multiplier) @@ -1294,6 +1296,84 @@ int Pokemod::Pokemod::newNatureId() const return i; } +const Pokemod::Skin* Pokemod::Pokemod::skin(const int index) const +{ + Q_ASSERT(index < skinCount()); + return m_skins.at(index); +} + +Pokemod::Skin* Pokemod::Pokemod::skin(const int index) +{ + Q_ASSERT(index < skinCount()); + return m_skins[index]; +} + +const Pokemod::Skin* Pokemod::Pokemod::skinById(const int id) const +{ + return skin(skinIndex(id)); +} + +Pokemod::Skin* Pokemod::Pokemod::skinById(const int id) +{ + return skin(skinIndex(id)); +} + +int Pokemod::Pokemod::skinIndex(const int id) const +{ + for (int i = 0; i < skinCount(); ++i) + { + if (m_skins[i]->id() == id) + return i; + } + return INT_MAX; +} + +int Pokemod::Pokemod::skinCount() const +{ + return m_skins.size(); +} + +Pokemod::Skin* Pokemod::Pokemod::newSkin() +{ + return newSkin(new Skin(this, newSkinId())); +} + +Pokemod::Skin* Pokemod::Pokemod::newSkin(const QDomElement& xml) +{ + return newSkin(new Skin(xml, this, newSkinId())); +} + +Pokemod::Skin* Pokemod::Pokemod::newSkin(const Skin& skin) +{ + return newSkin(new Skin(skin, this, newSkinId())); +} + +Pokemod::Skin* Pokemod::Pokemod::newSkin(Skin* skin) +{ + m_skins.append(skin); + return skin; +} + +void Pokemod::Pokemod::deleteSkin(const int index) +{ + Q_ASSERT(index < skinCount()); + delete m_skins[index]; + m_skins.removeAt(index); +} + +void Pokemod::Pokemod::deleteSkinById(const int id) +{ + deleteSkin(skinIndex(id)); +} + +int Pokemod::Pokemod::newSkinId() const +{ + int i = 0; + while ((i < skinCount()) && (skinIndex(i) != INT_MAX)) + ++i; + return i; +} + const Pokemod::Sound* Pokemod::Pokemod::sound(const int index) const { Q_ASSERT(index < soundCount()); @@ -2099,6 +2179,7 @@ Pokemod::Pokemod& Pokemod::Pokemod::operator=(const Pokemod& rhs) COPY_SUB(Map, maps); COPY_SUB(Move, moves); COPY_SUB(Nature, natures); + COPY_SUB(Skin, skins); COPY_SUB(Sound, sounds); COPY_SUB(Species, species); COPY_SUB(Sprite, sprites); @@ -2137,6 +2218,8 @@ void Pokemod::Pokemod::clear() deleteMove(0); while (natureCount()) deleteNature(0); + while (skinCount()) + deleteSkin(0); while (soundCount()) deleteSound(0); while (speciesCount()) |
