diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2007-05-11 01:33:42 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2007-05-11 01:33:42 +0000 |
| commit | fafbdab97afb5ec6498ea0ab66b693b9e335f6f1 (patch) | |
| tree | 2f8ad1e735f3b15b123ea2353fedec8affd22790 /pokemod/Badge.cpp | |
| parent | 0d2d8121cbb6a45180d88021fe2e5ac86b3532e3 (diff) | |
Starting INI migration
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@9 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Badge.cpp')
| -rw-r--r-- | pokemod/Badge.cpp | 132 |
1 files changed, 48 insertions, 84 deletions
diff --git a/pokemod/Badge.cpp b/pokemod/Badge.cpp index 257ca152..62a35274 100644 --- a/pokemod/Badge.cpp +++ b/pokemod/Badge.cpp @@ -40,10 +40,10 @@ PokeGen::PokeMod::Badge::Badge(unsigned _id) id = _id;
}
-PokeGen::PokeMod::Badge::Badge(XmlElement &xml, unsigned _id)
+PokeGen::PokeMod::Badge::Badge(Ini &ini, unsigned _id)
{
- LogCtorXml("Badge", _id);
- ImportXml(xml);
+ LogCtorIni("Badge", _id);
+ ImportIni(ini, _id);
if (id == UINT_MAX)
LogIdError("Badge");
}
@@ -78,7 +78,7 @@ void PokeGen::PokeMod::Badge::Validate() LogVarNotValid("Badge", "badge sprite", id, name);
isValid = false;
}
- LogValidationOver("Badge", isValid, is, name);
+ LogValidationOver("Badge", isValid, id, name);
}
#ifdef PG_DEBUG_WINDOW
@@ -124,112 +124,76 @@ void PokeGen::PokeMod::Badge::Validate(wxListBox &output) }
#endif
-void PokeGen::PokeMod::Badge::ImportXml(XmlElement &xml, unsigned _id)
+void PokeGen::PokeMod::Badge::ImportIni(Ini &ini, unsigned _id)
{
- LogImport("Badge");
- String curName;
+ LogImportStart("Badge");
if (_id == UINT_MAX)
{
- xml.GetValue(id);
+ ini.GetValue("id", id, UINT_MAX);
// Was there an id associated with the element?
if (id == UINT_MAX)
LogIdNotFound("Badge");
}
else
id = _id;
- name = "";
- face = "";
- badge = "";
- obey = 0;
- for (unsigned i = 0; i < STH_END_GSC; ++i)
- stats[i].Set(1, 1);
- for (unsigned i = 0; i < HM_END; ++i)
- hm[i] = false;
- xml.ClearCounter();
- for (XmlElement *child = xml.NextElement(); child; child = xml.NextElement())
+ ini.GetValue("name", name, "");
+ ini.GetValue("face", face, "");
+ ini.GetValue("badge", badge, "");
+ ini.GetValue("obey", obey, 0);
+ for (int i = 0; i < STH_END_GSC; ++i)
{
- curName = child->Value();
- if (curName == "name")
- name = child->GetTextOrDefault("");
- else if (curName == "face")
- face = child->GetTextOrDefault("");
- else if (curName == "badge")
- badge = child->GetTextOrDefault("");
- else if (curName == "obey")
- child->GetTextOrDefault(&obey, 0);
- else if (curName == "stats")
- {
- for (ticpp::Element *subChild = child->FirstChildElement(); subChild; subChild = subChild->NextSiblingElement())
- {
- curName = subChild->Value();
- int i = FindIn(STH_END_GSC, curName, StatHPGSCStr);
- if (i < STH_END_GSC)
- stats[i].ImportXml(*subChild);
- else if (curName == "Special")
- stats[STH_SPECIAL].ImportXml(*subChild);
- else
- PMLog(PMString("Badge Import: Unknown Stat XML Element \"%s\"", curName.c_str()), PM_DEBUG_ERROR);
- }
- }
- else if (curName == "hms")
- {
- for (ticpp::Element *subChild = child->FirstChildElement(); subChild; subChild = subChild->NextSiblingElement())
- {
- curName = subChild->Value();
- int i = FindIn(PokeGen::PokeMod::HM_END, curName, HMStr);
- if (i < HM_END)
- subChild->GetTextOrDefault(&hm[i], false);
- else
- PMLog(PMString("Badge Import: Unknown HM XML Element \"%s\"", curName.c_str()), PM_DEBUG_ERROR);
- }
- }
- else
- PMLog(PMString("Badge Import: Unknown XML element \"%s\"", curName.c_str()), PM_DEBUG_ERROR);
+ unsigned j;
+ unsigned k;
+ ini.GetValue(String("stats-%d-n", i), j, 1);
+ ini.GetValue(String("stats-%d-d", i), k, 1);
+ stats[i].Set(j, k);
}
+ for (int i = 0; i < HM_END; ++i)
+ ini.GetValue(String("hm-%d", i), hm[i], false);
LogImportOver("Badge", id, name);
}
-PokeGen::PokeMod::XmlElement PokeGen::PokeMod::Badge::ExportXml()
+void PokeGen::PokeMod::Badge::ExportIni(std::ofstream &fout)
{
LogExportStart("Badge", id, name);
- XmlElement exBadge("badge", id, true);
- XmlElement exStats("stats", 0, true);
- XmlElement exHm("hm", 0, true);
- exBadge.AddElement("name", name);
- exBadge.AddElement("face", face);
- exBadge.AddElement("badge", badge);
- exBadge.AddElement("obey", obey);
- for (unsigned i = 0; i < (curPokeMod.IsSpecialSplit() ? STH_END_GSC : STH_END_RBY); ++i)
- exStats.AddElement(stats[i].ExportXml((curPokeMod.IsSpecialSplit() ? StatHPGSCStr : StatHPRBYStr)[i]));
- exBadge.AddElement(exStats);
- for (unsigned i = 0; i < HM_END; ++i)
- exHm.AddElement(HMStr[i], hm[i]);
- exBadge.AddElement(exHm);
+ Ini exBadge("badge");
+ exBadge.AddField("id", id);
+ exBadge.AddField("name", name);
+ exBadge.AddField("face", face);
+ exBadge.AddField("badge", badge);
+ exBadge.AddField("obey", obey);
+ for (int i = 0; i < STH_END_GSC; ++i)
+ {
+ exBadge.AddField(String("stats-%d-n", i), stats[i].GetNum());
+ exBadge.AddField(String("stats-%d-d", i), stats[i].GetDenom());
+ }
+ for (int i = 0; i < HM_END; ++i)
+ exBadge.AddField(String("hm-%d", i), hm[i]);
+ exBadge.Export(fout);
LogExportOver("Badge", id, name);
- return exBadge;
}
void PokeGen::PokeMod::Badge::SetName(const String &n)
{
- LogSetVar("Badge", "name", id, INT_MIN, n);
+ LogSetVar("Badge", "name", id, LONG_MAX, n);
name = n;
}
void PokeGen::PokeMod::Badge::SetFace(const Path &f)
{
- LogSetVar("Badge", "face", id, INT_MIN, f);
+ LogSetVar("Badge", "face", id, LONG_MAX, f);
face = f;
}
void PokeGen::PokeMod::Badge::SetBadge(const Path &b)
{
- LogSetVar("Badge", "badge", id, INT_MIN, b);
+ LogSetVar("Badge", "badge", id, LONG_MAX, b);
badge = b;
}
void PokeGen::PokeMod::Badge::SetObey(unsigned o)
{
- LogSetVar("Badge", "obey", id, INT_MIN, o);
+ LogSetVar("Badge", "obey", id, o);
obey = o;
}
@@ -241,46 +205,46 @@ void PokeGen::PokeMod::Badge::SetStat(unsigned s, unsigned n, unsigned d) void PokeGen::PokeMod::Badge::SetStatNum(unsigned s, unsigned n)
{
- LogSetVar("Badge", String("stat[%u] numerator", s), id, INT_MIN, n);
+ LogSetVar("Badge", String("stat[%u] numerator", s), id, n);
stats[s].SetNum(n);
}
void PokeGen::PokeMod::Badge::SetStatDenom(unsigned s, unsigned d)
{
- LogSetVar("Badge", String("stat[%u] denominator", s), id, INT_MIN, d);
+ LogSetVar("Badge", String("stat[%u] denominator", s), id, d);
stats[s].SetDenom(d);
}
void PokeGen::PokeMod::Badge::SetHm(unsigned h, bool hb)
{
- LogSetVar("Badge", String("hm[%u]", s), id, INT_MIN, hb);
+ LogSetVar("Badge", String("hm[%u]", h), id, hb);
if (HM_END <= h)
- PMLog(PMString("Badge: Index of hm out-of-bounds (%d)", h), PM_DEBUG_ERROR);
+ Log(String("Badge: Index of hm out-of-bounds (%d)", h), PM_DEBUG_ERROR);
else
hm[h] = hb;
}
PokeGen::PokeMod::String PokeGen::PokeMod::Badge::GetName()
{
- LogFetchVar("Badge", "name", id, INT_MIN, name);
+ LogFetchVar("Badge", "name", id, LONG_MAX, name);
return name;
}
PokeGen::PokeMod::Path PokeGen::PokeMod::Badge::GetFace()
{
- LogFetchVar("Badge", "face", id, INT_MIN, face);
+ LogFetchVar("Badge", "face", id, LONG_MAX, face);
return face;
}
PokeGen::PokeMod::Path PokeGen::PokeMod::Badge::GetBadge()
{
- LogFetchVar("Badge", "badge", id, INT_MIN, badge);
+ LogFetchVar("Badge", "badge", id, LONG_MAX, badge);
return badge;
}
unsigned PokeGen::PokeMod::Badge::GetObey()
{
- LogFetchVar("Badge", "obey", id, INT_MIN, obey);
+ LogFetchVar("Badge", "obey", id, obey);
return obey;
}
@@ -288,7 +252,7 @@ PokeGen::PokeMod::Frac PokeGen::PokeMod::Badge::GetStat(unsigned s) {
LogFetchVar("Badge", String("stats[%u]", s), id, INT_MIN, stats[s]);
if ((curPokeMod.IsSpecialSplit() ? STH_END_RBY : STH_END_GSC) <= s)
- PMLog(PMString("Badge: Index of stats out-of-bounds (%d)", s), PM_DEBUG_ERROR);
+ Log(String("Badge: Index of stats out-of-bounds (%d)", s), PM_DEBUG_ERROR);
return stats[s];
}
@@ -296,6 +260,6 @@ bool PokeGen::PokeMod::Badge::GetHm(unsigned h) {
LogFetchVar("Badge", String("hm[%u]", h), id, INT_MIN, hm[h]);
if (HM_END <= h)
- PMLog(PMString("Badge: Index of hm out-of-bounds (%d)", h), PM_DEBUG_ERROR);
+ Log(String("Badge: Index of hm out-of-bounds (%d)", h), PM_DEBUG_ERROR);
return hm[h];
}
|
