summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/enums/resources/frametype.h40
-rw-r--r--src/resources/animation/animation.cpp14
-rw-r--r--src/resources/frame.h13
-rw-r--r--src/resources/sprite/animatedsprite.cpp16
6 files changed, 60 insertions, 25 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9b581c249..83a27177f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -671,6 +671,7 @@ SET(SRCS
resources/iteminfo.h
resources/iteminfo.cpp
enums/resources/cursor.h
+ enums/resources/frametype.h
enums/resources/imageposition.h
enums/resources/imagetype.h
enums/resources/item/itemdbtype.h
diff --git a/src/Makefile.am b/src/Makefile.am
index da16feadb..ab7a58b77 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1289,6 +1289,7 @@ manaplus_SOURCES += main.cpp \
resources/iteminfo.h \
resources/iteminfo.cpp \
enums/resources/cursor.h \
+ enums/resources/frametype.h \
enums/resources/imageposition.h \
enums/resources/imagetype.h \
enums/resources/item/itemdbtype.h \
diff --git a/src/enums/resources/frametype.h b/src/enums/resources/frametype.h
new file mode 100644
index 000000000..a784c9f2d
--- /dev/null
+++ b/src/enums/resources/frametype.h
@@ -0,0 +1,40 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2016 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_FRAMETYPE_H
+#define ENUMS_RESOURCES_FRAMETYPE_H
+
+#include "enums/simpletypes/enumdefines.h"
+
+#include "localconsts.h"
+
+enumStart(FrameType)
+{
+ ANIMATION = 0,
+ JUMP,
+ GOTO,
+ LABEL,
+ PAUSE
+}
+enumEnd(FrameType);
+
+#endif // ENUMS_RESOURCES_FRAMETYPE_H
diff --git a/src/resources/animation/animation.cpp b/src/resources/animation/animation.cpp
index 22ca96fd7..1a10f5224 100644
--- a/src/resources/animation/animation.cpp
+++ b/src/resources/animation/animation.cpp
@@ -45,7 +45,7 @@ void Animation::addFrame(Image *const image, const int delay,
const int rand) noexcept2
{
Frame frame
- = { image, delay, offsetX, offsetY, rand, Frame::ANIMATION, "" };
+ = { image, delay, offsetX, offsetY, rand, FrameType::ANIMATION, "" };
mFrames.push_back(frame);
mDuration += delay;
}
@@ -57,30 +57,30 @@ void Animation::addTerminator(const int rand) noexcept2
bool Animation::isTerminator(const Frame &candidate) noexcept2
{
- return (!candidate.image && candidate.type == Frame::ANIMATION);
+ return (!candidate.image && candidate.type == FrameType::ANIMATION);
}
void Animation::addJump(const std::string &name, const int rand) noexcept2
{
- Frame frame = { nullptr, 0, 0, 0, rand, Frame::JUMP, name };
+ Frame frame = { nullptr, 0, 0, 0, rand, FrameType::JUMP, name };
mFrames.push_back(frame);
}
void Animation::addLabel(const std::string &name) noexcept2
{
- Frame frame = { nullptr, 0, 0, 0, 100, Frame::LABEL, name };
+ Frame frame = { nullptr, 0, 0, 0, 100, FrameType::LABEL, name };
mFrames.push_back(frame);
}
void Animation::addGoto(const std::string &name, const int rand) noexcept2
{
- Frame frame = { nullptr, 0, 0, 0, rand, Frame::GOTO, name };
+ Frame frame = { nullptr, 0, 0, 0, rand, FrameType::GOTO, name };
mFrames.push_back(frame);
}
void Animation::addPause(const int delay, const int rand) noexcept2
{
- Frame frame = { nullptr, delay, 0, 0, rand, Frame::PAUSE, "" };
+ Frame frame = { nullptr, delay, 0, 0, rand, FrameType::PAUSE, "" };
mFrames.push_back(frame);
}
@@ -89,7 +89,7 @@ void Animation::setLastFrameDelay(const int delay) noexcept2
for (FramesRevIter it = mFrames.rbegin(), it_end = mFrames.rend();
it != it_end; ++ it)
{
- if ((*it).type == Frame::ANIMATION && (*it).image)
+ if ((*it).type == FrameType::ANIMATION && (*it).image)
{
(*it).delay = delay;
break;
diff --git a/src/resources/frame.h b/src/resources/frame.h
index 9359dba05..327a602a7 100644
--- a/src/resources/frame.h
+++ b/src/resources/frame.h
@@ -23,6 +23,8 @@
#ifndef RESOURCES_FRAME_H
#define RESOURCES_FRAME_H
+#include "enums/resources/frametype.h"
+
#include <string>
#include "localconsts.h"
@@ -34,21 +36,12 @@ class Image;
*/
struct Frame final
{
- enum FrameType
- {
- ANIMATION = 0,
- JUMP,
- GOTO,
- LABEL,
- PAUSE
- };
-
Image *image;
int delay;
int offsetX;
int offsetY;
int rand;
- FrameType type;
+ FrameTypeT type;
std::string nextAction;
};
diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp
index 60a2d7f9d..546c3a415 100644
--- a/src/resources/sprite/animatedsprite.cpp
+++ b/src/resources/sprite/animatedsprite.cpp
@@ -215,7 +215,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
{
// move code from Animation::isTerminator(*mFrame)
if (!mFrame || !mAnimation || (!mFrame->image
- && mFrame->type == Frame::ANIMATION))
+ && mFrame->type == FrameType::ANIMATION))
{
return false;
}
@@ -224,8 +224,8 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
while ((mFrameTime > CAST_U32(mFrame->delay) &&
mFrame->delay > 0) ||
- (mFrame->type != Frame::ANIMATION &&
- mFrame->type != Frame::PAUSE))
+ (mFrame->type != FrameType::ANIMATION &&
+ mFrame->type != FrameType::PAUSE))
{
bool fail(true);
mFrameTime -= CAST_U32(mFrame->delay);
@@ -239,12 +239,12 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
{
fail = true;
}
- else if ((mFrame->type == Frame::LABEL
+ else if ((mFrame->type == FrameType::LABEL
&& !mFrame->nextAction.empty()))
{
fail = false;
}
- else if (mFrame->type == Frame::GOTO &&
+ else if (mFrame->type == FrameType::GOTO &&
!mFrame->nextAction.empty())
{
const int rand = mFrame->rand;
@@ -255,7 +255,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
{
const Frame *restrict const frame =
&mAnimation->mFrames[i];
- if (frame->type == Frame::LABEL &&
+ if (frame->type == FrameType::LABEL &&
mFrame->nextAction == frame->nextAction)
{
mFrameIndex = CAST_U32(i);
@@ -277,7 +277,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
fail = false;
}
}
- else if (mFrame->type == Frame::JUMP &&
+ else if (mFrame->type == FrameType::JUMP &&
!mFrame->nextAction.empty())
{
const int rand = mFrame->rand;
@@ -290,7 +290,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
}
// copy code from Animation::isTerminator(*mFrame)
else if (!mFrame->image &&
- mFrame->type == Frame::ANIMATION)
+ mFrame->type == FrameType::ANIMATION)
{
const int rand = mFrame->rand;
if (rand == 100 ||