Crazy Eddie's GUI System  0.8.7
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  *************************************************************************/
67 
68 
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 
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 
169 
178 
184 
190 
196 
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 
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 
CEGUI::AnimationManager::instantiateAnimation
AnimationInstance * instantiateAnimation(const String &name)
Instantiates given animation by name.
CEGUI::AnimationManager
Definition: AnimationManager.h:49
CEGUI::AnimationInstance
Defines an 'animation instance' class.
Definition: AnimationInstance.h:75
CEGUI::AnimationManager::addInterpolator
void addInterpolator(Interpolator *interpolator)
Adds interpolator to be available for Affectors.
CEGUI::Singleton
Definition: Singleton.h:56
CEGUI::AnimationManager::getNumAnimations
size_t getNumAnimations() const
Retrieves number of defined animations.
CEGUI::AnimationManager::writeAnimationDefinitionToStream
void writeAnimationDefinitionToStream(const Animation &animation, OutStream &out_stream) const
Writes given animation definition to the given OutStream.
CEGUI::AnimationManager::destroyAnimation
void destroyAnimation(Animation *animation)
Destroys given animation definition.
CEGUI::AnimationManager::createAnimation
Animation * createAnimation(const String &name="")
Creates a new Animation definition.
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::AnimationManager::autoStepInstances
void autoStepInstances(float delta)
Internal method, gets called by CEGUI::System automatically.
CEGUI::AllocatedObject
Definition: MemoryAllocatedObject.h:110
CEGUI::AnimationManager::getAnimationInstanceAtIdx
AnimationInstance * getAnimationInstanceAtIdx(size_t index) const
Retrieves animation instance at given index.
CEGUI::AnimationManager::getNumAnimationInstances
size_t getNumAnimationInstances() const
Retrieves number of animation instances, number of times any animation was instantiated.
CEGUI::AnimationManager::loadAnimationsFromString
void loadAnimationsFromString(const String &source)
Parses XML source containing animation specifications to create and initialise Animation objects.
CEGUI::AnimationManager::getDefaultResourceGroup
static const String & getDefaultResourceGroup()
Returns the default resource group currently set for loading animation xml data.
Definition: AnimationManager.h:297
CEGUI::AnimationManager::~AnimationManager
~AnimationManager(void)
Destructor for AnimationManager objects.
CEGUI::AnimationManager::XMLSchemaName
static const String XMLSchemaName
Name of the schema used for loading animation xml files.
Definition: AnimationManager.h:52
CEGUI::AnimationManager::destroyAllAnimationInstances
void destroyAllAnimationInstances()
Destroys all instances of all animations.
CEGUI::AnimationManager::AnimationManager
AnimationManager(void)
Constructs a new AnimationManager object.
CEGUI::AnimationManager::getInterpolator
Interpolator * getInterpolator(const String &type) const
Retrieves interpolator by type.
CEGUI::AnimationManager::getAnimation
Animation * getAnimation(const String &name) const
Retrieves animation by name.
CEGUI::AnimationManager::setDefaultResourceGroup
static void setDefaultResourceGroup(const String &resourceGroup)
Sets the default resource group to be used when loading animation xml data.
Definition: AnimationManager.h:283
CEGUI::OutStream
std::ostream OutStream
Output stream class.
Definition: Base.h:185
CEGUI::AnimationManager::isAnimationPresent
bool isAnimationPresent(const String &name) const
Examines the list of Animations to see if one exists with the given name.
CEGUI::AnimationManager::destroyAllAnimations
void destroyAllAnimations()
Destroys all animations in existence!
CEGUI::AnimationManager::loadAnimationsFromXML
void loadAnimationsFromXML(const String &filename, const String &resourceGroup="")
Parses an XML file containing animation specifications to create and initialise Animation objects.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::Interpolator
Defines a 'interpolator' class.
Definition: Interpolator.h:55
CEGUI::Animation
Defines an 'animation' class.
Definition: Animation.h:65
CEGUI::AnimationManager::destroyAnimationInstance
void destroyAnimationInstance(AnimationInstance *instance)
Destroys given animation instance.
CEGUI::AnimationManager::removeInterpolator
void removeInterpolator(Interpolator *interpolator)
Removes interpolator.
CEGUI::AnimationManager::destroyAnimation
void destroyAnimation(const String &name)
Destroys given animation definition by name.
CEGUI::AnimationManager::destroyAllInstancesOfAnimation
void destroyAllInstancesOfAnimation(Animation *animation)
Destroys all instances of given animation.
CEGUI::AnimationManager::instantiateAnimation
AnimationInstance * instantiateAnimation(Animation *animation)
Instantiates given animation.
CEGUI::AnimationManager::getAnimationAtIdx
Animation * getAnimationAtIdx(size_t index) const
Retrieves animation by index.
CEGUI::AnimationManager::getAnimationDefinitionAsString
String getAnimationDefinitionAsString(const Animation &animation) const
Writes given animation definition and returns the result as String.