summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-30 00:27:14 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-30 00:27:14 +0300
commit478ffec82dae4f55c38ccd424079166ec8c38905 (patch)
tree96f9c597164c4bed24b5ab2040dcfffd1df624d7
parent67dd1ac770ed04fc7cbbbaa160c00f648d490858 (diff)
downloadmanaverse-478ffec82dae4f55c38ccd424079166ec8c38905.tar.gz
manaverse-478ffec82dae4f55c38ccd424079166ec8c38905.tar.bz2
manaverse-478ffec82dae4f55c38ccd424079166ec8c38905.tar.xz
manaverse-478ffec82dae4f55c38ccd424079166ec8c38905.zip
Convert TargetCursorSize enum into strong typed enum.
-rw-r--r--src/being/actorsprite.cpp20
-rw-r--r--src/being/actorsprite.h5
-rw-r--r--src/being/being.cpp2
-rw-r--r--src/being/being.h4
-rw-r--r--src/enums/being/targetcursorsize.h18
-rw-r--r--src/resources/beinginfo.h7
6 files changed, 28 insertions, 28 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index b7e30cacd..eb2268eb9 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -42,18 +42,18 @@
#include "debug.h"
#define for_each_cursors() \
- for (int size = TargetCursorSize::SMALL; \
- size < TargetCursorSize::NUM_TC; \
+ for (int size = static_cast<int>(TargetCursorSize::SMALL); \
+ size < static_cast<int>(TargetCursorSize::NUM_TC); \
size ++) \
{ \
- for (int type = TargetCursorType::NORMAL; \
- type < TargetCursorType::NUM_TCT; \
+ for (int type = static_cast<int>(TargetCursorType::NORMAL); \
+ type < static_cast<int>(TargetCursorType::NUM_TCT); \
type ++) \
#define end_foreach }
AnimatedSprite *ActorSprite::targetCursor[TargetCursorType::NUM_TCT]
- [TargetCursorSize::NUM_TC];
+ [static_cast<size_t>(TargetCursorSize::NUM_TC)];
bool ActorSprite::loaded = false;
ActorSprite::ActorSprite(const BeingId id) :
@@ -157,9 +157,11 @@ void ActorSprite::setTargetType(const TargetCursorType::Type type)
mUsedTargetCursor = targetCursor[static_cast<int>(type)][sz];
if (mUsedTargetCursor)
{
- static const int targetWidths[TargetCursorSize::NUM_TC]
+ static const int targetWidths[static_cast<size_t>(
+ TargetCursorSize::NUM_TC)]
= {0, 0, 0};
- static const int targetHeights[TargetCursorSize::NUM_TC]
+ static const int targetHeights[static_cast<size_t>(
+ TargetCursorSize::NUM_TC)]
= {-mapTileSize / 2, -mapTileSize / 2, -mapTileSize};
mCursorPaddingX = static_cast<int>(targetWidths[sz]);
@@ -361,7 +363,7 @@ static const char *cursorType(const int type)
}
}
-static const char *cursorSize(const int size)
+static const char *cursorSize(const TargetCursorSizeT size)
{
switch (size)
{
@@ -386,7 +388,7 @@ void ActorSprite::initTargetCursor()
Theme::resolveThemePath(strprintf(
targetCursorFile.c_str(),
cursorType(type),
- cursorSize(size))));
+ cursorSize(static_cast<TargetCursorSizeT>(size)))));
}
end_foreach
}
diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h
index 97553171a..9ba16a64c 100644
--- a/src/being/actorsprite.h
+++ b/src/being/actorsprite.h
@@ -90,8 +90,7 @@ class ActorSprite notfinal : public CompoundSprite, public Actor
/**
* Returns the required size of a target cursor for this being.
*/
- virtual TargetCursorSize::Size getTargetCursorSize() const
- A_WARN_UNUSED
+ virtual TargetCursorSizeT getTargetCursorSize() const A_WARN_UNUSED
{ return TargetCursorSize::MEDIUM; }
virtual int getTargetOffsetX() const A_WARN_UNUSED
@@ -216,7 +215,7 @@ class ActorSprite notfinal : public CompoundSprite, public Actor
/** Animated target cursors. */
static AnimatedSprite *targetCursor[TargetCursorType::NUM_TCT]
- [TargetCursorSize::NUM_TC];
+ [static_cast<size_t>(TargetCursorSize::NUM_TC)];
static bool loaded;
diff --git a/src/being/being.cpp b/src/being/being.cpp
index f433ec964..95d7330ed 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -442,7 +442,7 @@ void Being::setSubtype(const BeingTypeId subtype,
}
}
-TargetCursorSize::Size Being::getTargetCursorSize() const
+TargetCursorSizeT Being::getTargetCursorSize() const
{
if (!mInfo)
return TargetCursorSize::SMALL;
diff --git a/src/being/being.h b/src/being/being.h
index 63b531ff3..1837f9cbe 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -372,8 +372,8 @@ class Being notfinal : public ActorSprite,
const BeingInfo *getInfo() const A_WARN_UNUSED
{ return mInfo; }
- TargetCursorSize::Size getTargetCursorSize() const override final
- A_WARN_UNUSED;
+ TargetCursorSizeT getTargetCursorSize() const override final
+ A_WARN_UNUSED;
int getTargetOffsetX() const override A_WARN_UNUSED
{
diff --git a/src/enums/being/targetcursorsize.h b/src/enums/being/targetcursorsize.h
index 5344a7ad5..7bd048086 100644
--- a/src/enums/being/targetcursorsize.h
+++ b/src/enums/being/targetcursorsize.h
@@ -22,15 +22,15 @@
#ifndef ENUMS_BEING_TARGETCURSORSIZE_H
#define ENUMS_BEING_TARGETCURSORSIZE_H
-namespace TargetCursorSize
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(TargetCursorSize)
{
- enum Size
- {
- SMALL = 0,
- MEDIUM,
- LARGE,
- NUM_TC
- };
-} // TargetCursorSize
+ SMALL = 0,
+ MEDIUM,
+ LARGE,
+ NUM_TC
+}
+enumEnd(TargetCursorSize);
#endif // ENUMS_BEING_TARGETCURSORSIZE_H
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 33d1472c3..1d2a3546c 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -75,8 +75,7 @@ class BeingInfo final
void setTargetCursorSize(const std::string &size);
- void setTargetCursorSize(const TargetCursorSize::Size
- &targetSize)
+ void setTargetCursorSize(const TargetCursorSizeT &targetSize)
{ mTargetCursorSize = targetSize; }
void setHoverCursor(const std::string &name)
@@ -88,7 +87,7 @@ class BeingInfo final
Cursor::Cursor getHoverCursor() const A_WARN_UNUSED
{ return mHoverCursor; }
- TargetCursorSize::Size getTargetCursorSize() const A_WARN_UNUSED
+ TargetCursorSizeT getTargetCursorSize() const A_WARN_UNUSED
{ return mTargetCursorSize; }
void addSound(const ItemSoundEvent::Type event,
@@ -326,7 +325,7 @@ class BeingInfo final
private:
SpriteDisplay mDisplay;
std::string mName;
- TargetCursorSize::Size mTargetCursorSize;
+ TargetCursorSizeT mTargetCursorSize;
Cursor::Cursor mHoverCursor;
ItemSoundEvents mSounds;
Attacks mAttacks;