GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/animation/animation.h Lines: 2 4 50.0 %
Date: 2021-03-17 Branches: 0 0 0.0 %

Line Branch Exec Source
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
27
#include "resources/memorycounter.h"
28
29
#include "utils/vector.h"
30
31
#include "resources/frame.h"
32
33
#include "localconsts.h"
34
35
class Image;
36
37
/**
38
 * An animation consists of several frames, each with their own delay and
39
 * offset.
40
 */
41
3894
class Animation final : public MemoryCounter
42
{
43
    friend class AnimatedSprite;
44
    friend class ParticleEmitter;
45
    friend class SimpleAnimation;
46
47
    public:
48
        Animation() noexcept2;
49
50
        explicit Animation(const std::string &name) noexcept2;
51
52
        A_DEFAULT_COPY(Animation)
53
54
        /**
55
         * Appends a new animation at the end of the sequence.
56
         */
57
        void addFrame(Image *const image, const int delay,
58
                      const int offsetX, const int offsetY,
59
                      const int rand) noexcept2;
60
61
        /**
62
         * Appends an animation terminator that states that the animation
63
         * should not loop.
64
         */
65
        void addTerminator(const int rand) noexcept2;
66
67
        /**
68
         * Returns the length of this animation in frames.
69
         */
70
        size_t getLength() const noexcept2 A_WARN_UNUSED
71
1311
        { 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:
99
        Frames mFrames;
100
        std::string mName;
101
        int mDuration;
102
};
103
104
#endif  // RESOURCES_ANIMATION_ANIMATION_H