summaryrefslogtreecommitdiffstats
path: root/pokemod/Dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/Dialog.cpp')
-rw-r--r--pokemod/Dialog.cpp1227
1 files changed, 614 insertions, 613 deletions
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)