diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-22 01:45:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-22 01:45:59 +0300 |
commit | ad56ac4bda60beddf33640df346801af1ece9ccf (patch) | |
tree | 80b27c32a9e954dd747e261d4f7617e4c959bb26 | |
parent | c0b08d3f4f554c16e9a3599f1f1063c3a283bb93 (diff) | |
download | ManaVerse-ad56ac4bda60beddf33640df346801af1ece9ccf.tar.gz ManaVerse-ad56ac4bda60beddf33640df346801af1ece9ccf.tar.bz2 ManaVerse-ad56ac4bda60beddf33640df346801af1ece9ccf.tar.xz ManaVerse-ad56ac4bda60beddf33640df346801af1ece9ccf.zip |
Add strong typed enum DisplayType.
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/being/actorsprite.cpp | 8 | ||||
-rw-r--r-- | src/being/actorsprite.h | 4 | ||||
-rw-r--r-- | src/being/being.cpp | 16 | ||||
-rw-r--r-- | src/being/flooritem.cpp | 2 | ||||
-rw-r--r-- | src/enums/resources/displaytype.h | 33 |
7 files changed, 51 insertions, 14 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ec9ccd1ff..51ce6b1df 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -697,6 +697,7 @@ SET(SRCS resources/iteminfo.cpp resources/itemmenuitem.h enums/resources/cursor.h + enums/resources/displaytype.h enums/resources/frametype.h enums/resources/imageposition.h enums/resources/imagetype.h diff --git a/src/Makefile.am b/src/Makefile.am index 3697146ee..b925110f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1454,6 +1454,7 @@ SRC = ${BASE_SRC} \ resources/iteminfo.cpp \ resources/itemmenuitem.h \ enums/resources/cursor.h \ + enums/resources/displaytype.h \ enums/resources/frametype.h \ enums/resources/imageposition.h \ enums/resources/imagetype.h \ diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index 6c2c99a40..6594c7e3c 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -429,7 +429,7 @@ void ActorSprite::handleStatusEffect(const StatusEffect *const effect, void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display, const ForceDisplay forceDisplay, - const int imageType, + const DisplayTypeT displayType, const std::string &color) { clear(); @@ -457,14 +457,14 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display, else { std::string imagePath; - switch (imageType) + switch (displayType) { - case 0: + case DisplayType::Item: default: imagePath = pathJoin(paths.getStringValue("itemIcons"), display.image); break; - case 1: + case DisplayType::Floor: imagePath = pathJoin(paths.getStringValue("itemIcons"), display.floor); break; diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h index ff413f040..db912e059 100644 --- a/src/being/actorsprite.h +++ b/src/being/actorsprite.h @@ -36,6 +36,8 @@ #include "enums/simpletypes/forcedisplay.h" #include "enums/simpletypes/isstart.h" +#include "enums/resources/displaytype.h" + #include "enums/resources/map/blocktype.h" #include "particle/particlelist.h" @@ -228,7 +230,7 @@ class ActorSprite notfinal : public CompoundSprite, public Actor void setupSpriteDisplay(const SpriteDisplay &display, const ForceDisplay forceDisplay, - const int imageType, + const DisplayTypeT displayType, const std::string &color); /** Load the target cursors into memory */ diff --git a/src/being/being.cpp b/src/being/being.cpp index e43b71600..be998d05d 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -388,7 +388,7 @@ void Being::setSubtype(const BeingTypeId subtype, setName(mInfo->getName()); setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_true, - 0, + DisplayType::Item, mInfo->getColor(fromInt(mLook, ItemColor))); mYDiff = mInfo->getSortOffsetY(); } @@ -400,7 +400,7 @@ void Being::setSubtype(const BeingTypeId subtype, setName(mInfo->getName()); setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_true, - 0, + DisplayType::Item, mInfo->getColor(fromInt(mLook, ItemColor))); mYDiff = mInfo->getSortOffsetY(); } @@ -412,7 +412,7 @@ void Being::setSubtype(const BeingTypeId subtype, setName(mInfo->getName()); setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_true, - 0, + DisplayType::Item, mInfo->getColor(fromInt(mLook, ItemColor))); mYDiff = mInfo->getSortOffsetY(); } @@ -424,7 +424,7 @@ void Being::setSubtype(const BeingTypeId subtype, setName(mInfo->getName()); setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_true, - 0, + DisplayType::Item, mInfo->getColor(fromInt(mLook, ItemColor))); mYDiff = mInfo->getSortOffsetY(); } @@ -436,7 +436,7 @@ void Being::setSubtype(const BeingTypeId subtype, setName(mInfo->getName()); setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false, - 0, + DisplayType::Item, mInfo->getColor(fromInt(mLook, ItemColor))); mYDiff = mInfo->getSortOffsetY(); } @@ -448,7 +448,7 @@ void Being::setSubtype(const BeingTypeId subtype, setName(mInfo->getName()); setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false, - 0, + DisplayType::Item, mInfo->getColor(fromInt(mLook, ItemColor))); mYDiff = mInfo->getSortOffsetY(); } @@ -459,7 +459,7 @@ void Being::setSubtype(const BeingTypeId subtype, { setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false, - 0, + DisplayType::Item, std::string()); mYDiff = mInfo->getSortOffsetY(); } @@ -470,7 +470,7 @@ void Being::setSubtype(const BeingTypeId subtype, { setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false, - 0, + DisplayType::Item, std::string()); } break; diff --git a/src/being/flooritem.cpp b/src/being/flooritem.cpp index 545bae892..a69b8af0e 100644 --- a/src/being/flooritem.cpp +++ b/src/being/flooritem.cpp @@ -120,7 +120,7 @@ void FloorItem::postInit(Map *const map, int subX, int subY) mCursor = info.getPickupCursor(); setupSpriteDisplay(info.getDisplay(), ForceDisplay_true, - 1, + DisplayType::Floor, info.getDyeIconColorsString(mColor)); } diff --git a/src/enums/resources/displaytype.h b/src/enums/resources/displaytype.h new file mode 100644 index 000000000..a5aff2244 --- /dev/null +++ b/src/enums/resources/displaytype.h @@ -0,0 +1,33 @@ +/* + * The ManaPlus Client + * Copyright (C) 2016-2017 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef ENUMS_RESOURCES_DISPLAYTYPE_H +#define ENUMS_RESOURCES_DISPLAYTYPE_H + +#include "enums/simpletypes/enumdefines.h" + +enumStart(DisplayType) +{ + Item = 0, + Floor = 1 +} +enumEnd(DisplayType); + +#endif // ENUMS_RESOURCES_DISPLAYTYPE_H |