Crazy Eddie's GUI System  0.8.5
AnimationManager.h
1 /***********************************************************************
2  created: 7/8/2010
3  author: Martin Preisler
4 
5  purpose: Defines the interface for the AnimationManager object
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUIAnimationManager_h_
30 #define _CEGUIAnimationManager_h_
31 
32 #include "CEGUI/Singleton.h"
33 #include "CEGUI/String.h"
34 #include <map>
35 #include <vector>
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 
46 class CEGUIEXPORT AnimationManager :
47  public Singleton<AnimationManager>,
48  public AllocatedObject<AnimationManager>
49 {
50 public:
52  static const String XMLSchemaName;
53 
54  /*************************************************************************
55  Construction and Destruction
56  *************************************************************************/
66  AnimationManager(void);
67 
68 
76  ~AnimationManager(void);
77 
89  void addInterpolator(Interpolator* interpolator);
90 
95  void removeInterpolator(Interpolator* interpolator);
96 
101  Interpolator* getInterpolator(const String& type) const;
102 
110  Animation* createAnimation(const String& name = "");
111 
116  void destroyAnimation(Animation* animation);
117 
122  void destroyAnimation(const String& name);
123 
128  void destroyAllAnimations();
129 
134  Animation* getAnimation(const String& name) const;
135 
147  bool isAnimationPresent(const String& name) const;
148 
153  Animation* getAnimationAtIdx(size_t index) const;
154 
159  size_t getNumAnimations() const;
160 
168  AnimationInstance* instantiateAnimation(Animation* animation);
169 
177  AnimationInstance* instantiateAnimation(const String& name);
178 
183  void destroyAnimationInstance(AnimationInstance* instance);
184 
189  void destroyAllInstancesOfAnimation(Animation* animation);
190 
195  void destroyAllAnimationInstances();
196 
201  AnimationInstance* getAnimationInstanceAtIdx(size_t index) const;
202 
208  size_t getNumAnimationInstances() const;
209 
220  void autoStepInstances(float delta);
221 
234  void loadAnimationsFromXML(const String& filename,
235  const String& resourceGroup = "");
236 
245  void loadAnimationsFromString(const String& source);
246 
257  void writeAnimationDefinitionToStream(const Animation& animation, OutStream& out_stream) const;
258 
273  String getAnimationDefinitionAsString(const Animation& animation) const;
274 
283  static void setDefaultResourceGroup(const String& resourceGroup)
284  {
285  s_defaultResourceGroup = resourceGroup;
286  }
287 
298  {
299  return s_defaultResourceGroup;
300  }
301 
302 private:
303  typedef std::map<String, Interpolator*, std::less<String>
304  CEGUI_MAP_ALLOC(String, Interpolator*)> InterpolatorMap;
305  String generateUniqueAnimationName();
306 
308  InterpolatorMap d_interpolators;
309  typedef std::vector<Interpolator*
310  CEGUI_VECTOR_ALLOC(Interpolator*)> BasicInterpolatorList;
312  BasicInterpolatorList d_basicInterpolators;
313 
314  typedef std::map<String, Animation*> AnimationMap;
316  AnimationMap d_animations;
317 
318  typedef std::multimap<Animation*, AnimationInstance*, std::less<Animation*>
319  CEGUI_MULTIMAP_ALLOC(Animation*, AnimationInstance*)> AnimationInstanceMap;
321  AnimationInstanceMap d_animationInstances;
323  static String s_defaultResourceGroup;
325  static const String GeneratedAnimationNameBase;
327  unsigned long d_uid_counter;
328 };
329 
330 } // End of CEGUI namespace section
331 
332 #if defined(_MSC_VER)
333 # pragma warning(pop)
334 #endif
335 
336 #endif // end of guard _CEGUIAnimationManager_h_
337 
Definition: MemoryAllocatedObject.h:109
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
std::ostream OutStream
Output stream class.
Definition: Base.h:185
static void setDefaultResourceGroup(const String &resourceGroup)
Sets the default resource group to be used when loading animation xml data.
Definition: AnimationManager.h:283
Defines an 'animation' class.
Definition: Animation.h:64
static const String & getDefaultResourceGroup()
Returns the default resource group currently set for loading animation xml data.
Definition: AnimationManager.h:297
Definition: Singleton.h:55
Definition: AnimationManager.h:46
Defines a 'interpolator' class.
Definition: Interpolator.h:53
Defines an 'animation instance' class.
Definition: AnimationInstance.h:73
String class used within the GUI system.
Definition: String.h:62
static const String XMLSchemaName
Name of the schema used for loading animation xml files.
Definition: AnimationManager.h:52