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