diff options
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; } |
