diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-15 18:57:00 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-15 18:57:00 +0000 |
| commit | e1b5d7bc705810ac15ed36924617af52abdc8e81 (patch) | |
| tree | 0dae5af4e2737372ec479bb9ccdd2201edf684a8 /pokemod/Store.cpp | |
| parent | 12d5161318a4d8d781f896812f5a95fa7b46d8a8 (diff) | |
[FIX] Object::mid -> m_id
[FIX] XML is now used
[FIX] Images are stored in the XML file and classes rather than relying on external images
[FIX] Frac no longer keeps track of its type; the class should do it
[ADD] pokemod/Object.cpp
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@97 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Store.cpp')
| -rw-r--r-- | pokemod/Store.cpp | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/pokemod/Store.cpp b/pokemod/Store.cpp index 94def03a..37e1b3fa 100644 --- a/pokemod/Store.cpp +++ b/pokemod/Store.cpp @@ -36,10 +36,10 @@ Store::Store(const Pokemod* pokemod, const Store& store, const int id) : *this = store; } -Store::Store(const Pokemod* pokemod, const QString& fileName, const int id) : +Store::Store(const Pokemod* pokemod, const QDomElement& xml, const int id) : Object("Store", pokemod, id) { - load(fileName, id); + load(xml, id); } bool Store::validate() const @@ -71,34 +71,17 @@ bool Store::validate() const return valid; } -void Store::load(const QString& fileName, int id) throw(Exception) +void Store::load(const QDomElement& xml, int id) { - Ini ini(fileName); - if (id == INT_MAX) - ini.getValue("id", id); - setId(id); - m_items.clear(); - int i; - int j; - ini.getValue("name", m_name); - ini.getValue("numItems", i, 0); - for (int k = 0; k < i; ++k) - { - ini.getValue(QString("item-%1").arg(k), j); - if (!m_items.contains(j)) - m_items.append(j); - } + LOAD_ID(); + LOAD_LIST(int, items); } -void Store::save() const throw(Exception) +QDomElement Store::save() const { - Ini ini; - ini.addField("id", id()); - ini.addField("name", m_name); - ini.addField("numItems", m_items.size()); - for (int i = 0; i < m_items.size(); ++i) - ini.addField(QString("items-%1").arg(i), m_items[i]); - ini.save(QString("%1/store/%2.pini").arg(pokemod()->path()).arg(m_name)); + SAVE_CREATE(); + SAVE_LIST(int, items); + return xml; } void Store::setName(const QString& name) @@ -133,7 +116,7 @@ Store& Store::operator=(const Store& rhs) { if (this == &rhs) return *this; - m_name = rhs.m_name; - m_items = rhs.m_items; + COPY(name); + COPY(items); return *this; } |
