summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
commit807071d35159de0660f9df31c48d5bf895ca3622 (patch)
treea1e9dbdc1e58b91cd2e4a5e472597b0204ccb41d
parentf444f5a45e9325644a360f656176d47d7f540f52 (diff)
[FIX] Pokemod objects now know about parents
[FIX] Project includes are now relative [FIX] Headers included for better detection of invalid headers [FIX] Validation code commented out so it can be done better git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@111 6ecfd1a5-f3ed-3746-8530-beee90d26b22
-rw-r--r--Changelog10
-rw-r--r--general/Audio.cpp6
-rw-r--r--general/Audio.h10
-rw-r--r--general/BugCatcher.h8
-rw-r--r--general/Flag.h6
-rw-r--r--general/Fraction.h2
-rw-r--r--general/Hat.h6
-rw-r--r--general/Matrix.h7
-rw-r--r--general/general.pro2
-rw-r--r--pokemod/Ability.cpp80
-rw-r--r--pokemod/Ability.h19
-rw-r--r--pokemod/AbilityEffect.cpp305
-rw-r--r--pokemod/AbilityEffect.h22
-rw-r--r--pokemod/Author.cpp63
-rw-r--r--pokemod/Author.h13
-rw-r--r--pokemod/Badge.cpp57
-rw-r--r--pokemod/Badge.h22
-rw-r--r--pokemod/CoinList.cpp145
-rw-r--r--pokemod/CoinList.h19
-rw-r--r--pokemod/CoinListObject.cpp75
-rw-r--r--pokemod/CoinListObject.h20
-rw-r--r--pokemod/Dialog.cpp1227
-rw-r--r--pokemod/Dialog.h22
-rw-r--r--pokemod/EggGroup.cpp31
-rw-r--r--pokemod/EggGroup.h19
-rw-r--r--pokemod/Item.cpp95
-rw-r--r--pokemod/Item.h19
-rw-r--r--pokemod/ItemEffect.cpp508
-rw-r--r--pokemod/ItemEffect.h22
-rw-r--r--pokemod/ItemType.cpp59
-rw-r--r--pokemod/ItemType.h20
-rw-r--r--pokemod/Map.cpp287
-rw-r--r--pokemod/Map.h22
-rw-r--r--pokemod/MapEffect.cpp140
-rw-r--r--pokemod/MapEffect.h28
-rw-r--r--pokemod/MapTrainer.cpp142
-rw-r--r--pokemod/MapTrainer.h25
-rw-r--r--pokemod/MapTrainerTeamMember.cpp119
-rw-r--r--pokemod/MapTrainerTeamMember.h19
-rw-r--r--pokemod/MapWarp.cpp117
-rw-r--r--pokemod/MapWarp.h25
-rw-r--r--pokemod/MapWildList.cpp187
-rw-r--r--pokemod/MapWildList.h20
-rw-r--r--pokemod/MapWildListEncounter.cpp63
-rw-r--r--pokemod/MapWildListEncounter.h19
-rw-r--r--pokemod/Move.cpp135
-rw-r--r--pokemod/Move.h22
-rw-r--r--pokemod/MoveEffect.cpp28
-rw-r--r--pokemod/MoveEffect.h22
-rw-r--r--pokemod/Nature.cpp49
-rw-r--r--pokemod/Nature.h20
-rw-r--r--pokemod/Object.h30
-rw-r--r--pokemod/Pokemod.cpp577
-rw-r--r--pokemod/Pokemod.h21
-rw-r--r--pokemod/Rules.cpp115
-rw-r--r--pokemod/Rules.h21
-rw-r--r--pokemod/Species.cpp347
-rw-r--r--pokemod/Species.h23
-rw-r--r--pokemod/SpeciesAbility.cpp49
-rw-r--r--pokemod/SpeciesAbility.h17
-rw-r--r--pokemod/SpeciesEvolution.cpp163
-rw-r--r--pokemod/SpeciesEvolution.h20
-rw-r--r--pokemod/SpeciesItem.cpp49
-rw-r--r--pokemod/SpeciesItem.h19
-rw-r--r--pokemod/SpeciesMove.cpp63
-rw-r--r--pokemod/SpeciesMove.h19
-rw-r--r--pokemod/Store.cpp75
-rw-r--r--pokemod/Store.h21
-rw-r--r--pokemod/TODO2
-rw-r--r--pokemod/Tile.cpp107
-rw-r--r--pokemod/Tile.h21
-rw-r--r--pokemod/Time.cpp57
-rw-r--r--pokemod/Time.h19
-rw-r--r--pokemod/Trainer.cpp51
-rw-r--r--pokemod/Trainer.h19
-rw-r--r--pokemod/Type.cpp37
-rw-r--r--pokemod/Type.h18
-rw-r--r--pokemodr/AbilityUI.h6
-rw-r--r--pokemodr/AuthorUI.cpp6
-rw-r--r--pokemodr/AuthorUI.h6
-rw-r--r--pokemodr/BadgeUI.cpp26
-rw-r--r--pokemodr/BadgeUI.h6
-rw-r--r--pokemodr/CoinListObjectUI.cpp32
-rw-r--r--pokemodr/CoinListObjectUI.h6
-rw-r--r--pokemodr/CoinListUI.cpp26
-rw-r--r--pokemodr/CoinListUI.h6
-rw-r--r--pokemodr/EggGroupUI.h6
-rw-r--r--pokemodr/FileDialog.cpp12
-rw-r--r--pokemodr/FileDialog.h6
-rw-r--r--pokemodr/FractionWidget.cpp6
-rw-r--r--pokemodr/FractionWidget.h6
-rw-r--r--pokemodr/ItemTypeUI.cpp8
-rw-r--r--pokemodr/ItemTypeUI.h6
-rw-r--r--pokemodr/ItemUI.cpp20
-rw-r--r--pokemodr/ItemUI.h6
-rw-r--r--pokemodr/MapTrainerTeamMemberUI.cpp42
-rw-r--r--pokemodr/MapTrainerTeamMemberUI.h6
-rw-r--r--pokemodr/MapUI.cpp24
-rw-r--r--pokemodr/MapUI.h6
-rw-r--r--pokemodr/MapWarpUI.cpp34
-rw-r--r--pokemodr/MapWarpUI.h6
-rw-r--r--pokemodr/MapWildListEncounterUI.cpp20
-rw-r--r--pokemodr/MapWildListEncounterUI.h6
-rw-r--r--pokemodr/MapWildListUI.cpp36
-rw-r--r--pokemodr/MapWildListUI.h6
-rw-r--r--pokemodr/MoveUI.cpp20
-rw-r--r--pokemodr/MoveUI.h6
-rw-r--r--pokemodr/NatureUI.cpp20
-rw-r--r--pokemodr/NatureUI.h6
-rw-r--r--pokemodr/ObjectUI.h16
-rw-r--r--pokemodr/PointWidget.h6
-rw-r--r--pokemodr/PokeModr.cpp4
-rw-r--r--pokemodr/PokeModrUI.cpp36
-rw-r--r--pokemodr/PokeModrUI.h14
-rw-r--r--pokemodr/PokemodTreeModel.cpp49
-rw-r--r--pokemodr/PokemodTreeModel.h10
-rw-r--r--pokemodr/PokemodUI.cpp26
-rw-r--r--pokemodr/PokemodUI.h6
-rw-r--r--pokemodr/RulesUI.cpp8
-rw-r--r--pokemodr/RulesUI.h6
-rw-r--r--pokemodr/SpeciesAbilityUI.cpp26
-rw-r--r--pokemodr/SpeciesAbilityUI.h6
-rw-r--r--pokemodr/SpeciesEvolutionUI.cpp36
-rw-r--r--pokemodr/SpeciesEvolutionUI.h6
-rw-r--r--pokemodr/SpeciesItemUI.cpp26
-rw-r--r--pokemodr/SpeciesItemUI.h6
-rw-r--r--pokemodr/SpeciesMoveUI.cpp30
-rw-r--r--pokemodr/SpeciesMoveUI.h6
-rw-r--r--pokemodr/SpeciesUI.cpp52
-rw-r--r--pokemodr/SpeciesUI.h6
-rw-r--r--pokemodr/StoreUI.cpp28
-rw-r--r--pokemodr/StoreUI.h6
-rw-r--r--pokemodr/TODO2
-rw-r--r--pokemodr/TileDelegate.cpp20
-rw-r--r--pokemodr/TileUI.cpp28
-rw-r--r--pokemodr/TileUI.h10
-rw-r--r--pokemodr/TilemapModel.cpp14
-rw-r--r--pokemodr/TilemapModel.h12
-rw-r--r--pokemodr/TimeUI.cpp4
-rw-r--r--pokemodr/TimeUI.h6
-rw-r--r--pokemodr/TrainerUI.cpp16
-rw-r--r--pokemodr/TrainerUI.h6
-rw-r--r--pokemodr/TypeUI.cpp12
-rw-r--r--pokemodr/TypeUI.h6
-rw-r--r--pokemodr/TypechartWidgetItem.h6
-rw-r--r--pokemodr/models/AbilityEffectModel.cpp15
-rw-r--r--pokemodr/models/AbilityModel.cpp26
-rw-r--r--pokemodr/models/BadgeModel.cpp22
-rw-r--r--pokemodr/models/BaseModel.h2
-rw-r--r--pokemodr/models/CoinListModel.cpp26
-rw-r--r--pokemodr/models/CoinListObjectModel.cpp26
-rw-r--r--pokemodr/models/DialogModel.cpp22
-rw-r--r--pokemodr/models/EggGroupModel.cpp22
-rw-r--r--pokemodr/models/ItemTypeModel.cpp22
-rw-r--r--pokemodr/models/NatureModel.cpp22
-rw-r--r--pokemodr/models/PokemodModel.cpp45
-rw-r--r--pokemodr/models/RootModel.cpp11
-rw-r--r--pokemodr/models/RulesModel.cpp18
-rw-r--r--pokemodr/models/StoreModel.cpp22
-rw-r--r--pokemodr/models/TileModel.cpp22
-rw-r--r--pokemodr/models/TimeModel.cpp22
-rw-r--r--pokemodr/models/TrainerModel.cpp22
-rw-r--r--pokemodr/models/TypeModel.cpp22
163 files changed, 3863 insertions, 3885 deletions
diff --git a/Changelog b/Changelog
index aa05be0f..b69f04f4 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,14 @@
-----------------
+Rev: 111
+Date: 27 April 2008
+User: MathStuf
+-----------------
+[FIX] Pokemod objects now know about parents
+[FIX] Project includes are now relative
+[FIX] Headers included for better detection of invalid headers
+[FIX] Validation code commented out so it can be done better
+
+-----------------
Rev: 110
Date: 25 April 2008
User: MathStuf
diff --git a/general/Audio.cpp b/general/Audio.cpp
index 46f2853b..2301011d 100644
--- a/general/Audio.cpp
+++ b/general/Audio.cpp
@@ -15,12 +15,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMutableListIterator>
-
// Header include
#include "Audio.h"
+// Qt includes
+#include <QMutableListIterator>
+
void Audio::playSFX(const QString& url) throw(OpenException)
{
Phonon::MediaObject* sfx = new Phonon::MediaObject();
diff --git a/general/Audio.h b/general/Audio.h
index 4f60a44e..d06f7492 100644
--- a/general/Audio.h
+++ b/general/Audio.h
@@ -18,9 +18,8 @@
#ifndef __AUDIO__
#define __AUDIO__
-// KDE includes
-#include <phonon/audiooutput.h>
-#include <phonon/mediaobject.h>
+// General includes
+#include "Exception.h"
// Qt includes
// #include <Phonon/AudioOutput>
@@ -28,8 +27,9 @@
#include <QList>
#include <QObject>
-// General includes
-#include "Exception.h"
+// KDE includes
+#include <phonon/audiooutput.h>
+#include <phonon/mediaobject.h>
class Audio : public QObject
{
diff --git a/general/BugCatcher.h b/general/BugCatcher.h
index 4664be0e..8e607c95 100644
--- a/general/BugCatcher.h
+++ b/general/BugCatcher.h
@@ -18,13 +18,15 @@
#ifndef __BUGCATCHER__
#define __BUGCATCHER__
+// General includes
+#include "Exception.h"
+
// KDE includes
-class KAboutData;
#include <kbugreport.h>
#include <kmessagebox.h>
-// General includes
-#include "Exception.h"
+// Forward declarations
+class KAboutData;
class BugCatcher
{
diff --git a/general/Flag.h b/general/Flag.h
index ecf567f3..ca86082d 100644
--- a/general/Flag.h
+++ b/general/Flag.h
@@ -18,12 +18,12 @@
#ifndef __FLAG__
#define __FLAG__
-// Qt includes
-#include <QStringList>
-
// General includes
#include "Exception.h"
+// Qt includes
+#include <QStringList>
+
class Flag
{
public:
diff --git a/general/Fraction.h b/general/Fraction.h
index ff2b678b..b4df522d 100644
--- a/general/Fraction.h
+++ b/general/Fraction.h
@@ -20,9 +20,7 @@
// Qt includes
#include <QtGlobal>
-#include <QFile>
#include <QMetaType>
-#include <QString>
class Fraction
{
diff --git a/general/Hat.h b/general/Hat.h
index ebb19e40..3b9f0b68 100644
--- a/general/Hat.h
+++ b/general/Hat.h
@@ -18,14 +18,14 @@
#ifndef __HAT__
#define __HAT__
+// General includes
+#include "Exception.h"
+
// Qt includes
#include <QtGlobal>
#include <QDateTime>
#include <QMap>
-// General includes
-#include "Exception.h"
-
template<class T> class Hat
{
public:
diff --git a/general/Matrix.h b/general/Matrix.h
index 9fd4873b..fe4f452b 100644
--- a/general/Matrix.h
+++ b/general/Matrix.h
@@ -18,14 +18,13 @@
#ifndef __MATRIX__
#define __MATRIX__
+// General includes
+#include "Exception.h"
+
// Qt includes
#include <QtGlobal>
-#include <QFile>
#include <QVector>
-// General includes
-#include "Exception.h"
-
template<class T> class Matrix
{
public:
diff --git a/general/general.pro b/general/general.pro
index d13849b4..5aff8ae2 100644
--- a/general/general.pro
+++ b/general/general.pro
@@ -4,7 +4,7 @@ UI_DIR = .ui
MOC_DIR = .moc
DESTDIR = ../../bin
LIBS += -lphonon -lkdeui -lkdecore
-QMAKE_CXXFLAGS += -pg -O0
+; QMAKE_CXXFLAGS += -pg -O0
CONFIG += qt warn_on dll exceptions debug
CONFIG -= release
diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp
index ba2a7cb7..b8560e2a 100644
--- a/pokemod/Ability.cpp
+++ b/pokemod/Ability.cpp
@@ -15,36 +15,33 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
+// Header include
+#include "Ability.h"
// Pokemod includes
-#include "Pokemod.h"
#include "AbilityEffect.h"
-
-// Header include
-#include "Ability.h"
+#include "Pokemod.h"
Ability::Ability(const Ability& ability) :
- Object("Ability", ability.pokemod(), ability.id())
+ Object("Ability", ability.parent(), ability.id())
{
*this = ability;
}
-Ability::Ability(const Pokemod* pokemod, const int id) :
- Object("Ability", pokemod, id),
+Ability::Ability(const Object* parent, const int id) :
+ Object("Ability", parent, id),
m_name("")
{
}
-Ability::Ability(const Ability& ability, const Pokemod* pokemod, const int id) :
- Object("Ability", pokemod, id)
+Ability::Ability(const Ability& ability, const Object* parent, const int id) :
+ Object("Ability", parent, id)
{
*this = ability;
}
-Ability::Ability(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Ability", pokemod, id)
+Ability::Ability(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Ability", parent, id)
{
load(xml, id);
}
@@ -56,31 +53,32 @@ Ability::~Ability()
bool Ability::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Ability \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("No Name");
- valid = false;
- }
- if (effectCount())
- {
- QMap<int, bool> idChecker;
- foreach (AbilityEffect* effect, m_effects)
- {
- if (!effect->isValid())
- valid = false;
- if (idChecker[effect->id()])
- pokemod()->validationMsg(QString("Duplicate effect with id %1").arg(effect->id()));
- idChecker[effect->id()] = true;
- }
- }
- else
- {
- pokemod()->validationMsg(QString("No effects"));
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Ability \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("No Name");
+// valid = false;
+// }
+// if (effectCount())
+// {
+// QMap<int, bool> idChecker;
+// foreach (AbilityEffect* effect, m_effects)
+// {
+// if (!effect->isValid())
+// valid = false;
+// if (idChecker[effect->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate effect with id %1").arg(effect->id()));
+// idChecker[effect->id()] = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("No effects"));
+// valid = false;
+// }
+// return valid;
}
void Ability::load(const QDomElement& xml, int id)
@@ -149,19 +147,19 @@ int Ability::effectCount() const
AbilityEffect* Ability::newEffect()
{
- m_effects.append(new AbilityEffect(pokemod(), effectId()));
+ m_effects.append(new AbilityEffect(this, effectId()));
return m_effects[effectCount() - 1];
}
AbilityEffect* Ability::newEffect(const QDomElement& xml)
{
- m_effects.append(new AbilityEffect(xml, pokemod(), effectId()));
+ m_effects.append(new AbilityEffect(xml, this, effectId()));
return m_effects[effectCount() - 1];
}
AbilityEffect* Ability::newEffect(const AbilityEffect& effect)
{
- m_effects.append(new AbilityEffect(effect, pokemod(), effectId()));
+ m_effects.append(new AbilityEffect(effect, this, effectId()));
return m_effects[effectCount() - 1];
}
diff --git a/pokemod/Ability.h b/pokemod/Ability.h
index 845c51fe..ebb0df64 100644
--- a/pokemod/Ability.h
+++ b/pokemod/Ability.h
@@ -18,27 +18,26 @@
#ifndef __POKEMOD_ABILITY__
#define __POKEMOD_ABILITY__
-// Qt includes
-#include <QList>
-#include <QString>
+// Pokemod includes
+#include "Object.h"
// General includes
-#include <Exception.h>
+#include "../general/Exception.h"
-// Pokemod includes
-#include "Object.h"
+// Qt includes
+#include <QList>
+#include <QString>
// Forward declarations
class AbilityEffect;
-class Pokemod;
class Ability : public Object
{
public:
Ability(const Ability& ability);
- Ability(const Pokemod* pokemod, const int id);
- Ability(const Ability& ability, const Pokemod* pokemod, const int id);
- Ability(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Ability(const Object* parent, const int id);
+ Ability(const Ability& ability, const Object* parent, const int id);
+ Ability(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
~Ability();
void load(const QDomElement& xml, int id = INT_MAX);
diff --git a/pokemod/AbilityEffect.cpp b/pokemod/AbilityEffect.cpp
index 2b571fe4..dba7a5e2 100644
--- a/pokemod/AbilityEffect.cpp
+++ b/pokemod/AbilityEffect.cpp
@@ -15,13 +15,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Header include
+#include "AbilityEffect.h"
+
// Pokemod includes
#include "Ability.h"
-#include "Pokemod.h"
#include "Type.h"
-
-// Header include
-#include "AbilityEffect.h"
+#include "Pokemod.h"
const QStringList AbilityEffect::EffectStr = QStringList() << "Damage to HP" << "Prevent Damage" << "Auto Heal" << "Deal Damage" << "Wilds" << "Stat" << "Status" << "Ability" << "Accuracy/Power Trade" << "Bullseye" << "Item Effect" << "Type" << "Fast Hatch" << "Weather";
const QStringList AbilityEffect::TriggerStr = QStringList() << "Anything" << "Contact" << "Weather" << "Damage" << "Type" << "HP Boundary" << "Stat Change" << "Status";
@@ -34,13 +34,13 @@ const QStringList AbilityEffect::SideStr = QStringList() << "Above" << "Below";
AbilityEffect::AbilityEffect(const AbilityEffect& effect) :
- Object("AbilityEffect", effect.pokemod(), effect.id())
+ Object("AbilityEffect", effect.parent(), effect.id())
{
*this = effect;
}
-AbilityEffect::AbilityEffect(const Pokemod* pokemod, const int id) :
- Object("AbilityEffect", pokemod, id),
+AbilityEffect::AbilityEffect(const Object* parent, const int id) :
+ Object("AbilityEffect", parent, id),
m_chance(1, 1),
m_effect(INT_MAX),
m_value1(INT_MAX),
@@ -52,156 +52,157 @@ AbilityEffect::AbilityEffect(const Pokemod* pokemod, const int id) :
{
}
-AbilityEffect::AbilityEffect(const AbilityEffect& effect, const Pokemod* pokemod, const int id) :
- Object("AbilityEffect", pokemod, id)
+AbilityEffect::AbilityEffect(const AbilityEffect& effect, const Object* parent, const int id) :
+ Object("AbilityEffect", parent, id)
{
*this = effect;
}
-AbilityEffect::AbilityEffect(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("AbilityEffect", pokemod, id)
+AbilityEffect::AbilityEffect(const QDomElement& xml, const Object* parent, const int id) :
+ Object("AbilityEffect", parent, id)
{
load(xml, id);
}
bool AbilityEffect::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Effect with id %1---").arg(id()), Pokemod::V_Msg);
- if (m_effect < E_End)
- {
- bool ok = true;
- switch (m_effect)
- {
- case E_Stats:
- if ((Pokemod::ST_HP == m_value1) || (Pokemod::ST_End_Battle <= m_value1) || ((Pokemod::ST_SpecialDefense == m_value1) && !pokemod()->rules()->specialSplit()))
- ok = false;
- break;
- case E_Status:
- if (Pokemod::STS_End <= m_value1)
- ok = false;
- break;
- case E_Ability:
- if (pokemod()->abilityIndex(m_value1) == INT_MAX)
- ok = false;
- break;
- case E_AccuracyPowerTrade:
- if (PA_End <= m_value1)
- ok = false;
- break;
- case E_ItemEffect:
- if (IT_End <= m_value1)
- ok = false;
- break;
- case E_Type:
- if (pokemod()->typeIndex(m_value1) == INT_MAX)
- ok = false;
- break;
- case E_Weather:
- if (Pokemod::W_End_All <= m_value1)
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid value 1");
- valid = false;
- ok = true;
- }
- switch (m_effect)
- {
- case E_Stats:
- if (Pokemod::BM_End <= m_value2)
- ok = false;
- break;
- case E_Status:
- case E_Weather:
- if (C_End <= m_value2)
- ok = false;
- break;
- case E_Ability:
- if (I_End <= m_value2)
- ok = false;
- break;
- case E_Type:
- if (B_End <= m_value2)
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid value 2");
- valid = false;
- ok = true;
- }
- switch (m_effect)
- {
- case E_DamageToHP:
- case E_PreventDamage:
- case E_AutoHeal:
- case E_DealDamage:
- case E_Wilds:
- case E_AccuracyPowerTrade:
- case E_Type:
- case E_FastHatch:
- if ((m_value3 < 0) || (100 < m_value3))
- ok = false;
- break;
- case E_Stats:
- if ((m_value3 < -12) || (12 < m_value3))
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid value 3");
- valid = false;
- ok = true;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid effect");
- valid = false;
- }
- if (m_trigger < T_End)
- {
- bool ok = true;
- switch (m_trigger)
- {
- case T_Weather:
- if (Pokemod::W_End_All <= m_triggerValue1)
- ok = false;
- break;
- case T_Type:
- if (pokemod()->typeIndex(m_triggerValue1) == INT_MAX)
- ok = false;
- break;
- case T_HPBoundary:
- if (S_End <= m_triggerValue1)
- ok = false;
- break;
- case T_StatChange:
- if ((Pokemod::ST_HP == m_triggerValue1) || (Pokemod::ST_End_Battle <= m_triggerValue1) || ((Pokemod::ST_SpecialDefense == m_triggerValue1) && !pokemod()->rules()->specialSplit()))
- ok = false;
- break;
- case T_Status:
- if (Pokemod::STS_End <= m_triggerValue1)
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid trigger value 1");
- valid = false;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid trigger");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Effect with id %1---").arg(id()), Pokemod::V_Msg);
+// if (m_effect < E_End)
+// {
+// bool ok = true;
+// switch (m_effect)
+// {
+// case E_Stats:
+// if ((Pokemod::ST_HP == m_value1) || (Pokemod::ST_End_Battle <= m_value1) || ((Pokemod::ST_SpecialDefense == m_value1) && !static_cast<const Pokemod*>(pokemod())->rules()->specialSplit()))
+// ok = false;
+// break;
+// case E_Status:
+// if (Pokemod::STS_End <= m_value1)
+// ok = false;
+// break;
+// case E_Ability:
+// if (static_cast<const Pokemod*>(pokemod())->abilityIndex(m_value1) == INT_MAX)
+// ok = false;
+// break;
+// case E_AccuracyPowerTrade:
+// if (PA_End <= m_value1)
+// ok = false;
+// break;
+// case E_ItemEffect:
+// if (IT_End <= m_value1)
+// ok = false;
+// break;
+// case E_Type:
+// if (static_cast<const Pokemod*>(pokemod())->typeIndex(m_value1) == INT_MAX)
+// ok = false;
+// break;
+// case E_Weather:
+// if (Pokemod::W_End_All <= m_value1)
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid value 1");
+// valid = false;
+// ok = true;
+// }
+// switch (m_effect)
+// {
+// case E_Stats:
+// if (Pokemod::BM_End <= m_value2)
+// ok = false;
+// break;
+// case E_Status:
+// case E_Weather:
+// if (C_End <= m_value2)
+// ok = false;
+// break;
+// case E_Ability:
+// if (I_End <= m_value2)
+// ok = false;
+// break;
+// case E_Type:
+// if (B_End <= m_value2)
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid value 2");
+// valid = false;
+// ok = true;
+// }
+// switch (m_effect)
+// {
+// case E_DamageToHP:
+// case E_PreventDamage:
+// case E_AutoHeal:
+// case E_DealDamage:
+// case E_Wilds:
+// case E_AccuracyPowerTrade:
+// case E_Type:
+// case E_FastHatch:
+// if ((m_value3 < 0) || (100 < m_value3))
+// ok = false;
+// break;
+// case E_Stats:
+// if ((m_value3 < -12) || (12 < m_value3))
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid value 3");
+// valid = false;
+// ok = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid effect");
+// valid = false;
+// }
+// if (m_trigger < T_End)
+// {
+// bool ok = true;
+// switch (m_trigger)
+// {
+// case T_Weather:
+// if (Pokemod::W_End_All <= m_triggerValue1)
+// ok = false;
+// break;
+// case T_Type:
+// if (static_cast<const Pokemod*>(pokemod())->typeIndex(m_triggerValue1) == INT_MAX)
+// ok = false;
+// break;
+// case T_HPBoundary:
+// if (S_End <= m_triggerValue1)
+// ok = false;
+// break;
+// case T_StatChange:
+// if ((Pokemod::ST_HP == m_triggerValue1) || (Pokemod::ST_End_Battle <= m_triggerValue1) || ((Pokemod::ST_SpecialDefense == m_triggerValue1) && !static_cast<const Pokemod*>(pokemod())->rules()->specialSplit()))
+// ok = false;
+// break;
+// case T_Status:
+// if (Pokemod::STS_End <= m_triggerValue1)
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid trigger value 1");
+// valid = false;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid trigger");
+// valid = false;
+// }
+// return valid;
}
void AbilityEffect::load(const QDomElement& xml, int id)
@@ -253,7 +254,7 @@ void AbilityEffect::setValue1(const int value1) throw(Exception)
switch (m_effect)
{
case E_Stats:
- if ((Pokemod::ST_HP == value1) || (Pokemod::ST_End_Battle <= value1) || ((Pokemod::ST_SpecialDefense == value1) && !pokemod()->rules()->specialSplit()))
+ if ((Pokemod::ST_HP == value1) || (Pokemod::ST_End_Battle <= value1) || ((Pokemod::ST_SpecialDefense == value1) && !static_cast<const Pokemod*>(pokemod())->rules()->specialSplit()))
error<BoundsException>("value1");
break;
case E_Status:
@@ -261,7 +262,7 @@ void AbilityEffect::setValue1(const int value1) throw(Exception)
error<BoundsException>("value1");
break;
case E_Ability:
- if (pokemod()->abilityIndex(value1) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->abilityIndex(value1) == INT_MAX)
error<BoundsException>("value1");
break;
case E_AccuracyPowerTrade:
@@ -273,7 +274,7 @@ void AbilityEffect::setValue1(const int value1) throw(Exception)
error<BoundsException>("value1");
break;
case E_Type:
- if (pokemod()->typeIndex(value1) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->typeIndex(value1) == INT_MAX)
error<BoundsException>("value1");
break;
case E_Weather:
@@ -359,7 +360,7 @@ void AbilityEffect::setTriggerValue1(const int triggerValue1) throw(Exception)
error<BoundsException>("triggerValue1");
break;
case T_Type:
- if (pokemod()->typeIndex(triggerValue1) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->typeIndex(triggerValue1) == INT_MAX)
error<BoundsException>("triggerValue1");
break;
case T_HPBoundary:
@@ -367,7 +368,7 @@ void AbilityEffect::setTriggerValue1(const int triggerValue1) throw(Exception)
error<BoundsException>("triggerValue1");
break;
case T_StatChange:
- if ((Pokemod::ST_HP == triggerValue1) || (Pokemod::ST_End_Battle <= triggerValue1) || ((Pokemod::ST_SpecialDefense == triggerValue1) && !pokemod()->rules()->specialSplit()))
+ if ((Pokemod::ST_HP == triggerValue1) || (Pokemod::ST_End_Battle <= triggerValue1) || ((Pokemod::ST_SpecialDefense == triggerValue1) && !static_cast<const Pokemod*>(pokemod())->rules()->specialSplit()))
error<BoundsException>("triggerValue1");
break;
case T_Status:
diff --git a/pokemod/AbilityEffect.h b/pokemod/AbilityEffect.h
index 97cdc342..e4fca6ba 100644
--- a/pokemod/AbilityEffect.h
+++ b/pokemod/AbilityEffect.h
@@ -18,19 +18,15 @@
#ifndef __POKEMOD_ABILITYEFFECT__
#define __POKEMOD_ABILITYEFFECT__
-// Qt includes
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-#include <Fraction.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+#include "../general/Fraction.h"
+
+// Qt includes
+#include <QString>
class AbilityEffect : public Object
{
@@ -121,9 +117,9 @@ class AbilityEffect : public Object
static const QStringList SideStr;
AbilityEffect(const AbilityEffect& effect);
- AbilityEffect(const Pokemod* pokemod, const int id);
- AbilityEffect(const AbilityEffect& effect, const Pokemod* pokemod, const int id);
- AbilityEffect(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ AbilityEffect(const Object* parent, const int id);
+ AbilityEffect(const AbilityEffect& effect, const Object* parent, const int id);
+ AbilityEffect(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Author.cpp b/pokemod/Author.cpp
index abfd8cb1..bc5fc725 100644
--- a/pokemod/Author.cpp
+++ b/pokemod/Author.cpp
@@ -15,63 +15,64 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QRegExp>
+// Header include
+#include "Author.h"
// Pokemod includes
#include "Pokemod.h"
-// Header include
-#include "Author.h"
+// Qt includes
+#include <QRegExp>
Author::Author(const Author& author) :
- Object("Author", author.pokemod(), author.id())
+ Object("Author", author.parent(), author.id())
{
*this = author;
}
-Author::Author(const Pokemod* pokemod, const int id) :
- Object("Author", pokemod, id),
+Author::Author(const Object* parent, const int id) :
+ Object("Author", parent, id),
m_name(""),
m_email(""),
m_role("")
{
}
-Author::Author(const Author& author, const Pokemod* pokemod, const int id) :
- Object("Author", pokemod, id)
+Author::Author(const Author& author, const Object* parent, const int id) :
+ Object("Author", parent, id)
{
*this = author;
}
-Author::Author(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Author", pokemod, id)
+Author::Author(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Author", parent, id)
{
load(xml, id);
}
bool Author::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Author \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name not defined");
- valid = false;
- }
- if (m_email == "")
- pokemod()->validationMsg("Email not defined", Pokemod::V_Warn);
- else if (!QRegExp("[a-zA-Z0-9%-_\\.]+@[a-zA-Z0-9\\-]+(\\.[a-zA-Z]+)*\\.[a-zA-Z]{2,4}").exactMatch(m_email))
- {
- pokemod()->validationMsg("Invalid email");
- valid = false;
- }
- if (m_role == "")
- {
- pokemod()->validationMsg("Role not defined");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Author \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name not defined");
+// valid = false;
+// }
+// if (m_email == "")
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Email not defined", Pokemod::V_Warn);
+// else if (!QRegExp("[a-zA-Z0-9%-_\\.]+@[a-zA-Z0-9\\-]+(\\.[a-zA-Z]+)*\\.[a-zA-Z]{2,4}").exactMatch(m_email))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid email");
+// valid = false;
+// }
+// if (m_role == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Role not defined");
+// valid = false;
+// }
+// return valid;
}
void Author::load(const QDomElement& xml, int id)
diff --git a/pokemod/Author.h b/pokemod/Author.h
index 3af63143..87620b70 100644
--- a/pokemod/Author.h
+++ b/pokemod/Author.h
@@ -18,22 +18,19 @@
#ifndef __POKEMOD_AUTHOR__
#define __POKEMOD_AUTHOR__
-// Qt includes
-#include <QString>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// Qt includes
+#include <QString>
class Author : public Object
{
public:
Author(const Author& author);
- Author(const Pokemod* pokemod, const int id);
- Author(const Author& author, const Pokemod* pokemod, const int id);
- Author(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Author(const Object* parent, const int id);
+ Author(const Author& author, const Object* parent, const int id);
+ Author(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Badge.cpp b/pokemod/Badge.cpp
index 495bd162..28c5ae09 100644
--- a/pokemod/Badge.cpp
+++ b/pokemod/Badge.cpp
@@ -15,20 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QBuffer>
-
// Header include
#include "Badge.h"
+// Qt includes
+#include <QBuffer>
+
Badge::Badge(const Badge& badge) :
- Object("Badge", badge.pokemod(), badge.id())
+ Object("Badge", badge.parent(), badge.id())
{
*this = badge;
}
-Badge::Badge(const Pokemod* pokemod, const int id) :
- Object("Badge", pokemod, id),
+Badge::Badge(const Object* parent, const int id) :
+ Object("Badge", parent, id),
m_name(""),
m_face(64, 64),
m_badge(64, 64),
@@ -40,33 +40,34 @@ Badge::Badge(const Pokemod* pokemod, const int id) :
m_hm[i] = false;
}
-Badge::Badge(const Badge& badge, const Pokemod* pokemod, const int id) :
- Object("Badge", pokemod, id)
+Badge::Badge(const Badge& badge, const Object* parent, const int id) :
+ Object("Badge", parent, id)
{
*this = badge;
}
-Badge::Badge(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Badge", pokemod, id)
+Badge::Badge(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Badge", parent, id)
{
load(xml, id);
}
bool Badge::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Badge \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name not defined");
- valid = false;
- }
- if (pokemod()->rules()->maxLevel() < m_obey)
- {
- pokemod()->validationMsg("Obey level out of range");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Badge \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name not defined");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() < m_obey)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Obey level out of range");
+// valid = false;
+// }
+// return valid;
}
void Badge::load(const QDomElement& xml, int id)
@@ -76,7 +77,7 @@ void Badge::load(const QDomElement& xml, int id)
LOAD(QPixmap, face);
LOAD(QPixmap, badge);
LOAD(int, obey);
- LOAD_ARRAY(Fraction, stat, (pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY));
+ LOAD_ARRAY(Fraction, stat, (static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY));
LOAD_ARRAY(bool, hm, Pokemod::HM_End_All);
}
@@ -87,7 +88,7 @@ QDomElement Badge::save() const
SAVE(QPixmap, face);
SAVE(QPixmap, badge);
SAVE(int, obey);
- SAVE_ARRAY(Fraction, stat, (pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY));
+ SAVE_ARRAY(Fraction, stat, (static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY));
SAVE_ARRAY(bool, hm, Pokemod::HM_End_All);
return xml;
}
@@ -113,7 +114,7 @@ void Badge::setBadge(const QPixmap& badge) throw(SizeException)
void Badge::setObey(const int obey) throw(BoundsException)
{
- if (pokemod()->rules()->maxLevel() < obey)
+ if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() < obey)
error<BoundsException>("obey");
m_obey = obey;
}
@@ -122,7 +123,7 @@ void Badge::setStat(const int stat, const Fraction& multiplier) throw(BoundsExce
{
if (multiplier < 1)
error<BoundsException>("stat multiplier");
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
+ if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
error<BoundsException>("stat");
m_stat[stat] = multiplier;
}
@@ -156,7 +157,7 @@ int Badge::obey() const
Fraction Badge::stat(const int stat) const throw(BoundsException)
{
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
+ if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
warning<BoundsException>("stat");
return m_stat[stat];
}
diff --git a/pokemod/Badge.h b/pokemod/Badge.h
index d11bc9de..b276f5c1 100644
--- a/pokemod/Badge.h
+++ b/pokemod/Badge.h
@@ -18,25 +18,25 @@
#ifndef __POKEMOD_BADGE__
#define __POKEMOD_BADGE__
-// Qt includes
-#include <QPixmap>
-#include <QString>
-
-// General includes
-#include <Exception.h>
-#include <Fraction.h>
-
// Pokemod includes
#include "Object.h"
#include "Pokemod.h"
+// General includes
+#include "../general/Exception.h"
+#include "../general/Fraction.h"
+
+// Qt includes
+#include <QPixmap>
+#include <QString>
+
class Badge : public Object
{
public:
Badge(const Badge& badge);
- Badge(const Pokemod* pokemod, const int id);
- Badge(const Badge& badge, const Pokemod* pokemod, const int id);
- Badge(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Badge(const Object* parent, const int id);
+ Badge(const Badge& badge, const Object* parent, const int id);
+ Badge(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp
index 8c40db89..66086f94 100644
--- a/pokemod/CoinList.cpp
+++ b/pokemod/CoinList.cpp
@@ -15,39 +15,39 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
+// Header include
+#include "CoinList.h"
// Pokemod includes
-#include "Pokemod.h"
#include "CoinListObject.h"
#include "Item.h"
#include "ItemEffect.h"
+#include "Pokemod.h"
-// Header include
-#include "CoinList.h"
+// Qt includes
+#include <QMap>
CoinList::CoinList(const CoinList& coinList) :
- Object("CoinList", coinList.pokemod(), coinList.id())
+ Object("CoinList", coinList.parent(), coinList.id())
{
*this = coinList;
}
-CoinList::CoinList(const Pokemod* pokemod, const int id) :
- Object("CoinList", pokemod, id),
+CoinList::CoinList(const Object* parent, const int id) :
+ Object("CoinList", parent, id),
m_name(""),
m_value(0)
{
}
-CoinList::CoinList(const CoinList& coinList, const Pokemod* pokemod, const int id) :
- Object("CoinList", pokemod, id)
+CoinList::CoinList(const CoinList& coinList, const Object* parent, const int id) :
+ Object("CoinList", parent, id)
{
*this = coinList;
}
-CoinList::CoinList(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("CoinList", pokemod, id)
+CoinList::CoinList(const QDomElement& xml, const Object* parent, const int id) :
+ Object("CoinList", parent, id)
{
load(xml, id);
}
@@ -59,61 +59,62 @@ CoinList::~CoinList()
bool CoinList::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Coin List \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name not defined");
- valid = false;
- }
- bool ok = false;
- for (int i = 0; (i < pokemod()->itemCount()) && !ok; ++i)
- {
- const Item* item = pokemod()->item(i);
- for (int j = 0; (j < item->effectCount()) && !ok; ++j)
- {
- const ItemEffect* effect = item->effect(j);
- if (effect->effect() == ItemEffect::E_CoinCase)
- ok = (effect->value1() == m_value);
- }
- }
- if (!ok)
- {
- pokemod()->validationMsg("No coin cases which hold the right kind of coin");
- valid = false;
- }
- if (objectCount())
- {
- QMap<int, bool> idChecker;
- QMap<int, bool> itemChecker;
- QMap<int, bool> speciesChecker;
- foreach (CoinListObject* object, m_objects)
- {
- if (!object->isValid())
- valid = false;
- if (idChecker[object->id()])
- pokemod()->validationMsg(QString("Duplicate object with id %1").arg(object->id()));
- idChecker[object->id()] = true;
- if (object->type() == CoinListObject::Item)
- {
- if (itemChecker[object->object()])
- pokemod()->validationMsg(QString("Duplicate object with item %1").arg(object->id()));
- itemChecker[object->object()] = true;
- }
- else if (object->type() == CoinListObject::Species)
- {
- if (speciesChecker[object->object()])
- pokemod()->validationMsg(QString("Duplicate object with item %1").arg(object->id()));
- speciesChecker[object->object()] = true;
- }
- }
- }
- else
- {
- pokemod()->validationMsg("There are no objects");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Coin List \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name not defined");
+// valid = false;
+// }
+// bool ok = false;
+// for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()) && !ok; ++i)
+// {
+// const Item* item = static_cast<const Pokemod*>(pokemod())->item(i);
+// for (int j = 0; (j < item->effectCount()) && !ok; ++j)
+// {
+// const ItemEffect* effect = item->effect(j);
+// if (effect->effect() == ItemEffect::E_CoinCase)
+// ok = (effect->value1() == m_value);
+// }
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("No coin cases which hold the right kind of coin");
+// valid = false;
+// }
+// if (objectCount())
+// {
+// QMap<int, bool> idChecker;
+// QMap<int, bool> itemChecker;
+// QMap<int, bool> speciesChecker;
+// foreach (CoinListObject* object, m_objects)
+// {
+// if (!object->isValid())
+// valid = false;
+// if (idChecker[object->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate object with id %1").arg(object->id()));
+// idChecker[object->id()] = true;
+// if (object->type() == CoinListObject::Item)
+// {
+// if (itemChecker[object->object()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate object with item %1").arg(object->id()));
+// itemChecker[object->object()] = true;
+// }
+// else if (object->type() == CoinListObject::Species)
+// {
+// if (speciesChecker[object->object()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate object with item %1").arg(object->id()));
+// speciesChecker[object->object()] = true;
+// }
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no objects");
+// valid = false;
+// }
+// return valid;
}
void CoinList::load(const QDomElement& xml, int id)
@@ -140,9 +141,9 @@ void CoinList::setName(const QString& name)
void CoinList::setValue(const int value) throw(Exception)
{
- for (int i = 0; (i < pokemod()->itemCount()); ++i)
+ for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()); ++i)
{
- const Item* item = pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(pokemod())->item(i);
for (int j = 0; (j < item->effectCount()); ++j)
{
const ItemEffect* effect = item->effect(j);
@@ -207,19 +208,19 @@ int CoinList::objectCount() const
CoinListObject* CoinList::newObject()
{
- m_objects.append(new CoinListObject(pokemod(), objectId()));
+ m_objects.append(new CoinListObject(this, objectId()));
return m_objects[objectCount() - 1];
}
CoinListObject* CoinList::newObject(const QDomElement& xml)
{
- m_objects.append(new CoinListObject(xml, pokemod(), objectId()));
+ m_objects.append(new CoinListObject(xml, this, objectId()));
return m_objects[objectCount() - 1];
}
CoinListObject* CoinList::newObject(const CoinListObject& object)
{
- m_objects.append(new CoinListObject(object, pokemod(), objectId()));
+ m_objects.append(new CoinListObject(object, this, objectId()));
return m_objects[objectCount() - 1];
}
diff --git a/pokemod/CoinList.h b/pokemod/CoinList.h
index e9fd1752..c32037c0 100644
--- a/pokemod/CoinList.h
+++ b/pokemod/CoinList.h
@@ -18,27 +18,26 @@
#ifndef __POKEMOD_COINLIST__
#define __POKEMOD_COINLIST__
-// Qt includes
-#include <QList>
-#include <QString>
+// Pokemod includes
+#include "Object.h"
// General includes
-#include <Exception.h>
+#include "../general/Exception.h"
-// Pokemod includes
-#include "Object.h"
+// Qt includes
+#include <QList>
+#include <QString>
// Forward declarations
class CoinListObject;
-class Pokemod;
class CoinList : public Object
{
public:
CoinList(const CoinList& coinList);
- CoinList(const Pokemod* pokemod, const int id);
- CoinList(const CoinList& coinList, const Pokemod* pokemod, const int id);
- CoinList(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ CoinList(const Object* parent, const int id);
+ CoinList(const CoinList& coinList, const Object* parent, const int id);
+ CoinList(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
~CoinList();
void load(const QDomElement& xml, int id = INT_MAX);
diff --git a/pokemod/CoinListObject.cpp b/pokemod/CoinListObject.cpp
index bdc170fa..499427a5 100644
--- a/pokemod/CoinListObject.cpp
+++ b/pokemod/CoinListObject.cpp
@@ -21,13 +21,13 @@
const QStringList CoinListObject::TypeStr = QStringList() << "Item" << "Pokémon";
CoinListObject::CoinListObject(const CoinListObject& object) :
- Object("CoinListObject", object.pokemod(), object.id())
+ Object("CoinListObject", object.parent(), object.id())
{
*this = object;
}
-CoinListObject::CoinListObject(const Pokemod* pokemod, const int id) :
- Object("CoinListObject", pokemod, id),
+CoinListObject::CoinListObject(const Object* parent, const int id) :
+ Object("CoinListObject", parent, id),
m_type(Item),
m_object(INT_MAX),
m_amount(1),
@@ -35,49 +35,50 @@ CoinListObject::CoinListObject(const Pokemod* pokemod, const int id) :
{
}
-CoinListObject::CoinListObject(const CoinListObject& object, const Pokemod* pokemod, const int id) :
- Object("CoinListObject", pokemod, id)
+CoinListObject::CoinListObject(const CoinListObject& object, const Object* parent, const int id) :
+ Object("CoinListObject", parent, id)
{
*this = object;
}
-CoinListObject::CoinListObject(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("CoinListObject", pokemod, id)
+CoinListObject::CoinListObject(const QDomElement& xml, const Object* parent, const int id) :
+ Object("CoinListObject", parent, id)
{
load(xml, id);
}
bool CoinListObject::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Object with id %1---").arg(id()), Pokemod::V_Msg);
- if (Item == m_type)
- {
- if (pokemod()->itemIndex(m_object) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid item");
- valid = false;
- }
- }
- else if (Species == m_type)
- {
- if (pokemod()->speciesIndex(m_object) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid Species");
- valid = false;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid type");
- valid = false;
- }
- if (!m_amount || ((1 < m_amount) && (Species == m_type)))
- {
- pokemod()->validationMsg("Invalid amount");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Object with id %1---").arg(id()), Pokemod::V_Msg);
+// if (Item == m_type)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->itemIndex(m_object) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid item");
+// valid = false;
+// }
+// }
+// else if (Species == m_type)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->speciesIndex(m_object) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid Species");
+// valid = false;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid type");
+// valid = false;
+// }
+// if (!m_amount || ((1 < m_amount) && (Species == m_type)))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid amount");
+// valid = false;
+// }
+// return valid;
}
void CoinListObject::load(const QDomElement& xml, int id)
@@ -109,7 +110,7 @@ void CoinListObject::setType(const int type) throw(BoundsException)
void CoinListObject::setObject(const int object) throw(BoundsException)
{
- if (((Item == m_type) && (pokemod()->itemIndex(object) == INT_MAX)) || ((Species == m_type) && (pokemod()->speciesIndex(object) == INT_MAX)))
+ if (((Item == m_type) && (static_cast<const Pokemod*>(pokemod())->itemIndex(object) == INT_MAX)) || ((Species == m_type) && (static_cast<const Pokemod*>(pokemod())->speciesIndex(object) == INT_MAX)))
error<BoundsException>("object");
m_object = object;
}
diff --git a/pokemod/CoinListObject.h b/pokemod/CoinListObject.h
index 2613fbf0..761c8ee2 100644
--- a/pokemod/CoinListObject.h
+++ b/pokemod/CoinListObject.h
@@ -18,18 +18,14 @@
#ifndef __POKEMOD_COINLISTOBJECT__
#define __POKEMOD_COINLISTOBJECT__
-// Qt includes
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QString>
class CoinListObject : public Object
{
@@ -43,9 +39,9 @@ class CoinListObject : public Object
static const QStringList TypeStr;
CoinListObject(const CoinListObject& object);
- CoinListObject(const Pokemod* pokemod, const int id);
- CoinListObject(const CoinListObject& object, const Pokemod* pokemod, const int id);
- CoinListObject(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ CoinListObject(const Object* parent, const int id);
+ CoinListObject(const CoinListObject& object, const Object* parent, const int id);
+ CoinListObject(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Dialog.cpp b/pokemod/Dialog.cpp
index a24b88bb..8ec1ee1a 100644
--- a/pokemod/Dialog.cpp
+++ b/pokemod/Dialog.cpp
@@ -15,6 +15,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Header include
+#include "Dialog.h"
+
// Pokemod includes
#include "Item.h"
#include "ItemEffect.h"
@@ -23,646 +26,644 @@
#include "MapTrainer.h"
#include "MapWarp.h"
#include "Move.h"
-#include "Pokemod.h"
#include "Species.h"
-
-// Header include
-#include "Dialog.h"
+#include "Pokemod.h"
const QStringList Dialog::CommandStr = QStringList() << "Flip Flag" << "Set Flag" << "Unset Flag" << "Randomize Flag" << "Test Flag" << "Dialog" << "Yes/No" << "Item Shop" << "Give Item" << "Take Item" << "Check Item" << "Coin List" << "Teach Move" << "Delete Move" << "Give Pokemon" << "Take Pokemon" << "Show Pokemon" << "View Pokemon" << "Give Money" << "Take Money" << "Move Effect" << "Turn Effect" << "Check Direction" << "Check Roster" << "Check Levels" << "Check Species" << "Check Held Items" << "Check Money" << "Trade" << "Daycare" << "Battle" << "Badge" << "Warp" << "Name" << "Music" << "Sound Effect" << "Timer" << "Map Sign" << "Wild Scope" << "Safari" << "Heal Party" << "Refresh" << "Clear" << "Pause" << "New Line" << "Exit" << "Menu";
const QStringList Dialog::CommandAbbrStr = QStringList() << "FF" << "SF" << "UF" << "RF" << "TF" << "D" << "YN" << "ItS" << "GIt" << "TIt" << "CIt" << "CL" << "TMv" << "DMv" << "GPk" << "TPk" << "SPk" << "VPk" << "G$" << "T$" << "MvEf" << "TEf" << "CD" << "CR" << "CLv" << "CS" << "CHIt" << "C$" << "T" << "Dc" << "Bat" << "Bdg" << "W" << "N" << "Ms" << "SFX" << "Tmr" << "MS" << "WS" << "S" << "HP" << "R" << "C" << "P" << "NL" << "X" << "M";
const QList<int> Dialog::CommandNumArgs = QList<int>() << 1 << 1 << 1 << 1 << 3 << 2 << 2 << 1 << 4 << 4 << 4 << 1 << 5 << 3 << 7 << 4 << 1 << 4 << 1 << 4 << 6 << 3 << 6 << 5 << 5 << 4 << 4 << 5 << 6 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 3 << 1 << 1 << 3 << 0 << 0 << 0 << 0 << 0 << 0;
Dialog::Dialog(const Dialog& dialog) :
- Object("Dialog", dialog.pokemod(), dialog.id())
+ Object("Dialog", dialog.parent(), dialog.id())
{
*this = dialog;
}
-Dialog::Dialog(const Pokemod* pokemod, const int id) :
- Object("Dialog", pokemod, id),
+Dialog::Dialog(const Object* parent, const int id) :
+ Object("Dialog", parent, id),
m_dialog("")
{
}
-Dialog::Dialog(const Dialog& dialog, const Pokemod* pokemod, const int id) :
- Object("Dialog", pokemod, id)
+Dialog::Dialog(const Dialog& dialog, const Object* parent, const int id) :
+ Object("Dialog", parent, id)
{
*this = dialog;
}
-Dialog::Dialog(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Dialog", pokemod, id)
+Dialog::Dialog(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Dialog", parent, id)
{
load(xml, id);
}
bool Dialog::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Dialog with id %1---").arg(id()), Pokemod::V_Msg);
- if (m_dialog == "")
- {
- pokemod()->validationMsg("Dialog is empty");
- valid = false;
- }
- if (m_dialog.count('%') & 1)
- {
- pokemod()->validationMsg("Command delimiter mismatch");
- valid = false;
- }
- else
- {
- int curCmd = End;
- int numArgs = 0;
- for (int i = 0; i < m_dialog.length(); ++i)
- {
- switch (m_dialog.at(i).toAscii())
- {
- case '%':
- switch (curCmd)
- {
- case FlipFlag ... Exit:
- if (numArgs != CommandNumArgs[curCmd])
- {
- pokemod()->validationMsg(QString("Invalid number of arguments for \"%1\". %2 given when %3 needed").arg(CommandStr[curCmd]).arg(numArgs).arg(CommandNumArgs[curCmd]));
- valid = false;
- }
- break;
- case Menu:
- if (!(numArgs & 1))
- {
- pokemod()->validationMsg("Invalid number of arguments for Menu");
- valid = false;
- }
- break;
- case End:
- QString curCmdStr;
- for (; (m_dialog.at(i) != '%') && (m_dialog.at(i) != '#'); ++i)
- curCmdStr += m_dialog.at(i);
- if (((curCmd = CommandAbbrStr.indexOf(curCmdStr))) == INT_MAX)
- {
- if (curCmdStr != "")
- {
- pokemod()->validationMsg(QString("Invalid command \"%1\"").arg(curCmdStr));
- valid = false;
- }
- curCmd = End;
- }
- numArgs = 0;
- break;
- }
- break;
- case '#':
- if (curCmd != End)
- {
- QString arg;
- for (; (m_dialog.at(i) != '%') && (m_dialog.at(i) != '#'); ++i)
- arg += m_dialog.at(i);
- bool ok;
- int temp = arg.toInt(&ok);
- int invError = 0;
- const Map* map = NULL;
- ++numArgs;
- switch (curCmd)
- {
- case FlipFlag:
- case SetFlag:
- case UnsetFlag:
- case RandomizeFlag:
- if (numArgs == 1)
- {
- if (!ok)
- {
- pokemod()->validationMsg(QString("Bad flag in \"%1\"").arg(CommandStr[curCmd]));
- valid = false;
- }
- }
- break;
- case TestFlag:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- if (!ok)
- {
- pokemod()->validationMsg("Bad flag in \"Test Flag\"");
- valid = false;
- }
- break;
- case 3:
- case 4:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- }
- break;
- case DialogC:
- if (numArgs == 1)
- {
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- }
- else if (numArgs == 2)
- {
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = 2;
- }
- break;
- case YesNo:
- case DeleteMove:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- case 3:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- }
- break;
- case ItemShop:
- if (numArgs == 1)
- {
- if (!ok || (pokemod()->storeIndex(temp) == INT_MAX))
- invError = 1;
- }
- break;
- case GiveItem:
- case TakeItem:
- case CheckItem:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- if (!ok || (pokemod()->itemIndex(temp) == INT_MAX))
- invError = 2;
- break;
- case 3:
- case 4:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- break;
- }
- break;
- case CoinList:
- if (numArgs == 1)
- {
- if (!ok || (pokemod()->coinListIndex(temp) == INT_MAX))
- invError = 1;
- }
- break;
- case TeachMove:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- if (!ok || (pokemod()->moveIndex(temp) == INT_MAX))
- invError = 2;
- break;
- case 3:
- case 4:
- case 5:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- break;
- }
- break;
- case CheckMove:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- if ((arg != "Lead") && (arg != "All") && (arg != "0") && (arg != "1"))
- invError = 2;
- break;
- case 3:
- if (!ok || (pokemod()->moveIndex(temp) == INT_MAX))
- invError = 3;
- break;
- case 4:
- case 5:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- break;
- }
- break;
- case GivePokemon:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- if (!ok || (pokemod()->speciesIndex(temp) ==INT_MAX))
- invError = 2;
- break;
- case 3:
- if ((arg != "false") && (arg != "true") && (arg != "0") && (arg != "1"))
- invError = 3;
- break;
- case 4:
- if (ok)
- {
- if (pokemod()->rules()->maxLevel() < temp)
- {
- pokemod()->validationMsg("Higher level than allowed in \"Give Pokémon\"");
- valid = false;
- }
- }
- else
- invError = 4;
- break;
- case 5:
- if (!ok)
- invError = 5;
- break;
- case 6:
- case 7:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- break;
- }
- break;
- case TakePokemon:
- case ViewPokemon:
- case CheckSpecies:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- if (!ok || (pokemod()->speciesIndex(temp) == INT_MAX))
- invError = 2;
- break;
- case 3:
- case 4:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- break;
- }
- break;
- case ShowPokemon:
- if (numArgs == 1)
- {
- if (!ok || (pokemod()->speciesIndex(temp) == INT_MAX))
- invError = 1;
- }
- break;
- case GiveMoney:
- if (numArgs == 1)
- {
- if (ok)
- {
- if (pokemod()->rules()->maxMoney() < temp)
- {
- pokemod()->validationMsg("More money given than can be held in \"Give Money\"", Pokemod::V_Warn);
- valid = false;
- }
- }
- else
- invError = 1;
- }
- break;
- case TakeMoney:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- if (ok)
- {
- if (pokemod()->rules()->maxMoney() < temp)
- {
- pokemod()->validationMsg("More money taken than can be held in \"Take Money\"");
- valid = false;
- }
- }
- else
- invError = 2;
- break;
- case 3:
- case 4:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- break;
- }
- break;
- case MoveEffect:
- case CheckDirection:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- if (!ok || (pokemod()->mapIndex(temp) == INT_MAX))
- invError = 2;
- else
- map = pokemod()->mapById(temp);
- break;
- case 3:
- if (map)
- {
- if (!ok || (map->effectIndex(temp) == INT_MAX))
- invError = 3;
- }
- else if ((arg != "Player") && (arg != "INT_MAX"))
- pokemod()->validationMsg(QString("Unable to validate argument #3 in \"%1\"").arg(CommandStr[curCmd]));
- break;
- case 4:
- if ((arg != "Up") && (arg != "Down") && (arg != "Left") && (arg != "Right") && ((arg != "Random") || (curCmd == CheckDirection)) && (arg != "0") && (arg != "1") && (arg != "2") && (arg != "3") && ((arg != "4") || (curCmd == CheckDirection)))
- invError = 4;
- break;
- case 5:
- case 6:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- break;
- }
- break;
- case TurnEffect:
- switch (numArgs)
- {
- case 1:
- if (!ok || (pokemod()->mapIndex(temp) == INT_MAX))
- invError = 1;
- else
- map = pokemod()->mapById(temp);
- break;
- case 2:
- if (map)
- {
- if (!ok || (map->effectIndex(temp) == INT_MAX))
- invError = 2;
- }
- else if ((arg != "Player") && (arg != "INT_MAX"))
- pokemod()->validationMsg("Unable to validate argument #2 in \"Turn Effect\"");
- map = NULL;
- break;
- case 3:
- if ((arg != "Up") && (arg != "Down") && (arg != "Left") && (arg != "Right") && (arg != "Random") && (arg != "0") && (arg != "1") && (arg != "2") && (arg != "3") && (arg != "4"))
- invError = 3;
- break;
- }
- break;
- case CheckRoster:
- case CheckLevels:
- case CheckMoney:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- if ((arg != "<") && (arg != ">") && (arg != "="))
- invError = 2;
- break;
- case 3:
- if (ok)
- {
- if (((curCmd == CheckRoster) ? pokemod()->rules()->maxParty() : ((curCmd == CheckLevels) ? pokemod()->rules()->maxLevel() : pokemod()->rules()->maxMoney())) < temp)
- {
- pokemod()->validationMsg(QString("More %1 than can be carried in \"%2\"").arg((curCmd == CheckRoster) ? "party members" : ((curCmd == CheckLevels) ? "level" : "money")).arg(CommandStr[curCmd]));
- valid = false;
- }
- }
- else
- invError = 3;
- break;
- case 4:
- case 5:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- break;
- }
- break;
- case CheckHeldItems:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- case 3:
- case 4:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- }
- break;
- case Trade:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- case 3:
- if (!ok || (pokemod()->speciesIndex(temp) == INT_MAX))
- invError = numArgs;
- case 4:
- if (!ok)
- invError = 4;
- break;
- case 5:
- case 6:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = numArgs;
- break;
- }
- break;
- case Daycare:
- if (numArgs == 1)
- {
- if (!ok)
- invError = 1;
- }
- break;
- case Battle:
- if (numArgs == 1)
- {
- if (!ok || (pokemod()->mapIndex(temp) == INT_MAX))
- invError = 1;
- else
- map = pokemod()->mapById(temp);
- }
- else if (numArgs == 2)
- {
- if (map)
- {
- if (!ok || (map->trainerIndex(temp) == INT_MAX))
- invError = 2;
- }
- else
- pokemod()->validationMsg("Unable to validate argument #2 in \"Battle\"");
- map = NULL;
- }
- break;
- case Badge:
- if (numArgs == 1)
- {
- if (!ok || (pokemod()->badgeIndex(temp) == INT_MAX))
- invError = 1;
- }
- break;
- case Warp:
- if (numArgs == 1)
- {
- if (!ok || (pokemod()->mapIndex(temp) == INT_MAX))
- invError = 1;
- else
- map = pokemod()->mapById(temp);
- }
- else if (numArgs == 2)
- {
- if (map)
- {
- if (!ok || (map->warpIndex(temp) == INT_MAX))
- invError = 2;
- }
- else
- pokemod()->validationMsg("Unable to validate argument #2 in \"Warp\"");
- map = NULL;
- }
- break;
- case Name:
- case MapSign:
- if (numArgs == 1)
- {
- if (arg == "")
- invError = 1;
- }
- break;
- case Music:
- if (numArgs == 1)
- {
- // FIXME: find sound files
-// if (!QFile(QString("%1/music/%2").arg(pokemod()->path()).arg(arg)).exists())
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Dialog with id %1---").arg(id()), Pokemod::V_Msg);
+// if (m_dialog == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Dialog is empty");
+// valid = false;
+// }
+// if (m_dialog.count('%') & 1)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Command delimiter mismatch");
+// valid = false;
+// }
+// else
+// {
+// int curCmd = End;
+// int numArgs = 0;
+// for (int i = 0; i < m_dialog.length(); ++i)
+// {
+// switch (m_dialog.at(i).toAscii())
+// {
+// case '%':
+// switch (curCmd)
+// {
+// case FlipFlag ... Exit:
+// if (numArgs != CommandNumArgs[curCmd])
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Invalid number of arguments for \"%1\". %2 given when %3 needed").arg(CommandStr[curCmd]).arg(numArgs).arg(CommandNumArgs[curCmd]));
+// valid = false;
+// }
+// break;
+// case Menu:
+// if (!(numArgs & 1))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid number of arguments for Menu");
+// valid = false;
+// }
+// break;
+// case End:
+// QString curCmdStr;
+// for (; (m_dialog.at(i) != '%') && (m_dialog.at(i) != '#'); ++i)
+// curCmdStr += m_dialog.at(i);
+// if (((curCmd = CommandAbbrStr.indexOf(curCmdStr))) == INT_MAX)
+// {
+// if (curCmdStr != "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Invalid command \"%1\"").arg(curCmdStr));
+// valid = false;
+// }
+// curCmd = End;
+// }
+// numArgs = 0;
+// break;
+// }
+// break;
+// case '#':
+// if (curCmd != End)
+// {
+// QString arg;
+// for (; (m_dialog.at(i) != '%') && (m_dialog.at(i) != '#'); ++i)
+// arg += m_dialog.at(i);
+// bool ok;
+// int temp = arg.toInt(&ok);
+// int invError = 0;
+// const Map* map = NULL;
+// ++numArgs;
+// switch (curCmd)
+// {
+// case FlipFlag:
+// case SetFlag:
+// case UnsetFlag:
+// case RandomizeFlag:
+// if (numArgs == 1)
+// {
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Bad flag in \"%1\"").arg(CommandStr[curCmd]));
+// valid = false;
+// }
+// }
+// break;
+// case TestFlag:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Bad flag in \"Test Flag\"");
+// valid = false;
+// }
+// break;
+// case 3:
+// case 4:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// }
+// break;
+// case DialogC:
+// if (numArgs == 1)
+// {
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// }
+// else if (numArgs == 2)
+// {
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = 2;
+// }
+// break;
+// case YesNo:
+// case DeleteMove:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// case 3:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// }
+// break;
+// case ItemShop:
+// if (numArgs == 1)
+// {
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->storeIndex(temp) == INT_MAX))
+// invError = 1;
+// }
+// break;
+// case GiveItem:
+// case TakeItem:
+// case CheckItem:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->itemIndex(temp) == INT_MAX))
+// invError = 2;
+// break;
+// case 3:
+// case 4:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// break;
+// }
+// break;
+// case CoinList:
+// if (numArgs == 1)
+// {
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->coinListIndex(temp) == INT_MAX))
+// invError = 1;
+// }
+// break;
+// case TeachMove:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->moveIndex(temp) == INT_MAX))
+// invError = 2;
+// break;
+// case 3:
+// case 4:
+// case 5:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// break;
+// }
+// break;
+// case CheckMove:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// if ((arg != "Lead") && (arg != "All") && (arg != "0") && (arg != "1"))
+// invError = 2;
+// break;
+// case 3:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->moveIndex(temp) == INT_MAX))
+// invError = 3;
+// break;
+// case 4:
+// case 5:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// break;
+// }
+// break;
+// case GivePokemon:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->speciesIndex(temp) ==INT_MAX))
+// invError = 2;
+// break;
+// case 3:
+// if ((arg != "false") && (arg != "true") && (arg != "0") && (arg != "1"))
+// invError = 3;
+// break;
+// case 4:
+// if (ok)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() < temp)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Higher level than allowed in \"Give Pokémon\"");
+// valid = false;
+// }
+// }
+// else
+// invError = 4;
+// break;
+// case 5:
+// if (!ok)
+// invError = 5;
+// break;
+// case 6:
+// case 7:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// break;
+// }
+// break;
+// case TakePokemon:
+// case ViewPokemon:
+// case CheckSpecies:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->speciesIndex(temp) == INT_MAX))
+// invError = 2;
+// break;
+// case 3:
+// case 4:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// break;
+// }
+// break;
+// case ShowPokemon:
+// if (numArgs == 1)
+// {
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->speciesIndex(temp) == INT_MAX))
+// invError = 1;
+// }
+// break;
+// case GiveMoney:
+// if (numArgs == 1)
+// {
+// if (ok)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->rules()->maxMoney() < temp)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("More money given than can be held in \"Give Money\"", Pokemod::V_Warn);
+// valid = false;
+// }
+// }
+// else
+// invError = 1;
+// }
+// break;
+// case TakeMoney:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// if (ok)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->rules()->maxMoney() < temp)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("More money taken than can be held in \"Take Money\"");
+// valid = false;
+// }
+// }
+// else
+// invError = 2;
+// break;
+// case 3:
+// case 4:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// break;
+// }
+// break;
+// case MoveEffect:
+// case CheckDirection:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->mapIndex(temp) == INT_MAX))
+// invError = 2;
+// else
+// map = static_cast<const Pokemod*>(pokemod())->mapById(temp);
+// break;
+// case 3:
+// if (map)
+// {
+// if (!ok || (map->effectIndex(temp) == INT_MAX))
+// invError = 3;
+// }
+// else if ((arg != "Player") && (arg != "INT_MAX"))
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Unable to validate argument #3 in \"%1\"").arg(CommandStr[curCmd]));
+// break;
+// case 4:
+// if ((arg != "Up") && (arg != "Down") && (arg != "Left") && (arg != "Right") && ((arg != "Random") || (curCmd == CheckDirection)) && (arg != "0") && (arg != "1") && (arg != "2") && (arg != "3") && ((arg != "4") || (curCmd == CheckDirection)))
+// invError = 4;
+// break;
+// case 5:
+// case 6:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// break;
+// }
+// break;
+// case TurnEffect:
+// switch (numArgs)
+// {
+// case 1:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->mapIndex(temp) == INT_MAX))
+// invError = 1;
+// else
+// map = static_cast<const Pokemod*>(pokemod())->mapById(temp);
+// break;
+// case 2:
+// if (map)
+// {
+// if (!ok || (map->effectIndex(temp) == INT_MAX))
+// invError = 2;
+// }
+// else if ((arg != "Player") && (arg != "INT_MAX"))
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Unable to validate argument #2 in \"Turn Effect\"");
+// map = NULL;
+// break;
+// case 3:
+// if ((arg != "Up") && (arg != "Down") && (arg != "Left") && (arg != "Right") && (arg != "Random") && (arg != "0") && (arg != "1") && (arg != "2") && (arg != "3") && (arg != "4"))
+// invError = 3;
+// break;
+// }
+// break;
+// case CheckRoster:
+// case CheckLevels:
+// case CheckMoney:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// if ((arg != "<") && (arg != ">") && (arg != "="))
+// invError = 2;
+// break;
+// case 3:
+// if (ok)
+// {
+// if (((curCmd == CheckRoster) ? static_cast<const Pokemod*>(pokemod())->rules()->maxParty() : ((curCmd == CheckLevels) ? static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() : static_cast<const Pokemod*>(pokemod())->rules()->maxMoney())) < temp)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("More %1 than can be carried in \"%2\"").arg((curCmd == CheckRoster) ? "party members" : ((curCmd == CheckLevels) ? "level" : "money")).arg(CommandStr[curCmd]));
+// valid = false;
+// }
+// }
+// else
+// invError = 3;
+// break;
+// case 4:
+// case 5:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// break;
+// }
+// break;
+// case CheckHeldItems:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// case 3:
+// case 4:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// }
+// break;
+// case Trade:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// case 3:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->speciesIndex(temp) == INT_MAX))
+// invError = numArgs;
+// case 4:
+// if (!ok)
+// invError = 4;
+// break;
+// case 5:
+// case 6:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = numArgs;
+// break;
+// }
+// break;
+// case Daycare:
+// if (numArgs == 1)
+// {
+// if (!ok)
+// invError = 1;
+// }
+// break;
+// case Battle:
+// if (numArgs == 1)
+// {
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->mapIndex(temp) == INT_MAX))
+// invError = 1;
+// else
+// map = static_cast<const Pokemod*>(pokemod())->mapById(temp);
+// }
+// else if (numArgs == 2)
+// {
+// if (map)
+// {
+// if (!ok || (map->trainerIndex(temp) == INT_MAX))
+// invError = 2;
+// }
+// else
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Unable to validate argument #2 in \"Battle\"");
+// map = NULL;
+// }
+// break;
+// case Badge:
+// if (numArgs == 1)
+// {
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->badgeIndex(temp) == INT_MAX))
+// invError = 1;
+// }
+// break;
+// case Warp:
+// if (numArgs == 1)
+// {
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->mapIndex(temp) == INT_MAX))
+// invError = 1;
+// else
+// map = static_cast<const Pokemod*>(pokemod())->mapById(temp);
+// }
+// else if (numArgs == 2)
+// {
+// if (map)
+// {
+// if (!ok || (map->warpIndex(temp) == INT_MAX))
+// invError = 2;
+// }
+// else
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Unable to validate argument #2 in \"Warp\"");
+// map = NULL;
+// }
+// break;
+// case Name:
+// case MapSign:
+// if (numArgs == 1)
+// {
+// if (arg == "")
+// invError = 1;
+// }
+// break;
+// case Music:
+// if (numArgs == 1)
+// {
+// // FIXME: find sound files
+// // if (!QFile(QString("%1/music/%2").arg(static_cast<const Pokemod*>(pokemod())->path()).arg(arg)).exists())
+// // invError = 1;
+// }
+// break;
+// case SoundEffect:
+// if (numArgs == 1)
+// {
+// // FIXME: find sound files
+// // if (!QFile(QString("%1/sound/%2").arg(static_cast<const Pokemod*>(pokemod())->path()).arg(arg)).exists())
+// // invError = 1;
+// }
+// else if (numArgs == 2)
+// {
+// if (!ok)
+// invError = 2;
+// }
+// break;
+// case Timer:
+// switch (numArgs)
+// {
+// case 1:
+// if ((arg != "Time") && (arg != "Step") && (arg != "0") && (arg != "1"))
+// invError = 1;
+// break;
+// case 2:
+// if (!ok)
+// invError = 2;
+// break;
+// case 3:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX))
+// invError = 3;
+// break;
+// }
+// break;
+// case WildScope:
+// if (numArgs == 1)
+// {
+// if (!ok)
// invError = 1;
- }
- break;
- case SoundEffect:
- if (numArgs == 1)
- {
- // FIXME: find sound files
-// if (!QFile(QString("%1/sound/%2").arg(pokemod()->path()).arg(arg)).exists())
+// }
+// break;
+// case Safari:
+// switch (numArgs)
+// {
+// case 1:
+// if (ok && (static_cast<const Pokemod*>(pokemod())->itemIndex(temp) != INT_MAX))
+// {
+// const Item* item = static_cast<const Pokemod*>(pokemod())->itemById(temp);
+// bool temp = false;
+// for (int i = 0; (i < item->effectCount()) || !temp; ++i)
+// {
+// if (item->effect(i)->effect() == ItemEffect::E_Ball)
+// temp = true;
+// }
+// if (!temp)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Item in argument #1 in \"Safari\" isn\'t a PokéBall");
+// valid = false;
+// }
+// }
+// else
+// invError = 1;
+// break;
+// case 2:
+// if (!ok)
+// invError = 2;
+// break;
+// case 3:
+// if (!ok || (static_cast<const Pokemod*>(pokemod())->rules()->maxParty() < temp))
+// invError = 3;
+// break;
+// }
+// break;
+// case Menu:
+// if (numArgs == 1)
+// {
+// if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
// invError = 1;
- }
- else if (numArgs == 2)
- {
- if (!ok)
- invError = 2;
- }
- break;
- case Timer:
- switch (numArgs)
- {
- case 1:
- if ((arg != "Time") && (arg != "Step") && (arg != "0") && (arg != "1"))
- invError = 1;
- break;
- case 2:
- if (!ok)
- invError = 2;
- break;
- case 3:
- if (!ok || (pokemod()->dialogIndex(temp) == INT_MAX))
- invError = 3;
- break;
- }
- break;
- case WildScope:
- if (numArgs == 1)
- {
- if (!ok)
- invError = 1;
- }
- break;
- case Safari:
- switch (numArgs)
- {
- case 1:
- if (ok && (pokemod()->itemIndex(temp) != INT_MAX))
- {
- const Item* item = pokemod()->itemById(temp);
- bool temp = false;
- for (int i = 0; (i < item->effectCount()) || !temp; ++i)
- {
- if (item->effect(i)->effect() == ItemEffect::E_Ball)
- temp = true;
- }
- if (!temp)
- {
- pokemod()->validationMsg("Item in argument #1 in \"Safari\" isn\'t a PokéBall");
- valid = false;
- }
- }
- else
- invError = 1;
- break;
- case 2:
- if (!ok)
- invError = 2;
- break;
- case 3:
- if (!ok || (pokemod()->rules()->maxParty() < temp))
- invError = 3;
- break;
- }
- break;
- case Menu:
- if (numArgs == 1)
- {
- if ((arg != "Call") && (arg != "Goto") && (arg != "0") && (arg != "1"))
- invError = 1;
- }
- else if (numArgs & 1)
- {
- if (ok)
- {
- if (pokemod()->dialogIndex(temp) == INT_MAX)
- invError = numArgs;
- }
- else
- invError = numArgs;
- }
- else if (arg == "")
- invError = numArgs;
- break;
- }
- if (invError)
- {
- pokemod()->validationMsg(QString("Invalid argument #%1 in \"%2\"").arg(invError).arg(CommandStr[curCmd]));
- valid = false;
- }
- }
- break;
- }
- }
- }
- return valid;
+// }
+// else if (numArgs & 1)
+// {
+// if (ok)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->dialogIndex(temp) == INT_MAX)
+// invError = numArgs;
+// }
+// else
+// invError = numArgs;
+// }
+// else if (arg == "")
+// invError = numArgs;
+// break;
+// }
+// if (invError)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Invalid argument #%1 in \"%2\"").arg(invError).arg(CommandStr[curCmd]));
+// valid = false;
+// }
+// }
+// break;
+// }
+// }
+// }
+// return valid;
}
void Dialog::load(const QDomElement& xml, int id)
diff --git a/pokemod/Dialog.h b/pokemod/Dialog.h
index 0ac8b8a8..3695239b 100644
--- a/pokemod/Dialog.h
+++ b/pokemod/Dialog.h
@@ -18,19 +18,15 @@
#ifndef __POKEMOD_DIALOG__
#define __POKEMOD_DIALOG__
-// Qt includes
-#include <QList>
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QList>
+#include <QString>
class Dialog : public Object
{
@@ -92,9 +88,9 @@ class Dialog : public Object
static const QList<int> CommandNumArgs;
Dialog(const Dialog& dialog);
- Dialog(const Pokemod* pokemod, const int id);
- Dialog(const Dialog& dialog, const Pokemod* pokemod, const int id);
- Dialog(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Dialog(const Object* parent, const int id);
+ Dialog(const Dialog& dialog, const Object* parent, const int id);
+ Dialog(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/EggGroup.cpp b/pokemod/EggGroup.cpp
index 5e9fe519..3d8562b3 100644
--- a/pokemod/EggGroup.cpp
+++ b/pokemod/EggGroup.cpp
@@ -22,39 +22,40 @@
#include "EggGroup.h"
EggGroup::EggGroup(const EggGroup& eggGroup) :
- Object("EggGroup", eggGroup.pokemod(), eggGroup.id())
+ Object("EggGroup", eggGroup.parent(), eggGroup.id())
{
*this = eggGroup;
}
-EggGroup::EggGroup(const Pokemod* pokemod, const int id) :
- Object("EggGroup", pokemod, id),
+EggGroup::EggGroup(const Object* parent, const int id) :
+ Object("EggGroup", parent, id),
m_name("")
{
}
-EggGroup::EggGroup(const EggGroup& eggGroup, const Pokemod* pokemod, const int id) :
- Object("EggGroup", pokemod, id)
+EggGroup::EggGroup(const EggGroup& eggGroup, const Object* parent, const int id) :
+ Object("EggGroup", parent, id)
{
*this = eggGroup;
}
-EggGroup::EggGroup(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("EggGroup", pokemod, id)
+EggGroup::EggGroup(const QDomElement& xml, const Object* parent, const int id) :
+ Object("EggGroup", parent, id)
{
load(xml, id);
}
bool EggGroup::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Egg Group \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Egg Group \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// return valid;
}
void EggGroup::load(const QDomElement& xml, int id)
diff --git a/pokemod/EggGroup.h b/pokemod/EggGroup.h
index f0dbd077..1c28ed6b 100644
--- a/pokemod/EggGroup.h
+++ b/pokemod/EggGroup.h
@@ -18,25 +18,22 @@
#ifndef __POKEMOD_EGGGROUP__
#define __POKEMOD_EGGGROUP__
-// Qt includes
-#include <QString>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QString>
class EggGroup : public Object
{
public:
EggGroup(const EggGroup& eggGroup);
- EggGroup(const Pokemod* pokemod, const int id);
- EggGroup(const EggGroup& eggGroup, const Pokemod* pokemod, const int id);
- EggGroup(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ EggGroup(const Object* parent, const int id);
+ EggGroup(const EggGroup& eggGroup, const Object* parent, const int id);
+ EggGroup(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Item.cpp b/pokemod/Item.cpp
index a33d3012..cf38506d 100644
--- a/pokemod/Item.cpp
+++ b/pokemod/Item.cpp
@@ -26,13 +26,13 @@
#include "Item.h"
Item::Item(const Item& item) :
- Object("Item", item.pokemod(), item.id())
+ Object("Item", item.parent(), item.id())
{
*this = item;
}
-Item::Item(const Pokemod* pokemod, const int id) :
- Object("Item", pokemod, id),
+Item::Item(const Object* parent, const int id) :
+ Object("Item", parent, id),
m_name(""),
m_sellable(false),
m_type(INT_MAX),
@@ -41,14 +41,14 @@ Item::Item(const Pokemod* pokemod, const int id) :
{
}
-Item::Item(const Item& item, const Pokemod* pokemod, const int id) :
- Object("Item", pokemod, id)
+Item::Item(const Item& item, const Object* parent, const int id) :
+ Object("Item", parent, id)
{
*this = item;
}
-Item::Item(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Item", pokemod, id)
+Item::Item(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Item", parent, id)
{
load(xml, id);
}
@@ -60,41 +60,42 @@ Item::~Item()
bool Item::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Item \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- if (pokemod()->itemTypeIndex(m_type) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid item type");
- valid = false;
- }
- if (pokemod()->rules()->maxMoney() < m_price)
- {
- pokemod()->validationMsg("Invalid price");
- valid = false;
- }
- if (effectCount())
- {
- QMap<int, bool> idChecker;
- foreach (ItemEffect* effect, m_effects)
- {
- if (!effect->isValid())
- valid = false;
- if (idChecker[effect->id()])
- pokemod()->validationMsg(QString("Duplicate effect with id %1").arg(effect->id()));
- idChecker[effect->id()] = true;
- }
- }
- else
- {
- pokemod()->validationMsg("There are no effects");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Item \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->itemTypeIndex(m_type) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid item type");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->rules()->maxMoney() < m_price)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid price");
+// valid = false;
+// }
+// if (effectCount())
+// {
+// QMap<int, bool> idChecker;
+// foreach (ItemEffect* effect, m_effects)
+// {
+// if (!effect->isValid())
+// valid = false;
+// if (idChecker[effect->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate effect with id %1").arg(effect->id()));
+// idChecker[effect->id()] = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no effects");
+// valid = false;
+// }
+// return valid;
}
void Item::load(const QDomElement& xml, int id)
@@ -132,14 +133,14 @@ void Item::setSellable(const bool sellable)
void Item::setType(const int type) throw(BoundsException)
{
- if (pokemod()->itemTypeIndex(type) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->itemTypeIndex(type) == INT_MAX)
error<BoundsException>("type");
m_type = type;
}
void Item::setPrice(const int price) throw(BoundsException)
{
- if (pokemod()->rules()->maxMoney() < price)
+ if (static_cast<const Pokemod*>(pokemod())->rules()->maxMoney() < price)
error<BoundsException>("price");
m_price = price;
}
@@ -215,19 +216,19 @@ int Item::effectCount() const
ItemEffect* Item::newEffect()
{
- m_effects.append(new ItemEffect(pokemod(), effectId()));
+ m_effects.append(new ItemEffect(this, effectId()));
return m_effects[effectCount() - 1];
}
ItemEffect* Item::newEffect(const QDomElement& xml)
{
- m_effects.append(new ItemEffect(xml, pokemod(), effectId()));
+ m_effects.append(new ItemEffect(xml, this, effectId()));
return m_effects[effectCount() - 1];
}
ItemEffect* Item::newEffect(const ItemEffect& effect)
{
- m_effects.append(new ItemEffect(effect, pokemod(), effectId()));
+ m_effects.append(new ItemEffect(effect, this, effectId()));
return m_effects[effectCount() - 1];
}
diff --git a/pokemod/Item.h b/pokemod/Item.h
index f17c39b6..bc2dcd26 100644
--- a/pokemod/Item.h
+++ b/pokemod/Item.h
@@ -18,27 +18,26 @@
#ifndef __POKEMOD_ITEM__
#define __POKEMOD_ITEM__
-// Qt includes
-#include <QList>
-#include <QString>
+// Pokemod includes
+#include "Object.h"
// General includes
-#include <Exception.h>
+#include "../general/Exception.h"
-// Pokemod includes
-#include "Object.h"
+// Qt includes
+#include <QList>
+#include <QString>
// Forward declarations
class ItemEffect;
-class Pokemod;
class Item : public Object
{
public:
Item(const Item& item);
- Item(const Pokemod* pokemod, const int id);
- Item(const Item& item, const Pokemod* pokemod, const int id);
- Item(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Item(const Object* parent, const int id);
+ Item(const Item& item, const Object* parent, const int id);
+ Item(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
~Item();
void load(const QDomElement& xml, int id = INT_MAX);
diff --git a/pokemod/ItemEffect.cpp b/pokemod/ItemEffect.cpp
index 896a73d9..d7b98023 100644
--- a/pokemod/ItemEffect.cpp
+++ b/pokemod/ItemEffect.cpp
@@ -15,13 +15,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Header include
+#include "ItemEffect.h"
// Pokemod includes
-#include "Pokemod.h"
#include "MapWildList.h"
-
-// Header include
-#include "ItemEffect.h"
+#include "Pokemod.h"
const QStringList ItemEffect::EffectStr = QStringList() << "HP Cure" << "Revive" << "Cure Status" << "Level Boost" << "Stat Boost" << "Flinch" << "Go First" << "Keep Alive" << "Modify Stat (Battle Only)" << "Shield (Battle Only)" << "Run (Battle Only)" << "PP Boost" << "Type Boost" << "PP Restore" << "Experience Share" << "Fishing Rod" << "Repel" << "Escape" << "TM" << "HM" << "Map" << "Ball" << "Itemfinder" << "Bike" << "Scope" << "Coin" << "Coin Case" << "Berry" << "Acorn";
const QStringList ItemEffect::RelativeStr = QStringList() << "Absolute" << "Relative";
@@ -33,13 +32,13 @@ const QStringList ItemEffect::BallTypeStr = QStringList() << "Regular" << "Maste
const QStringList ItemEffect::BerryTypeStr = QStringList() << "HP Cure" << "Status Cure";
ItemEffect::ItemEffect(const ItemEffect& effect) :
- Object("ItemEffect", effect.pokemod(), effect.id())
+ Object("ItemEffect", effect.parent(), effect.id())
{
*this = effect;
}
-ItemEffect::ItemEffect(const Pokemod* pokemod, const int id) :
- Object("ItemEffect", pokemod, id),
+ItemEffect::ItemEffect(const Object* parent, const int id) :
+ Object("ItemEffect", parent, id),
m_overworld(false),
m_battle(false),
m_held(false),
@@ -51,255 +50,256 @@ ItemEffect::ItemEffect(const Pokemod* pokemod, const int id) :
{
}
-ItemEffect::ItemEffect(const ItemEffect& effect, const Pokemod* pokemod, const int id) :
- Object("ItemEffect", pokemod, id)
+ItemEffect::ItemEffect(const ItemEffect& effect, const Object* parent, const int id) :
+ Object("ItemEffect", parent, id)
{
*this = effect;
}
-ItemEffect::ItemEffect(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("ItemEffect", pokemod, id)
+ItemEffect::ItemEffect(const QDomElement& xml, const Object* parent, const int id) :
+ Object("ItemEffect", parent, id)
{
load(xml, id);
}
bool ItemEffect::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Effect with id %1---").arg(id()), Pokemod::V_Msg);
- switch (m_effect)
- {
- case E_Revive:
- case E_LevelBoost:
- case E_StatBoost:
- case E_PPBoost:
- case E_Fish:
- case E_Repel:
- case E_Escape:
- case E_TM:
- case E_HM:
- case E_Map:
- case E_Itemfinder:
- case E_Bike:
- case E_Scope:
- case E_Coin:
- case E_CoinCase:
- case E_Acorn:
- case E_Evolution:
- if (!m_overworld)
- {
- pokemod()->validationMsg("Effect only works in the overworld");
- valid = false;
- }
- break;
- case E_Flinch:
- case E_First:
- case E_KeepAlive:
- case E_ModifyStatBattle:
- case E_ShieldBattle:
- case E_RunBattle:
- case E_TypeBoost:
- case E_ExpShare:
- case E_Ball:
- case E_Berry:
- if (m_overworld)
- {
- valid = false;
- pokemod()->validationMsg("Effect cannot work in the overworld");
- }
- break;
- }
- if (m_effect < E_End)
- {
- bool ok = true;
- switch (m_effect)
- {
- case E_HPCure:
- case E_Revive:
- if ((m_value4 != R_Absolute) || !m_value1)
- ok = false;
- break;
- case E_LevelBoost:
- case E_ShieldBattle:
- case E_PPBoost:
- case E_Repel:
- if (!m_value1)
- ok = false;
- break;
- case E_StatBoost:
- case E_Acorn:
- if ((m_value1 < 0) || (65536 <= m_value1))
- ok = false;
- break;
- case E_ModifyStatBattle:
- if ((m_value1 < -12) || (12 < m_value1))
- ok = false;
- break;
- case E_Ball:
- switch (m_value2)
- {
- case B_Regular:
- if (256 <= m_value1)
- ok = false;
- break;
- case B_Level:
- if (pokemod()->rules()->maxLevel() < m_value1)
- ok = false;
- break;
- case B_Master:
- case B_Love:
- case B_Area:
- case B_Time:
- case B_Battle:
- case B_Friend:
- case B_Stat:
- case B_Type:
- case B_Weight:
- break;
- default:
- ok = false;
- break;
- }
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid value 1");
- valid = false;
- ok = true;
- }
- switch (m_effect)
- {
- case E_HPCure:
- case E_Revive:
- if (R_End <= m_value2)
- ok = false;
- break;
- case E_CureStatus:
- if (Pokemod::STS_End <= m_value2)
- ok = false;
- break;
- case E_StatBoost:
- if ((m_value2 <= 0) || (65536 <= m_value2))
- ok = false;
- break;
- case E_ModifyStatBattle:
- if (Pokemod::ST_End_Battle <= m_value2)
- ok = false;
- break;
- case E_ShieldBattle:
- if (SP_End <= m_value2)
- ok = false;
- break;
- case E_TypeBoost:
- if (pokemod()->typeIndex(m_value2) == INT_MAX)
- ok = false;
- break;
- case E_PPRestore:
- if (A_End <= m_value2)
- ok = false;
- break;
- case E_Repel:
- if (RP_End <= m_value2)
- ok = false;
- break;
- case E_Escape:
- if (ES_End <= m_value2)
- ok = false;
- break;
- case E_TM:
- case E_HM:
- if (pokemod()->moveIndex(m_value2) == INT_MAX)
- ok = false;
- break;
- case E_Ball:
- if (B_End <= m_value2)
- ok = false;
- break;
- case E_Berry:
- if (B2_End <= m_value2)
- ok = false;
- break;
- case E_Coin:
- case E_CoinCase:
- if (m_value2 <= 0)
- ok = false;
- break;
- case E_Acorn:
- if (pokemod()->itemIndex(m_value2) == INT_MAX)
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid value 2");
- valid = false;
- ok = true;
- }
- switch (m_effect)
- {
- case E_StatBoost:
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= m_value3)
- ok = false;
- break;
- case E_Ball:
- switch (m_value2)
- {
- case B_Regular:
- case B_Master:
- case B_Level:
- case B_Love:
- case B_Battle:
- case B_Friend:
- case B_Weight:
- break;
- case B_Area:
- if (MapWildList::End <= m_value3)
- ok = false;
- break;
- case B_Time:
- if (pokemod()->timeIndex(m_value3) == INT_MAX)
- ok = false;
- break;
- case B_Stat:
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= m_value3)
- ok = false;
- break;
- case B_Type:
- if (pokemod()->typeIndex(m_value3) == INT_MAX)
- ok = false;
- break;
- }
- break;
- case E_Berry:
- switch (m_value2)
- {
- case B2_HPCure:
- if (Pokemod::REL_End <= m_value3)
- ok = false;
- break;
- case B2_StatusCure:
- if (Pokemod::STS_End <= m_value3)
- ok = false;
- break;
- default:
- ok = false;
- break;
- }
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid value 3");
- valid = false;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid effect");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Effect with id %1---").arg(id()), Pokemod::V_Msg);
+// switch (m_effect)
+// {
+// case E_Revive:
+// case E_LevelBoost:
+// case E_StatBoost:
+// case E_PPBoost:
+// case E_Fish:
+// case E_Repel:
+// case E_Escape:
+// case E_TM:
+// case E_HM:
+// case E_Map:
+// case E_Itemfinder:
+// case E_Bike:
+// case E_Scope:
+// case E_Coin:
+// case E_CoinCase:
+// case E_Acorn:
+// case E_Evolution:
+// if (!m_overworld)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Effect only works in the overworld");
+// valid = false;
+// }
+// break;
+// case E_Flinch:
+// case E_First:
+// case E_KeepAlive:
+// case E_ModifyStatBattle:
+// case E_ShieldBattle:
+// case E_RunBattle:
+// case E_TypeBoost:
+// case E_ExpShare:
+// case E_Ball:
+// case E_Berry:
+// if (m_overworld)
+// {
+// valid = false;
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Effect cannot work in the overworld");
+// }
+// break;
+// }
+// if (m_effect < E_End)
+// {
+// bool ok = true;
+// switch (m_effect)
+// {
+// case E_HPCure:
+// case E_Revive:
+// if ((m_value4 != R_Absolute) || !m_value1)
+// ok = false;
+// break;
+// case E_LevelBoost:
+// case E_ShieldBattle:
+// case E_PPBoost:
+// case E_Repel:
+// if (!m_value1)
+// ok = false;
+// break;
+// case E_StatBoost:
+// case E_Acorn:
+// if ((m_value1 < 0) || (65536 <= m_value1))
+// ok = false;
+// break;
+// case E_ModifyStatBattle:
+// if ((m_value1 < -12) || (12 < m_value1))
+// ok = false;
+// break;
+// case E_Ball:
+// switch (m_value2)
+// {
+// case B_Regular:
+// if (256 <= m_value1)
+// ok = false;
+// break;
+// case B_Level:
+// if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() < m_value1)
+// ok = false;
+// break;
+// case B_Master:
+// case B_Love:
+// case B_Area:
+// case B_Time:
+// case B_Battle:
+// case B_Friend:
+// case B_Stat:
+// case B_Type:
+// case B_Weight:
+// break;
+// default:
+// ok = false;
+// break;
+// }
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid value 1");
+// valid = false;
+// ok = true;
+// }
+// switch (m_effect)
+// {
+// case E_HPCure:
+// case E_Revive:
+// if (R_End <= m_value2)
+// ok = false;
+// break;
+// case E_CureStatus:
+// if (Pokemod::STS_End <= m_value2)
+// ok = false;
+// break;
+// case E_StatBoost:
+// if ((m_value2 <= 0) || (65536 <= m_value2))
+// ok = false;
+// break;
+// case E_ModifyStatBattle:
+// if (Pokemod::ST_End_Battle <= m_value2)
+// ok = false;
+// break;
+// case E_ShieldBattle:
+// if (SP_End <= m_value2)
+// ok = false;
+// break;
+// case E_TypeBoost:
+// if (static_cast<const Pokemod*>(pokemod())->typeIndex(m_value2) == INT_MAX)
+// ok = false;
+// break;
+// case E_PPRestore:
+// if (A_End <= m_value2)
+// ok = false;
+// break;
+// case E_Repel:
+// if (RP_End <= m_value2)
+// ok = false;
+// break;
+// case E_Escape:
+// if (ES_End <= m_value2)
+// ok = false;
+// break;
+// case E_TM:
+// case E_HM:
+// if (static_cast<const Pokemod*>(pokemod())->moveIndex(m_value2) == INT_MAX)
+// ok = false;
+// break;
+// case E_Ball:
+// if (B_End <= m_value2)
+// ok = false;
+// break;
+// case E_Berry:
+// if (B2_End <= m_value2)
+// ok = false;
+// break;
+// case E_Coin:
+// case E_CoinCase:
+// if (m_value2 <= 0)
+// ok = false;
+// break;
+// case E_Acorn:
+// if (static_cast<const Pokemod*>(pokemod())->itemIndex(m_value2) == INT_MAX)
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid value 2");
+// valid = false;
+// ok = true;
+// }
+// switch (m_effect)
+// {
+// case E_StatBoost:
+// if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= m_value3)
+// ok = false;
+// break;
+// case E_Ball:
+// switch (m_value2)
+// {
+// case B_Regular:
+// case B_Master:
+// case B_Level:
+// case B_Love:
+// case B_Battle:
+// case B_Friend:
+// case B_Weight:
+// break;
+// case B_Area:
+// if (MapWildList::End <= m_value3)
+// ok = false;
+// break;
+// case B_Time:
+// if (static_cast<const Pokemod*>(pokemod())->timeIndex(m_value3) == INT_MAX)
+// ok = false;
+// break;
+// case B_Stat:
+// if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= m_value3)
+// ok = false;
+// break;
+// case B_Type:
+// if (static_cast<const Pokemod*>(pokemod())->typeIndex(m_value3) == INT_MAX)
+// ok = false;
+// break;
+// }
+// break;
+// case E_Berry:
+// switch (m_value2)
+// {
+// case B2_HPCure:
+// if (Pokemod::REL_End <= m_value3)
+// ok = false;
+// break;
+// case B2_StatusCure:
+// if (Pokemod::STS_End <= m_value3)
+// ok = false;
+// break;
+// default:
+// ok = false;
+// break;
+// }
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid value 3");
+// valid = false;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid effect");
+// valid = false;
+// }
+// return valid;
}
void ItemEffect::load(const QDomElement& xml, int id)
@@ -462,7 +462,7 @@ void ItemEffect::setValue1(const int value1) throw(Exception)
error<BoundsException>("value1");
break;
case B_Level:
- if (pokemod()->rules()->maxLevel() < value1)
+ if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() < value1)
error<BoundsException>("value1");
break;
case B_Master:
@@ -512,7 +512,7 @@ void ItemEffect::setValue2(const int value2) throw(Exception)
error<BoundsException>("value2");
break;
case E_TypeBoost:
- if (pokemod()->typeIndex(value2) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->typeIndex(value2) == INT_MAX)
error<BoundsException>("value2");
break;
case E_PPRestore:
@@ -529,7 +529,7 @@ void ItemEffect::setValue2(const int value2) throw(Exception)
break;
case E_TM:
case E_HM:
- if (pokemod()->moveIndex(value2) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->moveIndex(value2) == INT_MAX)
error<BoundsException>("value2");
break;
case E_Ball:
@@ -548,7 +548,7 @@ void ItemEffect::setValue2(const int value2) throw(Exception)
error<BoundsException>("value2");
break;
case E_Acorn:
- if (pokemod()->itemIndex(value2) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->itemIndex(value2) == INT_MAX)
error<BoundsException>("value2");
break;
default:
@@ -563,7 +563,7 @@ void ItemEffect::setValue3(const int value3) throw(Exception)
switch (m_effect)
{
case E_StatBoost:
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= value3)
+ if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= value3)
error<BoundsException>("value3");
break;
case E_Ball:
@@ -578,15 +578,15 @@ void ItemEffect::setValue3(const int value3) throw(Exception)
error<BoundsException>("value3");
break;
case B_Time:
- if (pokemod()->timeIndex(value3) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->timeIndex(value3) == INT_MAX)
error<BoundsException>("value3");
break;
case B_Stat:
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= value3)
+ if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= value3)
error<BoundsException>("value3");
break;
case B_Type:
- if (pokemod()->typeIndex(value3) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->typeIndex(value3) == INT_MAX)
error<BoundsException>("value3");
break;
case B_Regular:
diff --git a/pokemod/ItemEffect.h b/pokemod/ItemEffect.h
index b9d6c829..d8341726 100644
--- a/pokemod/ItemEffect.h
+++ b/pokemod/ItemEffect.h
@@ -18,19 +18,15 @@
#ifndef __POKEMOD_ITEMEFFECT__
#define __POKEMOD_ITEMEFFECT__
-// Qt includes
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-#include <Fraction.h>
-
// Pokemod include
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+#include "../general/Fraction.h"
+
+// Qt includes
+#include <QString>
class ItemEffect : public Object
{
@@ -138,9 +134,9 @@ class ItemEffect : public Object
static const QStringList BerryTypeStr;
ItemEffect(const ItemEffect& effect);
- ItemEffect(const Pokemod* pokemod, const int id);
- ItemEffect(const ItemEffect& effect, const Pokemod* pokemod, const int id);
- ItemEffect(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ ItemEffect(const Object* parent, const int id);
+ ItemEffect(const ItemEffect& effect, const Object* parent, const int id);
+ ItemEffect(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/ItemType.cpp b/pokemod/ItemType.cpp
index 88d1690f..8db3d8a5 100644
--- a/pokemod/ItemType.cpp
+++ b/pokemod/ItemType.cpp
@@ -15,25 +15,25 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QFile>
+// Header include
+#include "ItemType.h"
// Pokemod includes
#include "Pokemod.h"
-// Header include
-#include "ItemType.h"
+// Qt includes
+#include <QFile>
QStringList ItemType::CountStr = QStringList() << "Distinct" << "Total";
ItemType::ItemType(const ItemType& itemType) :
- Object("ItemType", itemType.pokemod(), itemType.id())
+ Object("ItemType", itemType.parent(), itemType.id())
{
*this = itemType;
}
-ItemType::ItemType(const Pokemod* pokemod, const int id) :
- Object("ItemType", pokemod, id),
+ItemType::ItemType(const Object* parent, const int id) :
+ Object("ItemType", parent, id),
m_name(""),
m_computer(0),
m_player(1),
@@ -41,38 +41,39 @@ ItemType::ItemType(const Pokemod* pokemod, const int id) :
{
}
-ItemType::ItemType(const ItemType& itemType, const Pokemod* pokemod, const int id) :
- Object("ItemType", pokemod, id)
+ItemType::ItemType(const ItemType& itemType, const Object* parent, const int id) :
+ Object("ItemType", parent, id)
{
*this = itemType;
}
-ItemType::ItemType(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("ItemType", pokemod, id)
+ItemType::ItemType(const QDomElement& xml, const Object* parent, const int id) :
+ Object("ItemType", parent, id)
{
load(xml, id);
}
bool ItemType::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Item Type \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- if (!m_player)
- {
- pokemod()->validationMsg("Invalid storage with the player");
- valid = false;
- }
- if (End <= m_count)
- {
- pokemod()->validationMsg("Invalid count");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Item Type \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// if (!m_player)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid storage with the player");
+// valid = false;
+// }
+// if (End <= m_count)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid count");
+// valid = false;
+// }
+// return valid;
}
void ItemType::load(const QDomElement& xml, int id)
diff --git a/pokemod/ItemType.h b/pokemod/ItemType.h
index cecc3e42..4d30addc 100644
--- a/pokemod/ItemType.h
+++ b/pokemod/ItemType.h
@@ -18,18 +18,14 @@
#ifndef __POKEMOD_ITEMTYPE__
#define __POKEMOD_ITEMTYPE__
-// Qt includes
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QString>
class ItemType : public Object
{
@@ -43,9 +39,9 @@ class ItemType : public Object
static QStringList CountStr;
ItemType(const ItemType& itemType);
- ItemType(const Pokemod* pokemod, const int id);
- ItemType(const ItemType& itemType, const Pokemod* pokemod, const int id);
- ItemType(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ ItemType(const Object* parent, const int id);
+ ItemType(const ItemType& itemType, const Object* parent, const int id);
+ ItemType(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp
index 6e00dc6b..cd364a55 100644
--- a/pokemod/Map.cpp
+++ b/pokemod/Map.cpp
@@ -15,43 +15,43 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
+// Header include
+#include "Map.h"
// Pokemod includes
-#include "Pokemod.h"
#include "MapEffect.h"
#include "MapTrainer.h"
#include "MapWarp.h"
#include "MapWildList.h"
+#include "Pokemod.h"
-// Header include
-#include "Map.h"
+// Qt includes
+#include <QMap>
const QStringList Map::TypeStr = QStringList() << "Outdoor" << "Dungeon" << "Building";
Map::Map(const Map& map) :
- Object("Map", map.pokemod(), map.id())
+ Object("Map", map.parent(), map.id())
{
*this = map;
}
-Map::Map(const Pokemod* pokemod, const int id) :
- Object("Map", pokemod, id),
+Map::Map(const Object* parent, const int id) :
+ Object("Map", parent, id),
m_name(""),
m_flyWarp(INT_MAX),
m_type(INT_MAX)
{
}
-Map::Map(const Map& map, const Pokemod* pokemod, const int id) :
- Object("Map", pokemod, id)
+Map::Map(const Map& map, const Object* parent, const int id) :
+ Object("Map", parent, id)
{
*this = map;
}
-Map::Map(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Map", pokemod, id)
+Map::Map(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Map", parent, id)
{
load(xml, id);
}
@@ -63,124 +63,125 @@ Map::~Map()
bool Map::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Map \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("name is not defined");
- valid = false;
- }
- if ((m_flyWarp != INT_MAX) && (warpIndex(m_flyWarp) == INT_MAX))
- {
- pokemod()->validationMsg("Invalid fly destination warp");
- valid = false;
- }
- if (m_type < End)
- {
- pokemod()->validationMsg("Invalid type");
- valid = false;
- }
- QMap<int, bool> idChecker;
- if (effectCount())
- {
- foreach (MapEffect* effect, m_effects)
- {
- if (!effect->isValid())
- valid = false;
- if (idChecker[effect->id()])
- pokemod()->validationMsg(QString("Duplicate effect with id %1").arg(effect->id()));
- idChecker[effect->id()] = true;
- if (width() <= effect->coordinate().x())
- {
- pokemod()->validationMsg("Invalid x coordinate");
- valid = false;
- }
- if (height() <= effect->coordinate().y())
- {
- pokemod()->validationMsg("Invalid y coordinate");
- valid = false;
- }
- }
- idChecker.clear();
- }
- else
- pokemod()->validationMsg("There are no effects", Pokemod::V_Warn);
- if (trainerCount())
- {
- foreach (MapTrainer* trainer, m_trainers)
- {
- if (!trainer->isValid())
- valid = false;
- if (idChecker[trainer->id()])
- pokemod()->validationMsg(QString("Duplicate trainer with id %1").arg(trainer->id()));
- idChecker[trainer->id()] = true;
- if (width() <= trainer->coordinate().x())
- {
- pokemod()->validationMsg("Invalid x coordinate");
- valid = false;
- }
- if (height() <= trainer->coordinate().y())
- {
- pokemod()->validationMsg("Invalid y coordinate");
- valid = false;
- }
- }
- idChecker.clear();
- }
- else
- pokemod()->validationMsg("There are no trainers", Pokemod::V_Warn);
- if (warpCount())
- {
- foreach (MapWarp* warp, m_warps)
- {
- if (!warp->isValid())
- valid = false;
- if (idChecker[warp->id()])
- pokemod()->validationMsg(QString("Duplicate warp with id %1").arg(warp->id()));
- idChecker[warp->id()] = true;
- if (width() <= warp->coordinate().x())
- {
- pokemod()->validationMsg("Invalid x coordinate");
- valid = false;
- }
- if (height() <= warp->coordinate().y())
- {
- pokemod()->validationMsg("Invalid y coordinate");
- valid = false;
- }
- }
- idChecker.clear();
- }
- else
- {
- pokemod()->validationMsg("There are no warps");
- valid = false;
- }
- if (wildListCount())
- {
- foreach (MapWildList* wildList, m_wildLists)
- {
- if (!wildList->isValid())
- valid = false;
- if (idChecker[wildList->id()])
- pokemod()->validationMsg(QString("Duplicate effect with id %1").arg(wildList->id()));
- idChecker[wildList->id()] = true;
- }
- }
- else
- pokemod()->validationMsg("There are no effects", Pokemod::V_Warn);
- for (int i = 0; i < width(); ++i)
- {
- for (int j = 0; j < height(); ++j)
- {
- if (pokemod()->tileIndex(m_tile(i, j)) == INT_MAX)
- {
- pokemod()->validationMsg(QString("Invalid tile at (%1, %2)").arg(i).arg(j));
- valid = false;
- }
- }
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Map \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("name is not defined");
+// valid = false;
+// }
+// if ((m_flyWarp != INT_MAX) && (warpIndex(m_flyWarp) == INT_MAX))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid fly destination warp");
+// valid = false;
+// }
+// if (m_type < End)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid type");
+// valid = false;
+// }
+// QMap<int, bool> idChecker;
+// if (effectCount())
+// {
+// foreach (MapEffect* effect, m_effects)
+// {
+// if (!effect->isValid())
+// valid = false;
+// if (idChecker[effect->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate effect with id %1").arg(effect->id()));
+// idChecker[effect->id()] = true;
+// if (width() <= effect->coordinate().x())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid x coordinate");
+// valid = false;
+// }
+// if (height() <= effect->coordinate().y())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid y coordinate");
+// valid = false;
+// }
+// }
+// idChecker.clear();
+// }
+// else
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no effects", Pokemod::V_Warn);
+// if (trainerCount())
+// {
+// foreach (MapTrainer* trainer, m_trainers)
+// {
+// if (!trainer->isValid())
+// valid = false;
+// if (idChecker[trainer->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate trainer with id %1").arg(trainer->id()));
+// idChecker[trainer->id()] = true;
+// if (width() <= trainer->coordinate().x())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid x coordinate");
+// valid = false;
+// }
+// if (height() <= trainer->coordinate().y())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid y coordinate");
+// valid = false;
+// }
+// }
+// idChecker.clear();
+// }
+// else
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no trainers", Pokemod::V_Warn);
+// if (warpCount())
+// {
+// foreach (MapWarp* warp, m_warps)
+// {
+// if (!warp->isValid())
+// valid = false;
+// if (idChecker[warp->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate warp with id %1").arg(warp->id()));
+// idChecker[warp->id()] = true;
+// if (width() <= warp->coordinate().x())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid x coordinate");
+// valid = false;
+// }
+// if (height() <= warp->coordinate().y())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid y coordinate");
+// valid = false;
+// }
+// }
+// idChecker.clear();
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no warps");
+// valid = false;
+// }
+// if (wildListCount())
+// {
+// foreach (MapWildList* wildList, m_wildLists)
+// {
+// if (!wildList->isValid())
+// valid = false;
+// if (idChecker[wildList->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate effect with id %1").arg(wildList->id()));
+// idChecker[wildList->id()] = true;
+// }
+// }
+// else
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no effects", Pokemod::V_Warn);
+// for (int i = 0; i < width(); ++i)
+// {
+// for (int j = 0; j < height(); ++j)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->tileIndex(m_tile(i, j)) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Invalid tile at (%1, %2)").arg(i).arg(j));
+// valid = false;
+// }
+// }
+// }
+// return valid;
}
void Map::load(const QDomElement& xml, int id)
@@ -246,7 +247,7 @@ int Map::type() const
void Map::setTile(int x, int y, int id) throw(BoundsException)
{
- if (pokemod()->tileIndex(id) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->tileIndex(id) == INT_MAX)
error<BoundsException>("tile");
m_tile(x, y) = id;
}
@@ -347,19 +348,19 @@ int Map::effectCount() const
MapEffect* Map::newEffect()
{
- m_effects.append(new MapEffect(pokemod(), newEffectId()));
+ m_effects.append(new MapEffect(this, newEffectId()));
return m_effects[effectCount() - 1];
}
MapEffect* Map::newEffect(const QDomElement& xml)
{
- m_effects.append(new MapEffect(xml, pokemod(), newEffectId()));
+ m_effects.append(new MapEffect(xml, this, newEffectId()));
return m_effects[effectCount() - 1];
}
MapEffect* Map::newEffect(const MapEffect& effect)
{
- m_effects.append(new MapEffect(effect, pokemod(), newEffectId()));
+ m_effects.append(new MapEffect(effect, this, newEffectId()));
return m_effects[effectCount() - 1];
}
@@ -425,19 +426,19 @@ int Map::trainerCount() const
MapTrainer* Map::newTrainer()
{
- m_trainers.append(new MapTrainer(pokemod(), newTrainerId()));
+ m_trainers.append(new MapTrainer(this, newTrainerId()));
return m_trainers[trainerCount() - 1];
}
MapTrainer* Map::newTrainer(const QDomElement& xml)
{
- m_trainers.append(new MapTrainer(xml, pokemod(), newTrainerId()));
+ m_trainers.append(new MapTrainer(xml, this, newTrainerId()));
return m_trainers[trainerCount() - 1];
}
MapTrainer* Map::newTrainer(const MapTrainer& trainer)
{
- m_trainers.append(new MapTrainer(trainer, pokemod(), newTrainerId()));
+ m_trainers.append(new MapTrainer(trainer, this, newTrainerId()));
return m_trainers[trainerCount() - 1];
}
@@ -503,19 +504,19 @@ int Map::warpCount() const
MapWarp* Map::newWarp()
{
- m_warps.append(new MapWarp(pokemod(), newWarpId()));
+ m_warps.append(new MapWarp(this, newWarpId()));
return m_warps[warpCount() - 1];
}
MapWarp* Map::newWarp(const QDomElement& xml)
{
- m_warps.append(new MapWarp(xml, pokemod(), newWarpId()));
+ m_warps.append(new MapWarp(xml, this, newWarpId()));
return m_warps[warpCount() - 1];
}
MapWarp* Map::newWarp(const MapWarp& warp)
{
- m_warps.append(new MapWarp(warp, pokemod(), newWarpId()));
+ m_warps.append(new MapWarp(warp, this, newWarpId()));
return m_warps[warpCount() - 1];
}
@@ -581,19 +582,19 @@ int Map::wildListCount() const
MapWildList* Map::newWildList()
{
- m_wildLists.append(new MapWildList(pokemod(), newWildListId()));
+ m_wildLists.append(new MapWildList(this, newWildListId()));
return m_wildLists[wildListCount() - 1];
}
MapWildList* Map::newWildList(const QDomElement& xml)
{
- m_wildLists.append(new MapWildList(xml, pokemod(), newWildListId()));
+ m_wildLists.append(new MapWildList(xml, this, newWildListId()));
return m_wildLists[wildListCount() - 1];
}
MapWildList* Map::newWildList(const MapWildList& wildList)
{
- m_wildLists.append(new MapWildList(wildList, pokemod(), newWildListId()));
+ m_wildLists.append(new MapWildList(wildList, this, newWildListId()));
return m_wildLists[wildListCount() - 1];
}
diff --git a/pokemod/Map.h b/pokemod/Map.h
index cdb7e71d..cea8768e 100644
--- a/pokemod/Map.h
+++ b/pokemod/Map.h
@@ -18,24 +18,22 @@
#ifndef __POKEMOD_MAP__
#define __POKEMOD_MAP__
-// Qt includes
-#include <QList>
-#include <QString>
-#include <QStringList>
+// Pokemod includes
+#include "Object.h"
// General includes
-#include <Exception.h>
-#include <Matrix.h>
+#include "../general/Exception.h"
+#include "../general/Matrix.h"
-// Pokemod includes
-#include "Object.h"
+// Qt includes
+#include <QList>
+#include <QString>
// Forward declarations
class MapEffect;
class MapTrainer;
class MapWarp;
class MapWildList;
-class Pokemod;
class Map : public Object
{
@@ -50,9 +48,9 @@ class Map : public Object
static const QStringList TypeStr;
Map(const Map& map);
- Map(const Pokemod* pokemod, const int id);
- Map(const Map& map, const Pokemod* pokemod, const int id);
- Map(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Map(const Object* parent, const int id);
+ Map(const Map& map, const Object* parent, const int id);
+ Map(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
~Map();
void load(const QDomElement& xml, int id = INT_MAX);
diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp
index 1bb70d8a..2c146a96 100644
--- a/pokemod/MapEffect.cpp
+++ b/pokemod/MapEffect.cpp
@@ -15,27 +15,28 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QBuffer>
+// Header include
+#include "MapEffect.h"
// Pokemod includes
-#include "Pokemod.h"
#include "Dialog.h"
+#include "Map.h"
+#include "Pokemod.h"
-// Header include
-#include "MapEffect.h"
+// Qt includes
+#include <QBuffer>
const QStringList MapEffect::MapEffectStr = QStringList() << "Item" << "PC" << "Strength Block" << "Button" << "Slot Machine" << "Card Flip Game";
const QStringList MapEffect::PCTypeStr = QStringList() << "Item" << "Pokémon" << "PokéDex" << "Hall of Fame" << "All";
MapEffect::MapEffect(const MapEffect& effect) :
- Object("MapEffect", effect.pokemod(), effect.id())
+ Object("MapEffect", effect.parent(), effect.id())
{
*this = effect;
}
-MapEffect::MapEffect(const Pokemod* pokemod, const int id) :
- Object("MapEffect", pokemod, id),
+MapEffect::MapEffect(const Object* parent, const int id) :
+ Object("MapEffect", parent, id),
m_name(""),
m_coordinate(0, 0),
m_existFlag(0, 0),
@@ -50,73 +51,74 @@ MapEffect::MapEffect(const Pokemod* pokemod, const int id) :
{
}
-MapEffect::MapEffect(const MapEffect& effect, const Pokemod* pokemod, const int id) :
- Object("MapEffect", pokemod, id)
+MapEffect::MapEffect(const MapEffect& effect, const Object* parent, const int id) :
+ Object("MapEffect", parent, id)
{
*this = effect;
}
-MapEffect::MapEffect(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MapEffect", pokemod, id)
+MapEffect::MapEffect(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MapEffect", parent, id)
{
load(xml, id);
}
bool MapEffect::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Effect \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- if (Flag::End <= m_existFlag.status())
- {
- pokemod()->validationMsg("Invalid existence flag status");
- valid = false;
- }
- if (m_effect < E_End)
- {
- bool ok = true;
- switch (m_effect)
- {
- case E_Item:
- if (pokemod()->itemIndex(m_value2) == INT_MAX)
- ok = false;
- break;
- case E_PC:
- if (PC_End <= m_value2)
- ok = false;
- break;
- case E_StrengthBlock:
- case E_Button:
- if (Flag::End <= m_value2)
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid val2");
- valid = false;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid effect");
- valid = false;
- }
- if (Pokemod::D_End_None <= m_direction)
- {
- pokemod()->validationMsg("Invalid driection");
- valid = false;
- }
- if (pokemod()->dialogIndex(m_dialog) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid dialog");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Effect \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// if (Flag::End <= m_existFlag.status())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid existence flag status");
+// valid = false;
+// }
+// if (m_effect < E_End)
+// {
+// bool ok = true;
+// switch (m_effect)
+// {
+// case E_Item:
+// if (static_cast<const Pokemod*>(pokemod())->itemIndex(m_value2) == INT_MAX)
+// ok = false;
+// break;
+// case E_PC:
+// if (PC_End <= m_value2)
+// ok = false;
+// break;
+// case E_StrengthBlock:
+// case E_Button:
+// if (Flag::End <= m_value2)
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid val2");
+// valid = false;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid effect");
+// valid = false;
+// }
+// if (Pokemod::D_End_None <= m_direction)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid driection");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->dialogIndex(m_dialog) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid dialog");
+// valid = false;
+// }
+// return valid;
}
void MapEffect::load(const QDomElement& xml, int id)
@@ -157,8 +159,10 @@ void MapEffect::setName(const QString& name)
m_name = name;
}
-void MapEffect::setCoordinate(const Point& coordinate)
+void MapEffect::setCoordinate(const Point& coordinate) throw(BoundsException)
{
+ if ((static_cast<const Map*>(parent())->width() <= coordinate.x()) || (static_cast<const Map*>(parent())->height() <= coordinate.y()))
+ error<BoundsException>("coordinate");
m_coordinate = coordinate;
}
@@ -195,7 +199,7 @@ void MapEffect::setValue2(const int value2) throw(Exception)
switch (m_effect)
{
case E_Item:
- if (pokemod()->itemIndex(value2) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->itemIndex(value2) == INT_MAX)
error<BoundsException>("val2");
break;
case E_PC:
@@ -233,7 +237,7 @@ void MapEffect::setCanMove(const bool canMove)
void MapEffect::setDialog(const int dialog) throw(BoundsException)
{
- if (pokemod()->dialogIndex(dialog) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->dialogIndex(dialog) == INT_MAX)
error<BoundsException>("dialog");
m_dialog = dialog;
}
diff --git a/pokemod/MapEffect.h b/pokemod/MapEffect.h
index e177dac3..7272df71 100644
--- a/pokemod/MapEffect.h
+++ b/pokemod/MapEffect.h
@@ -18,21 +18,17 @@
#ifndef __POKEMOD_MAPEFFECT__
#define __POKEMOD_MAPEFFECT__
-// Qt includes
-#include <QPixmap>
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-#include <Flag.h>
-#include <Point.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+#include "../general/Flag.h"
+#include "../general/Point.h"
+
+// Qt includes
+#include <QPixmap>
+#include <QString>
class MapEffect : public Object
{
@@ -61,15 +57,15 @@ class MapEffect : public Object
static const QStringList PCTypeStr;
MapEffect(const MapEffect& effect);
- MapEffect(const Pokemod* pokemod, const int id);
- MapEffect(const MapEffect& effect, const Pokemod* pokemod, const int id);
- MapEffect(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ MapEffect(const Object* parent, const int id);
+ MapEffect(const MapEffect& effect, const Object* parent, const int id);
+ MapEffect(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
void setName(const QString& name);
- void setCoordinate(const Point& coordinate);
+ void setCoordinate(const Point& coordinate) throw(BoundsException);
void setExistFlag(const Flag& existFlag);
void setSkin(const QPixmap& skin) throw(SizeException);
void setEffect(const int effect) throw(BoundsException);
diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp
index 217b8d2d..ab5abd21 100644
--- a/pokemod/MapTrainer.cpp
+++ b/pokemod/MapTrainer.cpp
@@ -15,25 +15,26 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
+// Header include
+#include "MapTrainer.h"
// Pokemod includes
-#include "Pokemod.h"
#include "Dialog.h"
+#include "Map.h"
#include "MapTrainerTeamMember.h"
+#include "Pokemod.h"
-// Header include
-#include "MapTrainer.h"
+// Qt includes
+#include <QMap>
MapTrainer::MapTrainer(const MapTrainer& trainer) :
- Object("MapTrainer", trainer.pokemod(), trainer.id())
+ Object("MapTrainer", trainer.parent(), trainer.id())
{
*this = trainer;
}
-MapTrainer::MapTrainer(const Pokemod* pokemod, const int id) :
- Object("MapTrainer", pokemod, id),
+MapTrainer::MapTrainer(const Object* parent, const int id) :
+ Object("MapTrainer", parent, id),
m_name(""),
m_trainerClass(INT_MAX),
m_coordinate(0, 0),
@@ -46,14 +47,14 @@ MapTrainer::MapTrainer(const Pokemod* pokemod, const int id) :
{
}
-MapTrainer::MapTrainer(const MapTrainer& trainer, const Pokemod* pokemod, const int id) :
- Object("MapTrainer", pokemod, id)
+MapTrainer::MapTrainer(const MapTrainer& trainer, const Object* parent, const int id) :
+ Object("MapTrainer", parent, id)
{
*this = trainer;
}
-MapTrainer::MapTrainer(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MapTrainer", pokemod, id)
+MapTrainer::MapTrainer(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MapTrainer", parent, id)
{
load(xml, id);
}
@@ -65,56 +66,57 @@ MapTrainer::~MapTrainer()
bool MapTrainer::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Trainer \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- if (pokemod()->trainerIndex(m_trainerClass) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid trainer class");
- valid = false;
- }
- if (Pokemod::D_End_None <= m_direction)
- {
- pokemod()->validationMsg("Invalid direction");
- valid = false;
- }
- if (!m_numFight || (pokemod()->rules()->maxFight() < m_numFight))
- {
- pokemod()->validationMsg("Invalid number of Pokémon for a fight");
- valid = false;
- }
- if (pokemod()->dialogIndex(m_dialog) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid dialog");
- valid = false;
- }
- if (teamMemberCount() <= m_leadTeamMember)
- {
- pokemod()->validationMsg("Invalid lead member");
- valid = false;
- }
- if (teamMemberCount())
- {
- QMap<int, bool> idChecker;
- foreach (MapTrainerTeamMember* teamMember, m_teamMember)
- {
- if (!teamMember->isValid())
- valid = false;
- if (idChecker[teamMember->id()])
- pokemod()->validationMsg(QString("Duplicate team member with id %1").arg(teamMember->id()));
- idChecker[teamMember->id()] = true;
- }
- }
- else
- {
- pokemod()->validationMsg("There are no team members");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Trainer \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->trainerIndex(m_trainerClass) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid trainer class");
+// valid = false;
+// }
+// if (Pokemod::D_End_None <= m_direction)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid direction");
+// valid = false;
+// }
+// if (!m_numFight || (static_cast<const Pokemod*>(pokemod())->rules()->maxFight() < m_numFight))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid number of Pokémon for a fight");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->dialogIndex(m_dialog) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid dialog");
+// valid = false;
+// }
+// if (teamMemberCount() <= m_leadTeamMember)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid lead member");
+// valid = false;
+// }
+// if (teamMemberCount())
+// {
+// QMap<int, bool> idChecker;
+// foreach (MapTrainerTeamMember* teamMember, m_teamMember)
+// {
+// if (!teamMember->isValid())
+// valid = false;
+// if (idChecker[teamMember->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate team member with id %1").arg(teamMember->id()));
+// idChecker[teamMember->id()] = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no team members");
+// valid = false;
+// }
+// return valid;
}
void MapTrainer::load(const QDomElement& xml, int id)
@@ -154,13 +156,15 @@ void MapTrainer::setName(const QString& name)
void MapTrainer::setTrainerClass(const int trainerClass) throw(BoundsException)
{
- if (pokemod()->trainerIndex(trainerClass) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->trainerIndex(trainerClass) == INT_MAX)
error<BoundsException>("trainerClass");
m_trainerClass = trainerClass;
}
-void MapTrainer::setCoordinate(const Point& coordinate)
+void MapTrainer::setCoordinate(const Point& coordinate) throw(BoundsException)
{
+ if ((static_cast<const Map*>(parent())->width() <= coordinate.x()) || (static_cast<const Map*>(parent())->height() <= coordinate.y()))
+ error<BoundsException>("coordinate");
m_coordinate = coordinate;
}
@@ -178,7 +182,7 @@ void MapTrainer::setDirection(const int direction) throw(BoundsException)
void MapTrainer::setNumFight(const int numFight) throw(BoundsException)
{
- if (!numFight || (pokemod()->rules()->maxFight() < numFight))
+ if (!numFight || (static_cast<const Pokemod*>(pokemod())->rules()->maxFight() < numFight))
error<BoundsException>("numFight");
m_numFight = numFight;
}
@@ -190,7 +194,7 @@ void MapTrainer::setAppearFlag(const Flag& appearFlag)
void MapTrainer::setDialog(const int dialog) throw(BoundsException)
{
- if (pokemod()->dialogIndex(dialog) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->dialogIndex(dialog) == INT_MAX)
error<BoundsException>("dialog");
m_dialog = dialog;
}
@@ -288,19 +292,19 @@ int MapTrainer::teamMemberCount() const
MapTrainerTeamMember* MapTrainer::newTeamMember()
{
- m_teamMember.append(new MapTrainerTeamMember(pokemod(), newTeamMemberId()));
+ m_teamMember.append(new MapTrainerTeamMember(this, newTeamMemberId()));
return m_teamMember[teamMemberCount() - 1];
}
MapTrainerTeamMember* MapTrainer::newTeamMember(const QDomElement& xml)
{
- m_teamMember.append(new MapTrainerTeamMember(xml, pokemod(), newTeamMemberId()));
+ m_teamMember.append(new MapTrainerTeamMember(xml, this, newTeamMemberId()));
return m_teamMember[teamMemberCount() - 1];
}
MapTrainerTeamMember* MapTrainer::newTeamMember(const MapTrainerTeamMember& teamMember)
{
- m_teamMember.append(new MapTrainerTeamMember(teamMember, pokemod(), newTeamMemberId()));
+ m_teamMember.append(new MapTrainerTeamMember(teamMember, this, newTeamMemberId()));
return m_teamMember[teamMemberCount() - 1];
}
diff --git a/pokemod/MapTrainer.h b/pokemod/MapTrainer.h
index 52b1845d..8553e0ca 100644
--- a/pokemod/MapTrainer.h
+++ b/pokemod/MapTrainer.h
@@ -18,29 +18,28 @@
#ifndef __POKEMOD_MAPTRAINER__
#define __POKEMOD_MAPTRAINER__
-// Qt includes
-#include <QList>
-#include <QString>
+// Pokemod includes
+#include "Object.h"
// General includes
-#include <Exception.h>
-#include <Flag.h>
-#include <Point.h>
+#include "../general/Exception.h"
+#include "../general/Flag.h"
+#include "../general/Point.h"
-// Pokemod includes
-#include "Object.h"
+// Qt includes
+#include <QList>
+#include <QString>
// Forward declarations
class MapTrainerTeamMember;
-class Pokemod;
class MapTrainer : public Object
{
public:
MapTrainer(const MapTrainer& trainer);
- MapTrainer(const Pokemod* pokemod, const int id);
- MapTrainer(const MapTrainer& trainer, const Pokemod* pokemod, const int id);
- MapTrainer(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ MapTrainer(const Object* parent, const int id);
+ MapTrainer(const MapTrainer& trainer, const Object* parent, const int id);
+ MapTrainer(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
~MapTrainer();
void load(const QDomElement& xml, int id = INT_MAX);
@@ -48,7 +47,7 @@ class MapTrainer : public Object
void setName(const QString& name);
void setTrainerClass(const int trainerClass) throw(BoundsException);
- void setCoordinate(const Point& coordinate);
+ void setCoordinate(const Point& coordinate) throw(BoundsException);
void setSight(const int sight);
void setDirection(const int direction) throw(BoundsException);
void setNumFight(const int numFight) throw(BoundsException);
diff --git a/pokemod/MapTrainerTeamMember.cpp b/pokemod/MapTrainerTeamMember.cpp
index 1338f7b8..34971486 100644
--- a/pokemod/MapTrainerTeamMember.cpp
+++ b/pokemod/MapTrainerTeamMember.cpp
@@ -15,88 +15,89 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
-#include <QMutableListIterator>
-#include <QString>
+// Header include
+#include "MapTrainerTeamMember.h"
// Pokemod includes
-#include "Pokemod.h"
#include "Item.h"
#include "Species.h"
+#include "Pokemod.h"
-// Header include
-#include "MapTrainerTeamMember.h"
+// Qt includes
+#include <QMap>
+#include <QMutableListIterator>
+#include <QString>
MapTrainerTeamMember::MapTrainerTeamMember(const MapTrainerTeamMember& teamMember) :
- Object("MapTrainerTeamMember", teamMember.pokemod(), teamMember.id())
+ Object("MapTrainerTeamMember", teamMember.parent(), teamMember.id())
{
*this = teamMember;
}
-MapTrainerTeamMember::MapTrainerTeamMember(const Pokemod* pokemod, const int id) :
- Object("MapTrainerTeamMember", pokemod, id),
+MapTrainerTeamMember::MapTrainerTeamMember(const Object* parent, const int id) :
+ Object("MapTrainerTeamMember", parent, id),
m_species(INT_MAX),
m_level(INT_MAX),
m_nature(INT_MAX)
{
}
-MapTrainerTeamMember::MapTrainerTeamMember(const MapTrainerTeamMember& teamMember, const Pokemod* pokemod, const int id) :
- Object("MapTrainerTeamMember", pokemod, id)
+MapTrainerTeamMember::MapTrainerTeamMember(const MapTrainerTeamMember& teamMember, const Object* parent, const int id) :
+ Object("MapTrainerTeamMember", parent, id)
{
*this = teamMember;
}
-MapTrainerTeamMember::MapTrainerTeamMember(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MapTrainerTeamMember", pokemod, id)
+MapTrainerTeamMember::MapTrainerTeamMember(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MapTrainerTeamMember", parent, id)
{
load(xml, id);
}
bool MapTrainerTeamMember::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---------Team Member with id %1---").arg(id()), Pokemod::V_Msg);
- if (pokemod()->speciesIndex(m_species) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid species");
- valid = false;
- }
- if (pokemod()->rules()->maxLevel() <= m_level)
- {
- pokemod()->validationMsg("Invalid level");
- valid = false;
- }
- if (m_items.size() <= pokemod()->rules()->holdItems())
- {
- QMap<int, bool> itemChecker;
- foreach (int item, m_items)
- {
- if (pokemod()->itemIndex(item) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid item");
- valid = false;
- }
- if (itemChecker[item])
- pokemod()->validationMsg(QString("Duplicate of item %1").arg(item));
- itemChecker[item] = true;
- }
- }
- else
- {
- pokemod()->validationMsg("Too many held items");
- valid = false;
- }
- if (pokemod()->rules()->natureAllowed())
- {
- if (pokemod()->natureIndex(m_nature) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid nature");
- valid = false;
- }
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---------Team Member with id %1---").arg(id()), Pokemod::V_Msg);
+// if (static_cast<const Pokemod*>(pokemod())->speciesIndex(m_species) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid species");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() <= m_level)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid level");
+// valid = false;
+// }
+// if (m_items.size() <= static_cast<const Pokemod*>(pokemod())->rules()->holdItems())
+// {
+// QMap<int, bool> itemChecker;
+// foreach (int item, m_items)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid item");
+// valid = false;
+// }
+// if (itemChecker[item])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of item %1").arg(item));
+// itemChecker[item] = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Too many held items");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->rules()->natureAllowed())
+// {
+// if (static_cast<const Pokemod*>(pokemod())->natureIndex(m_nature) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid nature");
+// valid = false;
+// }
+// }
+// return valid;
}
void MapTrainerTeamMember::load(const QDomElement& xml, int id)
@@ -120,21 +121,21 @@ QDomElement MapTrainerTeamMember::save() const
void MapTrainerTeamMember::setSpecies(const int species) throw(BoundsException)
{
- if (pokemod()->speciesIndex(species) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->speciesIndex(species) == INT_MAX)
error<BoundsException>("species");
m_species = species;
}
void MapTrainerTeamMember::setLevel(const int level) throw(BoundsException)
{
- if (pokemod()->rules()->maxLevel() < level)
+ if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() < level)
error<BoundsException>("level");
m_level = level;
}
void MapTrainerTeamMember::setItem(const int item, const bool state) throw(BoundsException)
{
- if (pokemod()->itemIndex(item) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX)
error<BoundsException>("item");
if (state)
{
@@ -147,7 +148,7 @@ void MapTrainerTeamMember::setItem(const int item, const bool state) throw(Bound
void MapTrainerTeamMember::setNature(const int nature) throw(BoundsException)
{
- if (!pokemod()->rules()->natureAllowed() || (pokemod()->natureIndex(nature) == INT_MAX))
+ if (!static_cast<const Pokemod*>(pokemod())->rules()->natureAllowed() || (static_cast<const Pokemod*>(pokemod())->natureIndex(nature) == INT_MAX))
error<BoundsException>("nature");
m_nature = nature;
}
diff --git a/pokemod/MapTrainerTeamMember.h b/pokemod/MapTrainerTeamMember.h
index ee546f8c..2b899574 100644
--- a/pokemod/MapTrainerTeamMember.h
+++ b/pokemod/MapTrainerTeamMember.h
@@ -18,25 +18,22 @@
#ifndef __POKEMOD_MAPTRAINERTEAMMEMBER__
#define __POKEMOD_MAPTRAINERTEAMMEMBER__
-// Qt includes
-#include <QList>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QList>
class MapTrainerTeamMember : public Object
{
public:
MapTrainerTeamMember(const MapTrainerTeamMember& teamMember);
- MapTrainerTeamMember(const Pokemod* pokemod, const int id);
- MapTrainerTeamMember(const MapTrainerTeamMember& teamMember, const Pokemod* pokemod, const int id);
- MapTrainerTeamMember(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ MapTrainerTeamMember(const Object* parent, const int id);
+ MapTrainerTeamMember(const MapTrainerTeamMember& teamMember, const Object* parent, const int id);
+ MapTrainerTeamMember(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/MapWarp.cpp b/pokemod/MapWarp.cpp
index 0dc045e9..15e6ee38 100644
--- a/pokemod/MapWarp.cpp
+++ b/pokemod/MapWarp.cpp
@@ -15,24 +15,24 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Header include
+#include "MapWarp.h"
+
// Pokemod includes
-#include "Pokemod.h"
#include "Dialog.h"
#include "Map.h"
-
-// Header include
-#include "MapWarp.h"
+#include "Pokemod.h"
const QStringList MapWarp::TypeStr = QStringList() << "Door/Stair" << "Warp Pad" << "Hole" << "Boundary";
MapWarp::MapWarp(const MapWarp& warp) :
- Object("MapWarp", warp.pokemod(), warp.id())
+ Object("MapWarp", warp.parent(), warp.id())
{
*this = warp;
}
-MapWarp::MapWarp(const Pokemod* pokemod, const int id) :
- Object("MapWarp", pokemod, id),
+MapWarp::MapWarp(const Object* parent, const int id) :
+ Object("MapWarp", parent, id),
m_name(""),
m_coordinate(0, 0),
m_directionOut(INT_MAX),
@@ -49,61 +49,62 @@ MapWarp::MapWarp(const Pokemod* pokemod, const int id) :
m_from[i] = false;
}
-MapWarp::MapWarp(const MapWarp& warp, const Pokemod* pokemod, const int id) :
- Object("MapWarp", pokemod, id)
+MapWarp::MapWarp(const MapWarp& warp, const Object* parent, const int id) :
+ Object("MapWarp", parent, id)
{
*this = warp;
}
-MapWarp::MapWarp(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MapWarp", pokemod, id)
+MapWarp::MapWarp(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MapWarp", parent, id)
{
load(xml, id);
}
bool MapWarp::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Warp \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- if (!m_from[Pokemod::D_Up] && !m_from[Pokemod::D_Down] && !m_from[Pokemod::D_Left] && !m_from[Pokemod::D_Right])
- {
- pokemod()->validationMsg("No access from any direction");
- valid = false;
- }
- if (Pokemod::D_End_None <= m_directionOut)
- {
- pokemod()->validationMsg("Invalid direction out");
- valid = false;
- }
- if (End <= m_warpType)
- {
- pokemod()->validationMsg("Invalid type");
- valid = false;
- }
- if (pokemod()->mapIndex(m_toMap) != INT_MAX)
- {
- if (pokemod()->mapById(m_toMap)->warpIndex(m_toWarp) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid destination warp");
- valid = false;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid destination map");
- valid = false;
- }
- if (pokemod()->dialogIndex(m_dialog) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid dialog");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Warp \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// if (!m_from[Pokemod::D_Up] && !m_from[Pokemod::D_Down] && !m_from[Pokemod::D_Left] && !m_from[Pokemod::D_Right])
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("No access from any direction");
+// valid = false;
+// }
+// if (Pokemod::D_End_None <= m_directionOut)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid direction out");
+// valid = false;
+// }
+// if (End <= m_warpType)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid type");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->mapIndex(m_toMap) != INT_MAX)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->mapById(m_toMap)->warpIndex(m_toWarp) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid destination warp");
+// valid = false;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid destination map");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->dialogIndex(m_dialog) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid dialog");
+// valid = false;
+// }
+// return valid;
}
void MapWarp::load(const QDomElement& xml, int id)
@@ -146,8 +147,10 @@ void MapWarp::setName(const QString& name)
m_name = name;
}
-void MapWarp::setCoordinate(const Point& coordinate)
+void MapWarp::setCoordinate(const Point& coordinate) throw(BoundsException)
{
+ if ((static_cast<const Map*>(parent())->width() <= coordinate.x()) || (static_cast<const Map*>(parent())->height() <= coordinate.y()))
+ error<BoundsException>("coordinate");
m_coordinate = coordinate;
}
@@ -195,7 +198,7 @@ void MapWarp::setIsFoggy(const int isFoggy) throw(BoundsException)
void MapWarp::setToMap(const int toMap) throw(BoundsException)
{
- if (pokemod()->mapIndex(toMap) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->mapIndex(toMap) == INT_MAX)
error<BoundsException>("toMap");
m_toMap = toMap;
m_toWarp = INT_MAX;
@@ -203,9 +206,9 @@ void MapWarp::setToMap(const int toMap) throw(BoundsException)
void MapWarp::setToWarp(const int toWarp) throw(BoundsException)
{
- if (pokemod()->mapIndex(m_toMap) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->mapIndex(m_toMap) == INT_MAX)
error<BoundsException>("toMap");
- if (pokemod()->mapById(m_toMap)->warpIndex(toWarp) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->mapById(m_toMap)->warpIndex(toWarp) == INT_MAX)
error<BoundsException>("toWarp");
m_toWarp = toWarp;
}
@@ -217,7 +220,7 @@ void MapWarp::setWorkingFlag(const Flag& workingFlag)
void MapWarp::setDialog(const int dialog) throw(BoundsException)
{
- if (pokemod()->dialogIndex(dialog) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->dialogIndex(dialog) == INT_MAX)
error<BoundsException>("dialog");
m_dialog = dialog;
}
diff --git a/pokemod/MapWarp.h b/pokemod/MapWarp.h
index 9885dc1f..b8898d68 100644
--- a/pokemod/MapWarp.h
+++ b/pokemod/MapWarp.h
@@ -18,19 +18,18 @@
#ifndef __POKEMOD_MAPWARP__
#define __POKEMOD_MAPWARP__
-// Qt includes
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-#include <Flag.h>
-#include <Point.h>
-
// Pokemod includes
#include "Object.h"
#include "Pokemod.h"
+// General includes
+#include "../general/Exception.h"
+#include "../general/Flag.h"
+#include "../general/Point.h"
+
+// Qt includes
+#include <QString>
+
class MapWarp : public Object
{
public:
@@ -45,15 +44,15 @@ class MapWarp : public Object
static const QStringList TypeStr;
MapWarp(const MapWarp& warp);
- MapWarp(const Pokemod* pokemod, const int id);
- MapWarp(const MapWarp& warp, const Pokemod* pokemod, const int id);
- MapWarp(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ MapWarp(const Object* parent, const int id);
+ MapWarp(const MapWarp& warp, const Object* parent, const int id);
+ MapWarp(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
void setName(const QString& name);
- void setCoordinate(const Point& coordinate);
+ void setCoordinate(const Point& coordinate) throw(BoundsException);
void setFrom(const int direction, const bool can) throw(BoundsException);
void setDirectionOut(const int directionOut) throw(BoundsException);
void setWarpType(const int warpType) throw(BoundsException);
diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp
index 1b239e8b..3bc04a18 100644
--- a/pokemod/MapWildList.cpp
+++ b/pokemod/MapWildList.cpp
@@ -15,42 +15,42 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
+// Header include
+#include "MapWildList.h"
// Pokemod includes
-#include "Pokemod.h"
#include "Item.h"
#include "ItemEffect.h"
#include "MapWildListEncounter.h"
+#include "Pokemod.h"
-// Header include
-#include "MapWildList.h"
+// Qt includes
+#include <QMap>
const QStringList MapWildList::ControlStr = QStringList() << "Grass" << "Surfing" << "Fishing" << "Dive" << "Headbutt" << "Rock Smash";
MapWildList::MapWildList(const MapWildList& wildList) :
- Object("MapWildList", wildList.pokemod(), wildList.id())
+ Object("MapWildList", wildList.parent(), wildList.id())
{
*this = wildList;
}
-MapWildList::MapWildList(const Pokemod* pokemod, const int id) :
- Object("MapWildList", pokemod, id),
+MapWildList::MapWildList(const Object* parent, const int id) :
+ Object("MapWildList", parent, id),
m_control(INT_MAX),
m_value(INT_MAX),
m_scope(INT_MAX)
{
}
-MapWildList::MapWildList(const MapWildList& wildList, const Pokemod* pokemod, const int id) :
- Object("MapWildList", pokemod, id)
+MapWildList::MapWildList(const MapWildList& wildList, const Object* parent, const int id) :
+ Object("MapWildList", parent, id)
{
*this = wildList;
}
-MapWildList::MapWildList(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MapWildList", pokemod, id)
+MapWildList::MapWildList(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MapWildList", parent, id)
{
load(xml, id);
}
@@ -62,79 +62,80 @@ MapWildList::~MapWildList()
bool MapWildList::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Wild List with id %1---").arg(id()), Pokemod::V_Msg);
- if (End <= m_control)
- {
- pokemod()->validationMsg("Invalid control");
- valid = false;
- }
- else if (m_control == Fishing)
- {
- bool ok = false;
- for (int i = 0; (i < pokemod()->itemCount()) && !ok; ++i)
- {
- const Item* item = pokemod()->item(i);
- for (int j = 0; (j < item->effectCount()) && !ok; ++j)
- {
- const ItemEffect* effect = item->effect(j);
- ok = ((effect->effect() == ItemEffect::E_Fish) && (effect->value2() == m_value));
- }
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid fishing value");
- valid = false;
- }
- }
- QMap<int, bool> idChecker;
- foreach (int time, m_times)
- {
- if (pokemod()->timeIndex(time) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid time");
- valid = false;
- }
- if (idChecker[time])
- pokemod()->validationMsg(QString("Duplicate of time %1").arg(time));
- idChecker[time] = true;
- }
- idChecker.clear();
- if (m_scope != INT_MAX)
- {
- bool ok = false;
- for (int i = 0; (i < pokemod()->itemCount()) && !ok; ++i)
- {
- const Item* item = pokemod()->item(i);
- for (int j = 0; (j < item->effectCount()) && !ok; ++j)
- {
- const ItemEffect* effect = item->effect(j);
- ok = ((effect->effect() == ItemEffect::E_Scope) && (effect->value2() == m_scope));
- }
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid scope");
- valid = false;
- }
- }
- if (encounterCount())
- {
- foreach (MapWildListEncounter* encounter, m_encounters)
- {
- if (!encounter->isValid())
- valid = false;
- if (idChecker[encounter->id()])
- pokemod()->validationMsg(QString("Duplicate encounter with id %1").arg(encounter->id()));
- idChecker[encounter->id()] = true;
- }
- }
- else
- {
- pokemod()->validationMsg(QString("No effects"));
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Wild List with id %1---").arg(id()), Pokemod::V_Msg);
+// if (End <= m_control)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid control");
+// valid = false;
+// }
+// else if (m_control == Fishing)
+// {
+// bool ok = false;
+// for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()) && !ok; ++i)
+// {
+// const Item* item = static_cast<const Pokemod*>(pokemod())->item(i);
+// for (int j = 0; (j < item->effectCount()) && !ok; ++j)
+// {
+// const ItemEffect* effect = item->effect(j);
+// ok = ((effect->effect() == ItemEffect::E_Fish) && (effect->value2() == m_value));
+// }
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid fishing value");
+// valid = false;
+// }
+// }
+// QMap<int, bool> idChecker;
+// foreach (int time, m_times)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->timeIndex(time) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid time");
+// valid = false;
+// }
+// if (idChecker[time])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of time %1").arg(time));
+// idChecker[time] = true;
+// }
+// idChecker.clear();
+// if (m_scope != INT_MAX)
+// {
+// bool ok = false;
+// for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()) && !ok; ++i)
+// {
+// const Item* item = static_cast<const Pokemod*>(pokemod())->item(i);
+// for (int j = 0; (j < item->effectCount()) && !ok; ++j)
+// {
+// const ItemEffect* effect = item->effect(j);
+// ok = ((effect->effect() == ItemEffect::E_Scope) && (effect->value2() == m_scope));
+// }
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid scope");
+// valid = false;
+// }
+// }
+// if (encounterCount())
+// {
+// foreach (MapWildListEncounter* encounter, m_encounters)
+// {
+// if (!encounter->isValid())
+// valid = false;
+// if (idChecker[encounter->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate encounter with id %1").arg(encounter->id()));
+// idChecker[encounter->id()] = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("No effects"));
+// valid = false;
+// }
+// return valid;
}
void MapWildList::load(const QDomElement& xml, int id)
@@ -171,9 +172,9 @@ void MapWildList::setValue(const int value) throw(Exception)
if (m_control != Fishing)
error<UnusedException>("value");
bool ok = false;
- for (int i = 0; (i < pokemod()->itemCount()) && !ok; ++i)
+ for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()) && !ok; ++i)
{
- const Item* item = pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(pokemod())->item(i);
for (int j = 0; (j < item->effectCount()) && !ok; ++j)
{
const ItemEffect* effect = item->effect(j);
@@ -187,7 +188,7 @@ void MapWildList::setValue(const int value) throw(Exception)
void MapWildList::setTime(const int time, const bool state) throw(BoundsException)
{
- if (pokemod()->timeIndex(time) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->timeIndex(time) == INT_MAX)
error<BoundsException>("time");
if (state)
{
@@ -203,9 +204,9 @@ void MapWildList::setScope(const int scope) throw(BoundsException)
if (scope != INT_MAX)
{
bool ok = false;
- for (int i = 0; (i < pokemod()->itemCount()) && !ok; ++i)
+ for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()) && !ok; ++i)
{
- const Item* item = pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(pokemod())->item(i);
for (int j = 0; (j < item->effectCount()) && !ok; ++j)
{
const ItemEffect* effect = item->effect(j);
@@ -279,19 +280,19 @@ int MapWildList::encounterCount() const
MapWildListEncounter* MapWildList::newEncounter()
{
- m_encounters.append(new MapWildListEncounter(pokemod(), newEncounterId()));
+ m_encounters.append(new MapWildListEncounter(this, newEncounterId()));
return m_encounters[encounterCount() - 1];
}
MapWildListEncounter* MapWildList::newEncounter(const QDomElement& xml)
{
- m_encounters.append(new MapWildListEncounter(xml, pokemod(), newEncounterId()));
+ m_encounters.append(new MapWildListEncounter(xml, this, newEncounterId()));
return m_encounters[encounterCount() - 1];
}
MapWildListEncounter* MapWildList::newEncounter(const MapWildListEncounter& encounter)
{
- m_encounters.append(new MapWildListEncounter(encounter, pokemod(), newEncounterId()));
+ m_encounters.append(new MapWildListEncounter(encounter, this, newEncounterId()));
return m_encounters[encounterCount() - 1];
}
diff --git a/pokemod/MapWildList.h b/pokemod/MapWildList.h
index 2167718d..1f79bfc3 100644
--- a/pokemod/MapWildList.h
+++ b/pokemod/MapWildList.h
@@ -18,20 +18,18 @@
#ifndef __POKEMOD_MAPWILDLIST__
#define __POKEMOD_MAPWILDLIST__
-// Qt includes
-#include <QList>
-#include <QString>
-#include <QStringList>
+// Pokemod includes
+#include "Object.h"
// General includes
-#include <Exception.h>
+#include "../general/Exception.h"
-// Pokemod includes
-#include "Object.h"
+// Qt includes
+#include <QList>
+#include <QString>
// Forward declarations
class MapWildListEncounter;
-class Pokemod;
class MapWildList : public Object
{
@@ -49,9 +47,9 @@ class MapWildList : public Object
static const QStringList ControlStr;
MapWildList(const MapWildList& wildList);
- MapWildList(const Pokemod* pokemod, const int id);
- MapWildList(const MapWildList& wildList, const Pokemod* pokemod, const int id);
- MapWildList(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ MapWildList(const Object* parent, const int id);
+ MapWildList(const MapWildList& wildList, const Object* parent, const int id);
+ MapWildList(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
~MapWildList();
void load(const QDomElement& xml, int id = INT_MAX);
diff --git a/pokemod/MapWildListEncounter.cpp b/pokemod/MapWildListEncounter.cpp
index 1fde361c..e230747e 100644
--- a/pokemod/MapWildListEncounter.cpp
+++ b/pokemod/MapWildListEncounter.cpp
@@ -15,59 +15,60 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include "Pokemod.h"
-#include "Species.h"
-
// Header include
#include "MapWildListEncounter.h"
+// Pokemod includes
+#include "Species.h"
+#include "Pokemod.h"
+
MapWildListEncounter::MapWildListEncounter(const MapWildListEncounter& encounter) :
- Object("MapWildListEncounter", encounter.pokemod(), encounter.id())
+ Object("MapWildListEncounter", encounter.parent(), encounter.id())
{
*this = encounter;
}
-MapWildListEncounter::MapWildListEncounter(const Pokemod* pokemod, const int id) :
- Object("MapWildListEncounter", pokemod, id),
+MapWildListEncounter::MapWildListEncounter(const Object* parent, const int id) :
+ Object("MapWildListEncounter", parent, id),
m_species(INT_MAX),
m_level(1),
m_weight(1)
{
}
-MapWildListEncounter::MapWildListEncounter(const MapWildListEncounter& encounter, const Pokemod* pokemod, const int id) :
- Object("MapWildListEncounter", pokemod, id)
+MapWildListEncounter::MapWildListEncounter(const MapWildListEncounter& encounter, const Object* parent, const int id) :
+ Object("MapWildListEncounter", parent, id)
{
*this = encounter;
}
-MapWildListEncounter::MapWildListEncounter(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MapWildListEncounter", pokemod, id)
+MapWildListEncounter::MapWildListEncounter(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MapWildListEncounter", parent, id)
{
load(xml, id);
}
bool MapWildListEncounter::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---------Encounter with id %1---").arg(id()), Pokemod::V_Msg);
- if (pokemod()->speciesIndex(m_species) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid species");
- valid = false;
- }
- if (!m_level || (pokemod()->rules()->maxLevel() <= m_level))
- {
- pokemod()->validationMsg("Invalid level");
- valid = false;
- }
- if (!m_weight)
- {
- pokemod()->validationMsg("Invalid weighting");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---------Encounter with id %1---").arg(id()), Pokemod::V_Msg);
+// if (static_cast<const Pokemod*>(pokemod())->speciesIndex(m_species) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid species");
+// valid = false;
+// }
+// if (!m_level || (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() <= m_level))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid level");
+// valid = false;
+// }
+// if (!m_weight)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid weighting");
+// valid = false;
+// }
+// return valid;
}
void MapWildListEncounter::load(const QDomElement& xml, int id)
@@ -89,14 +90,14 @@ QDomElement MapWildListEncounter::save() const
void MapWildListEncounter::setSpecies(const int species) throw(BoundsException)
{
- if (pokemod()->speciesIndex(species) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->speciesIndex(species) == INT_MAX)
error<BoundsException>("species");
m_species = species;
}
void MapWildListEncounter::setLevel(const int level) throw(BoundsException)
{
- if (!level || (pokemod()->rules()->maxLevel() <= level))
+ if (!level || (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() <= level))
error<BoundsException>("level");
m_level = level;
}
diff --git a/pokemod/MapWildListEncounter.h b/pokemod/MapWildListEncounter.h
index 2c0907bd..2c49a385 100644
--- a/pokemod/MapWildListEncounter.h
+++ b/pokemod/MapWildListEncounter.h
@@ -18,25 +18,22 @@
#ifndef __POKEMOD_MAPWILDLISTENCOUNTER__
#define __POKEMOD_MAPWILDLISTENCOUNTER__
-// Qt includes
-#include <QString>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QString>
class MapWildListEncounter: public Object
{
public:
MapWildListEncounter(const MapWildListEncounter& encounter);
- MapWildListEncounter(const Pokemod* pokemod, const int id);
- MapWildListEncounter(const MapWildListEncounter& encounter, const Pokemod* pokemod, const int id);
- MapWildListEncounter(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ MapWildListEncounter(const Object* parent, const int id);
+ MapWildListEncounter(const MapWildListEncounter& encounter, const Object* parent, const int id);
+ MapWildListEncounter(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp
index d1d17641..10c8affe 100644
--- a/pokemod/Move.cpp
+++ b/pokemod/Move.cpp
@@ -15,27 +15,27 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
+// Header include
+#include "Move.h"
// Pokemod includes
-#include "Pokemod.h"
#include "MoveEffect.h"
+#include "Pokemod.h"
-// Header include
-#include "Move.h"
+// Qt includes
+#include <QMap>
const QStringList Move::TargetStr = QStringList() << "Player" << "Enemy" << "All" << "Random";
const QStringList Move::ChoiceStr = QStringList() << "Player" << "Enemy" << "Random";
Move::Move(const Move& move) :
- Object("Move", move.pokemod(), move.id())
+ Object("Move", move.parent(), move.id())
{
*this = move;
}
-Move::Move(const Pokemod* pokemod, const int id) :
- Object("Move", pokemod, id),
+Move::Move(const Object* parent, const int id) :
+ Object("Move", parent, id),
m_name(""),
m_accuracy(1, 1),
m_power(0),
@@ -54,14 +54,14 @@ Move::Move(const Pokemod* pokemod, const int id) :
{
}
-Move::Move(const Move& move, const Pokemod* pokemod, const int id) :
- Object("Move", pokemod, id)
+Move::Move(const Move& move, const Object* parent, const int id) :
+ Object("Move", parent, id)
{
*this = move;
}
-Move::Move(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Move", pokemod, id)
+Move::Move(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Move", parent, id)
{
load(xml, id);
}
@@ -73,56 +73,57 @@ Move::~Move()
bool Move::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Move \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = "";
- }
- if (pokemod()->typeIndex(m_type) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid type");
- valid = false;
- }
- if (!m_powerPoints)
- {
- pokemod()->validationMsg("Invalid number of power points");
- valid = false;
- }
- if (T_End <= m_target)
- {
- pokemod()->validationMsg("Invalid target");
- valid = false;
- }
- if (!m_target || (pokemod()->rules()->maxFight() * ((m_target == T_All) ? pokemod()->rules()->maxPlayers() : 1)) < m_numTargets)
- {
- pokemod()->validationMsg("Invalid number of targets");
- valid = false;
- }
- if (C_End <= m_targetChoice)
- {
- pokemod()->validationMsg("Invalid target choice");
- valid = false;
- }
- if (effectCount())
- {
- QMap<int, bool> idChecker;
- foreach (MoveEffect* effect, m_effects)
- {
- if (!effect->isValid())
- valid = false;
- if (idChecker[effect->id()])
- pokemod()->validationMsg(QString("Duplicate effect with id %1").arg(effect->id()));
- idChecker[effect->id()] = true;
- }
- }
- else
- {
- pokemod()->validationMsg("There are no effects");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Move \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = "";
+// }
+// if (static_cast<const Pokemod*>(pokemod())->typeIndex(m_type) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid type");
+// valid = false;
+// }
+// if (!m_powerPoints)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid number of power points");
+// valid = false;
+// }
+// if (T_End <= m_target)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid target");
+// valid = false;
+// }
+// if (!m_target || (static_cast<const Pokemod*>(pokemod())->rules()->maxFight() * ((m_target == T_All) ? static_cast<const Pokemod*>(pokemod())->rules()->maxPlayers() : 1)) < m_numTargets)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid number of targets");
+// valid = false;
+// }
+// if (C_End <= m_targetChoice)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid target choice");
+// valid = false;
+// }
+// if (effectCount())
+// {
+// QMap<int, bool> idChecker;
+// foreach (MoveEffect* effect, m_effects)
+// {
+// if (!effect->isValid())
+// valid = false;
+// if (idChecker[effect->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate effect with id %1").arg(effect->id()));
+// idChecker[effect->id()] = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no effects");
+// valid = false;
+// }
+// return valid;
}
void Move::load(const QDomElement& xml, int id)
@@ -186,7 +187,7 @@ void Move::setPower(const int power)
void Move::setType(const int type) throw(BoundsException)
{
- if (pokemod()->typeIndex(type) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->typeIndex(type) == INT_MAX)
error<BoundsException>("type");
m_type = type;
}
@@ -212,7 +213,7 @@ void Move::setTarget(const int target) throw(BoundsException)
void Move::setNumTargets(const int numTargets) throw(BoundsException)
{
- if (!numTargets || ((pokemod()->rules()->maxFight() * ((m_target == T_All) ? pokemod()->rules()->maxPlayers() : 1)) < numTargets))
+ if (!numTargets || ((static_cast<const Pokemod*>(pokemod())->rules()->maxFight() * ((m_target == T_All) ? static_cast<const Pokemod*>(pokemod())->rules()->maxPlayers() : 1)) < numTargets))
error<BoundsException>("numTargets");
m_numTargets = numTargets;
}
@@ -370,19 +371,19 @@ int Move::effectCount() const
MoveEffect* Move::newEffect()
{
- m_effects.append(new MoveEffect(pokemod(), newEffectId()));
+ m_effects.append(new MoveEffect(this, newEffectId()));
return m_effects[effectCount() - 1];
}
MoveEffect* Move::newEffect(const QDomElement& xml)
{
- m_effects.append(new MoveEffect(xml, pokemod(), newEffectId()));
+ m_effects.append(new MoveEffect(xml, this, newEffectId()));
return m_effects[effectCount() - 1];
}
MoveEffect* Move::newEffect(const MoveEffect& effect)
{
- m_effects.append(new MoveEffect(effect, pokemod(), newEffectId()));
+ m_effects.append(new MoveEffect(effect, this, newEffectId()));
return m_effects[effectCount() - 1];
}
diff --git a/pokemod/Move.h b/pokemod/Move.h
index 3649ef6f..f7a862ec 100644
--- a/pokemod/Move.h
+++ b/pokemod/Move.h
@@ -18,21 +18,19 @@
#ifndef __POKEMOD_MOVE__
#define __POKEMOD_MOVE__
-// Qt includes
-#include <QList>
-#include <QString>
-#include <QStringList>
+// Pokemod includes
+#include "Object.h"
// General includes
-#include <Exception.h>
-#include <Fraction.h>
+#include "../general/Exception.h"
+#include "../general/Fraction.h"
-// Pokemod includes
-#include "Object.h"
+// Qt includes
+#include <QList>
+#include <QString>
// Forward declarations
class MoveEffect;
-class Pokemod;
class Move : public Object
{
@@ -57,9 +55,9 @@ class Move : public Object
static const QStringList ChoiceStr;
Move(const Move& move);
- Move(const Pokemod* pokemod, const int id);
- Move(const Move& move, const Pokemod* pokemod, const int id);
- Move(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Move(const Object* parent, const int id);
+ Move(const Move& move, const Object* parent, const int id);
+ Move(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
~Move();
void load(const QDomElement& xml, int id = INT_MAX);
diff --git a/pokemod/MoveEffect.cpp b/pokemod/MoveEffect.cpp
index f7c5835a..e790d672 100644
--- a/pokemod/MoveEffect.cpp
+++ b/pokemod/MoveEffect.cpp
@@ -15,22 +15,22 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include "Pokemod.h"
-
// Header include
#include "MoveEffect.h"
+// Pokemod includes
+#include "Pokemod.h"
+
const QStringList MoveEffect::EffectStr = QStringList() << "Damage" << "Status" << "Confuse" << "Stat" << "StealHP" << "Counter" << "Selfdestruct" << "Need Status" << "Mirror" << "GetMoney" << "Never Miss" << "Steal Types" << "Clear Effects" << "Wait And Return" << "Self Confuse" << "Force Switch" << "Hit Multiple" << "Hit Multiple Turns" << "Flinch" << "One Hit K.O." << "Recoil" << "Recover" << "Rest" << "Sheild" << "Substitute" << "Recharge" << "Rage" << "Mimic" << "Random Move" << "Seed" << "Disable" << "Cut HM" << "Fly HM" << "Surf HM" << "Strength HM" << "Flash HM" << "Rock Smash HM" << "Rock Climb HM" << "Whirlpool HM" << "Waterfall HM" << "Share HP HM " << "Escape HM";
MoveEffect::MoveEffect(const MoveEffect& effect) :
- Object("MoveEffect", effect.pokemod(), effect.id())
+ Object("MoveEffect", effect.parent(), effect.id())
{
*this = effect;
}
-MoveEffect::MoveEffect(const Pokemod* pokemod, const int id) :
- Object("MoveEffect", pokemod, id),
+MoveEffect::MoveEffect(const Object* parent, const int id) :
+ Object("MoveEffect", parent, id),
m_chance(1, 1),
m_effect(INT_MAX),
m_value1(INT_MAX),
@@ -40,24 +40,24 @@ MoveEffect::MoveEffect(const Pokemod* pokemod, const int id) :
{
}
-MoveEffect::MoveEffect(const MoveEffect& effect, const Pokemod* pokemod, const int id) :
- Object("MoveEffect", pokemod, id)
+MoveEffect::MoveEffect(const MoveEffect& effect, const Object* parent, const int id) :
+ Object("MoveEffect", parent, id)
{
*this = effect;
}
-MoveEffect::MoveEffect(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MoveEffect", pokemod, id)
+MoveEffect::MoveEffect(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MoveEffect", parent, id)
{
load(xml, id);
}
bool MoveEffect::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Effect with id %1---").arg(id()), Pokemod::V_Msg);
- // TODO: Move Effect validation
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Effect with id %1---").arg(id()), Pokemod::V_Msg);
+// return valid;
}
void MoveEffect::load(const QDomElement& xml, int id)
diff --git a/pokemod/MoveEffect.h b/pokemod/MoveEffect.h
index fff07b3b..63f60be3 100644
--- a/pokemod/MoveEffect.h
+++ b/pokemod/MoveEffect.h
@@ -18,19 +18,15 @@
#ifndef __POKEMOD_MOVEEFFECT__
#define __POKEMOD_MOVEEFFECT__
-// Qt includes
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-#include <Fraction.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+#include "../general/Fraction.h"
+
+// Qt includes
+#include <QString>
class MoveEffect : public Object
{
@@ -113,9 +109,9 @@ class MoveEffect : public Object
static const QStringList RecoilStr;
MoveEffect(const MoveEffect& effect);
- MoveEffect(const Pokemod* pokemod, const int id);
- MoveEffect(const MoveEffect& effect, const Pokemod* pokemod, const int id);
- MoveEffect(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ MoveEffect(const Object* parent, const int id);
+ MoveEffect(const MoveEffect& effect, const Object* parent, const int id);
+ MoveEffect(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp
index 873d720c..62e14267 100644
--- a/pokemod/Nature.cpp
+++ b/pokemod/Nature.cpp
@@ -15,20 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include "Pokemod.h"
-
// Header include
#include "Nature.h"
+// Pokemod includes
+#include "Pokemod.h"
+
Nature::Nature(const Nature& nature) :
- Object("Nature", nature.pokemod(), nature.id())
+ Object("Nature", nature.parent(), nature.id())
{
*this = nature;
}
-Nature::Nature(const Pokemod* pokemod, const int id) :
- Object("Nature", pokemod, id),
+Nature::Nature(const Object* parent, const int id) :
+ Object("Nature", parent, id),
m_name(""),
m_weight(1)
{
@@ -36,33 +36,34 @@ Nature::Nature(const Pokemod* pokemod, const int id) :
m_stat[i].set(1, 1);
}
-Nature::Nature(const Nature& nature, const Pokemod* pokemod, const int id) :
- Object("Nature", pokemod, id)
+Nature::Nature(const Nature& nature, const Object* parent, const int id) :
+ Object("Nature", parent, id)
{
*this = nature;
}
-Nature::Nature(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Nature", pokemod, id)
+Nature::Nature(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Nature", parent, id)
{
load(xml, id);
}
bool Nature::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Nature \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- if (!m_weight)
- {
- pokemod()->validationMsg("Weight is not valid");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Nature \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// if (!m_weight)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Weight is not valid");
+// valid = false;
+// }
+// return valid;
}
void Nature::load(const QDomElement& xml, int id)
@@ -89,7 +90,7 @@ void Nature::setName(const QString& name)
void Nature::setStat(const int stat, const Fraction& multiplier) throw(BoundsException)
{
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
+ if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
error<BoundsException>("stat");
m_stat[stat] = multiplier;
}
diff --git a/pokemod/Nature.h b/pokemod/Nature.h
index aac0b458..becebb21 100644
--- a/pokemod/Nature.h
+++ b/pokemod/Nature.h
@@ -18,24 +18,24 @@
#ifndef __POKEMOD_NATURE__
#define __POKEMOD_NATURE__
-// Qt includes
-#include <QString>
-
-// General includes
-#include <Exception.h>
-#include <Fraction.h>
-
// Pokemod includes
#include "Object.h"
#include "Pokemod.h"
+// General includes
+#include "../general/Exception.h"
+#include "../general/Fraction.h"
+
+// Qt includes
+#include <QString>
+
class Nature : public Object
{
public:
Nature(const Nature& nature);
- Nature(const Pokemod* pokemod, const int id);
- Nature(const Nature& nature, const Pokemod* pokemod, const int id);
- Nature(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Nature(const Object* parent, const int id);
+ Nature(const Nature& nature, const Object* parent, const int id);
+ Nature(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Object.h b/pokemod/Object.h
index 29b7c99a..96fde63a 100644
--- a/pokemod/Object.h
+++ b/pokemod/Object.h
@@ -18,29 +18,26 @@
#ifndef __POKEMOD_OBJECT__
#define __POKEMOD_OBJECT__
+// General includes
+#include "../general/Exception.h"
+
// Qt includes
#include <QDomDocument>
#include <QDomElement>
-// General includes
-#include <Exception.h>
-
-// Forward declarations
-class Pokemod;
-
class Object
{
public:
inline Object(const Object& object) :
m_id(object.id()),
m_className(object.className()),
- m_pokemod(object.pokemod())
+ m_parent(object.parent())
{
}
- inline Object(const QString& className, const Pokemod* pokemod, const int id) :
+ inline Object(const QString& className, const Object* parent, const int id) :
m_id(id),
m_className(className),
- m_pokemod(pokemod)
+ m_parent(parent)
{
}
virtual ~Object()
@@ -49,9 +46,16 @@ class Object
virtual void load(const QDomElement& xml, int id = INT_MAX) = 0;
virtual QDomElement save() const = 0;
- inline const Pokemod* pokemod() const
+ inline const Object* parent() const
+ {
+ return m_parent;
+ }
+
+ inline const Object* pokemod() const
{
- return m_pokemod;
+ if (m_parent)
+ return m_parent->pokemod();
+ return this;
}
inline int id() const
@@ -92,7 +96,7 @@ class Object
private:
int m_id;
const QString m_className;
- const Pokemod* m_pokemod;
+ const Object* m_parent;
bool m_valid;
};
@@ -229,6 +233,6 @@ class Object
COPY(variable[i])
#define COPY_SUB(class, variable) \
foreach (class* subclass, rhs.m_##variable) \
- m_##variable.append(new class(*subclass, pokemod(), subclass->id()))
+ m_##variable.append(new class(*subclass, this, subclass->id()))
#endif
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp
index 1d84fffc..e4191a85 100644
--- a/pokemod/Pokemod.cpp
+++ b/pokemod/Pokemod.cpp
@@ -15,11 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QBuffer>
-#include <QMap>
-#include <QTextStream>
-#include <QTime>
+// Header include
+#include "Pokemod.h"
// Pokemod includes
#include "Ability.h"
@@ -40,8 +37,11 @@
#include "Trainer.h"
#include "Type.h"
-// Header include
-#include "Pokemod.h"
+// Qt includes
+#include <QBuffer>
+#include <QMap>
+#include <QTextStream>
+#include <QTime>
const QStringList Pokemod::ValidationStr = QStringList() << "Message" << "Warn" << "Error";
const QStringList Pokemod::StatRBYStr = QStringList() << "HP" << "Attack" << "Defense" << "Speed" << "Special" << "Special" << "Accuracy" << "Evasion";
@@ -54,7 +54,7 @@ const QStringList Pokemod::StatusStr = QStringList() << "Freeze" << "Paralyze" <
const QStringList Pokemod::HMStr = QStringList() << "Cut" << "Fly" << "Surf" << "Strength" << "Flash" << "Whirlpool" << "Waterfall" << "Dive" << "Headbutt" << "Rock Smash" << "Defog" << "Rock Climb" << "Heal" << "Escape";
Pokemod::Pokemod() :
- Object("Pokemod", this, 0),
+ Object("Pokemod", NULL, 0),
valOutput(NULL),
m_title(""),
m_version(""),
@@ -75,14 +75,14 @@ Pokemod::Pokemod() :
}
Pokemod::Pokemod(const Pokemod& pokemod) :
- Object("Pokemod", this, 0),
+ Object("Pokemod", NULL, 0),
m_rules(this)
{
*this = pokemod;
}
Pokemod::Pokemod(const QDomElement& xml) :
- Object("Pokemod", this, 0),
+ Object("Pokemod", NULL, 0),
valOutput(NULL),
m_rules(this)
{
@@ -96,284 +96,285 @@ Pokemod::~Pokemod()
bool Pokemod::validate() const
{
- bool valid = true;
- validationMsg(QString("Pokemod \"%1\"").arg(m_title), V_Msg);
- if (m_title == "")
- {
- validationMsg("Title is not defined");
- valid = false;
- }
- if (m_version == "")
- {
- validationMsg("Version is not defined");
- valid = false;
- }
- if (m_description == "")
- validationMsg("Description is not defined", V_Warn);
- if (mapIndex(m_startMap))
- {
- if (mapById(m_startMap)->warpIndex(m_startWarp) == INT_MAX)
- {
- validationMsg("Invalid starting warp");
- valid = false;
- }
- }
- else
- {
- validationMsg("Invalid starting map");
- valid = false;
- }
- if (m_superPCUname == "")
- validationMsg("Super PC username not defined", V_Warn);
- if (m_superPCPasswd == "")
- validationMsg("Super PC password not defined", V_Warn);
- if ((m_typeChart.width() != typeCount()) || (m_typeChart.height() != typeCount()))
- {
- validationMsg("TypeChart is invalid");
- valid = false;
- }
- if (!m_rules.isValid())
- valid = false;
- QMap<int, bool> idChecker;
- QMap<int, bool> timeChecker;
- if (m_rules.abilityAllowed())
- {
- if (!abilityCount())
- {
- validationMsg("There are no abilities");
- valid = false;
- }
- foreach (Ability* ability, m_abilities)
- {
- if (!ability->isValid())
- valid = false;
- if (idChecker[ability->id()])
- validationMsg(QString("Duplicate ability with id %1").arg(ability->id()));
- idChecker[ability->id()] = true;
- }
- idChecker.clear();
- }
- if (!authorCount())
- {
- validationMsg("There are no authors");
- valid = false;
- }
- foreach (Author* author, m_authors)
- {
- if (!author->isValid())
- valid = false;
- if (idChecker[author->id()])
- validationMsg(QString("Duplicate author with id %1").arg(author->id()));
- idChecker[author->id()] = true;
- }
- idChecker.clear();
- if (!badgeCount())
- validationMsg("There are no badges", V_Warn);
- foreach (Badge* badge, m_badges)
- {
- if (!badge->isValid())
- valid = false;
- if (idChecker[badge->id()])
- validationMsg(QString("Duplicate badge with id %1").arg(badge->id()));
- idChecker[badge->id()] = true;
- }
- idChecker.clear();
- if (!coinListCount())
- validationMsg("There are no coin lists", V_Warn);
- foreach (CoinList* coinList, m_coinLists)
- {
- if (!coinList->isValid())
- valid = false;
- if (idChecker[coinList->id()])
- validationMsg(QString("Duplicate coin list with id %1").arg(coinList->id()));
- idChecker[coinList->id()] = true;
- }
- idChecker.clear();
- if (!dialogCount())
- {
- validationMsg("There are no dialogs");
- valid = false;
- }
- foreach (Dialog* dialog, m_dialogs)
- {
- if (!dialog->isValid())
- valid = false;
- if (idChecker[dialog->id()])
- validationMsg(QString("Duplicate dialog with id %1").arg(dialog->id()));
- idChecker[dialog->id()] = true;
- }
- idChecker.clear();
- if (m_rules.breedingAllowed())
- {
- if (!eggGroupCount())
- {
- validationMsg("There are no egg grous");
- valid = false;
- }
- foreach (EggGroup* eggGroup, m_eggGroups)
- {
- if (!eggGroup->isValid())
- valid = false;
- if (idChecker[eggGroup->id()])
- validationMsg(QString("Duplicate egg group with id %1").arg(eggGroup->id()));
- idChecker[eggGroup->id()] = true;
- }
- idChecker.clear();
- }
- if (!itemCount())
- validationMsg("There are no m_items", V_Warn);
- foreach (Item* item, m_items)
- {
- if (!item->isValid())
- valid = false;
- if (idChecker[item->id()])
- validationMsg(QString("Duplicate item with id %1").arg(item->id()));
- idChecker[item->id()] = true;
- }
- idChecker.clear();
- if (!itemTypeCount())
- {
- validationMsg("There are no item types", itemCount() ? V_Error : V_Warn);
- if (itemCount())
- valid = false;
- }
- foreach (ItemType* itemType, m_itemTypes)
- {
- if (!itemType->isValid())
- valid = false;
- if (idChecker[itemType->id()])
- validationMsg(QString("Duplicate item type with id %1").arg(itemType->id()));
- idChecker[itemType->id()] = true;
- }
- idChecker.clear();
- if (!mapCount())
- {
- validationMsg("There are no m_maps");
- valid = false;
- }
- foreach (Map* map, m_maps)
- {
- if (!map->isValid())
- valid = false;
- if (idChecker[map->id()])
- validationMsg(QString("Duplicate map with id %1").arg(map->id()));
- idChecker[map->id()] = true;
- }
- idChecker.clear();
- if (!moveCount())
- {
- validationMsg("There are no m_moves");
- valid = false;
- }
- foreach (Move* move, m_moves)
- {
- if (!move->isValid())
- valid = false;
- if (idChecker[move->id()])
- validationMsg(QString("Duplicate move with id %1").arg(move->id()));
- idChecker[move->id()] = true;
- }
- idChecker.clear();
- if (m_rules.natureAllowed())
- {
- if (!natureCount())
- {
- validationMsg("There are no natures");
- valid = false;
- }
- foreach (Nature* nature, m_natures)
- {
- if (!nature->isValid())
- valid = false;
- if (idChecker[nature->id()])
- validationMsg(QString("Duplicate ability with id %1").arg(nature->id()));
- idChecker[nature->id()] = true;
- }
- idChecker.clear();
- }
- if (!speciesCount())
- {
- validationMsg("There are no m_species");
- valid = false;
- }
- foreach (Species* m_species, m_species)
- {
- if (!m_species->isValid())
- valid = false;
- if (idChecker[m_species->id()])
- validationMsg(QString("Duplicate m_species with id %1").arg(m_species->id()));
- idChecker[m_species->id()] = true;
- }
- idChecker.clear();
- if (!storeCount())
- validationMsg("There are no m_stores", V_Warn);
- foreach (Store* store, m_stores)
- {
- if (!store->isValid())
- valid = false;
- if (idChecker[store->id()])
- validationMsg(QString("Duplicate store with id %1").arg(store->id()));
- idChecker[store->id()] = true;
- }
- idChecker.clear();
- if (!tileCount())
- {
- validationMsg("There are no m_tiles");
- valid = false;
- }
- foreach (Tile* tile, m_tiles)
- {
- if (!tile->isValid())
- valid = false;
- if (idChecker[tile->id()])
- validationMsg(QString("Duplicate tile with id %1").arg(tile->id()));
- idChecker[tile->id()] = true;
- }
- idChecker.clear();
- if (!trainerCount())
- {
- validationMsg("There are no times", Pokemod::V_Warn);
- }
- foreach (Trainer* trainer, m_trainers)
- {
- if (!trainer->isValid())
- valid = false;
- if (idChecker[trainer->id()])
- validationMsg(QString("Duplicate trainer with id %1").arg(trainer->id()));
- idChecker[trainer->id()] = true;
- }
- idChecker.clear();
- if (!timeCount())
- {
- validationMsg("There are no times");
- valid = false;
- }
- foreach (Time* time, m_times)
- {
- if (!time->isValid())
- valid = false;
- if (idChecker[time->id()])
- validationMsg(QString("Duplicate time with id %1").arg(time->id()));
- idChecker[time->id()] = true;
- if (timeChecker[(60 * time->hour()) + time->minute()])
- validationMsg(QString("Duplicate time at %1:%2").arg(time->hour()).arg(time->minute()));
- timeChecker[(60 * time->hour()) + time->minute()] = true;
- }
- idChecker.clear();
- if (!typeCount())
- {
- validationMsg("There are no types");
- valid = false;
- }
- foreach (Type* type, m_types)
- {
- if (!type->isValid())
- valid = false;
- if (idChecker[type->id()])
- validationMsg(QString("Duplicate type with id %1").arg(type->id()));
- idChecker[type->id()] = true;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// validationMsg(QString("Pokemod \"%1\"").arg(m_title), V_Msg);
+// if (m_title == "")
+// {
+// validationMsg("Title is not defined");
+// valid = false;
+// }
+// if (m_version == "")
+// {
+// validationMsg("Version is not defined");
+// valid = false;
+// }
+// if (m_description == "")
+// validationMsg("Description is not defined", V_Warn);
+// if (mapIndex(m_startMap))
+// {
+// if (mapById(m_startMap)->warpIndex(m_startWarp) == INT_MAX)
+// {
+// validationMsg("Invalid starting warp");
+// valid = false;
+// }
+// }
+// else
+// {
+// validationMsg("Invalid starting map");
+// valid = false;
+// }
+// if (m_superPCUname == "")
+// validationMsg("Super PC username not defined", V_Warn);
+// if (m_superPCPasswd == "")
+// validationMsg("Super PC password not defined", V_Warn);
+// if ((m_typeChart.width() != typeCount()) || (m_typeChart.height() != typeCount()))
+// {
+// validationMsg("TypeChart is invalid");
+// valid = false;
+// }
+// if (!m_rules.isValid())
+// valid = false;
+// QMap<int, bool> idChecker;
+// QMap<int, bool> timeChecker;
+// if (m_rules.abilityAllowed())
+// {
+// if (!abilityCount())
+// {
+// validationMsg("There are no abilities");
+// valid = false;
+// }
+// foreach (Ability* ability, m_abilities)
+// {
+// if (!ability->isValid())
+// valid = false;
+// if (idChecker[ability->id()])
+// validationMsg(QString("Duplicate ability with id %1").arg(ability->id()));
+// idChecker[ability->id()] = true;
+// }
+// idChecker.clear();
+// }
+// if (!authorCount())
+// {
+// validationMsg("There are no authors");
+// valid = false;
+// }
+// foreach (Author* author, m_authors)
+// {
+// if (!author->isValid())
+// valid = false;
+// if (idChecker[author->id()])
+// validationMsg(QString("Duplicate author with id %1").arg(author->id()));
+// idChecker[author->id()] = true;
+// }
+// idChecker.clear();
+// if (!badgeCount())
+// validationMsg("There are no badges", V_Warn);
+// foreach (Badge* badge, m_badges)
+// {
+// if (!badge->isValid())
+// valid = false;
+// if (idChecker[badge->id()])
+// validationMsg(QString("Duplicate badge with id %1").arg(badge->id()));
+// idChecker[badge->id()] = true;
+// }
+// idChecker.clear();
+// if (!coinListCount())
+// validationMsg("There are no coin lists", V_Warn);
+// foreach (CoinList* coinList, m_coinLists)
+// {
+// if (!coinList->isValid())
+// valid = false;
+// if (idChecker[coinList->id()])
+// validationMsg(QString("Duplicate coin list with id %1").arg(coinList->id()));
+// idChecker[coinList->id()] = true;
+// }
+// idChecker.clear();
+// if (!dialogCount())
+// {
+// validationMsg("There are no dialogs");
+// valid = false;
+// }
+// foreach (Dialog* dialog, m_dialogs)
+// {
+// if (!dialog->isValid())
+// valid = false;
+// if (idChecker[dialog->id()])
+// validationMsg(QString("Duplicate dialog with id %1").arg(dialog->id()));
+// idChecker[dialog->id()] = true;
+// }
+// idChecker.clear();
+// if (m_rules.breedingAllowed())
+// {
+// if (!eggGroupCount())
+// {
+// validationMsg("There are no egg grous");
+// valid = false;
+// }
+// foreach (EggGroup* eggGroup, m_eggGroups)
+// {
+// if (!eggGroup->isValid())
+// valid = false;
+// if (idChecker[eggGroup->id()])
+// validationMsg(QString("Duplicate egg group with id %1").arg(eggGroup->id()));
+// idChecker[eggGroup->id()] = true;
+// }
+// idChecker.clear();
+// }
+// if (!itemCount())
+// validationMsg("There are no m_items", V_Warn);
+// foreach (Item* item, m_items)
+// {
+// if (!item->isValid())
+// valid = false;
+// if (idChecker[item->id()])
+// validationMsg(QString("Duplicate item with id %1").arg(item->id()));
+// idChecker[item->id()] = true;
+// }
+// idChecker.clear();
+// if (!itemTypeCount())
+// {
+// validationMsg("There are no item types", itemCount() ? V_Error : V_Warn);
+// if (itemCount())
+// valid = false;
+// }
+// foreach (ItemType* itemType, m_itemTypes)
+// {
+// if (!itemType->isValid())
+// valid = false;
+// if (idChecker[itemType->id()])
+// validationMsg(QString("Duplicate item type with id %1").arg(itemType->id()));
+// idChecker[itemType->id()] = true;
+// }
+// idChecker.clear();
+// if (!mapCount())
+// {
+// validationMsg("There are no m_maps");
+// valid = false;
+// }
+// foreach (Map* map, m_maps)
+// {
+// if (!map->isValid())
+// valid = false;
+// if (idChecker[map->id()])
+// validationMsg(QString("Duplicate map with id %1").arg(map->id()));
+// idChecker[map->id()] = true;
+// }
+// idChecker.clear();
+// if (!moveCount())
+// {
+// validationMsg("There are no m_moves");
+// valid = false;
+// }
+// foreach (Move* move, m_moves)
+// {
+// if (!move->isValid())
+// valid = false;
+// if (idChecker[move->id()])
+// validationMsg(QString("Duplicate move with id %1").arg(move->id()));
+// idChecker[move->id()] = true;
+// }
+// idChecker.clear();
+// if (m_rules.natureAllowed())
+// {
+// if (!natureCount())
+// {
+// validationMsg("There are no natures");
+// valid = false;
+// }
+// foreach (Nature* nature, m_natures)
+// {
+// if (!nature->isValid())
+// valid = false;
+// if (idChecker[nature->id()])
+// validationMsg(QString("Duplicate ability with id %1").arg(nature->id()));
+// idChecker[nature->id()] = true;
+// }
+// idChecker.clear();
+// }
+// if (!speciesCount())
+// {
+// validationMsg("There are no m_species");
+// valid = false;
+// }
+// foreach (Species* m_species, m_species)
+// {
+// if (!m_species->isValid())
+// valid = false;
+// if (idChecker[m_species->id()])
+// validationMsg(QString("Duplicate m_species with id %1").arg(m_species->id()));
+// idChecker[m_species->id()] = true;
+// }
+// idChecker.clear();
+// if (!storeCount())
+// validationMsg("There are no m_stores", V_Warn);
+// foreach (Store* store, m_stores)
+// {
+// if (!store->isValid())
+// valid = false;
+// if (idChecker[store->id()])
+// validationMsg(QString("Duplicate store with id %1").arg(store->id()));
+// idChecker[store->id()] = true;
+// }
+// idChecker.clear();
+// if (!tileCount())
+// {
+// validationMsg("There are no m_tiles");
+// valid = false;
+// }
+// foreach (Tile* tile, m_tiles)
+// {
+// if (!tile->isValid())
+// valid = false;
+// if (idChecker[tile->id()])
+// validationMsg(QString("Duplicate tile with id %1").arg(tile->id()));
+// idChecker[tile->id()] = true;
+// }
+// idChecker.clear();
+// if (!trainerCount())
+// {
+// validationMsg("There are no times", Pokemod::V_Warn);
+// }
+// foreach (Trainer* trainer, m_trainers)
+// {
+// if (!trainer->isValid())
+// valid = false;
+// if (idChecker[trainer->id()])
+// validationMsg(QString("Duplicate trainer with id %1").arg(trainer->id()));
+// idChecker[trainer->id()] = true;
+// }
+// idChecker.clear();
+// if (!timeCount())
+// {
+// validationMsg("There are no times");
+// valid = false;
+// }
+// foreach (Time* time, m_times)
+// {
+// if (!time->isValid())
+// valid = false;
+// if (idChecker[time->id()])
+// validationMsg(QString("Duplicate time with id %1").arg(time->id()));
+// idChecker[time->id()] = true;
+// if (timeChecker[(60 * time->hour()) + time->minute()])
+// validationMsg(QString("Duplicate time at %1:%2").arg(time->hour()).arg(time->minute()));
+// timeChecker[(60 * time->hour()) + time->minute()] = true;
+// }
+// idChecker.clear();
+// if (!typeCount())
+// {
+// validationMsg("There are no types");
+// valid = false;
+// }
+// foreach (Type* type, m_types)
+// {
+// if (!type->isValid())
+// valid = false;
+// if (idChecker[type->id()])
+// validationMsg(QString("Duplicate type with id %1").arg(type->id()));
+// idChecker[type->id()] = true;
+// }
+// return valid;
}
void Pokemod::load(const QDomElement& xml, const int) throw(Exception)
diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h
index 93f14222..571b0171 100644
--- a/pokemod/Pokemod.h
+++ b/pokemod/Pokemod.h
@@ -18,21 +18,20 @@
#ifndef __POKEMOD_POKEMOD__
#define __POKEMOD_POKEMOD__
+// Pokemod includes
+#include "Object.h"
+#include "Rules.h"
+
+// General includes
+#include "../general/Exception.h"
+#include "../general/Fraction.h"
+#include "../general/Matrix.h"
+#include "../general/Point.h"
+
// Qt includes
#include <QList>
#include <QPixmap>
#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-#include <Fraction.h>
-#include <Matrix.h>
-#include <Point.h>
-
-// Pokemod includes
-#include "Object.h"
-#include "Rules.h"
// Forward declarations
class Ability;
diff --git a/pokemod/Rules.cpp b/pokemod/Rules.cpp
index 1f9b804d..6c113e88 100644
--- a/pokemod/Rules.cpp
+++ b/pokemod/Rules.cpp
@@ -15,22 +15,22 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include "Pokemod.h"
-
// Header include
#include "Rules.h"
+// Pokemod includes
+#include "Pokemod.h"
+
const QStringList Rules::DVStr = QStringList() << "16" << "32";
Rules::Rules(const Rules& rules) :
- Object("Rules", rules.pokemod(), 0)
+ Object("Rules", rules.parent(), 0)
{
*this = rules;
}
-Rules::Rules(const Pokemod* pokemod) :
- Object("Rules", pokemod, 0),
+Rules::Rules(const Object* parent) :
+ Object("Rules", parent, 0),
m_genderAllowed(false),
m_breedingAllowed(false),
m_holdItems(0),
@@ -60,67 +60,68 @@ Rules::Rules(const Pokemod* pokemod) :
{
}
-Rules::Rules(const Rules& rules, const Pokemod* pokemod) :
- Object("Rules", pokemod, 0)
+Rules::Rules(const Rules& rules, const Object* parent) :
+ Object("Rules", parent, 0)
{
*this = rules;
}
-Rules::Rules(const QDomElement& xml, const Pokemod* pokemod) :
- Object("Rules", pokemod, 0)
+Rules::Rules(const QDomElement& xml, const Object* parent) :
+ Object("Rules", parent, 0)
{
load(xml);
}
bool Rules::validate() const
{
- bool valid = true;
- pokemod()->validationMsg("---Rules", Pokemod::V_Msg);
- if (!m_numBoxes)
- pokemod()->validationMsg("No box storage", Pokemod::V_Warn);
- else if (!m_boxSize)
- {
- pokemod()->validationMsg("Invalid box size");
- valid = false;
- }
- if (!m_maxParty)
- {
- pokemod()->validationMsg("Invalid party size");
- valid = false;
- }
- if (!m_maxParty || (m_maxParty < m_maxFight))
- {
- pokemod()->validationMsg("Larger active than party");
- valid = false;
- }
- if (m_maxPlayers < 2)
- {
- pokemod()->validationMsg("Cannot have battles without at least two players");
- valid = false;
- }
- if (!m_maxMoves)
- {
- pokemod()->validationMsg("No moves can be learned");
- valid = false;
- }
- if (!m_maxMoney)
- pokemod()->validationMsg("Player cannot carry any money", Pokemod::V_Warn);
- if (1 < m_maxDVValue)
- {
- pokemod()->validationMsg("Invalid maximum DV value");
- valid = false;
- }
- if (m_effortValuesAllowed)
- {
- if (m_maxTotalEV < m_maxEVPerStat)
- {
- pokemod()->validationMsg("More EV points are allowed on a stat than allowed overall");
- valid = false;
- }
- }
- if (.005 < m_pokerusChance)
- pokemod()->validationMsg("Pokérus chance is unusually high", Pokemod::V_Warn);
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg("---Rules", Pokemod::V_Msg);
+// if (!m_numBoxes)
+// static_cast<const Pokemod*>(pokemod())->validationMsg("No box storage", Pokemod::V_Warn);
+// else if (!m_boxSize)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid box size");
+// valid = false;
+// }
+// if (!m_maxParty)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid party size");
+// valid = false;
+// }
+// if (!m_maxParty || (m_maxParty < m_maxFight))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Larger active than party");
+// valid = false;
+// }
+// if (m_maxPlayers < 2)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Cannot have battles without at least two players");
+// valid = false;
+// }
+// if (!m_maxMoves)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("No moves can be learned");
+// valid = false;
+// }
+// if (!m_maxMoney)
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Player cannot carry any money", Pokemod::V_Warn);
+// if (1 < m_maxDVValue)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid maximum DV value");
+// valid = false;
+// }
+// if (m_effortValuesAllowed)
+// {
+// if (m_maxTotalEV < m_maxEVPerStat)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("More EV points are allowed on a stat than allowed overall");
+// valid = false;
+// }
+// }
+// if (.005 < m_pokerusChance)
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Pokérus chance is unusually high", Pokemod::V_Warn);
+// return valid;
}
void Rules::load(const QDomElement& xml, const int) throw(Exception)
diff --git a/pokemod/Rules.h b/pokemod/Rules.h
index 44b9f65d..7733d11c 100644
--- a/pokemod/Rules.h
+++ b/pokemod/Rules.h
@@ -18,18 +18,15 @@
#ifndef __POKEMOD_RULES__
#define __POKEMOD_RULES__
-// Qt includes
-#include <QString>
-
-// General includes
-#include <Exception.h>
-#include <Fraction.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+#include "../general/Fraction.h"
+
+// Qt includes
+#include <QString>
class Rules : public Object
{
@@ -37,9 +34,9 @@ class Rules : public Object
static const QStringList DVStr;
Rules(const Rules& rules);
- Rules(const Pokemod* pokemod);
- Rules(const Rules& rules, const Pokemod* pokemod);
- Rules(const QDomElement& xml, const Pokemod* pokemod);
+ Rules(const Object* parent);
+ Rules(const Rules& rules, const Object* parent);
+ Rules(const QDomElement& xml, const Object* parent);
void load(const QDomElement& xml, const int = 0) throw(Exception);
QDomElement save() const;
diff --git a/pokemod/Species.cpp b/pokemod/Species.cpp
index 21857808..e6c2f0c3 100644
--- a/pokemod/Species.cpp
+++ b/pokemod/Species.cpp
@@ -15,30 +15,30 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QBuffer>
-#include <QMap>
+// Header include
+#include "Species.h"
// Pokemod includes
-#include "Pokemod.h"
#include "SpeciesAbility.h"
#include "SpeciesEvolution.h"
#include "SpeciesItem.h"
#include "SpeciesMove.h"
+#include "Pokemod.h"
-// Header include
-#include "Species.h"
+// Qt includes
+#include <QBuffer>
+#include <QMap>
const QStringList Species::StyleStr = QStringList() << "Fluctuating" << "Fading" << "Slow" << "Normal" << "Fast" << "Erratic";
Species::Species(const Species& species) :
- Object("Species", species.pokemod(), species.id())
+ Object("Species", species.parent(), species.id())
{
*this = species;
}
-Species::Species(const Pokemod* pokemod, const int id) :
- Object("Species", pokemod, id),
+Species::Species(const Object* parent, const int id) :
+ Object("Species", parent, id),
m_name(""),
m_growth(INT_MAX),
m_catchValue(0),
@@ -67,14 +67,14 @@ Species::Species(const Pokemod* pokemod, const int id) :
}
}
-Species::Species(const Species& species, const Pokemod* pokemod, const int id) :
- Object("Species", pokemod, id)
+Species::Species(const Species& species, const Object* parent, const int id) :
+ Object("Species", parent, id)
{
*this = species;
}
-Species::Species(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Species", pokemod, id)
+Species::Species(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Species", parent, id)
{
load(xml, id);
}
@@ -86,145 +86,146 @@ Species::~Species()
bool Species::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Species \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- for (int i = 0; i < (pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY); ++i)
- {
- if (!m_baseStat[i])
- {
- pokemod()->validationMsg(QString("Invalid baseStats[%1]").arg(i));
- valid = false;
- }
- }
- if (End <= m_growth)
- {
- pokemod()->validationMsg("Invalid growth style");
- valid = false;
- }
- if (!m_weight)
- pokemod()->validationMsg("Species weighs nothing", Pokemod::V_Warn);
- if (12 <= m_heightInches)
- {
- pokemod()->validationMsg("Invalid height inches");
- valid = false;
- }
- if (pokemod()->speciesIndex(m_eggSpecies) == INT_MAX)
- pokemod()->validationMsg("Invalid egg species", Pokemod::V_Warn);
- else
- {
- if (pokemod()->species(m_eggSpecies)->growth() != m_growth)
- {
- pokemod()->validationMsg("Growth styles do not match for egg species");
- valid = false;
- }
- if (!m_eggSteps)
- {
- pokemod()->validationMsg("Invalid egg steps");
- valid = false;
- }
- }
- QMap<int, bool> idChecker;
- QMap<int, bool> valueChecker;
- foreach (int type, m_types)
- {
- if (pokemod()->typeIndex(type) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid type");
- valid = false;
- }
- if (valueChecker[type])
- pokemod()->validationMsg(QString("Duplicate of type %1").arg(type));
- valueChecker[type] = true;
- }
- valueChecker.clear();
- foreach (int eggGroup, m_eggGroups)
- {
- if (pokemod()->eggGroupIndex(eggGroup) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid egg group");
- valid = false;
- }
- if (valueChecker[eggGroup])
- pokemod()->validationMsg(QString("Duplicate of egg group %1").arg(eggGroup));
- valueChecker[eggGroup] = true;
- }
- valueChecker.clear();
- if (pokemod()->rules()->abilityAllowed())
- {
- if (!abilityCount())
- pokemod()->validationMsg("There are no m_abilities", Pokemod::V_Warn);
- foreach (SpeciesAbility* ability, m_abilities)
- {
- if (!ability->isValid())
- valid = false;
- if (idChecker[ability->id()])
- pokemod()->validationMsg(QString("Duplicate ability with id %1").arg(ability->id()));
- idChecker[ability->id()] = true;
- if (valueChecker[ability->ability()])
- pokemod()->validationMsg(QString("Duplicate of ability %1").arg(ability->ability()));
- valueChecker[ability->ability()] = true;
- }
- idChecker.clear();
- valueChecker.clear();
- }
- if (!evolutionCount())
- pokemod()->validationMsg("There are no m_evolutions", Pokemod::V_Warn);
- foreach (SpeciesEvolution* evolution, m_evolutions)
- {
- if (!evolution->isValid())
- valid = false;
- if (evolution->species() == id())
- {
- pokemod()->validationMsg("Evolution is of the same species");
- valid = false;
- }
- if (pokemod()->species(evolution->species())->growth() != m_growth)
- {
- pokemod()->validationMsg("Growth styles do not match for m_evolutions");
- valid = false;
- }
- if (idChecker[evolution->id()])
- pokemod()->validationMsg(QString("Duplicate evolution with id %1").arg(evolution->id()));
- idChecker[evolution->id()] = true;
- }
- idChecker.clear();
- if (pokemod()->rules()->holdItems())
- {
- if (!itemCount())
- pokemod()->validationMsg("There are no m_items", Pokemod::V_Warn);
- foreach (SpeciesItem* item, m_items)
- {
- if (!item->isValid())
- valid = false;
- if (idChecker[item->id()])
- pokemod()->validationMsg(QString("Duplicate item with id %1").arg(item->id()));
- idChecker[item->id()] = true;
- if (valueChecker[item->item()])
- pokemod()->validationMsg(QString("Duplicate of item %1").arg(item->item()));
- valueChecker[item->item()] = true;
- }
- idChecker.clear();
- valueChecker.clear();
- }
- if (!moveCount())
- {
- pokemod()->validationMsg("There are no m_moves");
- valid = false;
- }
- foreach (SpeciesMove* move, m_moves)
- {
- if (!move->isValid())
- valid = false;
- if (idChecker[move->id()])
- pokemod()->validationMsg(QString("Duplicate move with id %1").arg(move->id()));
- idChecker[move->id()] = true;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Species \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// for (int i = 0; i < (static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY); ++i)
+// {
+// if (!m_baseStat[i])
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Invalid baseStats[%1]").arg(i));
+// valid = false;
+// }
+// }
+// if (End <= m_growth)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid growth style");
+// valid = false;
+// }
+// if (!m_weight)
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Species weighs nothing", Pokemod::V_Warn);
+// if (12 <= m_heightInches)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid height inches");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->speciesIndex(m_eggSpecies) == INT_MAX)
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid egg species", Pokemod::V_Warn);
+// else
+// {
+// if (static_cast<const Pokemod*>(pokemod())->species(m_eggSpecies)->growth() != m_growth)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Growth styles do not match for egg species");
+// valid = false;
+// }
+// if (!m_eggSteps)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid egg steps");
+// valid = false;
+// }
+// }
+// QMap<int, bool> idChecker;
+// QMap<int, bool> valueChecker;
+// foreach (int type, m_types)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->typeIndex(type) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid type");
+// valid = false;
+// }
+// if (valueChecker[type])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of type %1").arg(type));
+// valueChecker[type] = true;
+// }
+// valueChecker.clear();
+// foreach (int eggGroup, m_eggGroups)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->eggGroupIndex(eggGroup) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid egg group");
+// valid = false;
+// }
+// if (valueChecker[eggGroup])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of egg group %1").arg(eggGroup));
+// valueChecker[eggGroup] = true;
+// }
+// valueChecker.clear();
+// if (static_cast<const Pokemod*>(pokemod())->rules()->abilityAllowed())
+// {
+// if (!abilityCount())
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no m_abilities", Pokemod::V_Warn);
+// foreach (SpeciesAbility* ability, m_abilities)
+// {
+// if (!ability->isValid())
+// valid = false;
+// if (idChecker[ability->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate ability with id %1").arg(ability->id()));
+// idChecker[ability->id()] = true;
+// if (valueChecker[ability->ability()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of ability %1").arg(ability->ability()));
+// valueChecker[ability->ability()] = true;
+// }
+// idChecker.clear();
+// valueChecker.clear();
+// }
+// if (!evolutionCount())
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no m_evolutions", Pokemod::V_Warn);
+// foreach (SpeciesEvolution* evolution, m_evolutions)
+// {
+// if (!evolution->isValid())
+// valid = false;
+// if (evolution->species() == id())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Evolution is of the same species");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->species(evolution->species())->growth() != m_growth)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Growth styles do not match for m_evolutions");
+// valid = false;
+// }
+// if (idChecker[evolution->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate evolution with id %1").arg(evolution->id()));
+// idChecker[evolution->id()] = true;
+// }
+// idChecker.clear();
+// if (static_cast<const Pokemod*>(pokemod())->rules()->holdItems())
+// {
+// if (!itemCount())
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no m_items", Pokemod::V_Warn);
+// foreach (SpeciesItem* item, m_items)
+// {
+// if (!item->isValid())
+// valid = false;
+// if (idChecker[item->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate item with id %1").arg(item->id()));
+// idChecker[item->id()] = true;
+// if (valueChecker[item->item()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of item %1").arg(item->item()));
+// valueChecker[item->item()] = true;
+// }
+// idChecker.clear();
+// valueChecker.clear();
+// }
+// if (!moveCount())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no m_moves");
+// valid = false;
+// }
+// foreach (SpeciesMove* move, m_moves)
+// {
+// if (!move->isValid())
+// valid = false;
+// if (idChecker[move->id()])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate move with id %1").arg(move->id()));
+// idChecker[move->id()] = true;
+// }
+// return valid;
}
void Species::load(const QDomElement& xml, int id)
@@ -293,18 +294,18 @@ void Species::setName(const QString& name)
void Species::setBaseStat(const int stat, const int baseStat) throw(BoundsException)
{
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
+ if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
error<BoundsException>("stat");
m_baseStat[stat] = baseStat;
}
void Species::setEffortValue(const int stat, const int effortValue) throw(Exception)
{
- if (!pokemod()->rules()->effortValuesAllowed())
+ if (!static_cast<const Pokemod*>(pokemod())->rules()->effortValuesAllowed())
throw(Exception(className(), "effortValues not allowed"));
- if (pokemod()->rules()->maxEVPerStat() < effortValue)
+ if (static_cast<const Pokemod*>(pokemod())->rules()->maxEVPerStat() < effortValue)
error<BoundsException>("effortValue");
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
+ if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
error<BoundsException>("stat");
m_effortValue[stat] = effortValue;
}
@@ -396,7 +397,7 @@ void Species::setBackMaleSprite(const QPixmap& backMaleSprite) throw(Exception)
void Species::setFrontFemaleSprite(const QPixmap& frontFemaleSprite) throw(Exception)
{
- if (!pokemod()->rules()->genderAllowed())
+ if (!static_cast<const Pokemod*>(pokemod())->rules()->genderAllowed())
throw(Exception(className(), "gender is not allowed"));
if (!m_genderFactor.numerator())
error<Exception>("cannot be female");
@@ -407,7 +408,7 @@ void Species::setFrontFemaleSprite(const QPixmap& frontFemaleSprite) throw(Excep
void Species::setBackFemaleSprite(const QPixmap& backFemaleSprite) throw(Exception)
{
- if (!pokemod()->rules()->genderAllowed())
+ if (!static_cast<const Pokemod*>(pokemod())->rules()->genderAllowed())
throw(Exception(className(), "gender is not allowed"));
if (!m_genderFactor.numerator())
error<Exception>("cannot be female");
@@ -432,7 +433,7 @@ void Species::setGenderFactor(const Fraction& genderFactor) throw(BoundsExceptio
void Species::setEggSpecies(const int eggSpecies) throw(BoundsException)
{
- if (pokemod()->speciesIndex(eggSpecies) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->speciesIndex(eggSpecies) == INT_MAX)
error<BoundsException>("eggSpecies");
m_eggSpecies = eggSpecies;
}
@@ -449,7 +450,7 @@ void Species::setNidoranGroup(const int nidoranGroup)
void Species::setType(const int type, const bool state) throw(Exception)
{
- if (pokemod()->typeIndex(type) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->typeIndex(type) == INT_MAX)
error<BoundsException>("type");
if (state)
{
@@ -462,7 +463,7 @@ void Species::setType(const int type, const bool state) throw(Exception)
void Species::setEggGroup(const int eggGroup, const bool state) throw(Exception)
{
- if (pokemod()->eggGroupIndex(eggGroup) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->eggGroupIndex(eggGroup) == INT_MAX)
error<BoundsException>("eggGroup");
if (state)
{
@@ -643,19 +644,19 @@ int Species::abilityCount() const
SpeciesAbility* Species::newAbility()
{
- m_abilities.append(new SpeciesAbility(pokemod(), newAbilityId()));
+ m_abilities.append(new SpeciesAbility(this, newAbilityId()));
return m_abilities[abilityCount() - 1];
}
SpeciesAbility* Species::newAbility(const QDomElement& xml)
{
- m_abilities.append(new SpeciesAbility(xml, pokemod(), newAbilityId()));
+ m_abilities.append(new SpeciesAbility(xml, this, newAbilityId()));
return m_abilities[abilityCount() - 1];
}
SpeciesAbility* Species::newAbility(const SpeciesAbility& ability)
{
- m_abilities.append(new SpeciesAbility(ability, pokemod(), newAbilityId()));
+ m_abilities.append(new SpeciesAbility(ability, this, newAbilityId()));
return m_abilities[abilityCount() - 1];
}
@@ -721,19 +722,19 @@ int Species::evolutionCount() const
SpeciesEvolution* Species::newEvolution()
{
- m_evolutions.append(new SpeciesEvolution(pokemod(), newEvolutionId()));
+ m_evolutions.append(new SpeciesEvolution(this, newEvolutionId()));
return m_evolutions[evolutionCount() - 1];
}
SpeciesEvolution* Species::newEvolution(const QDomElement& xml)
{
- m_evolutions.append(new SpeciesEvolution(xml, pokemod(), newEvolutionId()));
+ m_evolutions.append(new SpeciesEvolution(xml, this, newEvolutionId()));
return m_evolutions[evolutionCount() - 1];
}
SpeciesEvolution* Species::newEvolution(const SpeciesEvolution& evolution)
{
- m_evolutions.append(new SpeciesEvolution(evolution, pokemod(), newEvolutionId()));
+ m_evolutions.append(new SpeciesEvolution(evolution, this, newEvolutionId()));
return m_evolutions[evolutionCount() - 1];
}
@@ -799,19 +800,19 @@ int Species::itemCount() const
SpeciesItem* Species::newItem()
{
- m_items.append(new SpeciesItem(pokemod(), newItemId()));
+ m_items.append(new SpeciesItem(this, newItemId()));
return m_items[itemCount() - 1];
}
SpeciesItem* Species::newItem(const QDomElement& xml)
{
- m_items.append(new SpeciesItem(xml, pokemod(), newItemId()));
+ m_items.append(new SpeciesItem(xml, this, newItemId()));
return m_items[itemCount() - 1];
}
SpeciesItem* Species::newItem(const SpeciesItem& item)
{
- m_items.append(new SpeciesItem(item, pokemod(), newItemId()));
+ m_items.append(new SpeciesItem(item, this, newItemId()));
return m_items[itemCount() - 1];
}
@@ -877,19 +878,19 @@ int Species::moveCount() const
SpeciesMove* Species::newMove()
{
- m_moves.append(new SpeciesMove(pokemod(), newMoveId()));
+ m_moves.append(new SpeciesMove(this, newMoveId()));
return m_moves[moveCount() - 1];
}
SpeciesMove* Species::newMove(const QDomElement& xml)
{
- m_moves.append(new SpeciesMove(xml, pokemod(), newMoveId()));
+ m_moves.append(new SpeciesMove(xml, this, newMoveId()));
return m_moves[moveCount() - 1];
}
SpeciesMove* Species::newMove(const SpeciesMove& move)
{
- m_moves.append(new SpeciesMove(move, pokemod(), newMoveId()));
+ m_moves.append(new SpeciesMove(move, this, newMoveId()));
return m_moves[moveCount() - 1];
}
diff --git a/pokemod/Species.h b/pokemod/Species.h
index 930de7ab..c36ec148 100644
--- a/pokemod/Species.h
+++ b/pokemod/Species.h
@@ -18,19 +18,18 @@
#ifndef __POKEMOD_SPECIES__
#define __POKEMOD_SPECIES__
-// Qt includes
-#include <QList>
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-#include <Fraction.h>
-
// Pokemod includes
#include "Object.h"
#include "Pokemod.h"
+// General includes
+#include "../general/Exception.h"
+#include "../general/Fraction.h"
+
+// Qt includes
+#include <QList>
+#include <QString>
+
// Forward declarations
class SpeciesAbility;
class SpeciesEvolution;
@@ -53,9 +52,9 @@ class Species : public Object
static const QStringList StyleStr;
Species(const Species& species);
- Species(const Pokemod* pokemod, const int id);
- Species(const Species& species, const Pokemod* pokemod, const int id);
- Species(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Species(const Object* parent, const int id);
+ Species(const Species& species, const Object* parent, const int id);
+ Species(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
~Species();
void load(const QDomElement& xml, int id = INT_MAX);
diff --git a/pokemod/SpeciesAbility.cpp b/pokemod/SpeciesAbility.cpp
index 488c2d62..b1c26740 100644
--- a/pokemod/SpeciesAbility.cpp
+++ b/pokemod/SpeciesAbility.cpp
@@ -15,52 +15,53 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include "Pokemod.h"
-
// Header include
#include "SpeciesAbility.h"
+// Pokemod includes
+#include "Pokemod.h"
+
SpeciesAbility::SpeciesAbility(const SpeciesAbility& ability) :
- Object("SpeciesAbility", ability.pokemod(), ability.id())
+ Object("SpeciesAbility", ability.parent(), ability.id())
{
*this = ability;
}
-SpeciesAbility::SpeciesAbility(const Pokemod* pokemod, const int id) :
- Object("SpeciesAbility", pokemod, id),
+SpeciesAbility::SpeciesAbility(const Object* parent, const int id) :
+ Object("SpeciesAbility", parent, id),
m_ability(INT_MAX),
m_weight(1)
{
}
-SpeciesAbility::SpeciesAbility(const SpeciesAbility& ability, const Pokemod* pokemod, const int id) :
- Object("SpeciesAbility", pokemod, id)
+SpeciesAbility::SpeciesAbility(const SpeciesAbility& ability, const Object* parent, const int id) :
+ Object("SpeciesAbility", parent, id)
{
*this = ability;
}
-SpeciesAbility::SpeciesAbility(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("SpeciesAbility", pokemod, id)
+SpeciesAbility::SpeciesAbility(const QDomElement& xml, const Object* parent, const int id) :
+ Object("SpeciesAbility", parent, id)
{
load(xml, id);
}
bool SpeciesAbility::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Ability with id %1---").arg(id()), Pokemod::V_Msg);
- if (pokemod()->abilityIndex(m_ability) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid ability");
- valid = false;
- }
- if (!m_weight)
- {
- pokemod()->validationMsg("Invalid weight");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Ability with id %1---").arg(id()), Pokemod::V_Msg);
+// if (static_cast<const Pokemod*>(pokemod())->abilityIndex(m_ability) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid ability");
+// valid = false;
+// }
+// if (!m_weight)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid weight");
+// valid = false;
+// }
+// return valid;
}
void SpeciesAbility::load(const QDomElement& xml, int id)
@@ -80,7 +81,7 @@ QDomElement SpeciesAbility::save() const
void SpeciesAbility::setAbility(const int ability) throw(BoundsException)
{
- if (pokemod()->abilityIndex(ability) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->abilityIndex(ability) == INT_MAX)
error<BoundsException>("ability");
m_ability = ability;
}
diff --git a/pokemod/SpeciesAbility.h b/pokemod/SpeciesAbility.h
index 35830fbe..ffd856f9 100644
--- a/pokemod/SpeciesAbility.h
+++ b/pokemod/SpeciesAbility.h
@@ -18,25 +18,22 @@
#ifndef __POKEMOD_SPECIESABILITY__
#define __POKEMOD_SPECIESABILITY__
-// Qt includes
-#include <QString>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
// General includes
-class Pokemod;
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QString>
class SpeciesAbility : public Object
{
public:
SpeciesAbility(const SpeciesAbility& ability);
- SpeciesAbility(const Pokemod* pokemod, const int id);
- SpeciesAbility(const SpeciesAbility& ability, const Pokemod* pokemod, const int id);
- SpeciesAbility(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ SpeciesAbility(const Object* parent, const int id);
+ SpeciesAbility(const SpeciesAbility& ability, const Object* parent, const int id);
+ SpeciesAbility(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/SpeciesEvolution.cpp b/pokemod/SpeciesEvolution.cpp
index 77ab032e..540c3302 100644
--- a/pokemod/SpeciesEvolution.cpp
+++ b/pokemod/SpeciesEvolution.cpp
@@ -15,25 +15,25 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Header include
+#include "SpeciesEvolution.h"
+
// Pokemod includes
-#include "Pokemod.h"
#include "Item.h"
#include "ItemEffect.h"
-
-// Header include
-#include "SpeciesEvolution.h"
+#include "Pokemod.h"
const QStringList SpeciesEvolution::StyleStr = QStringList() << "Level" << "Happiness" << "Stat" << "Item" << "Trade" << "TradeItem" << "Personality" << "Spare Slot";
const QStringList SpeciesEvolution::GiveHoldStr = QStringList() <<"Give" << "Hold";
SpeciesEvolution::SpeciesEvolution(const SpeciesEvolution& evolution) :
- Object("SpeciesEvolution", evolution.pokemod(), evolution.id())
+ Object("SpeciesEvolution", evolution.parent(), evolution.id())
{
*this = evolution;
}
-SpeciesEvolution::SpeciesEvolution(const Pokemod* pokemod, const int id) :
- Object("SpeciesEvolution", pokemod, id),
+SpeciesEvolution::SpeciesEvolution(const Object* parent, const int id) :
+ Object("SpeciesEvolution", parent, id),
m_species(INT_MAX),
m_style(INT_MAX),
m_value1(INT_MAX),
@@ -43,83 +43,84 @@ SpeciesEvolution::SpeciesEvolution(const Pokemod* pokemod, const int id) :
{
}
-SpeciesEvolution::SpeciesEvolution(const SpeciesEvolution& evolution, const Pokemod* pokemod, const int id) :
- Object("SpeciesEvolution", pokemod, id)
+SpeciesEvolution::SpeciesEvolution(const SpeciesEvolution& evolution, const Object* parent, const int id) :
+ Object("SpeciesEvolution", parent, id)
{
*this = evolution;
}
-SpeciesEvolution::SpeciesEvolution(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("SpeciesEvolution", pokemod, id)
+SpeciesEvolution::SpeciesEvolution(const QDomElement& xml, const Object* parent, const int id) :
+ Object("SpeciesEvolution", parent, id)
{
load(xml, id);
}
bool SpeciesEvolution::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Evolution with id %1---").arg(id()), Pokemod::V_Msg);
- if (pokemod()->speciesIndex(m_species) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid species");
- valid = false;
- }
- if (m_style < S_End)
- {
- bool ok = true;
- switch (m_style)
- {
- case S_Happiness:
- case S_Stat:
- case S_Personality:
- if (Pokemod::REL_End <= m_value1)
- ok = false;
- break;
- case S_Item:
- case S_TradeItem:
- if (pokemod()->itemIndex(m_value1) == INT_MAX)
- ok = false;
- else
- {
- for (int i = 0; (i < pokemod()->itemById(m_value1)->effectCount()) && !ok; ++i)
- ok = (pokemod()->itemById(m_value1)->effect(i)->effect() == ItemEffect::E_Evolution);
- }
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid m_value1");
- valid = false;
- ok = true;
- }
- switch (m_style)
- {
- case S_Stat:
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= m_value2)
- ok = false;
- case S_Item:
- if ((G_End <= m_value2) || ((m_value2 == G_Hold) && !pokemod()->rules()->holdItems()))
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid m_value2");
- valid = false;
- ok = true;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid style");
- valid = false;
- }
- if (pokemod()->rules()->maxLevel() <= m_level)
- {
- pokemod()->validationMsg("Invalid level");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Evolution with id %1---").arg(id()), Pokemod::V_Msg);
+// if (static_cast<const Pokemod*>(pokemod())->speciesIndex(m_species) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid species");
+// valid = false;
+// }
+// if (m_style < S_End)
+// {
+// bool ok = true;
+// switch (m_style)
+// {
+// case S_Happiness:
+// case S_Stat:
+// case S_Personality:
+// if (Pokemod::REL_End <= m_value1)
+// ok = false;
+// break;
+// case S_Item:
+// case S_TradeItem:
+// if (static_cast<const Pokemod*>(pokemod())->itemIndex(m_value1) == INT_MAX)
+// ok = false;
+// else
+// {
+// for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemById(m_value1)->effectCount()) && !ok; ++i)
+// ok = (static_cast<const Pokemod*>(pokemod())->itemById(m_value1)->effect(i)->effect() == ItemEffect::E_Evolution);
+// }
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid m_value1");
+// valid = false;
+// ok = true;
+// }
+// switch (m_style)
+// {
+// case S_Stat:
+// if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= m_value2)
+// ok = false;
+// case S_Item:
+// if ((G_End <= m_value2) || ((m_value2 == G_Hold) && !static_cast<const Pokemod*>(pokemod())->rules()->holdItems()))
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid m_value2");
+// valid = false;
+// ok = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid style");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() <= m_level)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid level");
+// valid = false;
+// }
+// return valid;
}
void SpeciesEvolution::load(const QDomElement& xml, int id)
@@ -147,7 +148,7 @@ QDomElement SpeciesEvolution::save() const
void SpeciesEvolution::setSpecies(const int species) throw(BoundsException)
{
- if (pokemod()->speciesIndex(species) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->speciesIndex(species) == INT_MAX)
error<BoundsException>("species");
m_species = species;
}
@@ -172,10 +173,10 @@ void SpeciesEvolution::setValue1(const int value1) throw(Exception)
break;
case S_Item:
case S_TradeItem:
- if (pokemod()->itemIndex(value1) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->itemIndex(value1) == INT_MAX)
error<BoundsException>("value1");
- for (int i = 0; (i < pokemod()->itemById(value1)->effectCount()) && !ok; ++i)
- ok = (pokemod()->itemById(value1)->effect(i)->effect() == ItemEffect::E_Evolution);
+ for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemById(value1)->effectCount()) && !ok; ++i)
+ ok = (static_cast<const Pokemod*>(pokemod())->itemById(value1)->effect(i)->effect() == ItemEffect::E_Evolution);
if (!ok)
error<BoundsException>("value1");
break;
@@ -191,10 +192,10 @@ void SpeciesEvolution::setValue2(const int value2) throw(Exception)
switch (m_style)
{
case S_Stat:
- if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= value2)
+ if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= value2)
error<BoundsException>("value2");
case S_Item:
- if ((G_End <= value2) || ((value2 == G_Hold) && !pokemod()->rules()->holdItems()))
+ if ((G_End <= value2) || ((value2 == G_Hold) && !static_cast<const Pokemod*>(pokemod())->rules()->holdItems()))
error<BoundsException>("value2");
break;
default:
@@ -221,7 +222,7 @@ void SpeciesEvolution::setValue3(const int value3) throw(UnusedException)
void SpeciesEvolution::setLevel(const int level) throw(BoundsException)
{
- if (pokemod()->rules()->maxLevel() < level)
+ if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() < level)
error<BoundsException>("level");
m_level = level;
}
diff --git a/pokemod/SpeciesEvolution.h b/pokemod/SpeciesEvolution.h
index 47683139..6cd9a5a3 100644
--- a/pokemod/SpeciesEvolution.h
+++ b/pokemod/SpeciesEvolution.h
@@ -18,18 +18,14 @@
#ifndef __POKEMOD_SPECIESEVOLUTION__
#define __POKEMOD_SPECIESEVOLUTION__
-// Qt includes
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QString>
class SpeciesEvolution : public Object
{
@@ -57,9 +53,9 @@ class SpeciesEvolution : public Object
static const QStringList GiveHoldStr;
SpeciesEvolution(const SpeciesEvolution& evolution);
- SpeciesEvolution(const Pokemod* pokemod, const int id);
- SpeciesEvolution(const SpeciesEvolution& evolution, const Pokemod* pokemod, const int id);
- SpeciesEvolution(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ SpeciesEvolution(const Object* parent, const int id);
+ SpeciesEvolution(const SpeciesEvolution& evolution, const Object* parent, const int id);
+ SpeciesEvolution(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/SpeciesItem.cpp b/pokemod/SpeciesItem.cpp
index fc263ca0..0cadaad4 100644
--- a/pokemod/SpeciesItem.cpp
+++ b/pokemod/SpeciesItem.cpp
@@ -15,52 +15,53 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include "Pokemod.h"
-
// Header include
#include "SpeciesItem.h"
+// Pokemod includes
+#include "Pokemod.h"
+
SpeciesItem::SpeciesItem(const SpeciesItem& item) :
- Object("SpeciesItem", item.pokemod(), item.id())
+ Object("SpeciesItem", item.parent(), item.id())
{
*this = item;
}
-SpeciesItem::SpeciesItem(const Pokemod* pokemod, const int id) :
- Object("SpeciesItem", pokemod, id),
+SpeciesItem::SpeciesItem(const Object* parent, const int id) :
+ Object("SpeciesItem", parent, id),
m_item(INT_MAX),
m_weight(1)
{
}
-SpeciesItem::SpeciesItem(const SpeciesItem& item, const Pokemod* pokemod, const int id) :
- Object("SpeciesItem", pokemod, id)
+SpeciesItem::SpeciesItem(const SpeciesItem& item, const Object* parent, const int id) :
+ Object("SpeciesItem", parent, id)
{
*this = item;
}
-SpeciesItem::SpeciesItem(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("SpeciesItem", pokemod, id)
+SpeciesItem::SpeciesItem(const QDomElement& xml, const Object* parent, const int id) :
+ Object("SpeciesItem", parent, id)
{
load(xml, id);
}
bool SpeciesItem::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Item with id %1---").arg(id()), Pokemod::V_Msg);
- if (pokemod()->itemIndex(m_item) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid item");
- valid = false;
- }
- if (!m_weight)
- {
- pokemod()->validationMsg("Invalid weight");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Item with id %1---").arg(id()), Pokemod::V_Msg);
+// if (static_cast<const Pokemod*>(pokemod())->itemIndex(m_item) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid item");
+// valid = false;
+// }
+// if (!m_weight)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid weight");
+// valid = false;
+// }
+// return valid;
}
void SpeciesItem::load(const QDomElement& xml, int id)
@@ -80,7 +81,7 @@ QDomElement SpeciesItem::save() const
void SpeciesItem::setItem(const int item) throw(BoundsException)
{
- if (pokemod()->itemIndex(item) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX)
error<BoundsException>("item");
m_item = item;
}
diff --git a/pokemod/SpeciesItem.h b/pokemod/SpeciesItem.h
index d858e3e0..f84808e9 100644
--- a/pokemod/SpeciesItem.h
+++ b/pokemod/SpeciesItem.h
@@ -18,25 +18,22 @@
#ifndef __POKEMOD_SPECIESITEM__
#define __POKEMOD_SPECIESITEM__
-// Qt includes
-#include <QString>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QString>
class SpeciesItem : public Object
{
public:
SpeciesItem(const SpeciesItem& item);
- SpeciesItem(const Pokemod* pokemod, const int id);
- SpeciesItem(const SpeciesItem& item, const Pokemod* pokemod, const int id);
- SpeciesItem(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ SpeciesItem(const Object* parent, const int id);
+ SpeciesItem(const SpeciesItem& item, const Object* parent, const int id);
+ SpeciesItem(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/SpeciesMove.cpp b/pokemod/SpeciesMove.cpp
index 65d952e5..79f2db12 100644
--- a/pokemod/SpeciesMove.cpp
+++ b/pokemod/SpeciesMove.cpp
@@ -15,58 +15,59 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include "Pokemod.h"
-
// Header include
#include "SpeciesMove.h"
+// Pokemod includes
+#include "Pokemod.h"
+
SpeciesMove::SpeciesMove(const SpeciesMove& move) :
- Object("SpeciesMove", move.pokemod(), move.id())
+ Object("SpeciesMove", move.parent(), move.id())
{
*this = move;
}
-SpeciesMove::SpeciesMove(const Pokemod* pokemod, const int id) :
- Object("SpeciesMove", pokemod, id),
+SpeciesMove::SpeciesMove(const Object* parent, const int id) :
+ Object("SpeciesMove", parent, id),
m_move(INT_MAX),
m_level(0),
m_wild(0)
{
}
-SpeciesMove::SpeciesMove(const SpeciesMove& move, const Pokemod* pokemod, const int id) :
- Object("SpeciesMove", pokemod, id)
+SpeciesMove::SpeciesMove(const SpeciesMove& move, const Object* parent, const int id) :
+ Object("SpeciesMove", parent, id)
{
*this = move;
}
-SpeciesMove::SpeciesMove(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("SpeciesMove", pokemod, id)
+SpeciesMove::SpeciesMove(const QDomElement& xml, const Object* parent, const int id) :
+ Object("SpeciesMove", parent, id)
{
load(xml, id);
}
bool SpeciesMove::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Move with id %1---").arg(id()), Pokemod::V_Msg);
- if (pokemod()->moveIndex(m_move) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid move");
- valid = false;
- }
- if (m_level < pokemod()->rules()->maxLevel())
- {
- pokemod()->validationMsg("Invalid level");
- valid = false;
- }
- if (m_wild < pokemod()->rules()->maxLevel())
- {
- pokemod()->validationMsg("Invalid wild level");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Move with id %1---").arg(id()), Pokemod::V_Msg);
+// if (static_cast<const Pokemod*>(pokemod())->moveIndex(m_move) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid move");
+// valid = false;
+// }
+// if (m_level < static_cast<const Pokemod*>(pokemod())->rules()->maxLevel())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid level");
+// valid = false;
+// }
+// if (m_wild < static_cast<const Pokemod*>(pokemod())->rules()->maxLevel())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid wild level");
+// valid = false;
+// }
+// return valid;
}
void SpeciesMove::load(const QDomElement& xml, int id)
@@ -88,21 +89,21 @@ QDomElement SpeciesMove::save() const
void SpeciesMove::setMove(const int move) throw(BoundsException)
{
- if (pokemod()->moveIndex(move) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->moveIndex(move) == INT_MAX)
error<BoundsException>("move");
m_move = move;
}
void SpeciesMove::setLevel(const int level) throw(BoundsException)
{
- if (pokemod()->rules()->maxLevel() <= level)
+ if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() <= level)
error<BoundsException>("level");
m_level = level;
}
void SpeciesMove::setWild(const int wild) throw(BoundsException)
{
- if (pokemod()->rules()->maxLevel() <= wild)
+ if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() <= wild)
error<BoundsException>("wild");
m_wild = wild;
}
diff --git a/pokemod/SpeciesMove.h b/pokemod/SpeciesMove.h
index b257d757..0613a78a 100644
--- a/pokemod/SpeciesMove.h
+++ b/pokemod/SpeciesMove.h
@@ -18,25 +18,22 @@
#ifndef __POKEMOD_SPECIESMOVE__
#define __POKEMOD_SPECIESMOVE__
-// Qt includes
-#include <QString>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QString>
class SpeciesMove : public Object
{
public:
SpeciesMove(const SpeciesMove& move);
- SpeciesMove(const Pokemod* pokemod, const int id);
- SpeciesMove(const SpeciesMove& move, const Pokemod* pokemod, const int id);
- SpeciesMove(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ SpeciesMove(const Object* parent, const int id);
+ SpeciesMove(const SpeciesMove& move, const Object* parent, const int id);
+ SpeciesMove(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Store.cpp b/pokemod/Store.cpp
index 1edbca32..e8f1af69 100644
--- a/pokemod/Store.cpp
+++ b/pokemod/Store.cpp
@@ -15,66 +15,67 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
+// Header include
+#include "Store.h"
// Pokemod includes
#include "Pokemod.h"
-// Header include
-#include "Store.h"
+// Qt includes
+#include <QMap>
Store::Store(const Store& store) :
- Object("Store", store.pokemod(), store.id())
+ Object("Store", store.parent(), store.id())
{
*this = store;
}
-Store::Store(const Pokemod* pokemod, const int id) :
- Object("Store", pokemod, id),
+Store::Store(const Object* parent, const int id) :
+ Object("Store", parent, id),
m_name("")
{
}
-Store::Store(const Store& store, const Pokemod* pokemod, const int id) :
- Object("Store", pokemod, id)
+Store::Store(const Store& store, const Object* parent, const int id) :
+ Object("Store", parent, id)
{
*this = store;
}
-Store::Store(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Store", pokemod, id)
+Store::Store(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Store", parent, id)
{
load(xml, id);
}
bool Store::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Store \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is noe defiend");
- valid = false;
- }
- if (!m_items.size())
- {
- pokemod()->validationMsg("There are no items");
- valid = false;
- }
- QMap<int, bool> valueChecker;
- foreach (int item, m_items)
- {
- if (pokemod()->itemIndex(item) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid item");
- valid = false;
- }
- if (valueChecker[item])
- pokemod()->validationMsg(QString("Duplicate of item %1").arg(item));
- valueChecker[item] = true;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Store \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is noe defiend");
+// valid = false;
+// }
+// if (!m_items.size())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no items");
+// valid = false;
+// }
+// QMap<int, bool> valueChecker;
+// foreach (int item, m_items)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid item");
+// valid = false;
+// }
+// if (valueChecker[item])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of item %1").arg(item));
+// valueChecker[item] = true;
+// }
+// return valid;
}
void Store::load(const QDomElement& xml, int id)
@@ -97,7 +98,7 @@ void Store::setName(const QString& name)
void Store::setItem(const int item, const bool state) throw(BoundsException)
{
- if (pokemod()->itemIndex(item) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX)
error<BoundsException>("item");
if (state)
{
diff --git a/pokemod/Store.h b/pokemod/Store.h
index e3a234e6..6a6a05a5 100644
--- a/pokemod/Store.h
+++ b/pokemod/Store.h
@@ -18,26 +18,23 @@
#ifndef __POKEMOD_STORE__
#define __POKEMOD_STORE__
-// Qt includes
-#include <QList>
-#include <QString>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QList>
+#include <QString>
class Store : public Object
{
public:
Store(const Store& store);
- Store(const Pokemod* pokemod, const int id);
- Store(const Store& store, const Pokemod* pokemod, const int id);
- Store(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Store(const Object* parent, const int id);
+ Store(const Store& store, const Object* parent, const int id);
+ Store(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/TODO b/pokemod/TODO
index febfdb29..5db4e0e4 100644
--- a/pokemod/TODO
+++ b/pokemod/TODO
@@ -12,3 +12,5 @@ Test library
* Type
- Immune to weather
+
+Optimize header include (in headers)
diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp
index 833e7f78..c6e346cb 100644
--- a/pokemod/Tile.cpp
+++ b/pokemod/Tile.cpp
@@ -15,25 +15,25 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QBuffer>
+// Header include
+#include "Tile.h"
// Pokemod includes
#include "Pokemod.h"
-// Header include
-#include "Tile.h"
+// Qt includes
+#include <QBuffer>
const QStringList Tile::ForceStr = QStringList() << "Slip" << "Stop" << "Force" << "Push";
Tile::Tile(const Tile& tile) :
- Object("Tile", tile.pokemod(), tile.id())
+ Object("Tile", tile.parent(), tile.id())
{
*this = tile;
}
-Tile::Tile(const Pokemod* pokemod, const int id) :
- Object("Tile", pokemod, id),
+Tile::Tile(const Object* parent, const int id) :
+ Object("Tile", parent, id),
m_name(""),
m_sprite(64, 64),
m_wildChance(1, 1),
@@ -46,61 +46,62 @@ Tile::Tile(const Pokemod* pokemod, const int id) :
m_from[i] = false;
}
-Tile::Tile(const Tile& tile, const Pokemod* pokemod, const int id) :
- Object("Tile", pokemod, id)
+Tile::Tile(const Tile& tile, const Object* parent, const int id) :
+ Object("Tile", parent, id)
{
*this = tile;
}
-Tile::Tile(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Tile", pokemod, id)
+Tile::Tile(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Tile", parent, id)
{
load(xml, id);
}
bool Tile::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Tile \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- if ((m_hmType == Pokemod::HM_Waterfall) && (!m_from[Pokemod::D_Up] || !m_from[Pokemod::D_Down]))
- {
- pokemod()->validationMsg("A waterfall tile must be accessible from above and below");
- valid = false;
- }
- else if ((m_hmType == Pokemod::HM_Whirlpool) && ((m_under == id()) || (pokemod()->tileIndex(m_under) == INT_MAX) || (pokemod()->tileById(m_under)->hmType() != Pokemod::HM_Surf) || (pokemod()->tileById(m_under)->hmType() != Pokemod::HM_Dive)))
- {
- pokemod()->validationMsg("Invalid under tile");
- valid = false;
- }
- else if ((m_hmType == Pokemod::HM_Whirlpool) && ((m_under == id()) || (pokemod()->tileIndex(m_under) == INT_MAX) || (pokemod()->tileById(m_under)->hmType() != Pokemod::HM_End)))
- {
- pokemod()->validationMsg("Invalid under tile");
- valid = false;
- }
- else if ((m_hmType == Pokemod::HM_RockClimb) && (!m_from[Pokemod::D_Up] || !m_from[Pokemod::D_Down]))
- {
- pokemod()->validationMsg("A rock climb tile must be accessible from above and below");
- valid = false;
- }
- if (m_forceType < End)
- {
- if (((m_forceType == Slip) || (m_forceType == Force) || (m_forceType == Push)) && (Pokemod::D_End <= m_forceDirection))
- {
- pokemod()->validationMsg("Invalid force direction");
- valid = false;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid force type");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Tile \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// if ((m_hmType == Pokemod::HM_Waterfall) && (!m_from[Pokemod::D_Up] || !m_from[Pokemod::D_Down]))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("A waterfall tile must be accessible from above and below");
+// valid = false;
+// }
+// else if ((m_hmType == Pokemod::HM_Whirlpool) && ((m_under == id()) || (static_cast<const Pokemod*>(pokemod())->tileIndex(m_under) == INT_MAX) || (static_cast<const Pokemod*>(pokemod())->tileById(m_under)->hmType() != Pokemod::HM_Surf) || (static_cast<const Pokemod*>(pokemod())->tileById(m_under)->hmType() != Pokemod::HM_Dive)))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid under tile");
+// valid = false;
+// }
+// else if ((m_hmType == Pokemod::HM_Whirlpool) && ((m_under == id()) || (static_cast<const Pokemod*>(pokemod())->tileIndex(m_under) == INT_MAX) || (static_cast<const Pokemod*>(pokemod())->tileById(m_under)->hmType() != Pokemod::HM_End)))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid under tile");
+// valid = false;
+// }
+// else if ((m_hmType == Pokemod::HM_RockClimb) && (!m_from[Pokemod::D_Up] || !m_from[Pokemod::D_Down]))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("A rock climb tile must be accessible from above and below");
+// valid = false;
+// }
+// if (m_forceType < End)
+// {
+// if (((m_forceType == Slip) || (m_forceType == Force) || (m_forceType == Push)) && (Pokemod::D_End <= m_forceDirection))
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid force direction");
+// valid = false;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid force type");
+// valid = false;
+// }
+// return valid;
}
void Tile::load(const QDomElement& xml, int id)
@@ -170,7 +171,7 @@ void Tile::setUnder(const int under) throw(Exception)
{
if ((m_hmType != Pokemod::HM_Whirlpool) || (m_hmType != Pokemod::HM_Cut) || (m_hmType != Pokemod::HM_RockSmash))
error<UnusedException>("under");
- if ((under == id()) || (pokemod()->tileIndex(under) == INT_MAX))
+ if ((under == id()) || (static_cast<const Pokemod*>(pokemod())->tileIndex(under) == INT_MAX))
error<BoundsException>("under");
}
m_under = under;
diff --git a/pokemod/Tile.h b/pokemod/Tile.h
index f64a10c7..0438cade 100644
--- a/pokemod/Tile.h
+++ b/pokemod/Tile.h
@@ -18,18 +18,17 @@
#ifndef __POKEMOD_TILE__
#define __POKEMOD_TILE__
-// Qt includes
-#include <QString>
-#include <QStringList>
-
-// General includes
-#include <Exception.h>
-#include <Fraction.h>
-
// Pokemod includes
#include "Object.h"
#include "Pokemod.h"
+// General includes
+#include "../general/Exception.h"
+#include "../general/Fraction.h"
+
+// Qt includes
+#include <QString>
+
class Tile : public Object
{
public:
@@ -44,9 +43,9 @@ class Tile : public Object
static const QStringList ForceStr;
Tile(const Tile& tile);
- Tile(const Pokemod* pokemod, const int id);
- Tile(const Tile& tile, const Pokemod* pokemod, const int id);
- Tile(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Tile(const Object* parent, const int id);
+ Tile(const Tile& tile, const Object* parent, const int id);
+ Tile(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Time.cpp b/pokemod/Time.cpp
index ba9d3f46..50754361 100644
--- a/pokemod/Time.cpp
+++ b/pokemod/Time.cpp
@@ -15,58 +15,59 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include "Pokemod.h"
-
// Header include
#include "Time.h"
+// Pokemod includes
+#include "Pokemod.h"
+
Time::Time(const Time& time) :
- Object("Time", time.pokemod(), time.id())
+ Object("Time", time.parent(), time.id())
{
*this = time;
}
-Time::Time(const Pokemod* pokemod, const int id) :
- Object("Time", pokemod, id),
+Time::Time(const Object* parent, const int id) :
+ Object("Time", parent, id),
m_name(""),
m_hour(0),
m_minute(0)
{
}
-Time::Time(const Time& time, const Pokemod* pokemod, const int id) :
- Object("Time", pokemod, id)
+Time::Time(const Time& time, const Object* parent, const int id) :
+ Object("Time", parent, id)
{
*this = time;
}
-Time::Time(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Time", pokemod, id)
+Time::Time(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Time", parent, id)
{
load(xml, id);
}
bool Time::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Time \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name not defined");
- valid = false;
- }
- if (23 < m_hour)
- {
- pokemod()->validationMsg("Invalid starting hour");
- valid = false;
- }
- if (59 < m_minute)
- {
- pokemod()->validationMsg("Invalid start minute");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Time \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name not defined");
+// valid = false;
+// }
+// if (23 < m_hour)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid starting hour");
+// valid = false;
+// }
+// if (59 < m_minute)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid start minute");
+// valid = false;
+// }
+// return valid;
}
void Time::load(const QDomElement& xml, int id)
diff --git a/pokemod/Time.h b/pokemod/Time.h
index 2f2d807e..2d17820b 100644
--- a/pokemod/Time.h
+++ b/pokemod/Time.h
@@ -18,25 +18,22 @@
#ifndef __POKEMOD_TIME__
#define __POKEMOD_TIME__
-// Qt includes
-#include <QString>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QString>
class Time : public Object
{
public:
Time(const Time& time);
- Time(const Pokemod* pokemod, const int id);
- Time(const Time& time, const Pokemod* pokemod, const int id);
- Time(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Time(const Object* parent, const int id);
+ Time(const Time& time, const Object* parent, const int id);
+ Time(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Trainer.cpp b/pokemod/Trainer.cpp
index 94a989fd..270df528 100644
--- a/pokemod/Trainer.cpp
+++ b/pokemod/Trainer.cpp
@@ -15,56 +15,57 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QBuffer>
+// Header include
+#include "Trainer.h"
// Pokemod includes
#include "Pokemod.h"
-// Header include
-#include "Trainer.h"
+// Qt includes
+#include <QBuffer>
Trainer::Trainer(const Trainer& trainer) :
- Object("Trainer", trainer.pokemod(), trainer.id())
+ Object("Trainer", trainer.parent(), trainer.id())
{
*this = trainer;
}
-Trainer::Trainer(const Pokemod* pokemod, const int id) :
- Object("Trainer", pokemod, id),
+Trainer::Trainer(const Object* parent, const int id) :
+ Object("Trainer", parent, id),
m_name(""),
m_moneyFactor(0),
m_skin(192, 128)
{
}
-Trainer::Trainer(const Trainer& trainer, const Pokemod* pokemod, const int id) :
- Object("Trainer", pokemod, id)
+Trainer::Trainer(const Trainer& trainer, const Object* parent, const int id) :
+ Object("Trainer", parent, id)
{
*this = trainer;
}
-Trainer::Trainer(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Trainer", pokemod, id)
+Trainer::Trainer(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Trainer", parent, id)
{
load(xml, id);
}
bool Trainer::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Trainer \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name not defined");
- valid = false;
- }
- if (m_moneyFactor < 0)
- {
- pokemod()->validationMsg("Invalid money factor");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Trainer \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name not defined");
+// valid = false;
+// }
+// if (m_moneyFactor < 0)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid money factor");
+// valid = false;
+// }
+// return valid;
}
void Trainer::load(const QDomElement& xml, int id)
@@ -129,7 +130,7 @@ QPixmap Trainer::skin() const
// QString Trainer::ai() const
// {
-// return QString("%1/trainer/%2/ai.pai").arg(pokemod()->path()).arg(m_name);
+// return QString("%1/trainer/%2/ai.pai").arg(static_cast<const Pokemod*>(pokemod())->path()).arg(m_name);
// }
Trainer& Trainer::operator=(const Trainer& rhs)
diff --git a/pokemod/Trainer.h b/pokemod/Trainer.h
index 22d9a6fb..dabaf685 100644
--- a/pokemod/Trainer.h
+++ b/pokemod/Trainer.h
@@ -18,25 +18,22 @@
#ifndef __POKEMOD_TRAINER__
#define __POKEMOD_TRAINER__
-// Qt includes
-#include <QPixmap>
-
-// General includes
-#include <Exception.h>
-
// Pokemod includes
#include "Object.h"
-// Forward declarations
-class Pokemod;
+// General includes
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QPixmap>
class Trainer : public Object
{
public:
Trainer(const Trainer& trainer);
- Trainer(const Pokemod* pokemod, const int id);
- Trainer(const Trainer& trainer, const Pokemod* pokemod, const int id);
- Trainer(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Trainer(const Object* parent, const int id);
+ Trainer(const Trainer& trainer, const Object* parent, const int id);
+ Trainer(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemod/Type.cpp b/pokemod/Type.cpp
index 13474083..6180c78a 100644
--- a/pokemod/Type.cpp
+++ b/pokemod/Type.cpp
@@ -15,20 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Header include
+#include "Type.h"
+
// Pokemod includes
#include "Pokemod.h"
-// Header includes
-#include "Type.h"
-
Type::Type(const Type& type) :
- Object("Type", type.pokemod(), type.id())
+ Object("Type", type.parent(), type.id())
{
*this = type;
}
-Type::Type(const Pokemod* pokemod, const int id) :
- Object("Type", pokemod, id),
+Type::Type(const Object* parent, const int id) :
+ Object("Type", parent, id),
m_name(""),
m_stab(1, 1)//, true)
{
@@ -36,28 +36,29 @@ Type::Type(const Pokemod* pokemod, const int id) :
m_immunity[i] = false;
}
-Type::Type(const Type& type, const Pokemod* pokemod, const int id) :
- Object("Type", pokemod, id)
+Type::Type(const Type& type, const Object* parent, const int id) :
+ Object("Type", parent, id)
{
*this = type;
}
-Type::Type(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("Type", pokemod, id)
+Type::Type(const QDomElement& xml, const Object* parent, const int id) :
+ Object("Type", parent, id)
{
load(xml, id);
}
bool Type::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---Type \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("No name defined");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Type \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("No name defined");
+// valid = false;
+// }
+// return valid;
}
void Type::load(const QDomElement& xml, int id)
diff --git a/pokemod/Type.h b/pokemod/Type.h
index e2ae790c..09e2acb1 100644
--- a/pokemod/Type.h
+++ b/pokemod/Type.h
@@ -18,23 +18,23 @@
#ifndef __POKEMOD_TYPE__
#define __POKEMOD_TYPE__
-// Qt includes
-#include <QString>
-
-// General includes
-#include <Fraction.h>
-
// Pokemod includes
#include "Object.h"
#include "Pokemod.h"
+// General includes
+#include "../general/Fraction.h"
+
+// Qt includes
+#include <QString>
+
class Type : public Object
{
public:
Type(const Type& type);
- Type(const Pokemod* pokemod, const int id);
- Type(const Type& type, const Pokemod* pokemod, const int id);
- Type(const QDomElement& xml, const Pokemod* pokemod, const int id = INT_MAX);
+ Type(const Object* parent, const int id);
+ Type(const Type& type, const Object* parent, const int id);
+ Type(const QDomElement& xml, const Object* parent, const int id = INT_MAX);
void load(const QDomElement& xml, const int id = INT_MAX);
QDomElement save() const;
diff --git a/pokemodr/AbilityUI.h b/pokemodr/AbilityUI.h
index ec6cd1dc..c6175dd1 100644
--- a/pokemodr/AbilityUI.h
+++ b/pokemodr/AbilityUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_ABILITYUI__
#define __POKEMODR_ABILITYUI__
-// Pokemod includes
-#include <Ability.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Ability.h"
+
// Form include
#include "ui_ability.h"
diff --git a/pokemodr/AuthorUI.cpp b/pokemodr/AuthorUI.cpp
index 641f6756..8e082277 100644
--- a/pokemodr/AuthorUI.cpp
+++ b/pokemodr/AuthorUI.cpp
@@ -15,12 +15,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// General includes
-#include <Exception.h>
-
// Header include
#include "AuthorUI.h"
+// General includes
+#include "../general/Exception.h"
+
AuthorUI::AuthorUI(Author* author, QWidget* parent) :
ObjectUI(parent),
m_author(author),
diff --git a/pokemodr/AuthorUI.h b/pokemodr/AuthorUI.h
index 6ba4a020..dc58b75b 100644
--- a/pokemodr/AuthorUI.h
+++ b/pokemodr/AuthorUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_AUTHORUI__
#define __POKEMODR_AUTHORUI__
-// Pokemod includes
-#include <Author.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Author.h"
+
// Form include
#include "ui_author.h"
diff --git a/pokemodr/BadgeUI.cpp b/pokemodr/BadgeUI.cpp
index b7ec48d5..efbdf11c 100644
--- a/pokemodr/BadgeUI.cpp
+++ b/pokemodr/BadgeUI.cpp
@@ -15,22 +15,22 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QListWidgetItem>
-#include <QSize>
+// Header include
+#include "BadgeUI.h"
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// PokeModr includes
+#include "FileDialog.h"
// Pokemod includes
-#include <Pokemod.h>
+#include "../pokemod/Pokemod.h"
-// PokeModr includes
-#include "FileDialog.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
-// Header include
-#include "BadgeUI.h"
+// Qt includes
+#include <QListWidgetItem>
+#include <QSize>
BadgeUI::BadgeUI(Badge* badge, QWidget* parent) :
ObjectUI(parent),
@@ -52,9 +52,9 @@ void BadgeUI::initGui()
void BadgeUI::refreshGui()
{
varStat->clear();
- const bool isSplit = m_badge->pokemod()->rules()->specialSplit();
+ const bool isSplit = static_cast<const Pokemod*>(m_badge->pokemod())->rules()->specialSplit();
varStat->addItems((isSplit ? Pokemod::StatGSCStr : Pokemod::StatRBYStr).mid(0, isSplit ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY));
- varObey->setMaximum(m_badge->pokemod()->rules()->maxLevel());
+ varObey->setMaximum(static_cast<const Pokemod*>(m_badge->pokemod())->rules()->maxLevel());
}
void BadgeUI::setGui()
diff --git a/pokemodr/BadgeUI.h b/pokemodr/BadgeUI.h
index b1d1c7e2..e6b69f4f 100644
--- a/pokemodr/BadgeUI.h
+++ b/pokemodr/BadgeUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_BADGEUI__
#define __POKEMODR_BADGEUI__
-// Pokemod includes
-#include <Badge.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Badge.h"
+
// Form include
#include "ui_badge.h"
diff --git a/pokemodr/CoinListObjectUI.cpp b/pokemodr/CoinListObjectUI.cpp
index 61fb5908..84fa4a22 100644
--- a/pokemodr/CoinListObjectUI.cpp
+++ b/pokemodr/CoinListObjectUI.cpp
@@ -15,21 +15,21 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QVariant>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "CoinListObjectUI.h"
// Pokemod includes
-#include <Item.h>
-#include <ItemEffect.h>
-#include <Pokemod.h>
-#include <Species.h>
+#include "../pokemod/Item.h"
+#include "../pokemod/ItemEffect.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Species.h"
-// Header include
-#include "CoinListObjectUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QVariant>
CoinListObjectUI::CoinListObjectUI(CoinListObject* coinListObject, QWidget* parent) :
ObjectUI(parent),
@@ -59,18 +59,18 @@ void CoinListObjectUI::setGui()
varObject->clear();
if (m_object_mod->type() == CoinListObject::Item)
{
- for (int i = 0; i < m_object->pokemod()->itemCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_object->pokemod())->itemCount(); ++i)
{
- const Item* item = m_object->pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(m_object->pokemod())->item(i);
varObject->addItem(item->name());
varObject->setItemData(i, item->id());
}
}
else
{
- for (int i = 0; i < m_object->pokemod()->speciesCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_object->pokemod())->speciesCount(); ++i)
{
- const Species* species = m_object->pokemod()->species(i);
+ const Species* species = static_cast<const Pokemod*>(m_object->pokemod())->species(i);
varObject->addItem(species->name());
varObject->setItemData(i, species->id());
}
diff --git a/pokemodr/CoinListObjectUI.h b/pokemodr/CoinListObjectUI.h
index ddbf1a1a..5fbba622 100644
--- a/pokemodr/CoinListObjectUI.h
+++ b/pokemodr/CoinListObjectUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_COINLISTOBJECTUI__
#define __POKEMODR_COINLISTOBJECTUI__
-// Pokemod includes
-#include <CoinListObject.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/CoinListObject.h"
+
// Form include
#include "ui_coinlistobject.h"
diff --git a/pokemodr/CoinListUI.cpp b/pokemodr/CoinListUI.cpp
index bf854781..d8eadc3d 100644
--- a/pokemodr/CoinListUI.cpp
+++ b/pokemodr/CoinListUI.cpp
@@ -15,20 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QVariant>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "CoinListUI.h"
// Pokemod includes
-#include <Item.h>
-#include <ItemEffect.h>
-#include <Pokemod.h>
+#include "../pokemod/Item.h"
+#include "../pokemod/ItemEffect.h"
+#include "../pokemod/Pokemod.h"
-// Header include
-#include "CoinListUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QVariant>
CoinListUI::CoinListUI(CoinList* coinList, QWidget* parent) :
ObjectUI(parent),
@@ -45,9 +45,9 @@ CoinListUI::CoinListUI(CoinList* coinList, QWidget* parent) :
void CoinListUI::refreshGui()
{
varValue->clear();
- for (int i = 0; i < m_coinList->pokemod()->itemCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_coinList->pokemod())->itemCount(); ++i)
{
- const Item* item = m_coinList->pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(m_coinList->pokemod())->item(i);
for (int j = 0; j < item->effectCount(); ++j)
{
const ItemEffect* effect = item->effect(j);
diff --git a/pokemodr/CoinListUI.h b/pokemodr/CoinListUI.h
index d5ac83dc..f19c8296 100644
--- a/pokemodr/CoinListUI.h
+++ b/pokemodr/CoinListUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_COINLISTUI__
#define __POKEMODR_COINLISTUI__
-// Pokemod includes
-#include <CoinList.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/CoinList.h"
+
// Form include
#include "ui_coinlist.h"
diff --git a/pokemodr/EggGroupUI.h b/pokemodr/EggGroupUI.h
index 5b565b2e..4e64e609 100644
--- a/pokemodr/EggGroupUI.h
+++ b/pokemodr/EggGroupUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_EGGGROUPUI__
#define __POKEMODR_EGGGROUPUI__
-// Pokemod includes
-#include <EggGroup.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/EggGroup.h"
+
// Form include
#include "ui_egggroup.h"
diff --git a/pokemodr/FileDialog.cpp b/pokemodr/FileDialog.cpp
index 3261bd9b..2de38c4a 100644
--- a/pokemodr/FileDialog.cpp
+++ b/pokemodr/FileDialog.cpp
@@ -15,18 +15,18 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// KDE includes
-#include <kdiroperator.h>
-#include <kfilewidget.h>
-#include <kimagefilepreview.h>
+// Header include
+#include "FileDialog.h"
// Qt includes
#include <QDir>
#include <QPixmap>
#include <QStringList>
-// Header include
-#include "FileDialog.h"
+// KDE includes
+#include <kdiroperator.h>
+#include <kfilewidget.h>
+#include <kimagefilepreview.h>
FileDialog::FileDialog(const QSize& size) :
KFileDialog(KUrl("kfiledialog:///image"), "", NULL)
diff --git a/pokemodr/FileDialog.h b/pokemodr/FileDialog.h
index 46af7175..c52d0592 100644
--- a/pokemodr/FileDialog.h
+++ b/pokemodr/FileDialog.h
@@ -18,13 +18,13 @@
#ifndef __POKEMODR_FILEDIALOG__
#define __POKEMODR_FILEDIALOG__
+// Qt includes
+#include <QSize>
+
// KDE includes
#include <kfiledialog.h>
#include <kfileitem.h>
-// Qt includes
-#include <QSize>
-
class FileDialog : public KFileDialog
{
Q_OBJECT
diff --git a/pokemodr/FractionWidget.cpp b/pokemodr/FractionWidget.cpp
index 8ef3ff95..24d257e0 100644
--- a/pokemodr/FractionWidget.cpp
+++ b/pokemodr/FractionWidget.cpp
@@ -15,13 +15,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Header include
+#include "FractionWidget.h"
+
// Qt includes
#include <QMetaObject>
#include <QString>
-// Header include
-#include "FractionWidget.h"
-
FractionWidget::FractionWidget(QWidget* parent, const Fraction& value) :
QWidget(parent),
m_behavior(-1),
diff --git a/pokemodr/FractionWidget.h b/pokemodr/FractionWidget.h
index 7195460c..9ac570a4 100644
--- a/pokemodr/FractionWidget.h
+++ b/pokemodr/FractionWidget.h
@@ -18,13 +18,13 @@
#ifndef __FRACWIDGET__
#define __FRACWIDGET__
+// General includes
+#include "Fraction.h"
+
// Qt includes
#include <QObject>
#include <QWidget>
-// General includes
-#include "Fraction.h"
-
// Form include
#include "ui_fraction.h"
diff --git a/pokemodr/ItemTypeUI.cpp b/pokemodr/ItemTypeUI.cpp
index 4891e8ac..731243d2 100644
--- a/pokemodr/ItemTypeUI.cpp
+++ b/pokemodr/ItemTypeUI.cpp
@@ -15,13 +15,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
-
// Header include
#include "ItemTypeUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
ItemTypeUI::ItemTypeUI(ItemType* itemType, QWidget* parent) :
ObjectUI(parent),
m_itemType(itemType),
diff --git a/pokemodr/ItemTypeUI.h b/pokemodr/ItemTypeUI.h
index 752a9c8e..ccdefc36 100644
--- a/pokemodr/ItemTypeUI.h
+++ b/pokemodr/ItemTypeUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_ITEMTYPEUI__
#define __POKEMODR_ITEMTYPEUI__
-// Pokemod includes
-#include <ItemType.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/ItemType.h"
+
// Form include
#include "ui_itemtype.h"
diff --git a/pokemodr/ItemUI.cpp b/pokemodr/ItemUI.cpp
index 70cf36b5..9257b0a8 100644
--- a/pokemodr/ItemUI.cpp
+++ b/pokemodr/ItemUI.cpp
@@ -15,16 +15,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "ItemUI.h"
// Pokemod includes
-#include <ItemType.h>
-#include <Pokemod.h>
+#include "../pokemod/ItemType.h"
+#include "../pokemod/Pokemod.h"
-// Header include
-#include "ItemUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
ItemUI::ItemUI(Item* item, QWidget* parent) :
ObjectUI(parent),
@@ -41,13 +41,13 @@ ItemUI::ItemUI(Item* item, QWidget* parent) :
void ItemUI::refreshGui()
{
varType->clear();
- for (int i = 0; i < m_item->pokemod()->itemTypeCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_item->pokemod())->itemTypeCount(); ++i)
{
- const ItemType* itemType = m_item->pokemod()->itemType(i);
+ const ItemType* itemType = static_cast<const Pokemod*>(m_item->pokemod())->itemType(i);
varType->addItem(itemType->name());
varType->setItemData(i, itemType->id());
}
- varPrice->setMaximum(m_item->pokemod()->rules()->maxMoney());
+ varPrice->setMaximum(static_cast<const Pokemod*>(m_item->pokemod())->rules()->maxMoney());
}
void ItemUI::setGui()
diff --git a/pokemodr/ItemUI.h b/pokemodr/ItemUI.h
index 7398738f..fe4daaa8 100644
--- a/pokemodr/ItemUI.h
+++ b/pokemodr/ItemUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_ITEMUI__
#define __POKEMODR_ITEMUI__
-// Pokemod includes
-#include <Item.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Item.h"
+
// Form include
#include "ui_item.h"
diff --git a/pokemodr/MapTrainerTeamMemberUI.cpp b/pokemodr/MapTrainerTeamMemberUI.cpp
index e630658f..531300ef 100644
--- a/pokemodr/MapTrainerTeamMemberUI.cpp
+++ b/pokemodr/MapTrainerTeamMemberUI.cpp
@@ -15,21 +15,21 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QListWidgetItem>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "MapTrainerTeamMemberUI.h"
// Pokemod includes
-#include <Item.h>
-#include <Nature.h>
-#include <Pokemod.h>
-#include <Species.h>
+#include "../pokemod/Item.h"
+#include "../pokemod/Nature.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Species.h"
-// Header include
-#include "MapTrainerTeamMemberUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QListWidgetItem>
MapTrainerTeamMemberUI::MapTrainerTeamMemberUI(MapTrainerTeamMember* teamMember, QWidget* parent) :
ObjectUI(parent),
@@ -46,13 +46,13 @@ MapTrainerTeamMemberUI::MapTrainerTeamMemberUI(MapTrainerTeamMember* teamMember,
void MapTrainerTeamMemberUI::refreshGui()
{
varSpecies->clear();
- for (int i = 0; i < m_teamMember->pokemod()->speciesCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_teamMember->pokemod())->speciesCount(); ++i)
{
- const Species* species = m_teamMember->pokemod()->species(i);
+ const Species* species = static_cast<const Pokemod*>(m_teamMember->pokemod())->species(i);
varSpecies->addItem(species->name());
varSpecies->setItemData(i, species->id());
}
- varLevel->setMaximum(m_teamMember->pokemod()->rules()->maxLevel());
+ varLevel->setMaximum(static_cast<const Pokemod*>(m_teamMember->pokemod())->rules()->maxLevel());
}
void MapTrainerTeamMemberUI::setGui()
@@ -66,11 +66,11 @@ void MapTrainerTeamMemberUI::setGui()
widgetItem->setSelected(m_teamMember_mod->item(widgetItem->data(Qt::UserRole).toInt()));
}
varNature->clear();
- if (m_teamMember->pokemod()->rules()->natureAllowed())
+ if (static_cast<const Pokemod*>(m_teamMember->pokemod())->rules()->natureAllowed())
{
- for (int i = 0; i < m_teamMember->pokemod()->natureCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_teamMember->pokemod())->natureCount(); ++i)
{
- const Nature* nature = m_teamMember->pokemod()->nature(i);
+ const Nature* nature = static_cast<const Pokemod*>(m_teamMember->pokemod())->nature(i);
varNature->addItem(nature->name());
varNature->setItemData(i, nature->id());
}
@@ -78,11 +78,11 @@ void MapTrainerTeamMemberUI::setGui()
else
boxNature->setEnabled(false);
varItems->clear();
- if (m_teamMember->pokemod()->rules()->holdItems())
+ if (static_cast<const Pokemod*>(m_teamMember->pokemod())->rules()->holdItems())
{
- for (int i = 0; i < m_teamMember->pokemod()->itemCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_teamMember->pokemod())->itemCount(); ++i)
{
- const Item* item = m_teamMember->pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(m_teamMember->pokemod())->item(i);
QListWidgetItem* widgetItem = new QListWidgetItem(item->name(), varItems);
widgetItem->setData(Qt::UserRole, item->id());
}
diff --git a/pokemodr/MapTrainerTeamMemberUI.h b/pokemodr/MapTrainerTeamMemberUI.h
index 116ce2ce..14a73696 100644
--- a/pokemodr/MapTrainerTeamMemberUI.h
+++ b/pokemodr/MapTrainerTeamMemberUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_MAPTRAINERTEAMMEMBERUI__
#define __POKEMODR_MAPTRAINERTEAMMEMBERUI__
-// Pokemod includes
-#include <MapTrainerTeamMember.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/MapTrainerTeamMember.h"
+
// Form include
#include "ui_maptrainerteammember.h"
diff --git a/pokemodr/MapUI.cpp b/pokemodr/MapUI.cpp
index 27bcfc6b..36a2cc3e 100644
--- a/pokemodr/MapUI.cpp
+++ b/pokemodr/MapUI.cpp
@@ -15,26 +15,26 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QHeaderView>
-#include <QIcon>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "MapUI.h"
// Pokemod includes
-#include <MapWarp.h>
-#include <Pokemod.h>
+#include "../pokemod/MapWarp.h"
+#include "../pokemod/Pokemod.h"
-// Header include
-#include "MapUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QHeaderView>
+#include <QIcon>
MapUI::MapUI(Map* map, QWidget* parent) :
ObjectUI(parent),
m_map(map),
m_map_mod(new Map(*map)),
- m_model(new TilemapModel(this, m_map_mod->map(), m_map->pokemod())),
+ m_model(new TilemapModel(this, m_map_mod->map(), static_cast<const Pokemod*>(m_map->pokemod()))),
m_delegate(new TileDelegate(this))
{
setupUi(this);
diff --git a/pokemodr/MapUI.h b/pokemodr/MapUI.h
index 85d281e6..475589a7 100644
--- a/pokemodr/MapUI.h
+++ b/pokemodr/MapUI.h
@@ -18,14 +18,14 @@
#ifndef __POKEMODR_MAPUI__
#define __POKEMODR_MAPUI__
-// Pokemod includes
-#include <Map.h>
-
// PokeModr includes
#include "ObjectUI.h"
#include "TileDelegate.h"
#include "TilemapModel.h"
+// Pokemod includes
+#include "../pokemod/Map.h"
+
// Form include
#include "ui_map.h"
diff --git a/pokemodr/MapWarpUI.cpp b/pokemodr/MapWarpUI.cpp
index 4d2d4f51..9eb84fe8 100644
--- a/pokemodr/MapWarpUI.cpp
+++ b/pokemodr/MapWarpUI.cpp
@@ -15,20 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QListWidgetItem>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "MapWarpUI.h"
// Pokemod includes
-#include <Dialog.h>
-#include <Pokemod.h>
-#include <Map.h>
+#include "../pokemod/Dialog.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Map.h"
-// Header includeo
-#include "MapWarpUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QListWidgetItem>
MapWarpUI::MapWarpUI(MapWarp* warp, QWidget* parent) :
ObjectUI(parent),
@@ -52,16 +52,16 @@ void MapWarpUI::initGui()
void MapWarpUI::refreshGui()
{
varToMap->clear();
- for (int i = 0; i < m_warp->pokemod()->mapCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_warp->pokemod())->mapCount(); ++i)
{
- const Map* map = m_warp->pokemod()->map(i);
+ const Map* map = static_cast<const Pokemod*>(m_warp->pokemod())->map(i);
varToMap->addItem(map->name());
varToMap->setItemData(i, map->id());
}
varDialog->clear();
- for (int i = 0; i < m_warp->pokemod()->dialogCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_warp->pokemod())->dialogCount(); ++i)
{
- const Dialog* dialog = m_warp->pokemod()->dialog(i);
+ const Dialog* dialog = static_cast<const Pokemod*>(m_warp->pokemod())->dialog(i);
varDialog->addItem(dialog->dialog().mid(0, 25));
varDialog->setItemData(i, dialog->id());
}
@@ -84,12 +84,12 @@ void MapWarpUI::setGui()
if (resetWarps)
{
varToWarp->clear();
- int index = m_warp->pokemod()->mapIndex(m_warp_mod->toMap());
+ int index = static_cast<const Pokemod*>(m_warp->pokemod())->mapIndex(m_warp_mod->toMap());
if (index != INT_MAX)
{
try
{
- const Map* map = m_warp->pokemod()->map(index);
+ const Map* map = static_cast<const Pokemod*>(m_warp->pokemod())->map(index);
for (int i = 0; i < map->warpCount(); ++i)
{
const MapWarp* warp = map->warp(i);
diff --git a/pokemodr/MapWarpUI.h b/pokemodr/MapWarpUI.h
index 899fd384..faa0056a 100644
--- a/pokemodr/MapWarpUI.h
+++ b/pokemodr/MapWarpUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_MAPWARPUI__
#define __POKEMODR_MAPWARPUI__
-// Pokemod includes
-#include <MapWarp.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/MapWarp.h"
+
// Form include
#include "ui_mapwarp.h"
diff --git a/pokemodr/MapWildListEncounterUI.cpp b/pokemodr/MapWildListEncounterUI.cpp
index 4ca92481..f56e07ee 100644
--- a/pokemodr/MapWildListEncounterUI.cpp
+++ b/pokemodr/MapWildListEncounterUI.cpp
@@ -15,16 +15,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "MapWildListEncounterUI.h"
// Pokemod includes
-#include <Pokemod.h>
-#include <Species.h>
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Species.h"
-// Header include
-#include "MapWildListEncounterUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
MapWildListEncounterUI::MapWildListEncounterUI(MapWildListEncounter* encounter, QWidget* parent) :
ObjectUI(parent),
@@ -41,13 +41,13 @@ MapWildListEncounterUI::MapWildListEncounterUI(MapWildListEncounter* encounter,
void MapWildListEncounterUI::refreshGui()
{
varSpecies->clear();
- for (int i = 0; i < m_encounter->pokemod()->speciesCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_encounter->pokemod())->speciesCount(); ++i)
{
- const Species* species = m_encounter->pokemod()->species(i);
+ const Species* species = static_cast<const Pokemod*>(m_encounter->pokemod())->species(i);
varSpecies->addItem(species->name());
varSpecies->setItemData(i, species->id());
}
- varLevel->setMaximum(m_encounter->pokemod()->rules()->maxLevel());
+ varLevel->setMaximum(static_cast<const Pokemod*>(m_encounter->pokemod())->rules()->maxLevel());
}
void MapWildListEncounterUI::setGui()
diff --git a/pokemodr/MapWildListEncounterUI.h b/pokemodr/MapWildListEncounterUI.h
index af3e384f..f8d0f123 100644
--- a/pokemodr/MapWildListEncounterUI.h
+++ b/pokemodr/MapWildListEncounterUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_MAPWILDLISTENCOUNTERUI__
#define __POKEMODR_MAPWILDLISTENCOUNTERUI__
-// Pokemod includes
-#include <MapWildListEncounter.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/MapWildListEncounter.h"
+
// Form include
#include "ui_mapwildlistencounter.h"
diff --git a/pokemodr/MapWildListUI.cpp b/pokemodr/MapWildListUI.cpp
index 87033b29..52b67b78 100644
--- a/pokemodr/MapWildListUI.cpp
+++ b/pokemodr/MapWildListUI.cpp
@@ -15,23 +15,23 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QListWidgetItem>
-#include <QVariant>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "MapWildListUI.h"
// Pokemod includes
-#include <Item.h>
-#include <ItemEffect.h>
-#include <Pokemod.h>
-#include <MapWildList.h>
-#include <Time.h>
+#include "../pokemod/Item.h"
+#include "../pokemod/ItemEffect.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/MapWildList.h"
+#include "../pokemod/Time.h"
-// Header include
-#include "MapWildListUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QListWidgetItem>
+#include <QVariant>
MapWildListUI::MapWildListUI(MapWildList* wildList, QWidget* parent) :
ObjectUI(parent),
@@ -54,9 +54,9 @@ void MapWildListUI::refreshGui()
{
varValue->clear();
varScope->clear();
- for (int i = 0; i < m_wildList->pokemod()->itemCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_wildList->pokemod())->itemCount(); ++i)
{
- const Item* item = m_wildList->pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(m_wildList->pokemod())->item(i);
for (int j = 0; j < item->effectCount(); ++j)
{
const ItemEffect* effect = item->effect(j);
@@ -73,9 +73,9 @@ void MapWildListUI::refreshGui()
}
}
varTimes->clear();
- for (int i = 0; i < m_wildList->pokemod()->timeCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_wildList->pokemod())->timeCount(); ++i)
{
- const Time* time = m_wildList->pokemod()->time(i);
+ const Time* time = static_cast<const Pokemod*>(m_wildList->pokemod())->time(i);
QListWidgetItem* widgetItem = new QListWidgetItem(time->name(), varTimes);
widgetItem->setData(Qt::UserRole, time->id());
}
diff --git a/pokemodr/MapWildListUI.h b/pokemodr/MapWildListUI.h
index c0514605..24dc9c6d 100644
--- a/pokemodr/MapWildListUI.h
+++ b/pokemodr/MapWildListUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_MAPWILDLISTUI__
#define __POKEMODR_MAPWILDLISTUI__
-// Pokemod includes
-#include <MapWildList.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/MapWildList.h"
+
// Form include
#include "ui_mapwildlist.h"
diff --git a/pokemodr/MoveUI.cpp b/pokemodr/MoveUI.cpp
index c9d2ba76..13603648 100644
--- a/pokemodr/MoveUI.cpp
+++ b/pokemodr/MoveUI.cpp
@@ -15,16 +15,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "MoveUI.h"
// Pokemod includes
-#include <Pokemod.h>
-#include <Type.h>
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Type.h"
-// Header include
-#include "MoveUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
MoveUI::MoveUI(Move* move, QWidget* parent) :
ObjectUI(parent),
@@ -47,13 +47,13 @@ void MoveUI::initGui()
void MoveUI::refreshGui()
{
varType->clear();
- for (int i = 0; i < m_move->pokemod()->typeCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_move->pokemod())->typeCount(); ++i)
{
- const Type* type = m_move->pokemod()->type(i);
+ const Type* type = static_cast<const Pokemod*>(m_move->pokemod())->type(i);
varType->addItem(type->name());
varType->setItemData(i, type->id());
}
- varNumTargets->setMaximum(m_move->pokemod()->rules()->maxFight());
+ varNumTargets->setMaximum(static_cast<const Pokemod*>(m_move->pokemod())->rules()->maxFight());
}
void MoveUI::setGui()
diff --git a/pokemodr/MoveUI.h b/pokemodr/MoveUI.h
index 1dbf9142..f19fee87 100644
--- a/pokemodr/MoveUI.h
+++ b/pokemodr/MoveUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_MOVEUI__
#define __POKEMODR_MOVEUI__
-// Pokemod includes
-#include <Move.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Move.h"
+
// Form include
#include "ui_move.h"
diff --git a/pokemodr/NatureUI.cpp b/pokemodr/NatureUI.cpp
index 775ba15a..c74575c6 100644
--- a/pokemodr/NatureUI.cpp
+++ b/pokemodr/NatureUI.cpp
@@ -15,18 +15,18 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QStringList>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "NatureUI.h"
// Pokemod includes
-#include <Pokemod.h>
+#include "../pokemod/Pokemod.h"
-// Header include
-#include "NatureUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QStringList>
NatureUI::NatureUI(Nature* nature, QWidget* parent) :
ObjectUI(parent),
@@ -43,7 +43,7 @@ NatureUI::NatureUI(Nature* nature, QWidget* parent) :
void NatureUI::refreshGui()
{
varStat->clear();
- const bool isSplit = m_nature->pokemod()->rules()->specialSplit();
+ const bool isSplit = static_cast<const Pokemod*>(m_nature->pokemod())->rules()->specialSplit();
varStat->addItems((isSplit ? Pokemod::StatRBYStr : Pokemod::StatGSCStr).mid(0, isSplit ? Pokemod::ST_End_RBY : Pokemod::ST_End_GSC));
}
diff --git a/pokemodr/NatureUI.h b/pokemodr/NatureUI.h
index 2f3cb1fb..2d8dbee4 100644
--- a/pokemodr/NatureUI.h
+++ b/pokemodr/NatureUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_NATUREUI__
#define __POKEMODR_NATUREUI__
-// Pokemod includes
-#include <Nature.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Nature.h"
+
// Form include
#include "ui_nature.h"
diff --git a/pokemodr/ObjectUI.h b/pokemodr/ObjectUI.h
index a37b6987..0bf9cf3e 100644
--- a/pokemodr/ObjectUI.h
+++ b/pokemodr/ObjectUI.h
@@ -18,8 +18,12 @@
#ifndef __POKEMODR_OBJECTUI__
#define __POKEMODR_OBJECTUI__
-// KDE includes
-#include <kmessagebox.h>
+// PokeModr includes
+#include "PokeModrUI.h"
+
+// Pokemod includes
+#include "../pokemod/Object.h"
+#include "../pokemod/Pokemod.h"
// Qt includes
#include <QCloseEvent>
@@ -28,12 +32,8 @@
#include <QObject>
#include <QWidget>
-// Pokemod includes
-#include <Object.h>
-#include <Pokemod.h>
-
-// PokeModr includes
-#include "PokeModrUI.h"
+// KDE includes
+#include <kmessagebox.h>
#define DBL_PREC 7
diff --git a/pokemodr/PointWidget.h b/pokemodr/PointWidget.h
index 24574e86..255bd990 100644
--- a/pokemodr/PointWidget.h
+++ b/pokemodr/PointWidget.h
@@ -18,13 +18,13 @@
#ifndef __POINTWIDGET__
#define __POINTWIDGET__
+// General includes
+#include "Point.h"
+
// Qt includes
#include <QObject>
#include <QWidget>
-// General includes
-#include "Point.h"
-
// Form include
#include "ui_point.h"
diff --git a/pokemodr/PokeModr.cpp b/pokemodr/PokeModr.cpp
index 7a50630c..5b9e31fc 100644
--- a/pokemodr/PokeModr.cpp
+++ b/pokemodr/PokeModr.cpp
@@ -23,8 +23,8 @@
#include <QTextCodec>
-#include <BugCatcher.h>
-#include <Exception.h>
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
#include "FileDialog.h"
#include "PokeModrUI.h"
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp
index 6c544cce..04b4b4b4 100644
--- a/pokemodr/PokeModrUI.cpp
+++ b/pokemodr/PokeModrUI.cpp
@@ -15,6 +15,24 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Header include
+#include "PokeModrUI.h"
+
+// PokeModr includes
+#include "PokemodTreeModel.h"
+
+// Pokemod includes
+#include "../pokemod/Pokemod.h"
+
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QCloseEvent>
+#include <QMutableListIterator>
+#include <QString>
+
// KDE includes
#include <kaction.h>
#include <kfiledialog.h>
@@ -28,24 +46,6 @@
#include <ktoolbar.h>
#include <kurl.h>
-// Qt includes
-#include <QCloseEvent>
-#include <QMutableListIterator>
-#include <QString>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
-
-// Pokemod includes
-#include <Pokemod.h>
-
-// PokeModr includes
-#include "PokemodTreeModel.h"
-
-// Header include
-#include "PokeModrUI.h"
-
// STL includes
#include <iostream>
diff --git a/pokemodr/PokeModrUI.h b/pokemodr/PokeModrUI.h
index d10a27f7..1aeb35ba 100644
--- a/pokemodr/PokeModrUI.h
+++ b/pokemodr/PokeModrUI.h
@@ -18,19 +18,19 @@
#ifndef __POKEMODR_POKEMODRUI__
#define __POKEMODR_POKEMODRUI__
-// KDE includes
-#include <kconfiggroup.h>
-#include <kmainwindow.h>
-#include <krecentfilesaction.h>
-#include <kurl.h>
+// Pokemod includes
+#include "../pokemod/Pokemod.h"
// Qt includes
#include <QList>
#include <QObject>
#include <QWidget>
-// Pokemod includes
-#include <Pokemod.h>
+// KDE includes
+#include <kconfiggroup.h>
+#include <kmainwindow.h>
+#include <krecentfilesaction.h>
+#include <kurl.h>
// Form include
#include "ui_pokemodr.h"
diff --git a/pokemodr/PokemodTreeModel.cpp b/pokemodr/PokemodTreeModel.cpp
index 0bf78e34..5271ba15 100644
--- a/pokemodr/PokemodTreeModel.cpp
+++ b/pokemodr/PokemodTreeModel.cpp
@@ -15,20 +15,21 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMimeData>
+// Header include
+#include "PokemodTreeModel.h"
// Model includes
#include "models/RootModel.h"
-// Header include
-#include "PokemodTreeModel.h"
+// Qt includes
+#include <QMimeData>
PokemodTreeModel::PokemodTreeModel(const QStringList& pokemods, QObject* parent) :
QAbstractItemModel(parent)
{
+ emit(layoutAboutToBeChanged());
m_root = new RootModel(QList<QVariant>());
- // TODO: construct
+ emit(layoutChanged());
}
PokemodTreeModel::~PokemodTreeModel()
@@ -44,6 +45,11 @@ QVariant PokemodTreeModel::data(const QModelIndex& index, int role) const
return object->data(role);
}
+QVariant PokemodTreeModel::headerData(int /*section*/, Qt::Orientation /*orientation*/, int /*role = Qt::DisplayRole*/) const
+{
+ return QVariant();
+}
+
QModelIndex PokemodTreeModel::index(int row, int /*column*/, const QModelIndex& parent) const
{
if (!parent.isValid())
@@ -68,9 +74,7 @@ QModelIndex PokemodTreeModel::parent(const QModelIndex& index) const
int PokemodTreeModel::rowCount(const QModelIndex& parent) const
{
- if (!parent.isValid())
- return 0;
- BaseModel* object = static_cast<BaseModel*>(parent.internalPointer());
+ BaseModel* object = getItem(parent);
return object->rowCount();
}
int PokemodTreeModel::columnCount(const QModelIndex& /*parent*/) const
@@ -91,17 +95,11 @@ bool PokemodTreeModel::setData(const QModelIndex& index, const QVariant& value,
if (!index.isValid())
return false;
BaseModel* object = static_cast<BaseModel*>(index.internalPointer());
- return object->setData(value, role);
-}
-
-bool PokemodTreeModel::insertColumns(int /*position*/, int /*columns*/, const QModelIndex& /*parent*/)
-{
- return false;
-}
-
-bool PokemodTreeModel::removeColumns(int /*position*/, int /*columns*/, const QModelIndex& /*parent*/)
-{
- return false;
+ emit(layoutAboutToBeChanged());
+ bool success = object->setData(value, role);
+ emit(dataChanged(index, index));
+ emit(layoutChanged());
+ return success;
}
bool PokemodTreeModel::insertRows(int /*position*/, int rows, const QModelIndex& parent)
@@ -109,9 +107,9 @@ bool PokemodTreeModel::insertRows(int /*position*/, int rows, const QModelIndex&
BaseModel* object = getItem(parent);
if (!object->canInsertRows())
return false;
- emit(beginInsertRows(parent, object->rowCount(), object->rowCount() + rows - 1));
+ emit(layoutAboutToBeChanged());
bool success = object->insertRows(rows);
- emit(endInsertRows());
+ emit(layoutChanged());
return success;
}
@@ -120,9 +118,9 @@ bool PokemodTreeModel::removeRows(int position, int rows, const QModelIndex& par
BaseModel* object = getItem(parent);
if (!object->canRemoveRows())
return false;
- emit(beginRemoveRows(parent, position, position + rows - 1));
+ emit(layoutAboutToBeChanged());
bool success = object->removeRows(position, rows);
- emit(endRemoveRows());
+ emit(layoutChanged());
return success;
}
@@ -162,5 +160,8 @@ bool PokemodTreeModel::dropMimeData(const QMimeData* data, Qt::DropAction action
return false;
if (parent.isValid())
return setData(parent, data->data("application/x-pokemod+xml"), BaseModel::XmlRole);
- return m_root->setData(data->data("application/x-pokemod+xml"), BaseModel::XmlRole);
+ emit(layoutAboutToBeChanged());
+ bool success = m_root->setData(data->data("application/x-pokemod+xml"), BaseModel::XmlRole);
+ emit(layoutChanged());
+ return success;
}
diff --git a/pokemodr/PokemodTreeModel.h b/pokemodr/PokemodTreeModel.h
index 6f55ff0d..d3921911 100644
--- a/pokemodr/PokemodTreeModel.h
+++ b/pokemodr/PokemodTreeModel.h
@@ -18,6 +18,9 @@
#ifndef __POKEMODR_POKEMODTREEMODELMODEL__
#define __POKEMODR_POKEMODTREEMODELMODEL__
+// Model includes
+#include "models/RootModel.h"
+
// Qt includes
#include <QAbstractItemModel>
#include <QModelIndex>
@@ -25,9 +28,6 @@
#include <QStringList>
#include <QVariant>
-// Model includes
-#include "models/RootModel.h"
-
class PokemodTreeModel : public QAbstractItemModel
{
Q_OBJECT
@@ -37,6 +37,7 @@ class PokemodTreeModel : public QAbstractItemModel
~PokemodTreeModel();
QVariant data(const QModelIndex& index, int role) const;
+ QVariant headerData(int /*section*/, Qt::Orientation /*orientation*/, int /*role = Qt::DisplayRole*/) const;
QModelIndex index(int row, int /*column*/, const QModelIndex& parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex& index) const;
@@ -47,9 +48,6 @@ class PokemodTreeModel : public QAbstractItemModel
Qt::ItemFlags flags(const QModelIndex& index) const;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
- bool insertColumns(int /*position*/, int /*columns*/, const QModelIndex& /*parent = QModelIndex()*/);
- bool removeColumns(int /*position*/, int /*columns*/, const QModelIndex& /*parent = QModelIndex()*/);
-
bool insertRows(int /*position*/, int rows, const QModelIndex& parent = QModelIndex());
bool removeRows(int position, int rows, const QModelIndex& parent = QModelIndex());
diff --git a/pokemodr/PokemodUI.cpp b/pokemodr/PokemodUI.cpp
index 63561a2e..0d9dd96a 100644
--- a/pokemodr/PokemodUI.cpp
+++ b/pokemodr/PokemodUI.cpp
@@ -15,24 +15,24 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QSize>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
-
-// Pokemod includes
-#include <Item.h>
-#include <Map.h>
-#include <MapWarp.h>
+// Header include
+#include "PokemodUI.h"
// PokeModr includes
#include "FileDialog.h"
#include "TypechartWidgetItem.h"
-// Header include
-#include "PokemodUI.h"
+// Pokemod includes
+#include "../pokemod/Item.h"
+#include "../pokemod/Map.h"
+#include "../pokemod/MapWarp.h"
+
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QSize>
PokemodUI::PokemodUI(Pokemod* pokemod, QWidget* parent) :
ObjectUI(parent),
diff --git a/pokemodr/PokemodUI.h b/pokemodr/PokemodUI.h
index 10a7cdd0..e702d4c7 100644
--- a/pokemodr/PokemodUI.h
+++ b/pokemodr/PokemodUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_POKEMODUI__
#define __POKEMODR_POKEMODUI__
-// Pokemod includes
-#include <Pokemod.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Pokemod.h"
+
// Form include
#include "ui_pokemod.h"
diff --git a/pokemodr/RulesUI.cpp b/pokemodr/RulesUI.cpp
index ae66439f..be5f7342 100644
--- a/pokemodr/RulesUI.cpp
+++ b/pokemodr/RulesUI.cpp
@@ -15,13 +15,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
-
// Header include
#include "RulesUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
RulesUI::RulesUI(Rules* rules, QWidget* parent) :
ObjectUI(parent),
m_rules(rules),
diff --git a/pokemodr/RulesUI.h b/pokemodr/RulesUI.h
index b3408e97..acf03a2d 100644
--- a/pokemodr/RulesUI.h
+++ b/pokemodr/RulesUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_RULESUI__
#define __POKEMODR_RULESUI__
-// Pokemod includes
-#include <Rules.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Rules.h"
+
// Form include
#include "ui_rules.h"
diff --git a/pokemodr/SpeciesAbilityUI.cpp b/pokemodr/SpeciesAbilityUI.cpp
index f6426f54..ad517fc8 100644
--- a/pokemodr/SpeciesAbilityUI.cpp
+++ b/pokemodr/SpeciesAbilityUI.cpp
@@ -15,20 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QVariant>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "SpeciesAbilityUI.h"
// Pokemod includes
-#include <Ability.h>
-#include <Pokemod.h>
-#include <SpeciesAbility.h>
+#include "../pokemod/Ability.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/SpeciesAbility.h"
-// Header include
-#include "SpeciesAbilityUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QVariant>
SpeciesAbilityUI::SpeciesAbilityUI(SpeciesAbility* ability, QWidget* parent) :
ObjectUI(parent),
@@ -45,9 +45,9 @@ SpeciesAbilityUI::SpeciesAbilityUI(SpeciesAbility* ability, QWidget* parent) :
void SpeciesAbilityUI::refreshGui()
{
varAbility->clear();
- for (int i = 0; i < m_ability->pokemod()->abilityCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_ability->pokemod())->abilityCount(); ++i)
{
- const Ability* a = m_ability->pokemod()->ability(i);
+ const Ability* a = static_cast<const Pokemod*>(m_ability->pokemod())->ability(i);
varAbility->addItem(a->name());
varAbility->setItemData(i, a->id());
}
diff --git a/pokemodr/SpeciesAbilityUI.h b/pokemodr/SpeciesAbilityUI.h
index fa780b80..b2b27a90 100644
--- a/pokemodr/SpeciesAbilityUI.h
+++ b/pokemodr/SpeciesAbilityUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_SPECIESABILITYUI__
#define __POKEMODR_SPECIESABILITYUI__
-// Pokemod includes
-#include <SpeciesAbility.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/SpeciesAbility.h"
+
// Form include
#include "ui_speciesability.h"
diff --git a/pokemodr/SpeciesEvolutionUI.cpp b/pokemodr/SpeciesEvolutionUI.cpp
index e04834a9..3a33b1a2 100644
--- a/pokemodr/SpeciesEvolutionUI.cpp
+++ b/pokemodr/SpeciesEvolutionUI.cpp
@@ -15,22 +15,22 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QVariant>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "SpeciesEvolutionUI.h"
// Pokemod includes
-#include <Item.h>
-#include <ItemEffect.h>
-#include <Pokemod.h>
-#include <Species.h>
-#include <SpeciesEvolution.h>
+#include "../pokemod/Item.h"
+#include "../pokemod/ItemEffect.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Species.h"
+#include "../pokemod/SpeciesEvolution.h"
-// Header include
-#include "SpeciesEvolutionUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QVariant>
SpeciesEvolutionUI::SpeciesEvolutionUI(SpeciesEvolution* evolution, QWidget* parent) :
ObjectUI(parent),
@@ -53,9 +53,9 @@ void SpeciesEvolutionUI::initGui()
void SpeciesEvolutionUI::refreshGui()
{
varSpecies->clear();
- for (int i = 0; i < m_evolution->pokemod()->speciesCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_evolution->pokemod())->speciesCount(); ++i)
{
- const Species* species = m_evolution->pokemod()->species(i);
+ const Species* species = static_cast<const Pokemod*>(m_evolution->pokemod())->species(i);
varSpecies->addItem(species->name());
varSpecies->setItemData(i, species->id());
}
@@ -86,9 +86,9 @@ void SpeciesEvolutionUI::setGui()
case SpeciesEvolution::S_Item:
case SpeciesEvolution::S_TradeItem:
varValue1->setEnabled(true);
- for (int i = 0; i < m_evolution->pokemod()->itemCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_evolution->pokemod())->itemCount(); ++i)
{
- const Item* item = m_evolution->pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(m_evolution->pokemod())->item(i);
for (int j = 0; j < item->effectCount(); ++j)
{
if (item->effect(i)->effect() == ItemEffect::E_Evolution)
@@ -100,7 +100,7 @@ void SpeciesEvolutionUI::setGui()
}
break;
}
- const bool isSplit = m_evolution->pokemod()->rules()->specialSplit();
+ const bool isSplit = static_cast<const Pokemod*>(m_evolution->pokemod())->rules()->specialSplit();
switch (m_evolution_mod->style())
{
case SpeciesEvolution::S_Stat:
diff --git a/pokemodr/SpeciesEvolutionUI.h b/pokemodr/SpeciesEvolutionUI.h
index 2f8b4818..82cd18dd 100644
--- a/pokemodr/SpeciesEvolutionUI.h
+++ b/pokemodr/SpeciesEvolutionUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_SPECIESEVOLUTIONUI__
#define __POKEMODR_SPECIESEVOLUTIONUI__
-// Pokemod includes
-#include <SpeciesEvolution.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/SpeciesEvolution.h"
+
// Form include
#include "ui_speciesevolution.h"
diff --git a/pokemodr/SpeciesItemUI.cpp b/pokemodr/SpeciesItemUI.cpp
index 09eaa43c..94b1c833 100644
--- a/pokemodr/SpeciesItemUI.cpp
+++ b/pokemodr/SpeciesItemUI.cpp
@@ -15,20 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QVariant>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "SpeciesItemUI.h"
// Pokemod includes
-#include <Item.h>
-#include <Pokemod.h>
-#include <SpeciesItem.h>
+#include "../pokemod/Item.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/SpeciesItem.h"
-// Header include
-#include "SpeciesItemUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QVariant>
SpeciesItemUI::SpeciesItemUI(SpeciesItem* item, QWidget* parent) :
ObjectUI(parent),
@@ -45,9 +45,9 @@ SpeciesItemUI::SpeciesItemUI(SpeciesItem* item, QWidget* parent) :
void SpeciesItemUI::refreshGui()
{
varItem->clear();
- for (int i = 0; i < m_item->pokemod()->itemCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_item->pokemod())->itemCount(); ++i)
{
- const Item* item = m_item->pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(m_item->pokemod())->item(i);
varItem->addItem(item->name());
varItem->setItemData(i, item->id());
}
diff --git a/pokemodr/SpeciesItemUI.h b/pokemodr/SpeciesItemUI.h
index bd1099c0..8253dada 100644
--- a/pokemodr/SpeciesItemUI.h
+++ b/pokemodr/SpeciesItemUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_SPECIESITEMUI__
#define __POKEMODR_SPECIESITEMUI__
-// Pokemod includes
-#include <SpeciesItem.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/SpeciesItem.h"
+
// Form include
#include "ui_speciesitem.h"
diff --git a/pokemodr/SpeciesMoveUI.cpp b/pokemodr/SpeciesMoveUI.cpp
index 9f74fff2..3150255e 100644
--- a/pokemodr/SpeciesMoveUI.cpp
+++ b/pokemodr/SpeciesMoveUI.cpp
@@ -15,20 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QVariant>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "SpeciesMoveUI.h"
// Pokemod includes
-#include <Move.h>
-#include <Pokemod.h>
-#include <SpeciesMove.h>
+#include "../pokemod/Move.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/SpeciesMove.h"
-// Header include
-#include "SpeciesMoveUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QVariant>
SpeciesMoveUI::SpeciesMoveUI(SpeciesMove* move, QWidget* parent) :
ObjectUI(parent),
@@ -45,14 +45,14 @@ SpeciesMoveUI::SpeciesMoveUI(SpeciesMove* move, QWidget* parent) :
void SpeciesMoveUI::refreshGui()
{
varMove->clear();
- for (int i = 0; i < m_move->pokemod()->moveCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_move->pokemod())->moveCount(); ++i)
{
- const Move* move = m_move->pokemod()->move(i);
+ const Move* move = static_cast<const Pokemod*>(m_move->pokemod())->move(i);
varMove->addItem(move->name());
varMove->setItemData(i, move->id());
}
- varLevel->setMaximum(m_move->pokemod()->rules()->maxLevel());
- varWildLevel->setMaximum(m_move->pokemod()->rules()->maxLevel());
+ varLevel->setMaximum(static_cast<const Pokemod*>(m_move->pokemod())->rules()->maxLevel());
+ varWildLevel->setMaximum(static_cast<const Pokemod*>(m_move->pokemod())->rules()->maxLevel());
}
void SpeciesMoveUI::setGui()
diff --git a/pokemodr/SpeciesMoveUI.h b/pokemodr/SpeciesMoveUI.h
index 36ff2a3b..57b5935d 100644
--- a/pokemodr/SpeciesMoveUI.h
+++ b/pokemodr/SpeciesMoveUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_SPECIESMOVEUI__
#define __POKEMODR_SPECIESMOVEUI__
-// Pokemod includes
-#include <SpeciesMove.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/SpeciesMove.h"
+
// Form include
#include "ui_speciesmove.h"
diff --git a/pokemodr/SpeciesUI.cpp b/pokemodr/SpeciesUI.cpp
index ed4ae584..7ca1220a 100644
--- a/pokemodr/SpeciesUI.cpp
+++ b/pokemodr/SpeciesUI.cpp
@@ -15,25 +15,25 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QSize>
-#include <QVariant>
+// Header include
+#include "SpeciesUI.h"
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// PokeModr includes
+#include "FileDialog.h"
// Pokemod includes
-#include <EggGroup.h>
-#include <Pokemod.h>
-#include <Species.h>
-#include <Type.h>
+#include "../pokemod/EggGroup.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Species.h"
+#include "../pokemod/Type.h"
-// PokeModr includes
-#include "FileDialog.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
-// Header include
-#include "SpeciesUI.h"
+// Qt includes
+#include <QSize>
+#include <QVariant>
SpeciesUI::SpeciesUI(Species* species, QWidget* parent) :
ObjectUI(parent),
@@ -56,29 +56,29 @@ void SpeciesUI::refreshGui()
{
varBaseStat->clear();
varEVStat->clear();
- const bool isSplit = m_species->pokemod()->rules()->specialSplit();
+ const bool isSplit = static_cast<const Pokemod*>(m_species->pokemod())->rules()->specialSplit();
varBaseStat->addItems((isSplit ? Pokemod::StatGSCStr : Pokemod::StatRBYStr).mid(0, isSplit ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY));
- if (m_species->pokemod()->rules()->effortValuesAllowed())
+ if (static_cast<const Pokemod*>(m_species->pokemod())->rules()->effortValuesAllowed())
varEVStat->addItems((isSplit ? Pokemod::StatGSCStr : Pokemod::StatRBYStr).mid(0, isSplit ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY));
else
boxEffortValues->setEnabled(false);
- if (!m_species->pokemod()->rules()->holdItems())
+ if (!static_cast<const Pokemod*>(m_species->pokemod())->rules()->holdItems())
boxItemChance->setEnabled(false);
- if (m_species->pokemod()->rules()->genderAllowed())
+ if (static_cast<const Pokemod*>(m_species->pokemod())->rules()->genderAllowed())
{
varEggSpecies->clear();
varEggGroups->clear();
- if (m_species->pokemod()->rules()->breedingAllowed())
+ if (static_cast<const Pokemod*>(m_species->pokemod())->rules()->breedingAllowed())
{
- for (int i = 0; i < m_species->pokemod()->speciesCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_species->pokemod())->speciesCount(); ++i)
{
- const Species* species = m_species->pokemod()->species(i);
+ const Species* species = static_cast<const Pokemod*>(m_species->pokemod())->species(i);
varEggSpecies->addItem(species->name());
varEggSpecies->setItemData(i, species->id());
}
- for (int i = 0; i < m_species->pokemod()->eggGroupCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_species->pokemod())->eggGroupCount(); ++i)
{
- const EggGroup* eggGroup = m_species->pokemod()->eggGroup(i);
+ const EggGroup* eggGroup = static_cast<const Pokemod*>(m_species->pokemod())->eggGroup(i);
QListWidgetItem* widgetItem = new QListWidgetItem(eggGroup->name(), varEggGroups);
widgetItem->setData(Qt::UserRole, eggGroup->id());
}
@@ -97,9 +97,9 @@ void SpeciesUI::refreshGui()
boxFemaleSprites->setEnabled(false);
}
varTypes->clear();
- for (int i = 0; i < m_species->pokemod()->typeCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_species->pokemod())->typeCount(); ++i)
{
- const Type* type = m_species->pokemod()->type(i);
+ const Type* type = static_cast<const Pokemod*>(m_species->pokemod())->type(i);
QListWidgetItem* widgetItem = new QListWidgetItem(type->name(), varTypes);
widgetItem->setData(Qt::UserRole, type->id());
}
@@ -122,7 +122,7 @@ void SpeciesUI::setGui()
varPokedexEntry->setText(m_species_mod->pokedexEntry());
varMaleFront->setIcon(m_species_mod->frontMaleSprite());
varMaleBack->setIcon(m_species_mod->backMaleSprite());
- if (m_species->pokemod()->rules()->genderAllowed())
+ if (static_cast<const Pokemod*>(m_species->pokemod())->rules()->genderAllowed())
{
varFemaleFront->setIcon(m_species_mod->frontFemaleSprite());
varFemaleBack->setIcon(m_species_mod->backFemaleSprite());
diff --git a/pokemodr/SpeciesUI.h b/pokemodr/SpeciesUI.h
index 9b076f86..fb05350e 100644
--- a/pokemodr/SpeciesUI.h
+++ b/pokemodr/SpeciesUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_SPECIESUI__
#define __POKEMODR_SPECIESUI__
-// Pokemod includes
-#include <Species.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Species.h"
+
// Form include
#include "ui_species.h"
diff --git a/pokemodr/StoreUI.cpp b/pokemodr/StoreUI.cpp
index 713563e4..c7043f77 100644
--- a/pokemodr/StoreUI.cpp
+++ b/pokemodr/StoreUI.cpp
@@ -15,21 +15,21 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QListWidgetItem>
-#include <QVariant>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "StoreUI.h"
// Pokemod includes
-#include <Item.h>
-#include <Pokemod.h>
-#include <Store.h>
+#include "../pokemod/Item.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Store.h"
-// Header include
-#include "StoreUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QListWidgetItem>
+#include <QVariant>
StoreUI::StoreUI(Store* store, QWidget* parent) :
ObjectUI(parent),
@@ -46,9 +46,9 @@ StoreUI::StoreUI(Store* store, QWidget* parent) :
void StoreUI::refreshGui()
{
varItems->clear();
- for (int i = 0; i < m_store->pokemod()->itemCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_store->pokemod())->itemCount(); ++i)
{
- const Item* item = m_store->pokemod()->item(i);
+ const Item* item = static_cast<const Pokemod*>(m_store->pokemod())->item(i);
QListWidgetItem* widgetItem = new QListWidgetItem(item->name(), varItems);
widgetItem->setData(Qt::UserRole, item->id());
}
diff --git a/pokemodr/StoreUI.h b/pokemodr/StoreUI.h
index 45266df3..733042ee 100644
--- a/pokemodr/StoreUI.h
+++ b/pokemodr/StoreUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_STOREUI__
#define __POKEMODR_STOREUI__
-// Pokemod includes
-#include <Store.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Store.h"
+
// Form include
#include "ui_store.h"
diff --git a/pokemodr/TODO b/pokemodr/TODO
index 21fcf866..38e42185 100644
--- a/pokemodr/TODO
+++ b/pokemodr/TODO
@@ -9,7 +9,5 @@ Update GUI to see new methods
Set sub class stuff by passing it on to subclasses via setData
-Drag and drop stuff
-
Flag widget
TilemapModel is (probably) wrong
diff --git a/pokemodr/TileDelegate.cpp b/pokemodr/TileDelegate.cpp
index 756edc66..96aa8dfd 100644
--- a/pokemodr/TileDelegate.cpp
+++ b/pokemodr/TileDelegate.cpp
@@ -15,20 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// KDE includes
-#include <kcombobox.h>
-
-// Pokemod includes
-#include <Pokemod.h>
-#include <Tile.h>
+// Header include
+#include "TileDelegate.h"
// PokeModr includes
#include "ObjectUI.h"
#include "MapUI.h"
#include "TilemapModel.h"
-// Header include
-#include "TileDelegate.h"
+// Pokemod includes
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Tile.h"
+
+// KDE includes
+#include <kcombobox.h>
QWidget* TileDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const
{
@@ -38,9 +38,9 @@ QWidget* TileDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&
void TileDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
- for (int i = 0; i < static_cast<ObjectUI*>(editor->parent())->original()->pokemod()->tileCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(static_cast<ObjectUI*>(editor->parent())->original()->pokemod())->tileCount(); ++i)
{
- const Tile* tile = static_cast<ObjectUI*>(editor->parent())->original()->pokemod()->tile(i);
+ const Tile* tile = static_cast<const Pokemod*>(static_cast<ObjectUI*>(editor->parent())->original()->pokemod())->tile(i);
static_cast<KComboBox*>(editor)->addItem(tile->sprite(), tile->name());
static_cast<KComboBox*>(editor)->setItemData(i, tile->id());
}
diff --git a/pokemodr/TileUI.cpp b/pokemodr/TileUI.cpp
index 46e1fc20..f53a9b10 100644
--- a/pokemodr/TileUI.cpp
+++ b/pokemodr/TileUI.cpp
@@ -15,23 +15,23 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QList>
-#include <QListWidgetItem>
-#include <QSize>
+// Header include
+#include "TileUI.h"
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// PokeModr includes
+#include "FileDialog.h"
// Pokemod includes
-#include <Pokemod.h>
+#include "../pokemod/Pokemod.h"
-// PokeModr includes
-#include "FileDialog.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
-// Header include
-#include "TileUI.h"
+// Qt includes
+#include <QList>
+#include <QListWidgetItem>
+#include <QSize>
TileUI::TileUI(Tile* tile, QWidget* parent) :
ObjectUI(parent),
@@ -56,9 +56,9 @@ void TileUI::initGui()
void TileUI::refreshGui()
{
varHMUnder->clear();
- for (int i = 0; i < m_tile->pokemod()->tileCount(); ++i)
+ for (int i = 0; i < static_cast<const Pokemod*>(m_tile->pokemod())->tileCount(); ++i)
{
- const Tile* tile = m_tile->pokemod()->tile(i);
+ const Tile* tile = static_cast<const Pokemod*>(m_tile->pokemod())->tile(i);
if (tile->id() != m_tile->id())
{
varHMUnder->addItem(tile->sprite(), tile->name());
diff --git a/pokemodr/TileUI.h b/pokemodr/TileUI.h
index 88e93067..07c9f90a 100644
--- a/pokemodr/TileUI.h
+++ b/pokemodr/TileUI.h
@@ -18,14 +18,14 @@
#ifndef __POKEMODR_TILEUI__
#define __POKEMODR_TILEUI__
-// Qt includes
-#include <QString>
+// PokeModr includes
+#include "ObjectUI.h"
// Pokemod includes
-#include <Tile.h>
+#include "../pokemod/Tile.h"
-// PokeModr includes
-#include "ObjectUI.h"
+// Qt includes
+#include <QString>
// Form include
#include "ui_tile.h"
diff --git a/pokemodr/TilemapModel.cpp b/pokemodr/TilemapModel.cpp
index 6fe1970c..b903fd00 100644
--- a/pokemodr/TilemapModel.cpp
+++ b/pokemodr/TilemapModel.cpp
@@ -15,18 +15,18 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// KDE includes
-#include <kcombobox.h>
-
-// Pokemod includes
-#include <Tile.h>
+// Header include
+#include "TilemapModel.h"
// PokeModr includes
#include "ObjectUI.h"
#include "MapUI.h"
-// Header include
-#include "TilemapModel.h"
+// Pokemod includes
+#include "../pokemod/Tile.h"
+
+// KDE includes
+#include <kcombobox.h>
TilemapModel::TilemapModel(QObject* parent, Matrix<int>* map, const Pokemod* pokemod) :
QAbstractTableModel(parent),
diff --git a/pokemodr/TilemapModel.h b/pokemodr/TilemapModel.h
index 34d0bf9e..98d585f2 100644
--- a/pokemodr/TilemapModel.h
+++ b/pokemodr/TilemapModel.h
@@ -18,17 +18,17 @@
#ifndef __POKEMODR_TILEMAPMODEL__
#define __POKEMODR_TILEMAPMODEL__
+// Pokemod includes
+#include "../pokemod/Pokemod.h"
+
+// General includes
+#include "../general/Matrix.h"
+
// Qt includes
#include <QAbstractTableModel>
#include <QObject>
#include <QVariant>
-// General includes
-#include <Matrix.h>
-
-// Pokemod includes
-#include <Pokemod.h>
-
class TilemapModel : public QAbstractTableModel
{
Q_OBJECT
diff --git a/pokemodr/TimeUI.cpp b/pokemodr/TimeUI.cpp
index 0554fc5b..cef3522e 100644
--- a/pokemodr/TimeUI.cpp
+++ b/pokemodr/TimeUI.cpp
@@ -16,8 +16,8 @@
*/
// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
// Gheaer include
#include "TimeUI.h"
diff --git a/pokemodr/TimeUI.h b/pokemodr/TimeUI.h
index a1ee5f09..884f34db 100644
--- a/pokemodr/TimeUI.h
+++ b/pokemodr/TimeUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_TIMEUI__
#define __POKEMODR_TIMEUI__
-// Pokemod includes
-#include <Time.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Time.h"
+
// Form include
#include "ui_time.h"
diff --git a/pokemodr/TrainerUI.cpp b/pokemodr/TrainerUI.cpp
index 4b5d0d26..f51c38c0 100644
--- a/pokemodr/TrainerUI.cpp
+++ b/pokemodr/TrainerUI.cpp
@@ -15,18 +15,18 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QSize>
-
-// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+// Header include
+#include "TrainerUI.h"
// PokeModr includes
#include "FileDialog.h"
-// Header include
-#include "TrainerUI.h"
+// General includes
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
+
+// Qt includes
+#include <QSize>
TrainerUI::TrainerUI(Trainer * trainer, QWidget * parent) :
ObjectUI(parent),
diff --git a/pokemodr/TrainerUI.h b/pokemodr/TrainerUI.h
index abbbccdb..efe5ea8f 100644
--- a/pokemodr/TrainerUI.h
+++ b/pokemodr/TrainerUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_TRAINERUI__
#define __POKEMODR_TRAINERUI__
-// Pokemod includes
-#include <Trainer.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Trainer.h"
+
// Form include
#include "ui_trainer.h"
diff --git a/pokemodr/TypeUI.cpp b/pokemodr/TypeUI.cpp
index 3d0b6f76..b81928d4 100644
--- a/pokemodr/TypeUI.cpp
+++ b/pokemodr/TypeUI.cpp
@@ -15,15 +15,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QStringList>
+// Header include
+#include "TypeUI.h"
// General includes
-#include <BugCatcher.h>
-#include <Exception.h>
+#include "../general/BugCatcher.h"
+#include "../general/Exception.h"
-// Header include
-#include "TypeUI.h"
+// Qt includes
+#include <QStringList>
TypeUI::TypeUI(Type* type, QWidget* parent) :
ObjectUI(parent),
diff --git a/pokemodr/TypeUI.h b/pokemodr/TypeUI.h
index 616629cf..78b317dd 100644
--- a/pokemodr/TypeUI.h
+++ b/pokemodr/TypeUI.h
@@ -18,12 +18,12 @@
#ifndef __POKEMODR_TYPEUI__
#define __POKEMODR_TYPEUI__
-// Pokemod includes
-#include <Type.h>
-
// PokeModr includes
#include "ObjectUI.h"
+// Pokemod includes
+#include "../pokemod/Type.h"
+
// Form include
#include "ui_type.h"
diff --git a/pokemodr/TypechartWidgetItem.h b/pokemodr/TypechartWidgetItem.h
index 51716f52..86c612fb 100644
--- a/pokemodr/TypechartWidgetItem.h
+++ b/pokemodr/TypechartWidgetItem.h
@@ -18,14 +18,14 @@
#ifndef __TYPECHARTWIDGETITEM__
#define __TYPECHARTWIDGETITEM__
+// General includes
+#include "../general/Fraction.h"
+
// Qt includes
#include <QObject>
#include <QTableWidgetItem>
#include <QVariant>
-// General includes
-#include <Fraction.h>
-
#define DBL_PREC_SHORT 3
class TypechartWidgetItem : public QObject, public QTableWidgetItem
diff --git a/pokemodr/models/AbilityEffectModel.cpp b/pokemodr/models/AbilityEffectModel.cpp
index b6221562..54fb67da 100644
--- a/pokemodr/models/AbilityEffectModel.cpp
+++ b/pokemodr/models/AbilityEffectModel.cpp
@@ -15,15 +15,18 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include <AbilityEffect.h>
-#include <Pokemod.h>
+// Header include
+#include "AbilityEffectModel.h"
// PokeModr includes
-// #include "AbilityEffectUI.h"
+// #include "../AbilityEffectUI.h"
-// Header include
-#include "AbilityEffectModel.h"
+// Pokemod includes
+#include "../../pokemod/AbilityEffect.h"
+#include "../../pokemod/Pokemod.h"
+
+// Qt includes
+#include <QFile>
AbilityEffectModel::AbilityEffectModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
diff --git a/pokemodr/models/AbilityModel.cpp b/pokemodr/models/AbilityModel.cpp
index 13b3707b..5d6bea06 100644
--- a/pokemodr/models/AbilityModel.cpp
+++ b/pokemodr/models/AbilityModel.cpp
@@ -15,23 +15,23 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
+// Header include
+#include "AbilityModel.h"
-// Pokemod includes
-#include <Ability.h>
-#include <AbilityEffect.h>
-#include <Pokemod.h>
+// Model includes
+#include "AbilityEffectModel.h"
// PokeModr includes
-#include "AbilityUI.h"
+#include "../AbilityUI.h"
-// Model includes
-#include "AbilityEffectModel.h"
+// Pokemod includes
+#include "../../pokemod/Ability.h"
+#include "../../pokemod/AbilityEffect.h"
+#include "../../pokemod/Pokemod.h"
-// Header include
-#include "AbilityModel.h"
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
AbilityModel::AbilityModel(BaseModel* parent, Object* object) :
GroupObjectModel(parent, object)
@@ -98,7 +98,7 @@ BaseModel* AbilityModel::childItem(const int row)
int AbilityModel::indexNumber() const
{
- return m_object->pokemod()->abilityIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->abilityIndex(m_object->id());
}
bool AbilityModel::insertRows(const int rows)
diff --git a/pokemodr/models/BadgeModel.cpp b/pokemodr/models/BadgeModel.cpp
index 5776526b..8953b457 100644
--- a/pokemodr/models/BadgeModel.cpp
+++ b/pokemodr/models/BadgeModel.cpp
@@ -15,19 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <Badge.h>
-#include <Pokemod.h>
+// Header include
+#include "BadgeModel.h"
// PokeModr includes
-#include "BadgeUI.h"
+#include "../BadgeUI.h"
-// Header include
-#include "BadgeModel.h"
+// Pokemod includes
+#include "../../pokemod/Badge.h"
+#include "../../pokemod/Pokemod.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
BadgeModel::BadgeModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -80,5 +80,5 @@ bool BadgeModel::setData(const QVariant& value, int role)
int BadgeModel::indexNumber() const
{
- return m_object->pokemod()->badgeIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->badgeIndex(m_object->id());
}
diff --git a/pokemodr/models/BaseModel.h b/pokemodr/models/BaseModel.h
index b0eec613..689e0ad5 100644
--- a/pokemodr/models/BaseModel.h
+++ b/pokemodr/models/BaseModel.h
@@ -24,7 +24,7 @@
#include <QVariant>
// Pokemod includes
-#include <Object.h>
+#include "../../pokemod/Object.h"
class BaseModel
{
diff --git a/pokemodr/models/CoinListModel.cpp b/pokemodr/models/CoinListModel.cpp
index a66a8a35..1b13ebd8 100644
--- a/pokemodr/models/CoinListModel.cpp
+++ b/pokemodr/models/CoinListModel.cpp
@@ -15,23 +15,23 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
+// Header include
+#include "CoinListModel.h"
-// Pokemod includes
-#include <CoinList.h>
-#include <CoinListObject.h>
-#include <Pokemod.h>
+// Model includes
+#include "CoinListObjectModel.h"
// PokeModr includes
-#include "CoinListUI.h"
+#include "../CoinListUI.h"
-// Model includes
-#include "CoinListObjectModel.h"
+// Pokemod includes
+#include "../../pokemod/CoinList.h"
+#include "../../pokemod/CoinListObject.h"
+#include "../../pokemod/Pokemod.h"
-// Header include
-#include "CoinListModel.h"
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
CoinListModel::CoinListModel(BaseModel* parent, Object* object) :
GroupObjectModel(parent, object)
@@ -98,7 +98,7 @@ BaseModel* CoinListModel::childItem(const int row)
int CoinListModel::indexNumber() const
{
- return m_object->pokemod()->coinListIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->coinListIndex(m_object->id());
}
bool CoinListModel::insertRows(const int rows)
diff --git a/pokemodr/models/CoinListObjectModel.cpp b/pokemodr/models/CoinListObjectModel.cpp
index 0176b7e2..ed788cae 100644
--- a/pokemodr/models/CoinListObjectModel.cpp
+++ b/pokemodr/models/CoinListObjectModel.cpp
@@ -15,20 +15,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <CoinListObject.h>
-#include <Item.h>
-#include <Species.h>
+// Header include
+#include "CoinListObjectModel.h"
// PokeModr includes
-#include "CoinListObjectUI.h"
+#include "../CoinListObjectUI.h"
-// Header include
-#include "CoinListObjectModel.h"
+// Pokemod includes
+#include "../../pokemod/CoinListObject.h"
+#include "../../pokemod/Item.h"
+#include "../../pokemod/Species.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
CoinListObjectModel::CoinListObjectModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -45,9 +45,9 @@ QVariant CoinListObjectModel::data(int role) const
{
CoinListObject* object = static_cast<CoinListObject*>(m_object);
if (object->type() == CoinListObject::Item)
- return m_object->pokemod()->item(object->object())->name();
+ return static_cast<const Pokemod*>(m_object->pokemod())->item(object->object())->name();
else if (object->type() == CoinListObject::Species)
- return m_object->pokemod()->species(object->object())->name();
+ return static_cast<const Pokemod*>(m_object->pokemod())->species(object->object())->name();
}
else if (role == BaseModel::XmlRole)
{
diff --git a/pokemodr/models/DialogModel.cpp b/pokemodr/models/DialogModel.cpp
index a39d160b..7cf453b6 100644
--- a/pokemodr/models/DialogModel.cpp
+++ b/pokemodr/models/DialogModel.cpp
@@ -15,19 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <Dialog.h>
-#include <Pokemod.h>
+// Header include
+#include "DialogModel.h"
// PokeModr includes
-// #include "DialogUI.h"
+// #include "../DialogUI.h"
-// Header include
-#include "DialogModel.h"
+// Pokemod includes
+#include "../../pokemod/Dialog.h"
+#include "../../pokemod/Pokemod.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
DialogModel::DialogModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -81,5 +81,5 @@ bool DialogModel::setData(const QVariant& value, int role)
int DialogModel::indexNumber() const
{
- return m_object->pokemod()->dialogIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->dialogIndex(m_object->id());
}
diff --git a/pokemodr/models/EggGroupModel.cpp b/pokemodr/models/EggGroupModel.cpp
index 5702706a..867b58c0 100644
--- a/pokemodr/models/EggGroupModel.cpp
+++ b/pokemodr/models/EggGroupModel.cpp
@@ -15,19 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <EggGroup.h>
-#include <Pokemod.h>
+// Header include
+#include "EggGroupModel.h"
// PokeModr includes
-#include "EggGroupUI.h"
+#include "../EggGroupUI.h"
-// Header include
-#include "EggGroupModel.h"
+// Pokemod includes
+#include "../../pokemod/EggGroup.h"
+#include "../../pokemod/Pokemod.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
EggGroupModel::EggGroupModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -80,5 +80,5 @@ bool EggGroupModel::setData(const QVariant& value, int role)
int EggGroupModel::indexNumber() const
{
- return m_object->pokemod()->eggGroupIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->eggGroupIndex(m_object->id());
}
diff --git a/pokemodr/models/ItemTypeModel.cpp b/pokemodr/models/ItemTypeModel.cpp
index 0fa25883..d90548c2 100644
--- a/pokemodr/models/ItemTypeModel.cpp
+++ b/pokemodr/models/ItemTypeModel.cpp
@@ -15,19 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <ItemType.h>
-#include <Pokemod.h>
+// Header include
+#include "ItemTypeModel.h"
// PokeModr includes
-#include "ItemTypeUI.h"
+#include "../ItemTypeUI.h"
-// Header include
-#include "ItemTypeModel.h"
+// Pokemod includes
+#include "../../pokemod/ItemType.h"
+#include "../../pokemod/Pokemod.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
ItemTypeModel::ItemTypeModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -80,5 +80,5 @@ bool ItemTypeModel::setData(const QVariant& value, int role)
int ItemTypeModel::indexNumber() const
{
- return m_object->pokemod()->itemTypeIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->itemTypeIndex(m_object->id());
}
diff --git a/pokemodr/models/NatureModel.cpp b/pokemodr/models/NatureModel.cpp
index d832c0f4..6f0c9e1c 100644
--- a/pokemodr/models/NatureModel.cpp
+++ b/pokemodr/models/NatureModel.cpp
@@ -15,19 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <Nature.h>
-#include <Pokemod.h>
+// Header include
+#include "NatureModel.h"
// PokeModr includes
-#include "NatureUI.h"
+#include "../NatureUI.h"
-// Header include
-#include "NatureModel.h"
+// Pokemod includes
+#include "../../pokemod/Nature.h"
+#include "../../pokemod/Pokemod.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
NatureModel::NatureModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -80,5 +80,5 @@ bool NatureModel::setData(const QVariant& value, int role)
int NatureModel::indexNumber() const
{
- return m_object->pokemod()->natureIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->natureIndex(m_object->id());
}
diff --git a/pokemodr/models/PokemodModel.cpp b/pokemodr/models/PokemodModel.cpp
index 73ecf36e..81afe8e3 100644
--- a/pokemodr/models/PokemodModel.cpp
+++ b/pokemodr/models/PokemodModel.cpp
@@ -15,25 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include <Ability.h>
-#include <Badge.h>
-#include <CoinList.h>
-#include <Dialog.h>
-#include <EggGroup.h>
-#include <Item.h>
-#include <ItemType.h>
-#include <Nature.h>
-#include <Pokemod.h>
-#include <Species.h>
-#include <Store.h>
-#include <Tile.h>
-#include <Time.h>
-#include <Trainer.h>
-#include <Type.h>
-
-// PokeModr includes
-#include "PokemodUI.h"
+// Header include
+#include "PokemodModel.h"
// Model includes
#include "AbilityModel.h"
@@ -53,8 +36,28 @@
#include "TrainerModel.h"
#include "TypeModel.h"
-// Header include
-#include "PokemodModel.h"
+// PokeModr includes
+#include "../PokemodUI.h"
+
+// Pokemod includes
+#include "../../pokemod/Ability.h"
+#include "../../pokemod/Badge.h"
+#include "../../pokemod/CoinList.h"
+#include "../../pokemod/Dialog.h"
+#include "../../pokemod/EggGroup.h"
+#include "../../pokemod/Item.h"
+#include "../../pokemod/ItemType.h"
+#include "../../pokemod/Nature.h"
+#include "../../pokemod/Pokemod.h"
+#include "../../pokemod/Species.h"
+#include "../../pokemod/Store.h"
+#include "../../pokemod/Tile.h"
+#include "../../pokemod/Time.h"
+#include "../../pokemod/Trainer.h"
+#include "../../pokemod/Type.h"
+
+// Qt includes
+#include <QFile>
AbilityGroupModel::AbilityGroupModel(BaseModel* parent, Object* object) :
GroupModel(parent, object, "Abilities")
diff --git a/pokemodr/models/RootModel.cpp b/pokemodr/models/RootModel.cpp
index 2e04b3d7..7413ece5 100644
--- a/pokemodr/models/RootModel.cpp
+++ b/pokemodr/models/RootModel.cpp
@@ -15,14 +15,17 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Pokemod includes
-#include <Pokemod.h>
+// Header include
+#include "RootModel.h"
// Model includes
#include "PokemodModel.h"
-// Header include
-#include "RootModel.h"
+// Pokemod includes
+#include "../../pokemod/Pokemod.h"
+
+// Test code includes
+#include <QFile>
RootModel::RootModel(const QList<QVariant>& pokemods) :
BaseModel(NULL, NULL, "")
diff --git a/pokemodr/models/RulesModel.cpp b/pokemodr/models/RulesModel.cpp
index 6b52b482..6eb131f0 100644
--- a/pokemodr/models/RulesModel.cpp
+++ b/pokemodr/models/RulesModel.cpp
@@ -15,18 +15,18 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <Rules.h>
+// Header include
+#include "RulesModel.h"
// PokeModr includes
-#include "RulesUI.h"
+#include "../RulesUI.h"
-// Header include
-#include "RulesModel.h"
+// Pokemod includes
+#include "../../pokemod/Rules.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
RulesModel::RulesModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
diff --git a/pokemodr/models/StoreModel.cpp b/pokemodr/models/StoreModel.cpp
index acf100fd..e5ad6cc6 100644
--- a/pokemodr/models/StoreModel.cpp
+++ b/pokemodr/models/StoreModel.cpp
@@ -15,19 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <Pokemod.h>
-#include <Store.h>
+// Header include
+#include "StoreModel.h"
// PokeModr includes
-#include "StoreUI.h"
+#include "../StoreUI.h"
-// Header include
-#include "StoreModel.h"
+// Pokemod includes
+#include "../../pokemod/Pokemod.h"
+#include "../../pokemod/Store.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
StoreModel::StoreModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -80,5 +80,5 @@ bool StoreModel::setData(const QVariant& value, int role)
int StoreModel::indexNumber() const
{
- return m_object->pokemod()->storeIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->storeIndex(m_object->id());
}
diff --git a/pokemodr/models/TileModel.cpp b/pokemodr/models/TileModel.cpp
index 3bca9275..5515650a 100644
--- a/pokemodr/models/TileModel.cpp
+++ b/pokemodr/models/TileModel.cpp
@@ -15,19 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <Pokemod.h>
-#include <Tile.h>
+// Header include
+#include "TileModel.h"
// PokeModr includes
-#include "TileUI.h"
+#include "../TileUI.h"
-// Header include
-#include "TileModel.h"
+// Pokemod includes
+#include "../../pokemod/Pokemod.h"
+#include "../../pokemod/Tile.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
TileModel::TileModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -80,5 +80,5 @@ bool TileModel::setData(const QVariant& value, int role)
int TileModel::indexNumber() const
{
- return m_object->pokemod()->tileIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->tileIndex(m_object->id());
}
diff --git a/pokemodr/models/TimeModel.cpp b/pokemodr/models/TimeModel.cpp
index 4fac20ce..3b45b70c 100644
--- a/pokemodr/models/TimeModel.cpp
+++ b/pokemodr/models/TimeModel.cpp
@@ -15,19 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <Pokemod.h>
-#include <Time.h>
+// Header include
+#include "TimeModel.h"
// PokeModr includes
-#include "TimeUI.h"
+#include "../TimeUI.h"
-// Header include
-#include "TimeModel.h"
+// Pokemod includes
+#include "../../pokemod/Pokemod.h"
+#include "../../pokemod/Time.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
TimeModel::TimeModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -80,5 +80,5 @@ bool TimeModel::setData(const QVariant& value, int role)
int TimeModel::indexNumber() const
{
- return m_object->pokemod()->timeIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->timeIndex(m_object->id());
}
diff --git a/pokemodr/models/TrainerModel.cpp b/pokemodr/models/TrainerModel.cpp
index 1fef0eea..8bd0ed4b 100644
--- a/pokemodr/models/TrainerModel.cpp
+++ b/pokemodr/models/TrainerModel.cpp
@@ -15,19 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <Pokemod.h>
-#include <Trainer.h>
+// Header include
+#include "TrainerModel.h"
// PokeModr includes
-#include "TrainerUI.h"
+#include "../TrainerUI.h"
-// Header include
-#include "TrainerModel.h"
+// Pokemod includes
+#include "../../pokemod/Pokemod.h"
+#include "../../pokemod/Trainer.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
TrainerModel::TrainerModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -80,5 +80,5 @@ bool TrainerModel::setData(const QVariant& value, int role)
int TrainerModel::indexNumber() const
{
- return m_object->pokemod()->trainerIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->trainerIndex(m_object->id());
}
diff --git a/pokemodr/models/TypeModel.cpp b/pokemodr/models/TypeModel.cpp
index b3678ab1..52c5c365 100644
--- a/pokemodr/models/TypeModel.cpp
+++ b/pokemodr/models/TypeModel.cpp
@@ -15,19 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QDomDocument>
-#include <QFile>
-
-// Pokemod includes
-#include <Type.h>
-#include <Pokemod.h>
+// Header include
+#include "TypeModel.h"
// PokeModr includes
-#include "TypeUI.h"
+#include "../TypeUI.h"
-// Header include
-#include "TypeModel.h"
+// Pokemod includes
+#include "../../pokemod/Type.h"
+#include "../../pokemod/Pokemod.h"
+
+// Qt includes
+#include <QDomDocument>
+#include <QFile>
TypeModel::TypeModel(BaseModel* parent, Object* object) :
ObjectModel(parent, object)
@@ -80,5 +80,5 @@ bool TypeModel::setData(const QVariant& value, int role)
int TypeModel::indexNumber() const
{
- return m_object->pokemod()->typeIndex(m_object->id());
+ return static_cast<const Pokemod*>(m_object->pokemod())->typeIndex(m_object->id());
}