diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-11-08 06:15:08 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-11-08 06:15:08 +0000 |
| commit | 8bad37e82371bd41864903ac0d6f49808ad119bf (patch) | |
| tree | 77f0cb46059654cefb357d6eb4064c5740edf3d4 /sigmod/MapWarp.cpp | |
| parent | c127c0dae65a7600e0ab30b634f25d4915c61d16 (diff) | |
[FIX] No more asserts in sigmod
[FIX] Moved to using *ById instead of *Index methods in sigmod
[FIX] Tilemaps are now collaged (not completely done on the editing side yet)
[FIX] Removed the resource files (drawn natively instead)
[FIX] ATBTimer now uses the built-in QTimer in a QObject
[FIX] Coordinates are now edited on the map for warps, trainers, and effects
[FIX] Tiles are now completely scripted
[FIX] Config is now thread-safe
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@308 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'sigmod/MapWarp.cpp')
| -rw-r--r-- | sigmod/MapWarp.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/sigmod/MapWarp.cpp b/sigmod/MapWarp.cpp index bd4934b6..e0482f14 100644 --- a/sigmod/MapWarp.cpp +++ b/sigmod/MapWarp.cpp @@ -34,7 +34,7 @@ Sigmod::MapWarp::MapWarp(const MapWarp& warp) : Sigmod::MapWarp::MapWarp(const Map* parent, const int id) : Object(parent, id), m_name(""), - m_coordinate(0, 0), + m_area(0, 0, 32, 32), m_type(Door), m_toMap(INT_MAX), m_toWarp(INT_MAX), @@ -60,6 +60,7 @@ void Sigmod::MapWarp::validate() TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST(setArea, area); TEST(setToMap, toMap); TEST(setToWarp, toWarp); TEST_END(); @@ -69,7 +70,7 @@ void Sigmod::MapWarp::load(const QDomElement& xml) { LOAD_BEGIN(); LOAD(name); - LOAD(coordinate); + LOAD(area); LOAD(type); LOAD(toMap); LOAD(toWarp); @@ -80,7 +81,7 @@ QDomElement Sigmod::MapWarp::save() const { SAVE_CREATE(); SAVE(name); - SAVE(coordinate); + SAVE(area); SAVE(type); SAVE(toMap); SAVE(toWarp); @@ -93,12 +94,15 @@ void Sigmod::MapWarp::setName(const QString& name) CHECK(name); } -void Sigmod::MapWarp::setCoordinate(const QPoint& coordinate) +void Sigmod::MapWarp::setArea(const QRect& area) { - if ((qobject_cast<const Map*>(parent())->width() <= coordinate.x()) || (qobject_cast<const Map*>(parent())->height() <= coordinate.y())) - emit(error(bounds("coordinate"))); + const Map* map = qobject_cast<const Map*>(parent()); + if ((map->width() <= area.x()) || (map->height() <= area.y())) + emit(error(bounds("area"))); + else if ((area.width() <= 0) || (area.height() <= 0)) + emit(error(bounds("area"))); else - CHECK(coordinate); + CHECK(area); } void Sigmod::MapWarp::setType(const Type type) @@ -108,7 +112,7 @@ void Sigmod::MapWarp::setType(const Type type) void Sigmod::MapWarp::setToMap(const int toMap) { - if (qobject_cast<const Sigmod*>(sigmod())->mapIndex(toMap) == INT_MAX) + if (!sigmod()->mapById(toMap)) emit(error(bounds("toMap"))); else CHECK(toMap); @@ -116,9 +120,10 @@ void Sigmod::MapWarp::setToMap(const int toMap) void Sigmod::MapWarp::setToWarp(const int toWarp) { - if (qobject_cast<const Sigmod*>(sigmod())->mapIndex(m_toMap) == INT_MAX) + const Map* map = sigmod()->mapById(m_toMap); + if (!map) emit(error(bounds("toMap"))); - else if (qobject_cast<const Sigmod*>(sigmod())->mapById(m_toMap)->warpIndex(toWarp) == INT_MAX) + else if (!map->warpById(toWarp)) emit(error(bounds("toWarp"))); else CHECK(toWarp); @@ -134,9 +139,9 @@ QString Sigmod::MapWarp::name() const return m_name; } -QPoint Sigmod::MapWarp::coordinate() const +QRect Sigmod::MapWarp::area() const { - return m_coordinate; + return m_area; } Sigmod::MapWarp::Type Sigmod::MapWarp::type() const @@ -164,7 +169,7 @@ Sigmod::MapWarp& Sigmod::MapWarp::operator=(const MapWarp& rhs) if (this == &rhs) return *this; COPY(name); - COPY(coordinate); + COPY(area); COPY(type); COPY(toMap); COPY(toWarp); |
