summaryrefslogtreecommitdiffstats
path: root/pokemod/MapEffect.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-15 18:57:00 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-15 18:57:00 +0000
commite1b5d7bc705810ac15ed36924617af52abdc8e81 (patch)
tree0dae5af4e2737372ec479bb9ccdd2201edf684a8 /pokemod/MapEffect.cpp
parent12d5161318a4d8d781f896812f5a95fa7b46d8a8 (diff)
downloadsigen-e1b5d7bc705810ac15ed36924617af52abdc8e81.tar.gz
sigen-e1b5d7bc705810ac15ed36924617af52abdc8e81.tar.xz
sigen-e1b5d7bc705810ac15ed36924617af52abdc8e81.zip
[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/MapEffect.cpp')
-rw-r--r--pokemod/MapEffect.cpp118
1 files changed, 52 insertions, 66 deletions
diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp
index f18c54e5..57000542 100644
--- a/pokemod/MapEffect.cpp
+++ b/pokemod/MapEffect.cpp
@@ -15,6 +15,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Qt includes
+#include <QBuffer>
+
// Pokemod includes
#include "Pokemod.h"
#include "Dialog.h"
@@ -47,10 +50,10 @@ MapEffect::MapEffect(const Pokemod* pokemod, const MapEffect& effect, const int
*this = effect;
}
-MapEffect::MapEffect(const Pokemod* pokemod, const QString& fileName, const int id) :
+MapEffect::MapEffect(const Pokemod* pokemod, const QDomElement& xml, const int id) :
Object("MapEffect", pokemod, id)
{
- load(fileName, id);
+ load(xml, id);
}
bool MapEffect::validate() const
@@ -67,11 +70,7 @@ bool MapEffect::validate() const
pokemod()->validationMsg("Invalid existence flag status");
valid = false;
}
- if (!QFile::exists(skin()))
- {
- pokemod()->validationMsg(QString("Skin not found"));
- valid = false;
- }
+ // TODO: check skin size is 128x128
if (m_effect < E_End)
{
bool ok = true;
@@ -115,49 +114,37 @@ bool MapEffect::validate() const
return valid;
}
-void MapEffect::load(const QString& fileName, int id) throw(Exception)
+void MapEffect::load(const QDomElement& xml, int id)
{
- Ini ini(fileName);
- if (id == INT_MAX)
- ini.getValue("id", id);
- setId(id);
- int i;
- int j;
- ini.getValue("name", m_name);
- ini.getValue("coordinate-x", i, 0);
- ini.getValue("coordinate-y", j, 0);
- m_coordinate.set(i, j);
- ini.getValue("existFlag-f", i, 0);
- ini.getValue("existFlag-s", j, 0);
- m_existFlag.set(i, j);
- ini.getValue("skin", m_skin);
- ini.getValue("effect", m_effect);
- ini.getValue("val1", m_value1);
- ini.getValue("val2", m_value2);
- ini.getValue("direction", m_direction);
- ini.getValue("isGhost", m_isGhost);
- ini.getValue("canMove", m_canMove);
- ini.getValue("dialog", m_dialog);
+ LOAD_ID();
+ LOAD(QString, name);
+ LOAD(Point, coordinate);
+ LOAD(Flag, existFlag);
+ LOAD(QPixmap, skin);
+ LOAD(int, effect);
+ LOAD(int, value1);
+ LOAD(int, value2);
+ LOAD(int, direction);
+ LOAD(bool, isGhost);
+ LOAD(bool, canMove);
+ LOAD(int, dialog);
}
-void MapEffect::save(const QString& map) const throw(Exception)
+QDomElement MapEffect::save() const
{
- Ini ini;
- ini.addField("id", id());
- ini.addField("name", m_name);
- ini.addField("coordinate-x", m_coordinate.x());
- ini.addField("coordinate-y", m_coordinate.y());
- ini.addField("existFlag-f", m_existFlag.flag());
- ini.addField("existFlag-s", m_existFlag.status());
- ini.addField("skin", m_skin);
- ini.addField("effect", m_effect);
- ini.addField("val1", m_value1);
- ini.addField("val2", m_value2);
- ini.addField("direction", m_direction);
- ini.addField("isGhost", m_isGhost);
- ini.addField("canMove", m_canMove);
- ini.addField("dialog", m_dialog);
- ini.save(QString("%1/map/%2/effect/%3.pini").arg(pokemod()->path()).arg(map).arg(m_name));
+ SAVE_CREATE();
+ SAVE(QString, name);
+ SAVE(Point, coordinate);
+ SAVE(Flag, existFlag);
+ SAVE(QPixmap, skin);
+ SAVE(int, effect);
+ SAVE(int, value1);
+ SAVE(int, value2);
+ SAVE(int, direction);
+ SAVE(bool, isGhost);
+ SAVE(bool, canMove);
+ SAVE(int, dialog);
+ return xml;
}
void MapEffect::setName(const QString& name)
@@ -165,20 +152,19 @@ void MapEffect::setName(const QString& name)
m_name = name;
}
-void MapEffect::setCoordinate(const int x, const int y)
+void MapEffect::setCoordinate(const Point& coordinate)
{
- m_coordinate.set(x, y);
+ m_coordinate = coordinate;
}
-void MapEffect::setExistFlag(const int flag, const int status)
+void MapEffect::setExistFlag(const Flag& existFlag)
{
- m_existFlag.set(flag, status);
+ m_existFlag = existFlag;
}
-void MapEffect::setSkin(const QString& skin) throw(Exception)
+void MapEffect::setSkin(const QPixmap& skin) throw(Exception)
{
- if (!QFile::exists(QString("%1/image/skin/%2.png").arg(pokemod()->path()).arg(skin)))
- throw(Exception(className(), "skin does not exist"));
+ // TODO: check size is 128x128
m_skin = skin;
}
@@ -261,9 +247,9 @@ Flag MapEffect::existFlag() const
return m_existFlag;
}
-QString MapEffect::skin() const
+QPixmap MapEffect::skin() const
{
- return QString("%1/image/skin/%2.png").arg(pokemod()->path()).arg(m_skin);
+ return m_skin;
}
int MapEffect::effect() const
@@ -305,16 +291,16 @@ MapEffect& MapEffect::operator=(const MapEffect& rhs)
{
if (this == &rhs)
return *this;
- m_name = rhs.m_name;
- m_coordinate = rhs.m_coordinate;
- m_existFlag = rhs.m_existFlag;
- m_skin = rhs.m_skin;
- m_effect = rhs.m_effect;
- m_value1 = rhs.m_value1;
- m_value2 = rhs.m_value2;
- m_direction = rhs.m_direction;
- m_isGhost = rhs.m_isGhost;
- m_canMove = rhs.m_canMove;
- m_dialog = rhs.m_dialog;
+ COPY(name);
+ COPY(coordinate);
+ COPY(existFlag);
+ COPY(skin);
+ COPY(effect);
+ COPY(value1);
+ COPY(value2);
+ COPY(direction);
+ COPY(isGhost);
+ COPY(canMove);
+ COPY(dialog);
return *this;
}