ScummVM API documentation
AnimationState.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  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_ANIMATION_STATE_H
29 #define HPL_ANIMATION_STATE_H
30 
31 #include "hpl1/engine/graphics/GraphicsTypes.h"
32 #include "hpl1/engine/math/MathTypes.h"
33 #include "hpl1/engine/system/SystemTypes.h"
34 
35 #include "hpl1/engine/game/SaveGame.h"
36 
37 namespace hpl {
38 
39 class cAnimation;
40 class cAnimationManager;
41 
42 //---------------------------------------------
43 
45  kSaveData_ClassInit(cAnimationState) public : tString msName;
46 
47  tString msAnimationName;
48  float mfDefaultSpeed; // Not needed later
49 
50  float mfLength;
51  float mfWeight;
52  float mfSpeed;
53  float mfTimePos;
54 
55  float mfBaseSpeed;
56 
57  bool mbActive;
58  bool mbLoop;
59  bool mbPaused;
60 
61  float mfFadeStep;
62 
63  float mfSpecialEventTime;
64 
65  virtual iSaveObject *CreateSaveObject(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame);
66  virtual int GetSaveCreatePrio();
67 };
68 
69 //---------------------------------------------
70 
72 public:
73  float mfTime;
74  eAnimationEventType mType;
75  tString msValue;
76 };
77 
78 //---------------------------------------------
79 
80 class cAnimationState : public iSaveObject {
81  typedef iSaveObject super;
82 
83 public:
84  cAnimationState(cAnimation *apAnimation, const tString &asName,
85  cAnimationManager *apAnimationManager);
86  ~cAnimationState();
87 
88  const char *GetName() { return msName.c_str(); }
89 
90  void Update(float afTimeStep);
91 
92  bool IsFading();
93 
97  bool IsOver();
98 
99  void FadeIn(float afTime);
100  void FadeOut(float afTime);
101 
102  void SetLength(float afLength);
103  float GetLength();
104 
105  void SetWeight(float afWeight);
106  float GetWeight();
107 
108  void SetSpeed(float afSpeed);
109  float GetSpeed();
110 
111  void SetBaseSpeed(float afSpeed);
112  float GetBaseSpeed();
113 
114  void SetTimePosition(float afPosition);
115  float GetTimePosition();
116  float GetPreviousTimePosition();
117 
122  void SetRelativeTimePosition(float afPosition);
123 
127  float GetRelativeTimePosition();
128 
129  bool IsActive();
130  void SetActive(bool abActive);
131 
132  bool IsLooping();
133  void SetLoop(bool abLoop);
134 
135  bool IsPaused();
136  void SetPaused(bool abPaused);
137 
138  void SetSpecialEventTime(float afT) { mfSpecialEventTime = afT; }
139  float GetSpecialEventTime() { return mfSpecialEventTime; }
140  bool IsAfterSpecialEvent();
141  bool IsBeforeSpecialEvent();
142 
143  void AddTimePosition(float afAdd);
144 
145  cAnimation *GetAnimation();
146 
147  cAnimationEvent *CreateEvent();
148  cAnimationEvent *GetEvent(int alIdx);
149  int GetEventNum();
150 
151  float GetFadeStep() { return mfFadeStep; }
152  void SetFadeStep(float afX) { mfFadeStep = afX; }
153 
154  // SaveObject implementation
155  virtual iSaveData *CreateSaveData();
156  virtual void SaveToSaveData(iSaveData *apSaveData);
157  virtual void LoadFromSaveData(iSaveData *apSaveData);
158  virtual void SaveDataSetup(cSaveObjectHandler *apSaveObjectHandler, cGame *apGame);
159 
160 private:
161  tString msName;
162 
163  cAnimationManager *mpAnimationManager;
164 
165  cAnimation *mpAnimation;
166 
168 
169  // Properties of the animation
170  float mfLength;
171  float mfWeight;
172  float mfSpeed;
173  float mfTimePos;
174  float mfPrevTimePos;
175 
176  float mfBaseSpeed;
177 
178  float mfSpecialEventTime;
179 
180  bool mbActive;
181  bool mbLoop;
182  bool mbPaused;
183 
184  // properties for update
185  float mfFadeStep;
186 };
187 
188 } // namespace hpl
189 
190 #endif // HPL_ANIMATION_STATE_H
Definition: AI.h:36
Definition: Game.h:91
Definition: str.h:59
Definition: array.h:52
Definition: AnimationState.h:80
Definition: SaveGame.h:130
Definition: Animation.h:44
Definition: AnimationManager.h:39
Definition: SaveGame.h:111
Definition: SaveGame.h:183
Definition: AnimationState.h:44
Definition: AnimationState.h:71