summaryrefslogtreecommitdiffstats
path: root/pokemod/MapWarp.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/MapWarp.cpp
parent12d5161318a4d8d781f896812f5a95fa7b46d8a8 (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/MapWarp.cpp')
-rw-r--r--pokemod/MapWarp.cpp112
1 files changed, 47 insertions, 65 deletions
diff --git a/pokemod/MapWarp.cpp b/pokemod/MapWarp.cpp
index 050b02e9..d23db520 100644
--- a/pokemod/MapWarp.cpp
+++ b/pokemod/MapWarp.cpp
@@ -49,10 +49,10 @@ MapWarp::MapWarp(const Pokemod* pokemod, const MapWarp& warp, const int id) :
*this = warp;
}
-MapWarp::MapWarp(const Pokemod* pokemod, const QString& fileName, const int id) :
+MapWarp::MapWarp(const Pokemod* pokemod, const QDomElement& xml, const int id) :
Object("MapWarp", pokemod, id)
{
- load(fileName, id);
+ load(xml, id);
}
bool MapWarp::validate() const
@@ -100,56 +100,39 @@ bool MapWarp::validate() const
return valid;
}
-void MapWarp::load(const QString& fileName, int id) throw(Exception)
+void MapWarp::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("from-up", m_from[Pokemod::D_Up], false);
- ini.getValue("from-down", m_from[Pokemod::D_Down], false);
- ini.getValue("from-left", m_from[Pokemod::D_Left], false);
- ini.getValue("from-right", m_from[Pokemod::D_Right], false);
- ini.getValue("directionOut", m_directionOut);
- ini.getValue("warpType", m_warpType);
- ini.getValue("isBiking", m_isBiking, false);
- ini.getValue("isFlash", m_isFlash, false);
- ini.getValue("isFoggy", m_isFoggy, false);
- ini.getValue("toMap", m_toMap);
- ini.getValue("toWarp", m_toWarp);
- ini.getValue("workingFlag-f", i, 0);
- ini.getValue("workingFlag-s", j, 0);
- m_workingFlag.set(i, j);
- ini.getValue("dialog", m_dialog);
+ LOAD_ID();
+ LOAD(QString, name);
+ LOAD(Point, coordinate);
+ LOAD_ARRAY(bool, from, Pokemod::D_End);
+ LOAD(int, directionOut);
+ LOAD(int, warpType);
+ LOAD(bool, isBiking);
+ LOAD(bool, isFlash);
+ LOAD(bool, isFoggy);
+ LOAD(int, toMap);
+ LOAD(int, toWarp);
+ LOAD(Flag, workingFlag);
+ LOAD(int, dialog);
}
-void MapWarp::save(const QString& map) const throw(Exception)
+QDomElement MapWarp::save() const
{
- Ini ini;
- ini.addField("id", id());
- ini.addField("coordinate-x", m_coordinate.x());
- ini.addField("coordinate-y", m_coordinate.y());
- ini.addField("from-up", m_from[Pokemod::D_Up]);
- ini.addField("from-down", m_from[Pokemod::D_Down]);
- ini.addField("from-left", m_from[Pokemod::D_Left]);
- ini.addField("from-right", m_from[Pokemod::D_Right]);
- ini.addField("directionOut", m_directionOut);
- ini.addField("warpType", m_warpType);
- ini.addField("isBiking", m_isBiking);
- ini.addField("isFlash", m_isFlash);
- ini.addField("isFoggy", m_isFoggy);
- ini.addField("toMap", m_toMap);
- ini.addField("toWarp", m_toWarp);
- ini.addField("workingFlag-f", m_workingFlag.flag());
- ini.addField("workingFlag-s", m_workingFlag.status());
- ini.addField("dialog", m_dialog);
- ini.save(QString("%1/map/%2/warp/%3.pini").arg(pokemod()->path()).arg(map).arg(m_name));
+ SAVE_CREATE();
+ SAVE(QString, name);
+ SAVE(Point, coordinate);
+ SAVE_ARRAY(bool, from, Pokemod::D_End);
+ SAVE(int, directionOut);
+ SAVE(int, warpType);
+ SAVE(bool, isBiking);
+ SAVE(bool, isFlash);
+ SAVE(bool, isFoggy);
+ SAVE(int, toMap);
+ SAVE(int, toWarp);
+ SAVE(Flag, workingFlag);
+ SAVE(int, dialog);
+ return xml;
}
void MapWarp::setName(const QString& name)
@@ -157,9 +140,9 @@ void MapWarp::setName(const QString& name)
m_name = name;
}
-void MapWarp::setCoordinate(const int x, const int y)
+void MapWarp::setCoordinate(const Point& coordinate)
{
- m_coordinate.set(x, y);
+ m_coordinate = coordinate;
}
void MapWarp::setFrom(const int direction, const bool can) throw(BoundsException)
@@ -221,9 +204,9 @@ void MapWarp::setToWarp(const int toWarp) throw(BoundsException)
m_toWarp = toWarp;
}
-void MapWarp::setWorkingFlag(const int flag, const int status)
+void MapWarp::setWorkingFlag(const Flag& workingFlag)
{
- m_workingFlag.set(flag, status);
+ m_workingFlag = workingFlag;
}
void MapWarp::setDialog(const int dialog) throw(BoundsException)
@@ -299,18 +282,17 @@ MapWarp& MapWarp::operator=(const MapWarp& rhs)
{
if (this == &rhs)
return *this;
- m_name = rhs.m_name;
- m_coordinate = rhs.m_coordinate;
- for (int i = 0; i < Pokemod::D_End; ++i)
- m_from[i] = rhs.m_from[i];
- m_directionOut = rhs.m_directionOut;
- m_warpType = rhs.m_warpType;
- m_isBiking = rhs.m_isBiking;
- m_isFlash = rhs.m_isFlash;
- m_isFoggy = rhs.m_isFoggy;
- m_toMap = rhs.m_toMap;
- m_toWarp = rhs.m_toWarp;
- m_workingFlag = rhs.m_workingFlag;
- m_dialog = rhs.m_dialog;
+ COPY(name);
+ COPY(coordinate);
+ COPY_ARRAY(from, Pokemod::D_End);
+ COPY(directionOut);
+ COPY(warpType);
+ COPY(isBiking);
+ COPY(isFlash);
+ COPY(isFoggy);
+ COPY(toMap);
+ COPY(toWarp);
+ COPY(workingFlag);
+ COPY(dialog);
return *this;
}