summaryrefslogtreecommitdiffstats
path: root/pokemod/MapWarp.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-06-02 18:12:48 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-06-02 18:12:48 +0000
commitc9afda3ab74614fb36986f96b7972c082f275eca (patch)
tree1b7c0b31950597d6ed562d94158dd3f8701496da /pokemod/MapWarp.cpp
parentf71140fae5218ee9839ffcd4ec83abfded5124f4 (diff)
downloadsigen-c9afda3ab74614fb36986f96b7972c082f275eca.tar.gz
sigen-c9afda3ab74614fb36986f96b7972c082f275eca.tar.xz
sigen-c9afda3ab74614fb36986f96b7972c082f275eca.zip
Finished off all PokeMod classes, added move validations, fixed up some GUI, various other fixes
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@18 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/MapWarp.cpp')
-rw-r--r--pokemod/MapWarp.cpp537
1 files changed, 537 insertions, 0 deletions
diff --git a/pokemod/MapWarp.cpp b/pokemod/MapWarp.cpp
new file mode 100644
index 00000000..3fbf3cf4
--- /dev/null
+++ b/pokemod/MapWarp.cpp
@@ -0,0 +1,537 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/MapWarp.cpp
+// Purpose: Define a warp for a map
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Fri June 1 2007 20:46:23
+// Copyright: ©2007 Nerdy Productions
+// Licence:
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MapWarp.h"
+
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::MapWarp::MapWarp(const unsigned _id) :
+ name(""),
+ coordinate(0, 0),
+ fromUp(false),
+ fromDown(false),
+ fromLeft(false),
+ fromRight(false),
+ directionOut(UINT_MAX),
+ warpType(UINT_MAX),
+ isBiking(false),
+ isFlash(false),
+ toMap(UINT_MAX),
+ toWarp(UINT_MAX),
+ workingFlag(0, 0),
+ dialog(UINT_MAX)
+{
+ LogCtor("MapWarp", _id);
+ id = _id;
+}
+
+PokeGen::PokeMod::MapWarp::MapWarp(Ini &ini, const unsigned _id)
+{
+ LogCtorIni("MapWarp", _id);
+ ImportIni(ini, _id);
+ if (id == UINT_MAX)
+ LogIdError("MapWarp");
+}
+
+PokeGen::PokeMod::MapWarp::~MapWarp()
+{
+ LogDtor("MapWarp", id, name);
+}
+
+void PokeGen::PokeMod::MapWarp::Validate()
+{
+ LogValidateStart("MapWarp", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("MapWarp", id, "name");
+ isValid = false;
+ }
+ if (!fromUp && !fromDown && !fromLeft && !fromRight)
+ {
+ LogVarNotSet("MapWarp", id, "directions", name);
+ isValid = false;
+ }
+ if (DIR_END_NONE <= directionOut)
+ {
+ LogVarNotValid("MapWarp", id, "directionOut", name);
+ isValid = false;
+ }
+ if (WT_END <= warpType)
+ {
+ LogVarNotValid("MapWarp", id, "warpType", name);
+ isValid = false;
+ }
+ if (const Map *m = curPokeMod.GetMap(toMap))
+ {
+ if (!m->GetMapWarp(toWarp))
+ {
+ LogVarNotValid("MapWarp", id, "toWarp");
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogVarNotValid("MapWarp", id, "toMap");
+ isValid = false;
+ }
+ if (!curPokeMod.GetDialog(dialog))
+ {
+ LogVarNotValid("MapWarp", id, "dialog");
+ isValid = false;
+ }
+ LogValidateOver("MapWarp", id, isValid, name);
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::MapWarp::Validate(const wxListBox &output)
+{
+ LogValidateStart("MapWarp", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("MapWarp", id, "name");
+ output.append(ConsoleLogVarNotSet("MapWarp", id, "name"));
+ isValid = false;
+ }
+ if (!fromUp && !fromDown && !fromLeft && !fromRight)
+ {
+ LogVarNotSet("MapWarp", id, "directions", name);
+ output.append(ConsoleLogVarNotSet("MapWarp", id, "directions", name));
+ isValid = false;
+ }
+ if (DIR_END_NONE <= directionOut)
+ {
+ LogVarNotValid("MapWarp", id, "directionOut", name);
+ output.append(ConsoleLogVarNotValid("MapWarp", id, "directionOut", name));
+ isValid = false;
+ }
+ if (WT_END <= warpType)
+ {
+ LogVarNotValid("MapWarp", id, "warpType", name);
+ output.append(ConsoleLogVarNotValid("MapWarp", id, "warpType", name));
+ isValid = false;
+ }
+ if (const Map *m = curPokeMod.GetMap(toMap))
+ {
+ if (!m->GetMapWarp(toWarp))
+ {
+ LogVarNotValid("MapWarp", id, "toWarp");
+ output.append(ConsoleLogVarNotValid("MapWarp", id, "toWarp"));
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogVarNotValid("MapWarp", id, "toMap");
+ output.append(ConsoleLogVarNotValid("MapWarp", id, "toMap"));
+ isValid = false;
+ }
+ if (!curPokeMod.GetDialog(dialog))
+ {
+ LogVarNotValid("MapWarp", id, "dialog");
+ output.append(ConsoleLogVarNotValid("MapWarp", id, "dialog"));
+ isValid = false;
+ }
+ LogValidateOver("MapWarp", id, isValid, name);
+}
+#endif
+
+void PokeGen::PokeMod::MapWarp::ImportIni(Ini &ini, const unsigned _id)
+{
+ LogImportStart("MapWarp");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id);
+ if (id == UINT_MAX)
+ LogIdNotFound("MapWarp");
+ }
+ else
+ id = _id;
+ unsigned i;
+ unsigned j;
+ ini.GetValue("name", name);
+ ini.GetValue("coordinate-x", i, 0);
+ ini.GetValue("coordinate-y", j, 0);
+ coordinate.Set(i, j);
+ ini.GetValue("fromUp", fromUp, false);
+ ini.GetValue("fromDown", fromDown, false);
+ ini.GetValue("fromLeft", fromLeft, false);
+ ini.GetValue("fromRight", fromRight, false);
+ ini.GetValue("directionOut", directionOut);
+ ini.GetValue("warpType", warpType);
+ ini.GetValue("isBiking", isBiking, false);
+ ini.GetValue("isFlash", isFlash, false);
+ ini.GetValue("toMap", toMap);
+ ini.GetValue("toWarp", toWarp);
+ ini.GetValue("workingFlag-f", i, 0);
+ ini.GetValue("workingFlag-s", j, 0);
+ workingFlag.Set(i, j);
+ ini.GetValue("dialog", dialog);
+ LogImportOver("MapWarp", id, name);
+}
+
+void PokeGen::PokeMod::MapWarp::ExportIni(std::ofstream &fout, const String &map) const
+{
+ LogExportStart("MapWarp", id, name);
+ Ini exMapWarp(map + " mapWarp");
+ exMapWarp.AddField("id", id);
+ exMapWarp.AddField("coordinate-x", coordinate.GetX());
+ exMapWarp.AddField("coordinate-y", coordinate.GetY());
+ exMapWarp.AddField("fromUp", fromUp);
+ exMapWarp.AddField("fromDown", fromDown);
+ exMapWarp.AddField("fromLeft", fromLeft);
+ exMapWarp.AddField("fromRight", fromRight);
+ exMapWarp.AddField("directionOut", directionOut);
+ exMapWarp.AddField("warpType", warpType);
+ exMapWarp.AddField("isBiking", isBiking);
+ exMapWarp.AddField("isFlash", isFlash);
+ exMapWarp.AddField("toMap", toMap);
+ exMapWarp.AddField("toWarp", toWarp);
+ exMapWarp.AddField("workingFlag-f", workingFlag.GetFlag());
+ exMapWarp.AddField("workingFlag-s", workingFlag.GetStatus());
+ exMapWarp.AddField("dialog", dialog);
+ exMapWarp.Export(fout);
+ LogExportOver("MapWarp", id, name);
+}
+
+void PokeGen::PokeMod::MapWarp::SetName(const String &n)
+{
+ LogSetVar("MapWarp", id, "name", n);
+ name = n;
+}
+
+void PokeGen::PokeMod::MapWarp::SetCoordinate(const Point &c)
+{
+ LogSetVar("MapWarp", id, "coordinate", c.GetX(), c.GetY(), name);
+ coordinate = c;
+}
+
+void PokeGen::PokeMod::MapWarp::SetCoordinate(const unsigned x, const unsigned y)
+{
+ LogSetVar("MapWarp", id, "coordinate", x, y, name);
+ coordinate.Set(x, y);
+}
+
+void PokeGen::PokeMod::MapWarp::SetCoordinateX(const unsigned x)
+{
+ LogSetVar("MapWarp", id, "coordinate x", x, name);
+ coordinate.SetX(x);
+}
+
+void PokeGen::PokeMod::MapWarp::SetCoordinateY(const unsigned y)
+{
+ LogSetVar("MapWarp", id, "coordinate y", y, name);
+ coordinate.SetY(y);
+}
+
+void PokeGen::PokeMod::MapWarp::SetFromUp(const bool f)
+{
+ LogSetVar("MapWarp", id, "fromUp", f, name);
+ fromUp = f;
+}
+
+void PokeGen::PokeMod::MapWarp::SetFromDown(const bool f)
+{
+ LogSetVar("MapWarp", id, "fromDown", f, name);
+ fromDown = f;
+}
+
+void PokeGen::PokeMod::MapWarp::SetFromLeft(const bool f)
+{
+ LogSetVar("MapWarp", id, "fromLeft", f, name);
+ fromLeft = f;
+}
+
+void PokeGen::PokeMod::MapWarp::SetFromRight(const bool f)
+{
+ LogSetVar("MapWarp", id, "fromRight", f, name);
+ fromRight = f;
+}
+
+void PokeGen::PokeMod::MapWarp::SetDirectionOut(const unsigned d)
+{
+ LogSetVar("MapWarp", id, "directionOut", d, name);
+ if (d < DIR_END)
+ directionOut = d;
+}
+
+void PokeGen::PokeMod::MapWarp::SetDirectionOut(const String &d)
+{
+ SetDirectionOut(FindIn(DIR_END, d, DirectionStr));
+}
+
+void PokeGen::PokeMod::MapWarp::SetWarpType(const unsigned w)
+{
+ LogSetVar("MapWarp", id, "warpType", w, name);
+ if (w < WT_END)
+ warpType = w;
+}
+
+void PokeGen::PokeMod::MapWarp::SetWarpType(const String &w)
+{
+ SetWarpType(FindIn(WT_END, w, WarpTypeStr));
+}
+
+void PokeGen::PokeMod::MapWarp::SetIsBiking(const bool i)
+{
+ LogSetVar("MapWarp", id, "isBiking", i, name);
+ isBiking = i;
+}
+
+void PokeGen::PokeMod::MapWarp::SetIsFlash(const bool i)
+{
+ LogSetVar("MapWarp", id, "isFlash", i, name);
+ isFlash = i;
+}
+
+void PokeGen::PokeMod::MapWarp::SetToMap(const unsigned t)
+{
+ LogSetVar("MapWarp", id, "toMap", t, name);
+ if (curPokeMod.GetMap(t))
+ {
+ toMap = t;
+ toWarp = UINT_MAX;
+ }
+}
+
+void PokeGen::PokeMod::MapWarp::SetToMap(const String &t)
+{
+ LogSetVar("MapWarp", id, "toMap string", t, name);
+ if (const Map *m = curPokeMod.GetMap(t))
+ {
+ toMap = m->GetId();
+ toWarp = UINT_MAX;
+ }
+}
+
+void PokeGen::PokeMod::MapWarp::SetToWarp(const unsigned t)
+{
+ LogSetVar("MapWarp", id, "toWarp", t, name);
+ if (const Map *m = curPokeMod.GetMap(toMap))
+ {
+ if (m->GetMapWarp(t))
+ toWarp = t;
+ }
+}
+
+void PokeGen::PokeMod::MapWarp::SetToWarp(const String &t)
+{
+ LogSetVar("MapWarp", id, "toWarp string", t, name);
+ if (const Map *m = curPokeMod.GetMap(toMap))
+ {
+ if (const MapWarp *w = m->GetMapWarp(t))
+ toWarp = w->GetId();
+ }
+}
+
+void PokeGen::PokeMod::MapWarp::SetWorkingFlag(const Flag &w)
+{
+ LogSetVar("MapWarp", id, "workingFlag", w.GetFlag(), w.GetStatus(), name);
+ workingFlag = w;
+}
+
+void PokeGen::PokeMod::MapWarp::SetWorkingFlag(const unsigned f, const unsigned s)
+{
+ LogSetVar("MapWarp", id, "workingFlag", f, s, name);
+ workingFlag.Set(f, s);
+}
+
+void PokeGen::PokeMod::MapWarp::SetWorkingFlagFlag(const unsigned f)
+{
+ LogSetVar("MapWarp", id, "workingFlag flag", f, name);
+ workingFlag.SetFlag(f);
+}
+
+void PokeGen::PokeMod::MapWarp::SetWorkingFlagStatus(const unsigned s)
+{
+ LogSetVar("MapWarp", id, "workingFlag status", s, name);
+ workingFlag.SetStatus(s);
+}
+
+void PokeGen::PokeMod::MapWarp::SetWorkingFlagStatus(const String &s)
+{
+ SetWorkingFlagStatus(FindIn(FV_END, s, FlagValueStr));
+}
+
+void PokeGen::PokeMod::MapWarp::SetDialog(const unsigned d)
+{
+ LogSetVar("MapWarp", id, "dialog", d, name);
+ if (curPokeMod.GetDialog(d))
+ dialog = d;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::MapWarp::GetName() const
+{
+ LogFetchVar("MapWarp", id, "name", name);
+ return name;
+}
+
+PokeGen::PokeMod::Point PokeGen::PokeMod::MapWarp::GetCoordinate() const
+{
+ LogFetchVar("MapWarp", id, "coorinate", coordinate.GetX(), coordinate.GetY(), name);
+ return coordinate;
+}
+
+unsigned PokeGen::PokeMod::MapWarp::GetCoordinateX() const
+{
+ LogFetchVar("MapWarp", id, "coordinate x", coordinate.GetX(), name);
+ return coordinate.GetX();
+}
+
+unsigned PokeGen::PokeMod::MapWarp::GetCoordinateY() const
+{
+ LogFetchVar("MapWarp", id, "coordinate y", coordinate.GetY(), name);
+ return coordinate.GetY();
+}
+
+bool PokeGen::PokeMod::MapWarp::GetFromUp() const
+{
+ LogFetchVar("MapWarp", id, "fromUp", fromUp, name);
+ return fromUp;
+}
+
+bool PokeGen::PokeMod::MapWarp::GetFromDown() const
+{
+ LogFetchVar("MapWarp", id, "fromDown", fromDown, name);
+ return fromDown;
+}
+
+bool PokeGen::PokeMod::MapWarp::GetFromLeft() const
+{
+ LogFetchVar("MapWarp", id, "fromLeft", fromLeft, name);
+ return fromLeft;
+}
+
+bool PokeGen::PokeMod::MapWarp::GetFromRight() const
+{
+ LogFetchVar("MapWarp", id, "fromRight", fromRight, name);
+ return fromRight;
+}
+
+unsigned PokeGen::PokeMod::MapWarp::GetDirectionOut() const
+{
+ LogFetchVar("MapWarp", id, "directionOut", directionOut, name);
+ return directionOut;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::MapWarp::GetDirectionOutString() const
+{
+ LogFetchVar("MapWarp", id, "directionOut string", directionOut, name);
+ if (directionOut < DIR_END)
+ return DirectionStr[directionOut];
+ return "";
+}
+
+unsigned PokeGen::PokeMod::MapWarp::GetWarpType() const
+{
+ LogFetchVar("MapWarp", id, "warpType", warpType, name);
+ return warpType;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::MapWarp::GetWarpTypeString() const
+{
+ LogFetchVar("MapWarp", id, "warpType string", warpType, name);
+ if (warpType < WT_END)
+ return WarpTypeStr[warpType];
+ return "";
+}
+
+bool PokeGen::PokeMod::MapWarp::GetIsBiking() const
+{
+ LogFetchVar("MapWarp", id, "isBiking", isBiking, name);
+ return isBiking;
+}
+
+bool PokeGen::PokeMod::MapWarp::GetIsFlash() const
+{
+ LogFetchVar("MapWarp", id, "isFlash", isFlash, name);
+ return isFlash;
+}
+
+unsigned PokeGen::PokeMod::MapWarp::GetToMap() const
+{
+ LogFetchVar("MapWarp", id, "toMap", toMap, name);
+ return toMap;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::MapWarp::GetToMapString() const
+{
+ LogFetchVar("MapWarp", id, "toMap string", toMap, name);
+ if (const Map *m = curPokeMod.GetMap(toMap))
+ return m->GetName();
+ return "";
+}
+
+unsigned PokeGen::PokeMod::MapWarp::GetToWarp() const
+{
+ LogFetchVar("MapWarp", id, "toWarp", toWarp, name);
+ return toWarp;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::MapWarp::GetToWarpString() const
+{
+ LogFetchVar("MapWarp", id, "toWarp string", toWarp, name);
+ if (const Map *m = curPokeMod.GetMap(toMap))
+ {
+ if (const MapWarp *w = m->GetMapWarp(toWarp))
+ return w->GetName();
+ }
+ return "";
+}
+
+PokeGen::PokeMod::Flag PokeGen::PokeMod::MapWarp::GetWorkingFlag() const
+{
+ LogFetchVar("MapWarp", id, "workingFlag", workingFlag.GetFlag(), workingFlag.GetStatus(), name);
+ return workingFlag;
+}
+
+unsigned PokeGen::PokeMod::MapWarp::GetWorkingFlagFlag() const
+{
+ LogFetchVar("MapWarp", id, "workingFlag flag", workingFlag.GetFlag(), name);
+ return workingFlag.GetFlag();
+}
+
+unsigned PokeGen::PokeMod::MapWarp::GetWorkingFlagStatus() const
+{
+ LogFetchVar("MapWarp", id, "workingFlag status", workingFlag.GetStatus(), name);
+ return workingFlag.GetStatus();
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::MapWarp::GetWorkingFlagStatusString() const
+{
+ LogFetchVar("MapWarp", id, "workingFlag status string", workingFlag.GetStatus(), name);
+ return workingFlag.GetStatusString();
+}
+
+unsigned PokeGen::PokeMod::MapWarp::GetDialog() const
+{
+ LogFetchVar("MapWarp", id, "dialog", dialog, name);
+ return dialog;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::MapWarp::GetDialogString() const
+{
+ LogFetchVar("MapWarp", id, "dialog string", dialog, name);
+ if (const Dialog *d = curPokeMod.GetDialog(dialog))
+ return d->GetDialog();
+ return "";
+}