From fafbdab97afb5ec6498ea0ab66b693b9e335f6f1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 11 May 2007 01:33:42 +0000 Subject: Starting INI migration git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@9 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/Nature.cpp | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) (limited to 'pokemod/Nature.cpp') diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp index 71a714fb..a38615ac 100644 --- a/pokemod/Nature.cpp +++ b/pokemod/Nature.cpp @@ -31,10 +31,10 @@ PokeGen::PokeMod::Nature::Nature(unsigned _id) id = _id; } -PokeGen::PokeMod::Nature::Nature(XmlElement &xml, unsigned _id) +PokeGen::PokeMod::Nature::Nature(Ini &ini, unsigned _id) { - LogCtorXml("Nature", _id); - ImportXml(xml, _id); + LogCtorIni("Nature", _id); + ImportIni(ini, _id); if (id == UINT_MAX) LogIdError("Nature"); } @@ -100,44 +100,33 @@ void PokeGen::PokeMod::Nature::Validate(wxListBox &output) } #endif -void PokeGen::PokeMod::Nature::ImportXml(XmlElement &xml, unsigned _id) +void PokeGen::PokeMod::Nature::ImportIni(Ini &ini, unsigned _id) { - LogImport("Nature"); + LogImportStart("Nature"); String curName; if (_id == UINT_MAX) { - xml.GetValue(id); - // Was there an id associated with the element? + ini.GetValue("id", id, UINT_MAX); + // Was there an id associated with the section? if (id == UINT_MAX) LogIdNotFound("Nature"); } else id = _id; - name = ""; effects.clear(); - xml.ClearCounter(); - for (XmlElement *child = xml.NextElement(); child; child = xml.NextElement()) - { - curName = child->GetName(); - if (curName == "name") - child->GetValue(name); - else if (curName == "effect") - effects.push_back(NatureEffect(*child)); - else - LogUnknownXml("Nature", curName); - } + ini.GetValue("name", name, ""); LogImportOver("Nature"); } -PokeGen::PokeMod::XmlElement PokeGen::PokeMod::Nature::ExportXml() +void PokeGen::PokeMod::Nature::ExportIni(const std::ofstream &fout) { LogExportStart("Nature"); - XmlElement exNature("nature", id, true); - exNature.AddElement("name", name); + Ini exNature("nature"); + exNature.AddField("name", name); + exNature.Export(fout); for (std::vector::iterator i = effects.begin(); i != effects.end(); ++i) - exNature.AddElement(i->ExportXml()); + i->ExportIni(fout, name); LogExportOver("Nature"); - return exNature; } void PokeGen::PokeMod::Nature::SetName(const String &n) @@ -170,7 +159,7 @@ unsigned PokeGen::PokeMod::Nature::GetNatureEffectCount() return effects.size(); } -void PokeGen::PokeMod::Nature::NewNatureEffect() +void PokeGen::PokeMod::Nature::NewNatureEffect(Ini *ini) { unsigned i = 0; // Find the first unused ID in the vector @@ -180,8 +169,8 @@ void PokeGen::PokeMod::Nature::NewNatureEffect() break; } NatureEffect newNatureEffect(i); - if (xml) - newNatureEffect.ImportXml(*xml); + if (ini) + newNatureEffect.ImportIni(*ini); LogSubmoduleNew("Nature", "effect", i, id, name); effects.push_back(newNatureEffect); } -- cgit