diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-10-04 03:33:13 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-10-04 03:33:13 +0300 |
commit | 29549cf31a03e2ac7290afaa7442b3b9519d4e7c (patch) | |
tree | cb01d06c5d2349ca5c6e843f07e251f3a85ae50b /src/resources | |
parent | 2ec30fd9bac60bb7e4752e3bba0036c078019d0a (diff) | |
download | mv-29549cf31a03e2ac7290afaa7442b3b9519d4e7c.tar.gz mv-29549cf31a03e2ac7290afaa7442b3b9519d4e7c.tar.bz2 mv-29549cf31a03e2ac7290afaa7442b3b9519d4e7c.tar.xz mv-29549cf31a03e2ac7290afaa7442b3b9519d4e7c.zip |
Move FrameType enum into enums directory.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/animation/animation.cpp | 14 | ||||
-rw-r--r-- | src/resources/frame.h | 13 | ||||
-rw-r--r-- | src/resources/sprite/animatedsprite.cpp | 16 |
3 files changed, 18 insertions, 25 deletions
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 || |