summaryrefslogtreecommitdiffstats
path: root/pokemod/Tile.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/Tile.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/Tile.cpp')
-rw-r--r--pokemod/Tile.cpp493
1 files changed, 435 insertions, 58 deletions
diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp
index ddacaae5..6465811f 100644
--- a/pokemod/Tile.cpp
+++ b/pokemod/Tile.cpp
@@ -23,26 +23,28 @@
#include "Tile.h"
-PokeGen::PokeMod::Tile::Tile(const unsigned _id)
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::Tile::Tile(const unsigned _id) :
+ name(""),
+ pic(""),
+ fromUp(false),
+ fromDown(false),
+ fromLeft(false),
+ fromRight(false),
+ isWild(false),
+ wildChance(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)
{
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;
}
@@ -62,12 +64,59 @@ PokeGen::PokeMod::Tile::~Tile()
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;
}
+ if (!pic.DoesExist())
+ {
+ if (pic == "")
+ LogVarNotSet("Tile", id, "pic", name);
+ else
+ LogVarNotValid("Tile", id, "pic", name);
+ isValid = false;
+ }
+ if (isWater)
+ {
+ if (WTRT_END <= waterType)
+ {
+ LogVarNotValid("Tile", id, "waterType", name);
+ isValid = false;
+ }
+ else if (waterType == WTRT_WHIRLPOOL)
+ {
+ if (!curPokeMod.GetTile(underWater))
+ {
+ LogVarNotValid("Tile", id, "underWater", name);
+ isValid = false;
+ }
+ }
+ }
+ if (isCuttable)
+ {
+ if (!curPokeMod.GetTile(underCut))
+ {
+ LogVarNotValid("Tile", id, "underCut", name);
+ isValid = false;
+ }
+ }
+ if (forceType < FT_END)
+ {
+ if ((forceType == FT_SLIP) || (forceType == FT_FORCE) || (forceType == FT_PUSH))
+ {
+ if (DIR_END <= forceDirection)
+ {
+ LogVarNotValid("Tile", id, "forceDirection", name);
+ isValid = false;
+ }
+ }
+ }
+ else
+ {
+ LogVarNotValid("Tile", id, "forceType", name);
+ isValid = false;
+ }
LogValidateOver("Tile", id, isValid, name);
}
@@ -75,6 +124,71 @@ void PokeGen::PokeMod::Tile::Validate()
void PokeGen::PokeMod::Tile::Validate(const wxListBox &output)
{
LogValidateStart("Tile", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("Tile", id, "Name", name);
+ output.append(ConsoleLogVarNotSet("Tile", id, "Name", name));
+ isValid = false;
+ }
+ if (!pic.DoesExist())
+ {
+ if (pic == "")
+ {
+ LogVarNotSet("Tile", id, "pic", name);
+ output.append(ConsoleLogVarNotSet("Tile", id, "pic", name));
+ }
+ else
+ {
+ LogVarNotValid("Tile", id, "pic", name);
+ output.append(ConsoleLogVarNotValid("Tile", id, "pic", name));
+ }
+ isValid = false;
+ }
+ if (isWater)
+ {
+ if (WT_END <= waterType)
+ {
+ LogVarNotValid("Tile", id, "waterType", name);
+ output.append(Console);
+ isValid = false;
+ }
+ else if (waterType == WT_WHIRLPOOL)
+ {
+ if (!curPokeMod.GetTile(underWater))
+ {
+ LogVarNotValid("Tile", id, "underWater", name);
+ output.append(Console);
+ isValid = false;
+ }
+ }
+ }
+ if (isCuttable)
+ {
+ if (!curPokeMod.GetTile(underCut))
+ {
+ LogVarNotValid("Tile", id, "underCut", name);
+ output.append(Console);
+ isValid = false;
+ }
+ }
+ if (forceType < FT_END)
+ {
+ if ((forceType == FT_SLIP) || (forceType == FT_FORCE) || (forceType == FT_PUSH))
+ {
+ if (DIR_END <= forceDirection)
+ {
+ LogVarNotValid("Tile", id, "forceDirection", name);
+ output.append(Console);
+ isValid = false;
+ }
+ }
+ }
+ else
+ {
+ LogVarNotValid("Tile", id, "forceType", name);
+ output.append(Console);
+ isValid = false;
+ }
LogValidateOver("Tile", id, isValid, name);
}
#endif
@@ -84,7 +198,7 @@ void PokeGen::PokeMod::Tile::ImportIni(Ini &ini, const unsigned _id)
LogImportStart("Tile");
if (_id == UINT_MAX)
{
- ini.GetValue("id", id, UINT_MAX);
+ ini.GetValue("id", id);
// Was there an id associated with the element?
if (id == UINT_MAX)
LogIdNotFound("Tile");
@@ -122,9 +236,24 @@ void PokeGen::PokeMod::Tile::ExportIni(std::ofstream &fout) const
Ini exTile("Tile");
exTile.AddField("id", id);
exTile.AddField("name", name);
+ exTile.AddField("pic", pic);
+ exTile.AddField("fromUp", fromUp);
+ exTile.AddField("fromDown", fromDown);
+ exTile.AddField("fromLeft", fromLeft);
+ exTile.AddField("fromRight", fromRight);
+ exTile.AddField("isWild", isWild);
+ exTile.AddField("wildChance-n", wildChance.GetNum());
+ exTile.AddField("wildChance-d", wildChance.GetDenom());
+ exTile.AddField("isWater", isWater);
+ exTile.AddField("waterType", waterType);
+ exTile.AddField("underWater", underWater);
+ exTile.AddField("canDive", canDive);
+ exTile.AddField("isCuttable", isCuttable);
+ exTile.AddField("underCut", underCut);
+ exTile.AddField("canHeadbutt", canHeadbutt);
+ exTile.AddField("forceType", forceType);
+ exTile.AddField("forceDirection", forceDirection);
exTile.Export(fout);
- for (std::vector<TileEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
- i->ExportIni(fout, name);
LogExportOver("Tile", id, name);
}
@@ -134,56 +263,304 @@ void PokeGen::PokeMod::Tile::SetName(const String &n)
name = n;
}
+void PokeGen::PokeMod::Tile::SetPic(const Path &p)
+{
+ LogSetVar("Tile", id, "pic", p, name);
+ pic = p;
+}
+
+void PokeGen::PokeMod::Tile::SetFromUp(const bool f)
+{
+ LogSetVar("Tile", id, "fromUp", f, name);
+ fromUp = f;
+}
+
+void PokeGen::PokeMod::Tile::SetFromDown(const bool f)
+{
+ LogSetVar("Tile", id, "fromDown", f, name);
+ fromDown = f;
+}
+
+void PokeGen::PokeMod::Tile::SetFromLeft(const bool f)
+{
+ LogSetVar("Tile", id, "fromLeft", f, name);
+ fromLeft = f;
+}
+
+void PokeGen::PokeMod::Tile::SetFromRight(const bool f)
+{
+ LogSetVar("Tile", id, "fromRight", f, name);
+ fromRight = f;
+}
+
+void PokeGen::PokeMod::Tile::SetIsWild(const bool i)
+{
+ LogSetVar("Tile", id, "isWild", i, name);
+ isWild = i;
+}
+
+void PokeGen::PokeMod::Tile::SetWildChance(const Frac &w)
+{
+ LogSetVar("Tile", id, "wildChance", w.GetNum(), w.GetDenom(), name);
+ wildChance = w;
+}
+
+void PokeGen::PokeMod::Tile::SetWildChance(const unsigned n, const unsigned d)
+{
+ LogSetVar("Tile", id, "wildChance", n, d, name);
+ wildChance.Set(n, d);
+}
+
+void PokeGen::PokeMod::Tile::SetWildChanceNumerator(const unsigned n)
+{
+ LogSetVar("Tile", id, "wildChance numerator", n, name);
+ wildChance.SetNum(n);
+}
+
+void PokeGen::PokeMod::Tile::SetWildChanceDenominator(const unsigned d)
+{
+ LogSetVar("Tile", id, "wildChance denominator", d, name);
+ wildChance.SetDenom(d);
+}
+
+void PokeGen::PokeMod::Tile::SetIsWater(const bool i)
+{
+ LogSetVar("Tile", id, "isWater", i, name);
+ isWater = i;
+}
+
+void PokeGen::PokeMod::Tile::SetWaterType(const unsigned w)
+{
+ LogSetVar("Tile", id, "waterType", w, name);
+ if (w < WTRT_END)
+ waterType = w;
+}
+
+void PokeGen::PokeMod::Tile::SetWaterType(const String &w)
+{
+ SetWaterType(FindIn(WTRT_END, w, WaterTypeStr));
+}
+
+void PokeGen::PokeMod::Tile::SetUnderWater(const unsigned u)
+{
+ LogSetVar("Tile", id, "underWater", u, name);
+ if (curPokeMod.GetTile(u))
+ underWater = u;
+}
+
+void PokeGen::PokeMod::Tile::SetUnderWater(const String &u)
+{
+ LogSetVar("Tile", id, "underWater string", u, name);
+ if (const Tile *t = curPokeMod.GetTile(u))
+ underWater = t->GetId();
+}
+
+void PokeGen::PokeMod::Tile::SetCanDive(const bool c)
+{
+ LogSetVar("Tile", id, "canDive", c, name);
+ canDive = c;
+}
+
+void PokeGen::PokeMod::Tile::SetIsCuttable(const bool i)
+{
+ LogSetVar("Tile", id, "isCuttable", i, name);
+ isCuttable = i;
+}
+
+void PokeGen::PokeMod::Tile::SetUnderCut(const unsigned u)
+{
+ LogSetVar("Tile", id, "underCut", u, name);
+ if (curPokeMod.GetTile(u))
+ underCut = u;
+}
+
+void PokeGen::PokeMod::Tile::SetUnderCut(const String &u)
+{
+ LogSetVar("Tile", id, "underCut string", u, name);
+ if (const Tile *t = curPokeMod.GetTile(u))
+ underCut = t->GetId();
+}
+
+void PokeGen::PokeMod::Tile::SetCanHeadbutt(const bool c)
+{
+ LogSetVar("Tile", id, "canHeadbutt", c, name);
+ canHeadbutt = c;
+}
+
+void PokeGen::PokeMod::Tile::SetForceType(const unsigned f)
+{
+ LogSetVar("Tile", id, "forceType", f, name);
+ if (f < FT_END)
+ forceType = f;
+}
+
+void PokeGen::PokeMod::Tile::SetForceType(const String &f)
+{
+ SetForceType(FindIn(FT_END, f, ForceTypeStr));
+}
+
+void PokeGen::PokeMod::Tile::SetForceDirection(const unsigned f)
+{
+ LogSetVar("Tile", id, "forceDirection", f, name);
+ if (f < DIR_END)
+ forceDirection = f;
+}
+
+void PokeGen::PokeMod::Tile::SetForceDirection(const String &f)
+{
+ SetForceType(FindIn(DIR_END, f, DirectionStr));
+}
+
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
+PokeGen::PokeMod::Path PokeGen::PokeMod::Tile::GetPic() 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;
+ LogFetchVar("Tile", id, "pic", pic, name);
+ return pic;
}
-unsigned PokeGen::PokeMod::Tile::GetTileEffectCount() const
+bool PokeGen::PokeMod::Tile::GetFromUp() const
{
- LogSubmoduleCount("Tile", id, "effects", name);
- return effects.size();
+ LogFetchVar("Tile", id, "fromUp", fromUp, name);
+ return fromUp;
}
-void PokeGen::PokeMod::Tile::NewTileEffect(Ini *const ini)
+bool PokeGen::PokeMod::Tile::GetFromDown() const
{
- 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);
+ LogFetchVar("Tile", id, "fromDown", fromDown, name);
+ return fromDown;
}
-void PokeGen::PokeMod::Tile::DeleteTileEffect(const unsigned _id)
+bool PokeGen::PokeMod::Tile::GetFromLeft() const
{
- 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);
+ LogFetchVar("Tile", id, "fromLeft", fromLeft, name);
+ return fromLeft;
+}
+
+bool PokeGen::PokeMod::Tile::GetFromRight() const
+{
+ LogFetchVar("Tile", id, "fromRight", fromRight, name);
+ return fromRight;
+}
+
+bool PokeGen::PokeMod::Tile::GetIsWild() const
+{
+ LogFetchVar("Tile", id, "isWild", isWild, name);
+ return isWild;
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Tile::GetWildChance() const
+{
+ LogFetchVar("Tile", id, "wildChance", 0, name);
+ return wildChance;
+}
+
+unsigned PokeGen::PokeMod::Tile::GetWildChanceNumerator() const
+{
+ LogFetchVar("Tile", id, "wildChance numerator", wildChance.GetNum(), name);
+ return wildChance.GetNum();
+}
+
+unsigned PokeGen::PokeMod::Tile::GetWildChanceDenominator() const
+{
+ LogFetchVar("Tile", id, "wildChance denominator", wildChance.GetDenom(), name);
+ return wildChance.GetDenom();
+}
+
+bool PokeGen::PokeMod::Tile::GetIsWater() const
+{
+ LogFetchVar("Tile", id, "isWater", isWater, name);
+ return isWater;
+}
+
+unsigned PokeGen::PokeMod::Tile::GetWaterType() const
+{
+ LogFetchVar("Tile", id, "waterType", waterType, name);
+ return waterType;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetWaterTypeString() const
+{
+ LogFetchVar("Tile", id, "waterType string", waterType, name);
+ if (waterType < WTRT_END)
+ return WaterTypeStr[waterType];
+ return "";
+}
+
+unsigned PokeGen::PokeMod::Tile::GetUnderWater() const
+{
+ LogFetchVar("Tile", id, "underWater", underWater, name);
+ return underWater;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetUnderWaterString() const
+{
+ LogFetchVar("Tile", id, "underWater", underWater, name);
+ if (const Tile *t = curPokeMod.GetTile(underWater))
+ return t->GetName();
+ return "";
+}
+
+bool PokeGen::PokeMod::Tile::GetCanDive() const
+{
+ LogFetchVar("Tile", id, "canDive", canDive, name);
+ return canDive;
+}
+
+bool PokeGen::PokeMod::Tile::GetIsCuttable() const
+{
+ LogFetchVar("Tile", id, "isCuttable", isCuttable, name);
+ return isCuttable;
+}
+
+unsigned PokeGen::PokeMod::Tile::GetUnderCut() const
+{
+ LogFetchVar("Tile", id, "underCut", underCut, name);
+ return underCut;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetUnderCutString() const
+{
+ LogFetchVar("Tile", id, "underCut string", underCut, name);
+ if (const Tile *t = curPokeMod.GetTile(underCut))
+ return t->GetName();
+ return "";
+}
+
+bool PokeGen::PokeMod::Tile::GetCanHeadbutt() const
+{
+ LogFetchVar("Tile", id, "canHeadbutt", canHeadbutt, name);
+ return canHeadbutt;
+}
+
+unsigned PokeGen::PokeMod::Tile::GetForceType() const
+{
+ LogFetchVar("Tile", id, "forceType", forceType, name);
+ return forceType;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetForceTypeString() const
+{
+ LogFetchVar("Tile", id, "forceType string", forceType, name);
+ if (forceType < FT_END)
+ return ForceTypeStr[forceType];
+ return "";
+}
+
+unsigned PokeGen::PokeMod::Tile::GetForceDirection() const
+{
+ LogFetchVar("Tile", id, "forceDirection", forceDirection, name);
+ return forceDirection;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetForceDirectionString() const
+{
+ LogFetchVar("Tile", id, "forceDirection string", forceDirection, name);
+ if (forceDirection < DIR_END)
+ return DirectionStr[forceDirection];
+ return "";
}