ScummVM API documentation
animation.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * This code is based on Broken Sword 2.5 engine
24 *
25 * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
26 *
27 * Licensed under GNU GPL v2
28 *
29 */
30
31#ifndef SWORD25_ANIMATION_H
32#define SWORD25_ANIMATION_H
33
34// Includes
35#include "sword25/kernel/common.h"
36#include "sword25/gfx/timedrenderobject.h"
37
38namespace Sword25 {
39
40// Forward declarations
41class Kernel;
42class AnimationResource;
43class AnimationTemplate;
44class AnimationDescription;
45class InputPersistenceBlock;
46
48 friend class RenderObject;
49
50private:
51 Animation(RenderObjectPtr<RenderObject> parentPtr, const Common::String &fileName);
53 Animation(InputPersistenceBlock &reader, RenderObjectPtr<RenderObject> parentPtr, uint handle);
54
55public:
56 enum ANIMATION_TYPES {
57 AT_ONESHOT,
58 AT_LOOP,
59 AT_JOJO
60 };
61
62 ~Animation() override;
63
64 void play();
65 void pause();
66 void stop();
67 void setFrame(uint nr);
68
69 void setPos(int x, int y) override;
70 void setX(int x) override;
71 void setY(int y) override;
72
73 int getX() const override;
74 int getY() const override;
75 int getAbsoluteX() const override;
76 int getAbsoluteY() const override;
77
83 void setAlpha(int alpha);
84
90 void setModulationColor(uint modulationColor);
91
97 void setScaleFactor(float scaleFactor);
98
104 void setScaleFactorX(float scaleFactorX);
105
111 void setScaleFactorY(float scaleFactorY);
112
117 float getScaleFactorX() const {
118 return _scaleFactorX;
119 }
120
125 float getScaleFactorY() const {
126 return _scaleFactorY;
127 }
128
129 bool persist(OutputPersistenceBlock &writer) override;
130 bool unpersist(InputPersistenceBlock &reader) override;
131
132 void frameNotification(int timeElapsed) override;
133
134 ANIMATION_TYPES getAnimationType() const;
135 int getFPS() const;
136 int getFrameCount() const;
137 bool isScalingAllowed() const;
138 bool isAlphaAllowed() const;
139 bool isColorModulationAllowed() const;
140 uint getCurrentFrame() const {
141 return _currentFrame;
142 }
143 const Common::String &getCurrentAction() const;
144 bool isRunning() const {
145 return _running;
146 }
147
148 typedef bool (*ANIMATION_CALLBACK)(uint);
149
150 void setCallbacks();
151
152protected:
153 bool doRender(RectangleList *updateRects) override;
154
155private:
156 enum Direction {
157 FORWARD,
158 BACKWARD
159 };
160
161 int32 _relX;
162 int32 _relY;
163 float _scaleFactorX;
164 float _scaleFactorY;
165 uint32 _modulationColor;
166 uint32 _currentFrame;
167 int32 _currentFrameTime;
168 bool _running;
169 bool _finished;
170 Direction _direction;
171 AnimationResource *_animationResourcePtr;
172 uint32 _animationTemplateHandle;
173 bool _framesLocked;
174
175 ANIMATION_CALLBACK _loopPointCallback;
176 ANIMATION_CALLBACK _actionCallback;
177 ANIMATION_CALLBACK _deleteCallback;
178
183 bool lockAllFrames();
184
189 bool unlockAllFrames();
190
196 void computeCurrentCharacteristics();
197
201 int computeXModifier() const;
202
206 int computeYModifier() const;
207
208 void initMembers();
209 AnimationDescription *getAnimationDescription() const;
210
214 void initializeAnimationResource(const Common::String &fileName);
215};
216
217} // End of namespace Sword25
218
219#endif
Definition: str.h:59
Definition: animationdescription.h:40
Definition: animation.h:47
void setY(int y) override
Setzt die Position des Objektes auf der Y-Achse.
void setAlpha(int alpha)
Setzt den Alphawert der Animation.
int getAbsoluteX() const override
Gibt die absolute Position des Objektes auf der X-Achse zurück.
int getAbsoluteY() const override
Gibt die absolute Position des Objektes auf der Y-Achse zurück.
void setScaleFactorX(float scaleFactorX)
Setzt den Skalierungsfaktor der Animation auf der X-Achse.
int getX() const override
Gibt die Position des Objektes auf der X-Achse relativ zum Elternobjekt zurück.
void setScaleFactor(float scaleFactor)
Setzt den Skalierungsfaktor der Animation.
bool doRender(RectangleList *updateRects) override
Einschubmethode, die den tatsächlichen Redervorgang durchführt.
float getScaleFactorX() const
Gibt den Skalierungsfakter der Animation auf der X-Achse zurück.
Definition: animation.h:117
void setScaleFactorY(float scaleFactorY)
Setzt den Skalierungsfaktor der Animation auf der Y-Achse.
void setModulationColor(uint modulationColor)
Setzt die Modulationfarbe der Animation.
void setX(int x) override
Setzt die Position des Objektes auf der X-Achse.
void setPos(int x, int y) override
Setzt die Position des Objektes.
int getY() const override
Gibt die Position des Objektes auf der Y-Achse relativ zum Elternobjekt zurück.
float getScaleFactorY() const
Gibt den Skalierungsfakter der Animation auf der Y-Achse zurück.
Definition: animation.h:125
void frameNotification(int timeElapsed) override
Teilt dem Objekt mit, dass ein neuer Frame begonnen wird.
Definition: animationresource.h:45
Definition: animationtemplate.h:46
Definition: inputpersistenceblock.h:40
Definition: outputpersistenceblock.h:39
Definition: microtiles.h:38
Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt.
Definition: renderobject.h:72
Definition: renderobjectptr.h:46
Definition: timedrenderobject.h:43
Definition: console.h:27