From bf41f3154225eb49d9d6f83563f157d1f9ce3f6b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 29 Dec 2015 01:23:47 +0300 Subject: Move animation into animation directory. --- src/CMakeLists.txt | 8 +-- src/Makefile.am | 4 +- src/gui/widgets/progressindicator.cpp | 3 +- src/particle/particleemitter.h | 2 +- src/resources/action.cpp | 2 +- src/resources/animation.cpp | 88 ------------------------------ src/resources/animation.h | 95 --------------------------------- src/resources/animation/animation.cpp | 88 ++++++++++++++++++++++++++++++ src/resources/animation/animation.h | 95 +++++++++++++++++++++++++++++++++ src/resources/mapreader.cpp | 3 +- src/resources/sprite/animatedsprite.cpp | 3 +- src/resources/sprite/spritedef.cpp | 3 +- src/simpleanimation.cpp | 3 +- 13 files changed, 201 insertions(+), 196 deletions(-) delete mode 100644 src/resources/animation.cpp delete mode 100644 src/resources/animation.h create mode 100644 src/resources/animation/animation.cpp create mode 100644 src/resources/animation/animation.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 33a7e139b..7e94161b9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -591,8 +591,8 @@ SET(SRCS resources/action.h resources/ambientlayer.cpp resources/ambientlayer.h - resources/animation.cpp - resources/animation.h + resources/animation/animation.cpp + resources/animation/animation.h resources/atlas/atlasitem.h resources/atlas/atlasmanager.cpp resources/atlas/atlasmanager.h @@ -1330,8 +1330,8 @@ SET(DYE_CMD_SRCS render/mgltypes.h resources/action.cpp resources/action.h - resources/animation.cpp - resources/animation.h + resources/animation/animation.cpp + resources/animation/animation.h resources/db/palettedb.cpp resources/db/palettedb.h resources/delayedmanager.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 72579252d..1b365ed6f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -640,8 +640,8 @@ SRC += events/actionevent.h \ render/shaders/shaderprogram.h \ render/shaders/shadersmanager.cpp \ render/shaders/shadersmanager.h \ - resources/animation.cpp \ - resources/animation.h \ + resources/animation/animation.cpp \ + resources/animation/animation.h \ simpleanimation.cpp \ simpleanimation.h \ resources/sprite/sprite.h \ diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index cdbbc7335..efe65507f 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -25,9 +25,10 @@ #include "gui/gui.h" -#include "resources/animation.h" #include "resources/imageset.h" +#include "resources/animation/animation.h" + #include "utils/delete2.h" #include "debug.h" diff --git a/src/particle/particleemitter.h b/src/particle/particleemitter.h index 41381b6e1..00fd34db6 100644 --- a/src/particle/particleemitter.h +++ b/src/particle/particleemitter.h @@ -25,7 +25,7 @@ #include "particle/particleemitterprop.h" -#include "resources/animation.h" +#include "resources/animation/animation.h" #include "utils/xml.h" diff --git a/src/resources/action.cpp b/src/resources/action.cpp index 64057300b..f79611a57 100644 --- a/src/resources/action.cpp +++ b/src/resources/action.cpp @@ -22,7 +22,7 @@ #include "resources/action.h" -#include "resources/animation.h" +#include "resources/animation/animation.h" #include "utils/dtor.h" diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp deleted file mode 100644 index a47220b2b..000000000 --- a/src/resources/animation.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2015 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 . - */ - -#include "resources/animation.h" - -#include "debug.h" - -Animation::Animation() noexcept : - mFrames(), - mDuration(0) -{ -} - -void Animation::addFrame(Image *const image, const int delay, - const int offsetX, const int offsetY, - const int rand) noexcept -{ - Frame frame - = { image, delay, offsetX, offsetY, rand, Frame::ANIMATION, "" }; - mFrames.push_back(frame); - mDuration += delay; -} - -void Animation::addTerminator(const int rand) noexcept -{ - addFrame(nullptr, 0, 0, 0, rand); -} - -bool Animation::isTerminator(const Frame &candidate) noexcept -{ - return (!candidate.image && candidate.type == Frame::ANIMATION); -} - -void Animation::addJump(const std::string &name, const int rand) noexcept -{ - Frame frame = { nullptr, 0, 0, 0, rand, Frame::JUMP, name }; - mFrames.push_back(frame); -} - -void Animation::addLabel(const std::string &name) noexcept -{ - Frame frame = { nullptr, 0, 0, 0, 100, Frame::LABEL, name }; - mFrames.push_back(frame); -} - -void Animation::addGoto(const std::string &name, const int rand) noexcept -{ - Frame frame = { nullptr, 0, 0, 0, rand, Frame::GOTO, name }; - mFrames.push_back(frame); -} - -void Animation::addPause(const int delay, const int rand) noexcept -{ - Frame frame = { nullptr, delay, 0, 0, rand, Frame::PAUSE, "" }; - mFrames.push_back(frame); -} - -void Animation::setLastFrameDelay(const int delay) noexcept -{ - for (FramesRevIter it = mFrames.rbegin(), it_end = mFrames.rend(); - it != it_end; ++ it) - { - if ((*it).type == Frame::ANIMATION && (*it).image) - { - (*it).delay = delay; - break; - } - } -} diff --git a/src/resources/animation.h b/src/resources/animation.h deleted file mode 100644 index 763818e4b..000000000 --- a/src/resources/animation.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2015 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 . - */ - -#ifndef RESOURCES_ANIMATION_H -#define RESOURCES_ANIMATION_H - -#include "resources/frame.h" - -#include - -#include "localconsts.h" - -class Image; - -/** - * An animation consists of several frames, each with their own delay and - * offset. - */ -class Animation final -{ - friend class AnimatedSprite; - friend class ParticleEmitter; - friend class SimpleAnimation; - - public: - Animation() noexcept; - - /** - * Appends a new animation at the end of the sequence. - */ - void addFrame(Image *const image, const int delay, - const int offsetX, const int offsetY, - const int rand) noexcept; - - /** - * Appends an animation terminator that states that the animation - * should not loop. - */ - void addTerminator(const int rand) noexcept; - - /** - * Returns the length of this animation in frames. - */ - size_t getLength() const noexcept A_WARN_UNUSED - { return mFrames.size(); } - - void addJump(const std::string &name, const int rand) noexcept; - - void addLabel(const std::string &name) noexcept; - - void addGoto(const std::string &name, const int rand) noexcept; - - void addPause(const int delay, const int rand) noexcept; - - void setLastFrameDelay(const int delay) noexcept; - - typedef std::vector Frames; - typedef Frames::iterator FramesIter; - typedef Frames::reverse_iterator FramesRevIter; - -#ifdef UNITTESTS - Frames &getFrames() noexcept - { return mFrames; } -#endif - - /** - * Determines whether the given animation frame is a terminator. - */ - static bool isTerminator(const Frame &phase) noexcept A_WARN_UNUSED; - - protected: - Frames mFrames; - int mDuration; -}; - -#endif // RESOURCES_ANIMATION_H diff --git a/src/resources/animation/animation.cpp b/src/resources/animation/animation.cpp new file mode 100644 index 000000000..31e4eaf5c --- /dev/null +++ b/src/resources/animation/animation.cpp @@ -0,0 +1,88 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2015 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 . + */ + +#include "resources/animation/animation.h" + +#include "debug.h" + +Animation::Animation() noexcept : + mFrames(), + mDuration(0) +{ +} + +void Animation::addFrame(Image *const image, const int delay, + const int offsetX, const int offsetY, + const int rand) noexcept +{ + Frame frame + = { image, delay, offsetX, offsetY, rand, Frame::ANIMATION, "" }; + mFrames.push_back(frame); + mDuration += delay; +} + +void Animation::addTerminator(const int rand) noexcept +{ + addFrame(nullptr, 0, 0, 0, rand); +} + +bool Animation::isTerminator(const Frame &candidate) noexcept +{ + return (!candidate.image && candidate.type == Frame::ANIMATION); +} + +void Animation::addJump(const std::string &name, const int rand) noexcept +{ + Frame frame = { nullptr, 0, 0, 0, rand, Frame::JUMP, name }; + mFrames.push_back(frame); +} + +void Animation::addLabel(const std::string &name) noexcept +{ + Frame frame = { nullptr, 0, 0, 0, 100, Frame::LABEL, name }; + mFrames.push_back(frame); +} + +void Animation::addGoto(const std::string &name, const int rand) noexcept +{ + Frame frame = { nullptr, 0, 0, 0, rand, Frame::GOTO, name }; + mFrames.push_back(frame); +} + +void Animation::addPause(const int delay, const int rand) noexcept +{ + Frame frame = { nullptr, delay, 0, 0, rand, Frame::PAUSE, "" }; + mFrames.push_back(frame); +} + +void Animation::setLastFrameDelay(const int delay) noexcept +{ + for (FramesRevIter it = mFrames.rbegin(), it_end = mFrames.rend(); + it != it_end; ++ it) + { + if ((*it).type == Frame::ANIMATION && (*it).image) + { + (*it).delay = delay; + break; + } + } +} diff --git a/src/resources/animation/animation.h b/src/resources/animation/animation.h new file mode 100644 index 000000000..cb0c3afb6 --- /dev/null +++ b/src/resources/animation/animation.h @@ -0,0 +1,95 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2015 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 . + */ + +#ifndef RESOURCES_ANIMATION_ANIMATION_H +#define RESOURCES_ANIMATION_ANIMATION_H + +#include "resources/frame.h" + +#include + +#include "localconsts.h" + +class Image; + +/** + * An animation consists of several frames, each with their own delay and + * offset. + */ +class Animation final +{ + friend class AnimatedSprite; + friend class ParticleEmitter; + friend class SimpleAnimation; + + public: + Animation() noexcept; + + /** + * Appends a new animation at the end of the sequence. + */ + void addFrame(Image *const image, const int delay, + const int offsetX, const int offsetY, + const int rand) noexcept; + + /** + * Appends an animation terminator that states that the animation + * should not loop. + */ + void addTerminator(const int rand) noexcept; + + /** + * Returns the length of this animation in frames. + */ + size_t getLength() const noexcept A_WARN_UNUSED + { return mFrames.size(); } + + void addJump(const std::string &name, const int rand) noexcept; + + void addLabel(const std::string &name) noexcept; + + void addGoto(const std::string &name, const int rand) noexcept; + + void addPause(const int delay, const int rand) noexcept; + + void setLastFrameDelay(const int delay) noexcept; + + typedef std::vector Frames; + typedef Frames::iterator FramesIter; + typedef Frames::reverse_iterator FramesRevIter; + +#ifdef UNITTESTS + Frames &getFrames() noexcept + { return mFrames; } +#endif + + /** + * Determines whether the given animation frame is a terminator. + */ + static bool isTerminator(const Frame &phase) noexcept A_WARN_UNUSED; + + protected: + Frames mFrames; + int mDuration; +}; + +#endif // RESOURCES_ANIMATION_ANIMATION_H diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index be4b4cb67..a2f493f0d 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -36,11 +36,12 @@ #include "resources/map/mapheights.h" #include "resources/map/tileset.h" -#include "resources/animation.h" #include "resources/beingcommon.h" #include "resources/image.h" #include "resources/resourcemanager.h" +#include "resources/animation/animation.h" + #ifdef USE_OPENGL #include "resources/db/mapdb.h" #endif diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp index 32a0cf983..f06a3cc6a 100644 --- a/src/resources/sprite/animatedsprite.cpp +++ b/src/resources/sprite/animatedsprite.cpp @@ -29,11 +29,12 @@ #include "render/graphics.h" #include "resources/action.h" -#include "resources/animation.h" #include "resources/delayedmanager.h" #include "resources/image.h" #include "resources/resourcemanager.h" +#include "resources/animation/animation.h" + #include "utils/delete2.h" #include "debug.h" diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp index 42c076f5a..d54516ad1 100644 --- a/src/resources/sprite/spritedef.cpp +++ b/src/resources/sprite/spritedef.cpp @@ -31,10 +31,11 @@ #include "const/resources/map/map.h" #include "resources/action.h" -#include "resources/animation.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" +#include "resources/animation/animation.h" + #include "resources/dye/dye.h" #include "resources/sprite/spritereference.h" diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 877b51e7c..e6c98dddd 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -26,10 +26,11 @@ #include "render/graphics.h" -#include "resources/animation.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" +#include "resources/animation/animation.h" + #include "resources/dye/dye.h" #include "utils/delete2.h" -- cgit v1.2.3-70-g09d2