diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-03-19 18:53:46 -0400 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-03-19 18:53:46 -0400 |
commit | 7f1b56b96c812d8b4ff6121afc933c30edae7f47 (patch) | |
tree | 46be731a27a46b649914aa68ec20dfe361df79c6 /sigmod | |
parent | 71b55b334827dfdfe565bfdc72263a945fb462ec (diff) | |
download | sigen-7f1b56b96c812d8b4ff6121afc933c30edae7f47.tar.gz sigen-7f1b56b96c812d8b4ff6121afc933c30edae7f47.tar.xz sigen-7f1b56b96c812d8b4ff6121afc933c30edae7f47.zip |
Add position to MapEffect and MapWarp
Diffstat (limited to 'sigmod')
-rw-r--r-- | sigmod/MapEffect.cpp | 12 | ||||
-rw-r--r-- | sigmod/MapEffect.h | 14 | ||||
-rw-r--r-- | sigmod/MapWarp.cpp | 12 | ||||
-rw-r--r-- | sigmod/MapWarp.h | 14 |
4 files changed, 52 insertions, 0 deletions
diff --git a/sigmod/MapEffect.cpp b/sigmod/MapEffect.cpp index dff6a370..a1f401ac 100644 --- a/sigmod/MapEffect.cpp +++ b/sigmod/MapEffect.cpp @@ -39,6 +39,7 @@ MapEffect::MapEffect(const MapEffect& effect) : MapEffect::MapEffect(const Map* parent, const int id) : Object(parent, id), m_name(""), + m_position(0, 0), m_area(), m_skin(-1), m_isGhost(false), @@ -64,6 +65,7 @@ void MapEffect::validate() TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST(position); if (m_area.isEmpty()) TEST(skin); TEST_END(); @@ -73,6 +75,7 @@ void MapEffect::load(const QDomElement& xml) { LOAD_BEGIN(); LOAD(name); + LOAD(position); LOAD(area); LOAD(skin); LOAD(isGhost); @@ -83,6 +86,7 @@ QDomElement MapEffect::save() const { SAVE_CREATE(); SAVE(name); + SAVE(position); SAVE(area); SAVE(skin); SAVE(isGhost); @@ -91,18 +95,25 @@ QDomElement MapEffect::save() const } SETTER(MapEffect, QString&, Name, name) +SETTER(MapEffect, QPoint&, Position, position) SETTER(MapEffect, QPainterPath&, Area, area) SETTER(MapEffect, int, Skin, skin) SETTER(MapEffect, bool, IsGhost, isGhost) SETTER(MapEffect, Script&, Script, script) GETTER(MapEffect, QString, name) +GETTER(MapEffect, QPoint, position) GETTER(MapEffect, QPainterPath, area) GETTER(MapEffect, int, skin) GETTER(MapEffect, bool, isGhost) GETTER(MapEffect, Script, script) CHECK(MapEffect, QString&, name) +CHECK_BEGIN(MapEffect, QPoint&, position) + const Map* map = qobject_cast<const Map*>(parent()); + TBOUNDS_MOD(position_x, 0, map->width() - 1, position.x()) + TBOUNDS_MOD(position_y, 0, map->height() - 1, position.y()) +CHECK_END() CHECK(MapEffect, QPainterPath&, area) CHECK_INDEX(MapEffect, int, skin, game(), skin) CHECK(MapEffect, bool, isGhost) @@ -113,6 +124,7 @@ MapEffect& MapEffect::operator=(const MapEffect& rhs) if (this == &rhs) return *this; COPY(name); + COPY(position); COPY(area); COPY(skin); COPY(isGhost); diff --git a/sigmod/MapEffect.h b/sigmod/MapEffect.h index 9c8f3a24..e8ec3192 100644 --- a/sigmod/MapEffect.h +++ b/sigmod/MapEffect.h @@ -105,6 +105,12 @@ class SIGMOD_EXPORT MapEffect : public Object */ void setName(const QString& name); /** + * Sets the position of the effect on the map. + * + * \param position The position of the effect on the map. + */ + void setPosition(const QPoint& position); + /** * Sets the area of the map the effect takes up. It is only used if the skin is not valid. * * \param area The area of the map the effect takes up. @@ -141,6 +147,12 @@ class SIGMOD_EXPORT MapEffect : public Object */ QString name() const; /** + * \sa setPosition + * + * \return The position of the effect on the map. + */ + QPoint position() const; + /** * \sa setArea * * \return The area of the effect. @@ -166,6 +178,7 @@ class SIGMOD_EXPORT MapEffect : public Object Sigcore::Script script() const; bool nameCheck(const QString& name) const; + bool positionCheck(const QPoint& point) const; bool areaCheck(const QPainterPath& area) const; bool skinCheck(const int skin) const; bool isGhostCheck(const bool isGhost) const; @@ -174,6 +187,7 @@ class SIGMOD_EXPORT MapEffect : public Object MapEffect& operator=(const MapEffect& rhs); private: QString m_name; + QPoint m_position; QPainterPath m_area; int m_skin; bool m_isGhost; diff --git a/sigmod/MapWarp.cpp b/sigmod/MapWarp.cpp index 39868edc..214a1eb7 100644 --- a/sigmod/MapWarp.cpp +++ b/sigmod/MapWarp.cpp @@ -39,6 +39,7 @@ MapWarp::MapWarp(const MapWarp& warp) : MapWarp::MapWarp(const Map* parent, const int id) : Object(parent, id), m_name(""), + m_position(0, 0), m_area(), m_toMap(INT_MAX), m_toWarp(INT_MAX), @@ -64,6 +65,7 @@ void MapWarp::validate() TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST(position); TEST(toMap); TEST(toWarp); TEST_END(); @@ -73,6 +75,7 @@ void MapWarp::load(const QDomElement& xml) { LOAD_BEGIN(); LOAD(name); + LOAD(position); LOAD(area); LOAD(toMap); LOAD(toWarp); @@ -83,6 +86,7 @@ QDomElement MapWarp::save() const { SAVE_CREATE(); SAVE(name); + SAVE(position); SAVE(area); SAVE(toMap); SAVE(toWarp); @@ -91,18 +95,25 @@ QDomElement MapWarp::save() const } SETTER(MapWarp, QString&, Name, name) +SETTER(MapWarp, QPoint&, Position, position) SETTER(MapWarp, QPainterPath&, Area, area) SETTER(MapWarp, int, ToMap, toMap) SETTER(MapWarp, int, ToWarp, toWarp) SETTER(MapWarp, Script&, Script, script) GETTER(MapWarp, QString, name) +GETTER(MapWarp, QPoint, position) GETTER(MapWarp, QPainterPath, area) GETTER(MapWarp, int, toMap) GETTER(MapWarp, int, toWarp) GETTER(MapWarp, Script, script) CHECK(MapWarp, QString&, name) +CHECK_BEGIN(MapWarp, QPoint&, position) + const Map* map = qobject_cast<const Map*>(parent()); + TBOUNDS_MOD(position_x, 0, map->width() - 1, position.x()) + TBOUNDS_MOD(position_y, 0, map->height() - 1, position.y()) +CHECK_END() CHECK(MapWarp, QPainterPath&, area) CHECK_INDEX(MapWarp, int, toMap, game(), map) CHECK_BEGIN(MapWarp, int, toWarp) @@ -121,6 +132,7 @@ MapWarp& MapWarp::operator=(const MapWarp& rhs) if (this == &rhs) return *this; COPY(name); + COPY(position); COPY(area); COPY(toMap); COPY(toWarp); diff --git a/sigmod/MapWarp.h b/sigmod/MapWarp.h index 75ffb47b..e3801cbe 100644 --- a/sigmod/MapWarp.h +++ b/sigmod/MapWarp.h @@ -104,6 +104,12 @@ class SIGMOD_EXPORT MapWarp : public Object */ void setName(const QString& name); /** + * Sets the position of the warp on the map. + * + * \param position The position of the warp on the map. + */ + void setPosition(const QPoint& position); + /** * Sets the area of the map the warp takes up. * * \param area The area of the map the warp takes up. @@ -141,6 +147,12 @@ class SIGMOD_EXPORT MapWarp : public Object */ QString name() const; /** + * \sa setPosition + * + * \return The position of the warp on the map. + */ + QPoint position() const; + /** * \sa setArea * * \return The area that the warp takes up. @@ -166,6 +178,7 @@ class SIGMOD_EXPORT MapWarp : public Object Sigcore::Script script() const; bool nameCheck(const QString& name) const; + bool positionCheck(const QPoint& point) const; bool areaCheck(const QPainterPath& area) const; bool toMapCheck(const int toMap) const; bool toWarpCheck(const int toWarp) const; @@ -174,6 +187,7 @@ class SIGMOD_EXPORT MapWarp : public Object MapWarp& operator=(const MapWarp& rhs); private: QString m_name; + QPoint m_position; QPainterPath m_area; int m_toMap; int m_toWarp; |