diff options
Diffstat (limited to 'pokemod/Tile.cpp')
| -rw-r--r-- | pokemod/Tile.cpp | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp new file mode 100644 index 00000000..ddacaae5 --- /dev/null +++ b/pokemod/Tile.cpp @@ -0,0 +1,189 @@ +/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/Tile.cpp
+// Purpose: Define a tile for the map
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Thu May 31 2007 13:52:39
+// 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
+// MERCHANTTile 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 "Tile.h"
+
+PokeGen::PokeMod::Tile::Tile(const unsigned _id)
+{
+ LogCtor("Tile", id);
+ name = "";
+ pic = "";
+ fromUp = false;
+ fromDown = false;
+ fromLeft = false;
+ fromRight = false;
+ isWild = false;
+ wildChance.Set(1, 1);
+ isWater = false;
+ waterType = UINT_MAX;
+ underWater = UINT_MAX;
+ canDive = false;
+ isCuttable = false;
+ underCut = UINT_MAX;
+ canHeadbutt = false;
+ forceType = UINT_MAX;
+ forceDirection = UINT_MAX;
+ id = _id;
+}
+
+PokeGen::PokeMod::Tile::Tile(Ini &ini, const unsigned _id)
+{
+ LogCtorIni("Tile", id);
+ ImportIni(ini, _id);
+ if (id == UINT_MAX)
+ LogIdError("Tile");
+}
+
+PokeGen::PokeMod::Tile::~Tile()
+{
+ LogDtor("Tile", id, name);
+}
+
+void PokeGen::PokeMod::Tile::Validate()
+{
+ LogValidateStart("Tile", id, name);
+ // Make sure the name is set to something
+ if (name == "")
+ {
+ LogVarNotSet("Tile", id, "Name", name);
+ isValid = false;
+ }
+ LogValidateOver("Tile", id, isValid, name);
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::Tile::Validate(const wxListBox &output)
+{
+ LogValidateStart("Tile", id, name);
+ LogValidateOver("Tile", id, isValid, name);
+}
+#endif
+
+void PokeGen::PokeMod::Tile::ImportIni(Ini &ini, const unsigned _id)
+{
+ LogImportStart("Tile");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("Tile");
+ }
+ else
+ id = _id;
+ unsigned i;
+ unsigned j;
+ ini.GetValue("name", name);
+ ini.GetValue("pic", pic);
+ ini.GetValue("fromUp", fromUp, false);
+ ini.GetValue("fromDown", fromDown, false);
+ ini.GetValue("fromLeft", fromLeft, false);
+ ini.GetValue("fromRight", fromRight, false);
+ ini.GetValue("isWild", isWild, false);
+ ini.GetValue("wildChance-n", i, 1);
+ ini.GetValue("wildChance-d", j, 1);
+ wildChance.Set(i, j);
+ ini.GetValue("isWater", isWater, false);
+ ini.GetValue("waterType", waterType);
+ ini.GetValue("underWater", underWater);
+ ini.GetValue("canDive", canDive, false);
+ ini.GetValue("isCuttable", isCuttable, false);
+ ini.GetValue("underCut", underCut);
+ ini.GetValue("canHeadbutt", canHeadbutt, false);
+ ini.GetValue("forceType", forceType);
+ ini.GetValue("forceDirection", forceDirection);
+ LogImportOver("Tile", id, name);
+}
+
+void PokeGen::PokeMod::Tile::ExportIni(std::ofstream &fout) const
+{
+ LogExportStart("Tile", id, name);
+ // Make elements
+ Ini exTile("Tile");
+ exTile.AddField("id", id);
+ exTile.AddField("name", name);
+ exTile.Export(fout);
+ for (std::vector<TileEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
+ i->ExportIni(fout, name);
+ LogExportOver("Tile", id, name);
+}
+
+void PokeGen::PokeMod::Tile::SetName(const String &n)
+{
+ LogSetVar("Tile", id, "name", n);
+ name = n;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetName() const
+{
+ LogFetchVar("Tile", id, "name", name);
+ return name;
+}
+
+const PokeGen::PokeMod::TileEffect *PokeGen::PokeMod::Tile::GetTileEffect(const unsigned _id) const
+{
+ LogSubmoduleFetch("Tile", id, "effect", _id, name);
+ for (unsigned i = 0; i < GetTileEffectCount(); ++i)
+ {
+ if (effects[i].GetId() == _id)
+ return &effects[i];
+ }
+ LogSubmoduleFetchFail("Tile", id, "effect", _id, name);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Tile::GetTileEffectCount() const
+{
+ LogSubmoduleCount("Tile", id, "effects", name);
+ return effects.size();
+}
+
+void PokeGen::PokeMod::Tile::NewTileEffect(Ini *const ini)
+{
+ unsigned i = 0;
+ // Find the first unused ID in the vector
+ for (; i < GetTileEffectCount(); ++i)
+ {
+ if (!GetTileEffect(i))
+ break;
+ }
+ TileEffect newTileEffect(i);
+ if (ini)
+ newTileEffect.ImportIni(*ini);
+ LogSubmoduleNew("Tile", id, "effect", i, name);
+ effects.push_back(newTileEffect);
+}
+
+void PokeGen::PokeMod::Tile::DeleteTileEffect(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Tile", id, "effect", _id, name);
+ for (std::vector<TileEffect>::const_iterator i = effects.begin(); i != effects.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Tile", id, "effect", _id, name);
+ effects.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Tile", id, "effect", _id, name);
+}
|
