GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/sprite/sprite.h Lines: 2 10 20.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 RESOURCES_SPRITE_SPRITE_H
23
#define RESOURCES_SPRITE_SPRITE_H
24
25
#include "resources/sprite/spritedef.h"
26
27
#include "localconsts.h"
28
29
class Graphics;
30
class Image;
31
32
class Sprite notfinal
33
{
34
    public:
35
        A_DELETE_COPY(Sprite)
36
37
        virtual ~Sprite()
38
        { }
39
40
        /**
41
         * Resets the sprite.
42
         *
43
         * @returns true if the sprite changed, false otherwise
44
         */
45
        virtual bool reset() = 0;
46
47
        /**
48
         * Plays an action using the current direction.
49
         *
50
         * @returns true if the sprite changed, false otherwise
51
         */
52
        virtual bool play(const std::string &action) = 0;
53
54
        /**
55
         * Inform the animation of the passed time so that it can output the
56
         * correct animation frame.
57
         *
58
         * @returns true if the sprite changed, false otherwise
59
         */
60
        virtual bool update(const int time) = 0;
61
62
        /**
63
         * Draw the current animation frame at the coordinates given in screen
64
         * pixels.
65
         */
66
        virtual void draw(Graphics *const graphics,
67
                          const int posX, const int posY)
68
                          const A_NONNULL(2) = 0;
69
70
        /**
71
         * Gets the width in pixels of the image of the current frame
72
         */
73
        virtual int getWidth() const A_WARN_UNUSED = 0;
74
75
        /**
76
         * Gets the height in pixels of the image of the current frame
77
         */
78
        virtual int getHeight() const A_WARN_UNUSED = 0;
79
80
        /**
81
         * Returns a reference to the current image being drawn.
82
         */
83
        virtual const Image* getImage() const A_WARN_UNUSED = 0;
84
85
        /**
86
         * Sets the direction.
87
         *
88
         * @returns true if the sprite changed, false otherwise
89
         */
90
        virtual bool setSpriteDirection(const SpriteDirection::Type
91
                                        direction) = 0;
92
93
        /**
94
         * Sets the alpha value of the animated sprite
95
         */
96
        virtual void setAlpha(float alpha)
97
        { mAlpha = alpha; }
98
99
        /**
100
         * Returns the current alpha opacity of the animated sprite.
101
         */
102
        virtual float getAlpha() const A_WARN_UNUSED
103
        { return mAlpha; }
104
105
        /**
106
         * Returns the current frame number for the sprite.
107
         */
108
        virtual unsigned int getCurrentFrame() const A_WARN_UNUSED = 0;
109
110
        /**
111
         * Returns the frame count for the sprite.
112
         */
113
        virtual unsigned int getFrameCount() const A_WARN_UNUSED = 0;
114
115
        virtual const void *getHash() const A_WARN_UNUSED
116
        { return nullptr; }
117
118
        virtual const void *getHash2() const A_WARN_UNUSED
119
        { return this; }
120
121
        virtual bool updateNumber(const unsigned num) = 0;
122
123
    protected:
124
2514
        Sprite() :
125
204
            mAlpha()
126
        {
127
        }
128
129
        float mAlpha;                  /**< The alpha opacity used to draw */
130
};
131
132
#endif  // RESOURCES_SPRITE_SPRITE_H