GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/being/compoundsprite.h Lines: 0 3 0.0 %
Date: 2017-11-29 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2010  The Mana Developers
4
 *  Copyright (C) 2011-2017  The ManaPlus Developers
5
 *
6
 *  This file is part of The ManaPlus Client.
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  any later version.
12
 *
13
 *  This program is distributed in the hope that it will be useful,
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *  GNU General Public License for more details.
17
 *
18
 *  You should have received a copy of the GNU General Public License
19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
#ifndef BEING_COMPOUNDSPRITE_H
23
#define BEING_COMPOUNDSPRITE_H
24
25
#include "resources/sprite/sprite.h"
26
27
#include "utils/vector.h"
28
29
#include <list>
30
31
#include "localconsts.h"
32
33
class CompoundItem;
34
class Image;
35
36
class CompoundSprite notfinal : public Sprite
37
{
38
    public:
39
        typedef STD_VECTOR<Sprite*>::iterator SpriteIterator;
40
        typedef STD_VECTOR<Sprite*>::const_iterator SpriteConstIterator;
41
42
        CompoundSprite();
43
44
        A_DELETE_COPY(CompoundSprite)
45
46
        virtual ~CompoundSprite();
47
48
        bool reset() override final;
49
50
        bool play(const std::string &action) override final;
51
52
        bool update(const int time) override final;
53
54
        void drawSimple(Graphics *const graphics,
55
                        const int posX,
56
                        const int posY) const A_NONNULL(2);
57
58
        /**
59
         * Gets the width in pixels of the first sprite in the list.
60
         */
61
        int getWidth() const override A_WARN_UNUSED;
62
63
        /**
64
         * Gets the height in pixels of the first sprite in the list.
65
         */
66
        int getHeight() const override A_WARN_UNUSED;
67
68
        const Image *getImage() const override final A_WARN_UNUSED;
69
70
        bool setSpriteDirection(const SpriteDirection::Type direction)
71
                                override final;
72
73
        int getNumberOfLayers() const A_WARN_UNUSED;
74
75
        unsigned int getCurrentFrame() const override final A_WARN_UNUSED;
76
77
        unsigned int getFrameCount() const override final A_WARN_UNUSED;
78
79
        void addSprite(Sprite *const sprite);
80
81
        void setSprite(const size_t layer, Sprite *const sprite);
82
83
        void removeSprite(const int layer);
84
85
        void clear();
86
87
        void ensureSize(const size_t layerCount);
88
89
        void drawSprites(Graphics *const graphics,
90
                         const int posX,
91
                         const int posY) const;
92
93
        virtual void drawSpritesSDL(Graphics *const graphics,
94
                                    const int posX,
95
                                    const int posY) const;
96
97
        void setAlpha(float alpha) override;
98
99
        bool updateNumber(const unsigned num) override final;
100
101
        constexpr2 static void setEnableDelay(bool b) noexcept2
102
        { mEnableDelay = b; }
103
104
        int getLastTime() const noexcept2 A_WARN_UNUSED
105
        { return mLastTime; }
106
107
        int getStartTime() const noexcept2 A_WARN_UNUSED
108
        { return mStartTime; }
109
110
        STD_VECTOR<Sprite*> mSprites;
111
112
    protected:
113
        void redraw() const;
114
115
        void updateImages() const;
116
117
        bool updateFromCache() const;
118
119
        void initCurrentCacheItem() const;
120
121
        typedef std::list<CompoundItem*> ImagesCache;
122
        mutable ImagesCache imagesCache;
123
        mutable CompoundItem *mCacheItem;
124
125
        mutable Image *mImage;
126
        mutable Image *mAlphaImage;
127
128
        mutable int mOffsetX;
129
        mutable int mOffsetY;
130
        int mStartTime;
131
        int mLastTime;
132
#ifndef USE_SDL2
133
        mutable int mNextRedrawTime;
134
#endif  // USE_SDL2
135
136
        static bool mEnableDelay;
137
        mutable bool mNeedsRedraw;
138
        bool mEnableAlphaFix;
139
        bool mDisableAdvBeingCaching;
140
        bool mDisableBeingCaching;
141
};
142
143
#endif  // BEING_COMPOUNDSPRITE_H