ManaPlus
animation.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef RESOURCES_ANIMATION_ANIMATION_H
25 #define RESOURCES_ANIMATION_ANIMATION_H
26 
28 
29 #include "utils/vector.h"
30 
31 #include "resources/frame.h"
32 
33 #include "localconsts.h"
34 
35 class Image;
36 
42 {
43  friend class AnimatedSprite;
44  friend class ParticleEmitter;
45  friend class SimpleAnimation;
46 
47  public:
49 
50  explicit Animation(const std::string &name) noexcept2;
51 
53 
57  void addFrame(Image *const image, const int delay,
58  const int offsetX, const int offsetY,
59  const int rand) noexcept2;
60 
65  void addTerminator(const int rand) noexcept2;
66 
71  { return mFrames.size(); }
72 
73  void addJump(const std::string &name, const int rand) noexcept2;
74 
75  void addLabel(const std::string &name) noexcept2;
76 
77  void addGoto(const std::string &name, const int rand) noexcept2;
78 
79  void addPause(const int delay, const int rand) noexcept2;
80 
81  void setLastFrameDelay(const int delay) noexcept2;
82 
83  typedef STD_VECTOR<Frame> Frames;
84  typedef Frames::iterator FramesIter;
85  typedef Frames::const_iterator FramesCIter;
86  typedef Frames::reverse_iterator FramesRevIter;
87 
88 #ifdef UNITTESTS
89  Frames &getFrames() noexcept2
90  { return mFrames; }
91 #endif // UNITTESTS
92 
93  int calcMemoryLocal() const override final;
94 
95  std::string getCounterName() const override
96  { return mName; }
97 
98  protected:
100  std::string mName;
102 };
103 
104 #endif // RESOURCES_ANIMATION_ANIMATION_H
Frames::reverse_iterator FramesRevIter
Definition: animation.h:86
std::string mName
Definition: animation.h:100
void addLabel(const std::string &name)
Definition: animation.cpp:67
std::vector< Frame > Frames
Definition: animation.h:83
void addGoto(const std::string &name, const int rand)
Definition: animation.cpp:73
void addJump(const std::string &name, const int rand)
Definition: animation.cpp:61
Frames mFrames
Definition: animation.h:99
int mDuration
Definition: animation.h:101
Frames::iterator FramesIter
Definition: animation.h:84
void addTerminator(const int rand)
Definition: animation.cpp:56
void addFrame(Image *const image, const int delay, const int offsetX, const int offsetY, const int rand)
Definition: animation.cpp:46
int calcMemoryLocal() const
Definition: animation.cpp:98
std::string getCounterName() const
Definition: animation.h:95
Frames::const_iterator FramesCIter
Definition: animation.h:85
size_t getLength() const
Definition: animation.h:70
void setLastFrameDelay(const int delay)
Definition: animation.cpp:85
void addPause(const int delay, const int rand)
Definition: animation.cpp:79
#define override
Definition: localconsts.h:47
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DEFAULT_COPY(func)
Definition: localconsts.h:41