From c9afda3ab74614fb36986f96b7972c082f275eca Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 2 Jun 2007 18:12:48 +0000 Subject: 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 --- pokemod/MapEffect.cpp | 382 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 382 insertions(+) create mode 100644 pokemod/MapEffect.cpp (limited to 'pokemod/MapEffect.cpp') diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp new file mode 100644 index 00000000..35022b16 --- /dev/null +++ b/pokemod/MapEffect.cpp @@ -0,0 +1,382 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokemod/MapEffect.cpp +// Purpose: Define an effect for a map +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Fri June 1 2007 20:23:15 +// 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 "MapEffect.h" + +extern PokeGen::PokeMod::Pokemod curPokeMod; + +PokeGen::PokeMod::MapEffect::MapEffect(const unsigned _id) : + name(""), + coordinate(0, 0), + existFlag(0, 0), + skin(""), + effect(UINT_MAX), + val1(UINT_MAX), + val2(UINT_MAX), + direction(UINT_MAX), + isTransparent(false), + dialog(UINT_MAX) +{ + LogCtor("MapEffect", _id); + id = _id; +} + +PokeGen::PokeMod::MapEffect::MapEffect(Ini &ini, const unsigned _id) +{ + LogCtorIni("MapEffect", _id); + ImportIni(ini, _id); + if (id == UINT_MAX) + LogIdError("MapEffect"); +} + +PokeGen::PokeMod::MapEffect::~MapEffect() +{ + LogDtor("MapEffect", id, name); +} + +void PokeGen::PokeMod::MapEffect::Validate() +{ + LogValidateStart("MapEffect", id, name); + // TODO (Ben#1#): MapEffect validation + LogValidateOver("MapEffect", id, isValid, name); +} + +#ifdef PG_DEBUG_WINDOW +void PokeGen::PokeMod::MapEffect::Validate(const wxListBox &output) +{ + +} +#endif + +void PokeGen::PokeMod::MapEffect::ImportIni(Ini &ini, const unsigned _id) +{ + LogImportStart("MapEffect"); + if (_id == UINT_MAX) + { + ini.GetValue("id", id); + if (id == UINT_MAX) + LogIdNotFound("MapEffect"); + } + 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("existFlag-f", i, 0); + ini.GetValue("existFlag-s", j, 0); + existFlag.Set(i, j); + ini.GetValue("skin", skin); + ini.GetValue("effect", effect); + ini.GetValue("val1", val1); + ini.GetValue("val2", val2); + ini.GetValue("direction", direction); + ini.GetValue("isTransparetn", isTransparent); + ini.GetValue("dialog", dialog); + LogImportOver("MapEffect", id, name); +} + +void PokeGen::PokeMod::MapEffect::ExportIni(std::ofstream &fout, const String &map) const +{ + LogExportStart("MapEffect", id, name); + Ini exMapEffect(map + "mapEffect"); + exMapEffect.AddField("id", id); + exMapEffect.AddField("name", name); + exMapEffect.AddField("coordinate-x", coordinate.GetX()); + exMapEffect.AddField("coordinate-y", coordinate.GetY()); + exMapEffect.AddField("existFlag-f", existFlag.GetFlag()); + exMapEffect.AddField("existFlag-s", existFlag.GetStatus()); + exMapEffect.AddField("skin", skin); + exMapEffect.AddField("effect", effect); + exMapEffect.AddField("val1", val1); + exMapEffect.AddField("val2", val2); + exMapEffect.AddField("direction", direction); + exMapEffect.AddField("isTransparent", isTransparent); + exMapEffect.AddField("dialog", dialog); + exMapEffect.Export(fout); + LogExportOver("MapEffect", id, name); +} + +void PokeGen::PokeMod::MapEffect::SetName(const String &n) +{ + LogSetVar("MapEffect", id, "name", n); + name = n; +} + +void PokeGen::PokeMod::MapEffect::SetCoordinate(const Point &c) +{ + LogSetVar("MapEffect", id, "coordinate", c.GetX(), c.GetY(), name); + coordinate = c; +} + +void PokeGen::PokeMod::MapEffect::SetCoordinate(const unsigned x, const unsigned y) +{ + LogSetVar("MapEffect", id, "coordinate", x, y, name); + coordinate.Set(x, y); +} + +void PokeGen::PokeMod::MapEffect::SetCoordinateX(const unsigned x) +{ + LogSetVar("MapEffect", id, "coordinate x", x, name); + coordinate.SetX(x); +} + +void PokeGen::PokeMod::MapEffect::SetCoordinateY(const unsigned y) +{ + LogSetVar("MapEffect", id, "coordinate y", y, name); + coordinate.SetY(y); +} + +void PokeGen::PokeMod::MapEffect::SetExistFlag(const Flag &e) +{ + LogSetVar("MapEffect", id, "existFlag", e.GetFlag(), e.GetStatus(), name); + existFlag = e; +} + +void PokeGen::PokeMod::MapEffect::SetExistFlag(const unsigned f, const unsigned s) +{ + LogSetVar("MapEffect", id, "existFlag", f, s, name); + existFlag.Set(f, s); +} + +void PokeGen::PokeMod::MapEffect::SetExistFlagFlag(const unsigned f) +{ + LogSetVar("MapEffect", id, "existFlag flag", f, name); + existFlag.SetFlag(f); +} + +void PokeGen::PokeMod::MapEffect::SetExistFlagStatus(const unsigned s) +{ + LogSetVar("MapEffect", id, "existFlag status", s, name); + if (s < FV_END) + existFlag.SetStatus(s); +} + +void PokeGen::PokeMod::MapEffect::SetExistFlagStatus(const String &s) +{ + SetExistFlagStatus(FindIn(FV_END, s, FlagValueStr)); +} + +void PokeGen::PokeMod::MapEffect::SetSkin(const Path &s) +{ + LogSetVar("MapEffect", id, "skin", s, name); + skin = s; +} + +void PokeGen::PokeMod::MapEffect::SetEffect(const unsigned e) +{ + LogSetVar("MapEffect", id, "effect", e, name); + if (e < MAPE_END) + { + effect = e; + val1 = UINT_MAX; + val2 = UINT_MAX; + } +} + +void PokeGen::PokeMod::MapEffect::SetEffect(const String &e) +{ + SetEffect(FindIn(MAPE_END, e, MapEffectStr)); +} + +// TODO (Ben#1#): effect values +void PokeGen::PokeMod::MapEffect::SetVal1(const unsigned v1) +{ + LogSetVar("MapEffect", id, "val1", v1, name); + switch(effect) + { + default: + LogNotSet("MapEffect", id, "val1", v1, "effect"); + } +} + +void PokeGen::PokeMod::MapEffect::SetVal2(const unsigned v2) +{ + LogSetVar("MapEffect", id, "val2", v2, name); + switch(effect) + { + default: + LogNotSet("MapEffect", id, "val2", v2, "effect"); + } +} + +void PokeGen::PokeMod::MapEffect::SetVal2(const String &v2) +{ + switch(effect) + { + default: + LogNotSet("MapEffect", id, "val2", v2, "effect"); + } +} + +void PokeGen::PokeMod::MapEffect::SetDirection(const unsigned d) +{ + LogSetVar("MapEffect", id, "direction", d, name); + if (d < DIR_END_NONE) + direction = d; +} + +void PokeGen::PokeMod::MapEffect::SetDirection(const String &d) +{ + SetDirection(FindIn(DIR_END_NONE, d, DirectionStr)); +} + +void PokeGen::PokeMod::MapEffect::SetIsTransparent(const bool i) +{ + LogSetVar("MapEffect", id, "isTransparent", i, name); + isTransparent = i; +} + +void PokeGen::PokeMod::MapEffect::SetDialog(const unsigned d) +{ + LogSetVar("MapEffect", id, "dialog", d, name); + if (curPokeMod.GetDialog(d)) + dialog = d; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::MapEffect::GetName() const +{ + LogFetchVar("MapEffect", id, "name", name); + return name; +} + +PokeGen::PokeMod::Point PokeGen::PokeMod::MapEffect::GetCoordinate() const +{ + LogFetchVar("MapEffect", id, "coordinate", coordinate.GetX(), coordinate.GetY(), name); + return coordinate; +} + +unsigned PokeGen::PokeMod::MapEffect::GetCoordinateX() const +{ + LogFetchVar("MapEffect", id, "coordinate x", coordinate.GetX(), name); + return coordinate.GetX(); +} + +unsigned PokeGen::PokeMod::MapEffect::GetCoordinateY() const +{ + LogFetchVar("MapEffect", id, "coordinate y", coordinate.GetY(), name); + return coordinate.GetY(); +} + +PokeGen::PokeMod::Flag PokeGen::PokeMod::MapEffect::GetExistFlag() const +{ + LogFetchVar("MapEffect", id, "existFlag", existFlag.GetFlag(), existFlag.GetStatus(), name); + return existFlag; +} + +unsigned PokeGen::PokeMod::MapEffect::GetExistFlagFlag() const +{ + LogFetchVar("MapEffect", id, "existFlag flag", existFlag.GetFlag(), name); + return existFlag.GetFlag(); +} + +unsigned PokeGen::PokeMod::MapEffect::GetExistFlagStatus() const +{ + LogFetchVar("MapEffect", id, "existFlag status", existFlag.GetStatus(), name); + return existFlag.GetStatus(); +} + +PokeGen::PokeMod::String PokeGen::PokeMod::MapEffect::GetExistFlagStatusString() const +{ + LogFetchVar("MapEffect", id, "existFlag status string", existFlag.GetStatus(), name); + return existFlag.GetStatusString(); +} + +PokeGen::PokeMod::Path PokeGen::PokeMod::MapEffect::GetSkin() const +{ + LogFetchVar("MapEffect", id, "skin", skin, name); + return skin; +} + +unsigned PokeGen::PokeMod::MapEffect::GetEffect() const +{ + LogFetchVar("MapEffect", id, "effect", effect, name); + return effect; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::MapEffect::GetEffectString() const +{ + LogFetchVar("MapEffect", id, "effect string", effect, name); + if (effect < MAPE_END) + return MapEffectStr[effect]; + return ""; +} + +unsigned PokeGen::PokeMod::MapEffect::GetVal1() const +{ + LogFetchVar("MapEffect", id, "val1", val1, name); + return val1; +} + +unsigned PokeGen::PokeMod::MapEffect::GetVal2() const +{ + LogFetchVar("MapEffect", id, "val2", val2, name); + return val2; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::MapEffect::GetVal2String() const +{ + LogFetchVar("MapEffect", id, "val2 string", val2, name); + String ret = ""; + switch(effect) + { + // TODO (Ben#1#): Effect code + } + return ret; +} + +unsigned PokeGen::PokeMod::MapEffect::GetDirection() const +{ + LogFetchVar("MapEffect", id, "direction", direction, name); + return direction; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::MapEffect::GetDirectionString() const +{ + LogFetchVar("MapEffect", id, "direction string", direction, name); + if (direction < DIR_END_NONE) + return DirectionStr[direction]; + return ""; +} + +bool PokeGen::PokeMod::MapEffect::GetIsTransparent() const +{ + LogFetchVar("MapEffect", id, "isTransparent", isTransparent, name); + return isTransparent; +} + +unsigned PokeGen::PokeMod::MapEffect::GetDialog() const +{ + LogFetchVar("MapEffect", id, "dialog", dialog, name); + return dialog; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::MapEffect::GetDialogString() const +{ + LogFetchVar("MapEffect", id, "dialog string", dialog, name); + if (const Dialog *d = curPokeMod.GetDialog(dialog)) + return d->GetDialog(); + return ""; +} -- cgit