summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-13 13:12:06 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-13 13:12:06 +0300
commit13baf331faa43913cb836661113ba63d3c2bc0a3 (patch)
tree03ddeb1936a712228c0514dc70926f2f74177a54
parent7b4b302ffe79cdba0fa35b66741a9d6c3d9184f2 (diff)
downloadmanaverse-13baf331faa43913cb836661113ba63d3c2bc0a3.tar.gz
manaverse-13baf331faa43913cb836661113ba63d3c2bc0a3.tar.bz2
manaverse-13baf331faa43913cb836661113ba63d3c2bc0a3.tar.xz
manaverse-13baf331faa43913cb836661113ba63d3c2bc0a3.zip
Move targetcursortype into separate file.
-rw-r--r--src/being/actorsprite.cpp19
-rw-r--r--src/being/actorsprite.h14
-rw-r--r--src/being/localplayer.cpp8
-rw-r--r--src/being/targetcursortype.h36
4 files changed, 56 insertions, 21 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index 6d5702da0..f52820f86 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -42,7 +42,8 @@
#include "debug.h"
-AnimatedSprite *ActorSprite::targetCursor[NUM_TCT][TargetCursorSize::NUM_TC];
+AnimatedSprite *ActorSprite::targetCursor[TargetCursorType::NUM_TCT]
+ [TargetCursorSize::NUM_TC];
bool ActorSprite::loaded = false;
ActorSprite::ActorSprite(const int id) :
@@ -136,9 +137,9 @@ void ActorSprite::controlParticle(Particle *const particle)
mChildParticleEffects.addLocally(particle);
}
-void ActorSprite::setTargetType(const TargetCursorType type)
+void ActorSprite::setTargetType(const TargetCursorType::Type type)
{
- if (type == TCT_NONE)
+ if (type == TargetCursorType::NONE)
{
untarget();
}
@@ -334,10 +335,10 @@ static const char *cursorType(const int type)
{
switch (type)
{
- case ActorSprite::TCT_IN_RANGE:
+ case TargetCursorType::IN_RANGE:
return "in-range";
default:
- case ActorSprite::TCT_NORMAL:
+ case TargetCursorType::NORMAL:
return "normal";
}
}
@@ -365,7 +366,9 @@ void ActorSprite::initTargetCursor()
size < TargetCursorSize::NUM_TC;
size ++)
{
- for (int type = TCT_NORMAL; type < NUM_TCT; type++)
+ for (int type = TargetCursorType::NORMAL;
+ type < TargetCursorType::NUM_TCT;
+ type ++)
{
targetCursor[type][size] = AnimatedSprite::load(
Theme::resolveThemePath(strprintf(
@@ -382,7 +385,9 @@ void ActorSprite::cleanupTargetCursors()
size < TargetCursorSize::NUM_TC;
size ++)
{
- for (int type = TCT_NORMAL; type < NUM_TCT; type++)
+ for (int type = TargetCursorType::NORMAL;
+ type < TargetCursorType::NUM_TCT;
+ type ++)
{
if (targetCursor[type][size])
delete2(targetCursor[type][size])
diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h
index b646500da..1c08e4333 100644
--- a/src/being/actorsprite.h
+++ b/src/being/actorsprite.h
@@ -31,6 +31,7 @@
#include "being/actortype.h"
#include "being/compoundsprite.h"
#include "being/targetcursorsize.h"
+#include "being/targetcursortype.h"
#include "particle/particlecontainer.h"
@@ -46,14 +47,6 @@ class ActorSpriteListener;
class ActorSprite : public CompoundSprite, public Actor
{
public:
- enum TargetCursorType
- {
- TCT_NONE = -1,
- TCT_NORMAL = 0,
- TCT_IN_RANGE,
- NUM_TCT
- };
-
explicit ActorSprite(const int id);
A_DELETE_COPY(ActorSprite)
@@ -108,7 +101,7 @@ public:
/**
* Sets the target animation for this actor.
*/
- void setTargetType(const TargetCursorType type);
+ void setTargetType(const TargetCursorType::Type type);
/**
* Untargets the actor.
@@ -218,7 +211,8 @@ private:
static void cleanupTargetCursors();
/** Animated target cursors. */
- static AnimatedSprite *targetCursor[NUM_TCT][TargetCursorSize::NUM_TC];
+ static AnimatedSprite *targetCursor[TargetCursorType::NUM_TCT]
+ [TargetCursorSize::NUM_TC];
static bool loaded;
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index d22e8503c..b64c494b7 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -298,7 +298,7 @@ void LocalPlayer::logic()
if (mTarget->getType() == ActorType::NPC)
{
// NPCs are always in range
- mTarget->setTargetType(TCT_IN_RANGE);
+ mTarget->setTargetType(TargetCursorType::IN_RANGE);
}
else
{
@@ -308,9 +308,9 @@ void LocalPlayer::logic()
const int rangeY = static_cast<int>(
abs(mTarget->getTileY() - getTileY()));
const int attackRange = getAttackRange();
- const TargetCursorType targetType = rangeX > attackRange ||
- rangeY > attackRange ?
- TCT_NORMAL : TCT_IN_RANGE;
+ const TargetCursorType::Type targetType
+ = rangeX > attackRange || rangeY > attackRange
+ ? TargetCursorType::NORMAL : TargetCursorType::IN_RANGE;
mTarget->setTargetType(targetType);
if (!mTarget->isAlive() && (!mTargetDeadPlayers
diff --git a/src/being/targetcursortype.h b/src/being/targetcursortype.h
new file mode 100644
index 000000000..f245d4384
--- /dev/null
+++ b/src/being/targetcursortype.h
@@ -0,0 +1,36 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2010 The Mana Developers
+ * Copyright (C) 2011-2014 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 BEING_TARGETCURSORTYPE_H
+#define BEING_TARGETCURSORTYPE_H
+
+namespace TargetCursorType
+{
+ enum Type
+ {
+ NONE = -1,
+ NORMAL = 0,
+ IN_RANGE,
+ NUM_TCT
+ };
+}
+
+#endif // BEING_TARGETCURSORTYPE_H