GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/being/compoundsprite.h Lines: 0 3 0.0 %
Date: 2021-03-17 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-2019  The ManaPlus Developers
5
 *  Copyright (C) 2019-2021  Andrei Karas
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 BEING_COMPOUNDSPRITE_H
24
#define BEING_COMPOUNDSPRITE_H
25
26
#include "resources/sprite/sprite.h"
27
28
#include "utils/vector.h"
29
30
#include <list>
31
32
#include "localconsts.h"
33
34
class CompoundItem;
35
class Image;
36
37
class CompoundSprite notfinal : public Sprite
38
{
39
    public:
40
        typedef STD_VECTOR<Sprite*>::iterator SpriteIterator;
41
        typedef STD_VECTOR<Sprite*>::const_iterator SpriteConstIterator;
42
43
        CompoundSprite();
44
45
        A_DELETE_COPY(CompoundSprite)
46
47
        ~CompoundSprite() override;
48
49
        bool reset() override final;
50
51
        bool play(const std::string &action) override final;
52
53
        bool update(const int time) override final;
54
55
        void drawSimple(Graphics *const graphics,
56
                        const int posX,
57
                        const int posY) const A_NONNULL(2);
58
59
        /**
60
         * Gets the width in pixels of the first sprite in the list.
61
         */
62
        int getWidth() const override A_WARN_UNUSED;
63
64
        /**
65
         * Gets the height in pixels of the first sprite in the list.
66
         */
67
        int getHeight() const override A_WARN_UNUSED;
68
69
        const Image *getImage() const override final A_WARN_UNUSED;
70
71
        bool setSpriteDirection(const SpriteDirection::Type direction)
72
                                override final;
73
74
        int getNumberOfLayers() const A_WARN_UNUSED;
75
76
        unsigned int getCurrentFrame() const override final A_WARN_UNUSED;
77
78
        unsigned int getFrameCount() const override final A_WARN_UNUSED;
79
80
        void addSprite(Sprite *const sprite);
81
82
        void setSprite(const size_t layer, Sprite *const sprite);
83
84
        void removeSprite(const int layer);
85
86
        void clear();
87
88
        void ensureSize(const size_t layerCount);
89
90
        void drawSprites(Graphics *const graphics,
91
                         const int posX,
92
                         const int posY) const;
93
94
        virtual void drawSpritesSDL(Graphics *const graphics,
95
                                    const int posX,
96
                                    const int posY) const;
97
98
        void setAlpha(float alpha) override;
99
100
        bool updateNumber(const unsigned num) override final;
101
102
        constexpr2 static void setEnableDelay(bool b) noexcept2
103
        { mEnableDelay = b; }
104
105
        int getLastTime() const noexcept2 A_WARN_UNUSED
106
        { return mLastTime; }
107
108
        int getStartTime() const noexcept2 A_WARN_UNUSED
109
        { return mStartTime; }
110
111
        STD_VECTOR<Sprite*> mSprites;
112
113
    protected:
114
        void redraw() const;
115
116
        void updateImages() const;
117
118
        bool updateFromCache() const;
119
120
        void initCurrentCacheItem() const;
121
122
        typedef std::list<CompoundItem*> ImagesCache;
123
        mutable ImagesCache imagesCache;
124
        mutable CompoundItem *mCacheItem;
125
126
        mutable Image *mImage;
127
        mutable Image *mAlphaImage;
128
129
        mutable int mOffsetX;
130
        mutable int mOffsetY;
131
        int mStartTime;
132
        int mLastTime;
133
#ifndef USE_SDL2
134
        mutable int mNextRedrawTime;
135
#endif  // USE_SDL2
136
137
        static bool mEnableDelay;
138
        mutable bool mNeedsRedraw;
139
        bool mEnableAlphaFix;
140
        bool mDisableAdvBeingCaching;
141
        bool mDisableBeingCaching;
142
};
143
144
#endif  // BEING_COMPOUNDSPRITE_H