From 0a9826815fdf65c5c48c1cc78dde8ad43c47c4ac Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 3 Jun 2015 18:08:05 +0300 Subject: Convert MapType enum into strong typed enum. --- src/enums/resources/map/maptype.h | 24 ++++++++++++------------ src/gamemodifiers.cpp | 2 +- src/gui/viewport.cpp | 4 ++-- src/resources/map/map.cpp | 7 ++++--- src/resources/map/map.h | 8 ++++---- src/resources/map/maplayer.cpp | 2 +- src/resources/map/maplayer.h | 4 ++-- src/settings.h | 2 +- 8 files changed, 27 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/enums/resources/map/maptype.h b/src/enums/resources/map/maptype.h index 27a58bccf..bb3607aa4 100644 --- a/src/enums/resources/map/maptype.h +++ b/src/enums/resources/map/maptype.h @@ -23,18 +23,18 @@ #ifndef RESOURCES_MAP_MAPTYPE_H #define RESOURCES_MAP_MAPTYPE_H -namespace MapType +#include "enums/simpletypes/enumdefines.h" + +enumStart(MapType) { - enum MapType - { - NORMAL = 0, - DEBUG = 1, - SPECIAL = 2, - SPECIAL2 = 3, - SPECIAL3 = 4, - SPECIAL4 = 5, - BLACKWHITE = 6 - }; -} // namespace MapType + NORMAL = 0, + DEBUG = 1, + SPECIAL = 2, + SPECIAL2 = 3, + SPECIAL3 = 4, + SPECIAL4 = 5, + BLACKWHITE = 6 +} +enumEnd(MapType); #endif // RESOURCES_MAP_MAPTYPE_H diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp index 158a6f2cd..56facd8cc 100644 --- a/src/gamemodifiers.cpp +++ b/src/gamemodifiers.cpp @@ -55,7 +55,7 @@ std::string GameModifiers::get##name1##String() \ { \ return gettext(getVarItem(&m##name1##Strings[0], \ - settings.name2, m##name1##Size)); \ + static_cast(settings.name2), m##name1##Size)); \ } #define addModifier2(name1, name2, str, sz, ...) \ diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 5c0c7328c..7bb6e2eef 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -228,7 +228,7 @@ void Viewport::draw(Graphics *graphics) // Draw tiles and sprites mMap->draw(graphics, mPixelViewX, mPixelViewY); - const MapType::MapType drawType = settings.mapDrawType; + const MapTypeT drawType = settings.mapDrawType; if (drawType != MapType::NORMAL) { if (drawType != MapType::SPECIAL4) @@ -874,7 +874,7 @@ void Viewport::mouseMoved(MouseEvent &event) void Viewport::toggleMapDrawType() { - settings.mapDrawType = static_cast( + settings.mapDrawType = static_cast( static_cast(settings.mapDrawType) + 1); if (settings.mapDrawType > MapType::BLACKWHITE) settings.mapDrawType = MapType::NORMAL; diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index 6ccc7b7a4..7bad7ee3d 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -550,8 +550,9 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) }\ void Map::drawCollision(Graphics *const graphics, - const int scrollX, const int scrollY, - const MapType::MapType drawFlags) const + const int scrollX, + const int scrollY, + const MapTypeT drawFlags) const { const int endPixelY = graphics->mHeight + scrollY + mTileHeight - 1; int startX = scrollX / mTileWidth; @@ -1591,7 +1592,7 @@ void Map::addAnimation(const int gid, TileAnimation *const animation) mTileAnimations[gid] = animation; } -void Map::setDrawLayersFlags(const MapType::MapType &n) +void Map::setDrawLayersFlags(const MapTypeT &n) { mDrawLayersFlags = n; if (mDrawLayersFlags == MapType::SPECIAL3 diff --git a/src/resources/map/map.h b/src/resources/map/map.h index 2cba3de6f..28bf9c4b2 100644 --- a/src/resources/map/map.h +++ b/src/resources/map/map.h @@ -116,7 +116,7 @@ class Map final : public Properties, public ConfigListener */ void drawCollision(Graphics *const graphics, const int scrollX, const int scrollY, - const MapType::MapType drawFlags) const; + const MapTypeT drawFlags) const; /** * Adds a layer to this map. The map takes ownership of the layer. @@ -217,9 +217,9 @@ class Map final : public Properties, public ConfigListener */ void addAnimation(const int gid, TileAnimation *const animation); - void setDrawLayersFlags(const MapType::MapType &n); + void setDrawLayersFlags(const MapTypeT &n); - MapType::MapType getDrawLayersFlags() const A_WARN_UNUSED + MapTypeT getDrawLayersFlags() const A_WARN_UNUSED { return mDrawLayersFlags; } void addExtraLayer(); @@ -385,7 +385,7 @@ class Map final : public Properties, public ConfigListener bool mHasWarps; // draw flags - MapType::MapType mDrawLayersFlags; + MapTypeT mDrawLayersFlags; // Pathfinding members unsigned int mOnClosedList; diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp index d7aaa8e72..584d5702b 100644 --- a/src/resources/map/maplayer.cpp +++ b/src/resources/map/maplayer.cpp @@ -664,7 +664,7 @@ int MapLayer::getTileDrawWidth(const Image *img, return c; } -void MapLayer::setDrawLayerFlags(const MapType::MapType &n) +void MapLayer::setDrawLayerFlags(const MapTypeT &n) { mDrawLayerFlags = n; mSpecialFlag = (mDrawLayerFlags != MapType::SPECIAL diff --git a/src/resources/map/maplayer.h b/src/resources/map/maplayer.h index 9b2617d32..4cf30ade1 100644 --- a/src/resources/map/maplayer.h +++ b/src/resources/map/maplayer.h @@ -129,7 +129,7 @@ class MapLayer final: public ConfigListener void optionChanged(const std::string &value) override final; - void setDrawLayerFlags(const MapType::MapType &n); + void setDrawLayerFlags(const MapTypeT &n); void setActorsFix(const int y) { mActorsFix = y; } @@ -145,7 +145,7 @@ class MapLayer final: public ConfigListener const int mWidth; const int mHeight; Image **const mTiles; - MapType::MapType mDrawLayerFlags; + MapTypeT mDrawLayerFlags; const SpecialLayer *mSpecialLayer; const SpecialLayer *mTempLayer; typedef std::vector MapRows; diff --git a/src/settings.h b/src/settings.h index 068bfc573..bb5e0a67b 100644 --- a/src/settings.h +++ b/src/settings.h @@ -111,7 +111,7 @@ class Settings final unsigned int imitationMode; unsigned int cameraMode; unsigned int crazyMoveState; - MapType::MapType mapDrawType; + MapTypeT mapDrawType; bool persistentIp; bool limitFps; bool inputFocused; -- cgit v1.2.3-70-g09d2