///////////////////////////////////////////////////////////////////////////// // 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" PokeGen::PokeMod::MapWarp::MapWarp(const Pokemod *par, 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; pokemod = par; } PokeGen::PokeMod::MapWarp::MapWarp(const Pokemod *par, Ini &ini, const unsigned _id) { LogCtorIni("MapWarp", _id); pokemod = par; 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 = pokemod->GetMap(toMap)) { if (!m->GetMapWarp(toWarp)) { LogVarNotValid("MapWarp", id, "toWarp"); isValid = false; } } else { LogVarNotValid("MapWarp", id, "toMap"); isValid = false; } if (!pokemod->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 = pokemod->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 (!pokemod->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("mapWarp " + map); 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 (pokemod->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 = pokemod->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 = pokemod->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 = pokemod->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 (pokemod->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 = pokemod->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 = pokemod->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 = pokemod->GetDialog(dialog)) return d->GetDialog(); return ""; }