summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-13 12:56:09 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-13 12:56:09 +0300
commit7b4b302ffe79cdba0fa35b66741a9d6c3d9184f2 (patch)
tree1be01271ab942e0e6e321fa2ce45a6b527f97b07 /src
parentea0b61e18f36f28806940b00a2cddaef912c3340 (diff)
downloadmanaverse-7b4b302ffe79cdba0fa35b66741a9d6c3d9184f2.tar.gz
manaverse-7b4b302ffe79cdba0fa35b66741a9d6c3d9184f2.tar.bz2
manaverse-7b4b302ffe79cdba0fa35b66741a9d6c3d9184f2.tar.xz
manaverse-7b4b302ffe79cdba0fa35b66741a9d6c3d9184f2.zip
Move targetcursorsize into separate file.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/being/actorsprite.cpp23
-rw-r--r--src/being/actorsprite.h15
-rw-r--r--src/being/being.cpp4
-rw-r--r--src/being/being.h4
-rw-r--r--src/being/targetcursorsize.h36
-rw-r--r--src/resources/beinginfo.cpp10
-rw-r--r--src/resources/beinginfo.h6
9 files changed, 68 insertions, 32 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bca0cc342..29a0b0061 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -773,6 +773,7 @@ SET(SRCS
being/playerrelation.h
being/playerrelations.cpp
being/playerrelations.h
+ being/targetcursorsize.h
listeners/playerrelationslistener.h
position.cpp
position.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 52741624c..0d31b40cd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -860,6 +860,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
being/playerrelation.h \
being/playerrelations.cpp \
being/playerrelations.h \
+ being/targetcursorsize.h \
listeners/playerrelationslistener.h \
position.cpp \
position.h \
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index eb695a0e2..6d5702da0 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -42,7 +42,7 @@
#include "debug.h"
-AnimatedSprite *ActorSprite::targetCursor[NUM_TCT][NUM_TC];
+AnimatedSprite *ActorSprite::targetCursor[NUM_TCT][TargetCursorSize::NUM_TC];
bool ActorSprite::loaded = false;
ActorSprite::ActorSprite(const int id) :
@@ -144,12 +144,13 @@ void ActorSprite::setTargetType(const TargetCursorType type)
}
else
{
- const TargetCursorSize sz = getTargetCursorSize();
+ const TargetCursorSize::Size sz = getTargetCursorSize();
mUsedTargetCursor = targetCursor[static_cast<int>(type)][sz];
if (mUsedTargetCursor)
{
- static const int targetWidths[ActorSprite::NUM_TC] = {0, 0, 0};
- static const int targetHeights[ActorSprite::NUM_TC]
+ static const int targetWidths[TargetCursorSize::NUM_TC]
+ = {0, 0, 0};
+ static const int targetHeights[TargetCursorSize::NUM_TC]
= {-mapTileSize / 2, -mapTileSize / 2, -mapTileSize};
mCursorPaddingX = static_cast<int>(targetWidths[sz]);
@@ -345,12 +346,12 @@ static const char *cursorSize(const int size)
{
switch (size)
{
- case ActorSprite::TC_LARGE:
+ case TargetCursorSize::LARGE:
return "l";
- case ActorSprite::TC_MEDIUM:
+ case TargetCursorSize::MEDIUM:
return "m";
default:
- case ActorSprite::TC_SMALL:
+ case TargetCursorSize::SMALL:
return "s";
}
}
@@ -360,7 +361,9 @@ void ActorSprite::initTargetCursor()
static const std::string targetCursorFile("target-cursor-%s-%s.xml");
// Load target cursors
- for (int size = TC_SMALL; size < NUM_TC; size++)
+ for (int size = TargetCursorSize::SMALL;
+ size < TargetCursorSize::NUM_TC;
+ size ++)
{
for (int type = TCT_NORMAL; type < NUM_TCT; type++)
{
@@ -375,7 +378,9 @@ void ActorSprite::initTargetCursor()
void ActorSprite::cleanupTargetCursors()
{
- for (int size = TC_SMALL; size < NUM_TC; size++)
+ for (int size = TargetCursorSize::SMALL;
+ size < TargetCursorSize::NUM_TC;
+ size ++)
{
for (int type = TCT_NORMAL; type < NUM_TCT; type++)
{
diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h
index 5b9c438d8..b646500da 100644
--- a/src/being/actorsprite.h
+++ b/src/being/actorsprite.h
@@ -30,6 +30,7 @@
#include "being/actor.h"
#include "being/actortype.h"
#include "being/compoundsprite.h"
+#include "being/targetcursorsize.h"
#include "particle/particlecontainer.h"
@@ -45,14 +46,6 @@ class ActorSpriteListener;
class ActorSprite : public CompoundSprite, public Actor
{
public:
- enum TargetCursorSize
- {
- TC_SMALL = 0,
- TC_MEDIUM,
- TC_LARGE,
- NUM_TC
- };
-
enum TargetCursorType
{
TCT_NONE = -1,
@@ -103,8 +96,8 @@ public:
/**
* Returns the required size of a target cursor for this being.
*/
- virtual TargetCursorSize getTargetCursorSize() const A_WARN_UNUSED
- { return TC_MEDIUM; }
+ virtual TargetCursorSize::Size getTargetCursorSize() const A_WARN_UNUSED
+ { return TargetCursorSize::MEDIUM; }
virtual int getTargetOffsetX() const A_WARN_UNUSED
{ return 0; }
@@ -225,7 +218,7 @@ private:
static void cleanupTargetCursors();
/** Animated target cursors. */
- static AnimatedSprite *targetCursor[NUM_TCT][NUM_TC];
+ static AnimatedSprite *targetCursor[NUM_TCT][TargetCursorSize::NUM_TC];
static bool loaded;
diff --git a/src/being/being.cpp b/src/being/being.cpp
index a494df61e..a2be3a071 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -345,10 +345,10 @@ void Being::setSubtype(const uint16_t subtype, const uint8_t look)
}
}
-ActorSprite::TargetCursorSize Being::getTargetCursorSize() const
+TargetCursorSize::Size Being::getTargetCursorSize() const
{
if (!mInfo)
- return ActorSprite::TC_SMALL;
+ return TargetCursorSize::SMALL;
return mInfo->getTargetCursorSize();
}
diff --git a/src/being/being.h b/src/being/being.h
index dfa920e68..e01c7b08e 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -390,8 +390,8 @@ class Being : public ActorSprite, public ConfigListener
const BeingInfo *getInfo() const A_WARN_UNUSED
{ return mInfo; }
- TargetCursorSize getTargetCursorSize() const override final
- A_WARN_UNUSED;
+ TargetCursorSize::Size getTargetCursorSize() const override final
+ A_WARN_UNUSED;
int getTargetOffsetX() const A_WARN_UNUSED
{
diff --git a/src/being/targetcursorsize.h b/src/being/targetcursorsize.h
new file mode 100644
index 000000000..655fd6acd
--- /dev/null
+++ b/src/being/targetcursorsize.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_TARGETCURSORSIZE_H
+#define BEING_TARGETCURSORSIZE_H
+
+namespace TargetCursorSize
+{
+ enum Size
+ {
+ SMALL = 0,
+ MEDIUM,
+ LARGE,
+ NUM_TC
+ };
+} // TargetCursorSize
+
+#endif // BEING_TARGETCURSORSIZE_H
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index f13055b49..5cf6b2397 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -42,7 +42,7 @@ BeingInfo::BeingInfo() :
mDisplay(),
// TRANSLATORS: being info default name
mName(_("unnamed")),
- mTargetCursorSize(ActorSprite::TC_MEDIUM),
+ mTargetCursorSize(TargetCursorSize::MEDIUM),
mHoverCursor(Cursor::CURSOR_POINTER),
mSounds(),
mAttacks(),
@@ -106,21 +106,21 @@ void BeingInfo::setTargetCursorSize(const std::string &size)
{
if (size == "small")
{
- setTargetCursorSize(ActorSprite::TC_SMALL);
+ setTargetCursorSize(TargetCursorSize::SMALL);
}
else if (size == "medium")
{
- setTargetCursorSize(ActorSprite::TC_MEDIUM);
+ setTargetCursorSize(TargetCursorSize::MEDIUM);
}
else if (size == "large")
{
- setTargetCursorSize(ActorSprite::TC_LARGE);
+ setTargetCursorSize(TargetCursorSize::LARGE);
}
else
{
logger->log("Unknown target cursor type \"%s\" for %s - using medium "
"sized one", size.c_str(), getName().c_str());
- setTargetCursorSize(ActorSprite::TC_MEDIUM);
+ setTargetCursorSize(TargetCursorSize::MEDIUM);
}
}
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 554b1efaf..f76a08cc6 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -95,7 +95,7 @@ class BeingInfo final
void setTargetCursorSize(const std::string &size);
- void setTargetCursorSize(const ActorSprite::TargetCursorSize
+ void setTargetCursorSize(const TargetCursorSize::Size
&targetSize)
{ mTargetCursorSize = targetSize; }
@@ -108,7 +108,7 @@ class BeingInfo final
Cursor::Cursor getHoverCursor() const A_WARN_UNUSED
{ return mHoverCursor; }
- ActorSprite::TargetCursorSize getTargetCursorSize() const A_WARN_UNUSED
+ TargetCursorSize::Size getTargetCursorSize() const A_WARN_UNUSED
{ return mTargetCursorSize; }
void addSound(const ItemSoundEvent event, const std::string &filename,
@@ -341,7 +341,7 @@ class BeingInfo final
private:
SpriteDisplay mDisplay;
std::string mName;
- ActorSprite::TargetCursorSize mTargetCursorSize;
+ TargetCursorSize::Size mTargetCursorSize;
Cursor::Cursor mHoverCursor;
ItemSoundEvents mSounds;
Attacks mAttacks;