diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-12-29 12:09:27 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-12-29 12:09:27 -0500 |
| commit | 8e278873d4bd35a7cd7f3b6d9d7852fa422370b8 (patch) | |
| tree | 9e97b71d30779c07c79ca166e1d704a3de4d5e4f /sigmod/MapWarp.cpp | |
| parent | e801b73a2f9cb845913cf546002c8f50eefc473c (diff) | |
Merged CHECK macro branch
Diffstat (limited to 'sigmod/MapWarp.cpp')
| -rw-r--r-- | sigmod/MapWarp.cpp | 105 |
1 files changed, 31 insertions, 74 deletions
diff --git a/sigmod/MapWarp.cpp b/sigmod/MapWarp.cpp index 137c5f98..157f2de9 100644 --- a/sigmod/MapWarp.cpp +++ b/sigmod/MapWarp.cpp @@ -60,9 +60,9 @@ 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(area); + TEST(toMap); + TEST(toWarp); TEST_END(); } @@ -89,80 +89,37 @@ QDomElement Sigmod::MapWarp::save() const return xml; } -void Sigmod::MapWarp::setName(const QString& name) -{ - CHECK(name); -} - -void Sigmod::MapWarp::setArea(const QRect& area) -{ - const Map* map = qobject_cast<const Map*>(parent()); - if ((map->width() <= area.x()) || (map->height() <= area.y())) - emit(error(bounds("area", QPoint(0, 0), QPoint(map->width(), map->height()), area.topLeft()))); - else if ((area.width() <= 0) || (area.height() <= 0) || ((map->width() - area.x()) < area.width()) || ((map->height() - area.y()) < area.height())) - emit(error(bounds("area size", QPoint(0, 0), QPoint(map->width() - area.x(), map->height() - area.y()), area.translated(-area.topLeft()).bottomRight()))); - else - CHECK(area); -} - -void Sigmod::MapWarp::setType(const Type type) -{ - CHECK(type); -} +SETTER(MapWarp, QString&, Name, name) +SETTER(MapWarp, QRect&, Area, area) +SETTER(MapWarp, Type, Type, type) +SETTER(MapWarp, int, ToMap, toMap) +SETTER(MapWarp, int, ToWarp, toWarp) +SETTER(MapWarp, Sigcore::Script&, Script, script) -void Sigmod::MapWarp::setToMap(const int toMap) -{ - if (!sigmod()->mapById(toMap)) - emit(error(bounds("toMap", toMap))); - else - CHECK(toMap); -} +GETTER(MapWarp, QString, name) +GETTER(MapWarp, QRect, area) +GETTER(MapWarp, Sigmod::MapWarp::Type, type) +GETTER(MapWarp, int, toMap) +GETTER(MapWarp, int, toWarp) +GETTER(MapWarp, Sigcore::Script, script) -void Sigmod::MapWarp::setToWarp(const int toWarp) -{ - const Map* map = sigmod()->mapById(m_toMap); +CHECK(MapWarp, QString&, name) +CHECK_BEGIN(MapWarp, QRect&, area) + const Map* map = qobject_cast<const Map*>(parent()); + TBOUNDS_MOD(area_x, 0, map->width() - 1, area.x()); + TBOUNDS_MOD(area_y, 0, map->height() - 1, area.y()); + TBOUNDS_MOD(area_width, 1, map->width() - area.x(), area.width()); + TBOUNDS_MOD(area_height, 1, map->height() - area.y(), area.height()); +CHECK_END() +CHECK(MapWarp, Type, type) +CHECK_INDEX(MapWarp, int, toMap, sigmod(), map) +CHECK_BEGIN(MapWarp, int, toWarp) + const Map* map = qobject_cast<const Map*>(parent()); if (!map) - emit(error(bounds("toMap", m_toMap))); - else if (!map->warpById(toWarp)) - emit(error(bounds("toWarp", toWarp))); - else - CHECK(toWarp); -} - -void Sigmod::MapWarp::setScript(const Sigcore::Script& script) -{ - CHECK(script); -} - -QString Sigmod::MapWarp::name() const -{ - return m_name; -} - -QRect Sigmod::MapWarp::area() const -{ - return m_area; -} - -Sigmod::MapWarp::Type Sigmod::MapWarp::type() const -{ - return m_type; -} - -int Sigmod::MapWarp::toMap() const -{ - return m_toMap; -} - -int Sigmod::MapWarp::toWarp() const -{ - return m_toWarp; -} - -Sigcore::Script Sigmod::MapWarp::script() const -{ - return m_script; -} + EBOUNDS_IDX(m_toMap); + IBOUNDS(toWarp, map, warp); +CHECK_END() +CHECK(MapWarp, Sigcore::Script&, script) Sigmod::MapWarp& Sigmod::MapWarp::operator=(const MapWarp& rhs) { |
