summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-30 00:36:56 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-30 00:36:56 +0300
commit7969f0590204ac48d74e98c3211bca27693bac44 (patch)
tree78b2952b547aabe9f018e308dc57834322715707 /src
parent478ffec82dae4f55c38ccd424079166ec8c38905 (diff)
downloadplus-7969f0590204ac48d74e98c3211bca27693bac44.tar.gz
plus-7969f0590204ac48d74e98c3211bca27693bac44.tar.bz2
plus-7969f0590204ac48d74e98c3211bca27693bac44.tar.xz
plus-7969f0590204ac48d74e98c3211bca27693bac44.zip
Convert TargetCursorType enum into strong typed enum.
Diffstat (limited to 'src')
-rw-r--r--src/being/actorsprite.cpp9
-rw-r--r--src/being/actorsprite.h5
-rw-r--r--src/being/localplayer.cpp2
-rw-r--r--src/enums/being/targetcursortype.h16
4 files changed, 17 insertions, 15 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index eb2268eb9..1f7ea4b95 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -52,7 +52,8 @@
#define end_foreach }
-AnimatedSprite *ActorSprite::targetCursor[TargetCursorType::NUM_TCT]
+AnimatedSprite *ActorSprite::targetCursor
+ [static_cast<size_t>(TargetCursorType::NUM_TCT)]
[static_cast<size_t>(TargetCursorSize::NUM_TC)];
bool ActorSprite::loaded = false;
@@ -145,7 +146,7 @@ void ActorSprite::controlParticle(Particle *const particle)
mChildParticleEffects.addLocally(particle);
}
-void ActorSprite::setTargetType(const TargetCursorType::Type type)
+void ActorSprite::setTargetType(const TargetCursorTypeT type)
{
if (type == TargetCursorType::NONE)
{
@@ -351,7 +352,7 @@ void ActorSprite::removeActorSpriteListener(ActorSpriteListener *const
mActorSpriteListeners.remove(listener);
}
-static const char *cursorType(const int type)
+static const char *cursorType(const TargetCursorTypeT type)
{
switch (type)
{
@@ -387,7 +388,7 @@ void ActorSprite::initTargetCursor()
targetCursor[type][size] = AnimatedSprite::load(
Theme::resolveThemePath(strprintf(
targetCursorFile.c_str(),
- cursorType(type),
+ cursorType(static_cast<TargetCursorTypeT>(type)),
cursorSize(static_cast<TargetCursorSizeT>(size)))));
}
end_foreach
diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h
index 9ba16a64c..72ceb2f84 100644
--- a/src/being/actorsprite.h
+++ b/src/being/actorsprite.h
@@ -102,7 +102,7 @@ class ActorSprite notfinal : public CompoundSprite, public Actor
/**
* Sets the target animation for this actor.
*/
- void setTargetType(const TargetCursorType::Type type);
+ void setTargetType(const TargetCursorTypeT type);
/**
* Untargets the actor.
@@ -214,7 +214,8 @@ class ActorSprite notfinal : public CompoundSprite, public Actor
static void cleanupTargetCursors();
/** Animated target cursors. */
- static AnimatedSprite *targetCursor[TargetCursorType::NUM_TCT]
+ static AnimatedSprite *targetCursor
+ [static_cast<size_t>(TargetCursorType::NUM_TCT)]
[static_cast<size_t>(TargetCursorSize::NUM_TC)];
static bool loaded;
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index fedda2777..e9fa6e2c4 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -305,7 +305,7 @@ void LocalPlayer::logic()
const int rangeY = static_cast<int>(
abs(mTarget->getTileY() - getTileY()));
const int attackRange = getAttackRange();
- const TargetCursorType::Type targetType
+ const TargetCursorTypeT targetType
= rangeX > attackRange || rangeY > attackRange
? TargetCursorType::NORMAL : TargetCursorType::IN_RANGE;
mTarget->setTargetType(targetType);
diff --git a/src/enums/being/targetcursortype.h b/src/enums/being/targetcursortype.h
index a47b1ede0..7bc6cadaf 100644
--- a/src/enums/being/targetcursortype.h
+++ b/src/enums/being/targetcursortype.h
@@ -22,15 +22,15 @@
#ifndef ENUMS_BEING_TARGETCURSORTYPE_H
#define ENUMS_BEING_TARGETCURSORTYPE_H
-namespace TargetCursorType
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(TargetCursorType)
{
- enum Type
- {
- NONE = -1,
- NORMAL = 0,
- IN_RANGE,
- NUM_TCT
- };
+ NONE = -1,
+ NORMAL = 0,
+ IN_RANGE,
+ NUM_TCT
}
+enumEnd(TargetCursorType);
#endif // ENUMS_BEING_TARGETCURSORTYPE_H