GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/animation/animation.h Lines: 2 4 50.0 %
Date: 2017-11-29 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-2017  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#ifndef RESOURCES_ANIMATION_ANIMATION_H
24
#define RESOURCES_ANIMATION_ANIMATION_H
25
26
#include "resources/memorycounter.h"
27
28
#include "utils/vector.h"
29
30
#include "resources/frame.h"
31
32
#include "localconsts.h"
33
34
class Image;
35
36
/**
37
 * An animation consists of several frames, each with their own delay and
38
 * offset.
39
 */
40
6960
class Animation final : public MemoryCounter
41
{
42
    friend class AnimatedSprite;
43
    friend class ParticleEmitter;
44
    friend class SimpleAnimation;
45
46
    public:
47
        Animation() noexcept2;
48
49
        explicit Animation(const std::string &name) noexcept2;
50
51
        A_DEFAULT_COPY(Animation)
52
53
        /**
54
         * Appends a new animation at the end of the sequence.
55
         */
56
        void addFrame(Image *const image, const int delay,
57
                      const int offsetX, const int offsetY,
58
                      const int rand) noexcept2;
59
60
        /**
61
         * Appends an animation terminator that states that the animation
62
         * should not loop.
63
         */
64
        void addTerminator(const int rand) noexcept2;
65
66
        /**
67
         * Returns the length of this animation in frames.
68
         */
69
        size_t getLength() const noexcept2 A_WARN_UNUSED
70
2346
        { return mFrames.size(); }
71
72
        void addJump(const std::string &name, const int rand) noexcept2;
73
74
        void addLabel(const std::string &name) noexcept2;
75
76
        void addGoto(const std::string &name, const int rand) noexcept2;
77
78
        void addPause(const int delay, const int rand) noexcept2;
79
80
        void setLastFrameDelay(const int delay) noexcept2;
81
82
        typedef STD_VECTOR<Frame> Frames;
83
        typedef Frames::iterator FramesIter;
84
        typedef Frames::const_iterator FramesCIter;
85
        typedef Frames::reverse_iterator FramesRevIter;
86
87
#ifdef UNITTESTS
88
        Frames &getFrames() noexcept2
89
        { return mFrames; }
90
#endif  // UNITTESTS
91
92
        int calcMemoryLocal() const override final;
93
94
        std::string getCounterName() const override
95
        { return mName; }
96
97
    protected:
98
        Frames mFrames;
99
        std::string mName;
100
        int mDuration;
101
};
102
103
#endif  // RESOURCES_ANIMATION_ANIMATION_H