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 
38 namespace Sword25 {
39 
40 // Forward declarations
41 class Kernel;
42 class AnimationResource;
43 class AnimationTemplate;
44 class AnimationDescription;
45 class InputPersistenceBlock;
46 
47 class Animation : public TimedRenderObject {
48  friend class RenderObject;
49 
50 private:
51  Animation(RenderObjectPtr<RenderObject> parentPtr, const Common::String &fileName);
52  Animation(RenderObjectPtr<RenderObject> parentPtr, const AnimationTemplate &template_);
53  Animation(InputPersistenceBlock &reader, RenderObjectPtr<RenderObject> parentPtr, uint handle);
54 
55 public:
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 
152 protected:
153  bool doRender(RectangleList *updateRects) override;
154 
155 private:
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
float getScaleFactorX() const
Gibt den Skalierungsfakter der Animation auf der X-Achse zurück.
Definition: animation.h:117
Definition: str.h:59
void setX(int x) override
Setzt die Position des Objektes auf der X-Achse.
Definition: animation.h:47
float getScaleFactorY() const
Gibt den Skalierungsfakter der Animation auf der Y-Achse zurück.
Definition: animation.h:125
void setAlpha(int alpha)
Setzt den Alphawert der Animation.
void setPos(int x, int y) override
Setzt die Position des Objektes.
Definition: renderobjectptr.h:46
void frameNotification(int timeElapsed) override
Teilt dem Objekt mit, dass ein neuer Frame begonnen wird.
Definition: microtiles.h:38
void setScaleFactor(float scaleFactor)
Setzt den Skalierungsfaktor der Animation.
int getX() const override
Gibt die Position des Objektes auf der X-Achse relativ zum Elternobjekt zurück.
Definition: console.h:27
Definition: timedrenderobject.h:40
void setModulationColor(uint modulationColor)
Setzt die Modulationfarbe der Animation.
int getY() const override
Gibt die Position des Objektes auf der Y-Achse relativ zum Elternobjekt zurück.
bool doRender(RectangleList *updateRects) override
Einschubmethode, die den tatsächlichen Redervorgang durchführt.
Definition: animationdescription.h:40
void setY(int y) override
Setzt die Position des Objektes auf der Y-Achse.
Definition: animationtemplate.h:46
void setScaleFactorY(float scaleFactorY)
Setzt den Skalierungsfaktor der Animation auf der Y-Achse.
Definition: animationresource.h:45
int getAbsoluteY() const override
Gibt die absolute Position des Objektes auf der Y-Achse zurück.
Definition: inputpersistenceblock.h:40
Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt.
Definition: renderobject.h:72
int getAbsoluteX() const override
Gibt die absolute Position des Objektes auf der X-Achse zurück.
Definition: outputpersistenceblock.h:39
void setScaleFactorX(float scaleFactorX)
Setzt den Skalierungsfaktor der Animation auf der X-Achse.