Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
AnimationManager.h
1 /***********************************************************************
2  filename: CEGUIAnimationManager.h
3  created: 7/8/2010
4  author: Martin Preisler
5 
6  purpose: Defines the interface for the AnimationManager object
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIAnimationManager_h_
31 #define _CEGUIAnimationManager_h_
32 
33 #include "CEGUI/Singleton.h"
34 #include "CEGUI/String.h"
35 #include <map>
36 #include <vector>
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
46 
47 class CEGUIEXPORT AnimationManager :
48  public Singleton<AnimationManager>,
49  public AllocatedObject<AnimationManager>
50 {
51 public:
53  static const String XMLSchemaName;
54 
55  /*************************************************************************
56  Construction and Destruction
57  *************************************************************************/
67  AnimationManager(void);
68 
69 
77  ~AnimationManager(void);
78 
90  void addInterpolator(Interpolator* interpolator);
91 
96  void removeInterpolator(Interpolator* interpolator);
97 
102  Interpolator* getInterpolator(const String& type) const;
103 
111  Animation* createAnimation(const String& name = "");
112 
117  void destroyAnimation(Animation* animation);
118 
123  void destroyAnimation(const String& name);
124 
129  void destroyAllAnimations();
130 
135  Animation* getAnimation(const String& name) const;
136 
148  bool isAnimationPresent(const String& name) const;
149 
154  Animation* getAnimationAtIdx(size_t index) const;
155 
160  size_t getNumAnimations() const;
161 
169  AnimationInstance* instantiateAnimation(Animation* animation);
170 
178  AnimationInstance* instantiateAnimation(const String& name);
179 
184  void destroyAnimationInstance(AnimationInstance* instance);
185 
190  void destroyAllInstancesOfAnimation(Animation* animation);
191 
196  void destroyAllAnimationInstances();
197 
202  AnimationInstance* getAnimationInstanceAtIdx(size_t index) const;
203 
209  size_t getNumAnimationInstances() const;
210 
221  void autoStepInstances(float delta);
222 
235  void loadAnimationsFromXML(const String& filename,
236  const String& resourceGroup = "");
237 
246  void loadAnimationsFromString(const String& source);
247 
258  void writeAnimationDefinitionToStream(const Animation& animation, OutStream& out_stream) const;
259 
274  String getAnimationDefinitionAsString(const Animation& animation) const;
275 
284  static void setDefaultResourceGroup(const String& resourceGroup)
285  {
286  s_defaultResourceGroup = resourceGroup;
287  }
288 
298  static const String& getDefaultResourceGroup()
299  {
300  return s_defaultResourceGroup;
301  }
302 
303 private:
304  typedef std::map<String, Interpolator*, std::less<String>
305  CEGUI_MAP_ALLOC(String, Interpolator*)> InterpolatorMap;
306  String generateUniqueAnimationName();
307 
309  InterpolatorMap d_interpolators;
310  typedef std::vector<Interpolator*
311  CEGUI_VECTOR_ALLOC(Interpolator*)> BasicInterpolatorList;
313  BasicInterpolatorList d_basicInterpolators;
314 
315  typedef std::map<String, Animation*> AnimationMap;
317  AnimationMap d_animations;
318 
319  typedef std::multimap<Animation*, AnimationInstance*, std::less<Animation*>
320  CEGUI_MULTIMAP_ALLOC(Animation*, AnimationInstance*)> AnimationInstanceMap;
322  AnimationInstanceMap d_animationInstances;
324  static String s_defaultResourceGroup;
326  static const String GeneratedAnimationNameBase;
328  unsigned long d_uid_counter;
329 };
330 
331 } // End of CEGUI namespace section
332 
333 #if defined(_MSC_VER)
334 # pragma warning(pop)
335 #endif
336 
337 #endif // end of guard _CEGUIAnimationManager_h_
338