Crazy Eddie's GUI System  0.8.4
AnimationManager.h
00001 /***********************************************************************
00002     created:    7/8/2010
00003     author:     Martin Preisler
00004 
00005     purpose:    Defines the interface for the AnimationManager object
00006 *************************************************************************/
00007 /***************************************************************************
00008  *   Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
00009  *
00010  *   Permission is hereby granted, free of charge, to any person obtaining
00011  *   a copy of this software and associated documentation files (the
00012  *   "Software"), to deal in the Software without restriction, including
00013  *   without limitation the rights to use, copy, modify, merge, publish,
00014  *   distribute, sublicense, and/or sell copies of the Software, and to
00015  *   permit persons to whom the Software is furnished to do so, subject to
00016  *   the following conditions:
00017  *
00018  *   The above copyright notice and this permission notice shall be
00019  *   included in all copies or substantial portions of the Software.
00020  *
00021  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00023  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00024  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00025  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00026  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00027  *   OTHER DEALINGS IN THE SOFTWARE.
00028  ***************************************************************************/
00029 #ifndef _CEGUIAnimationManager_h_
00030 #define _CEGUIAnimationManager_h_
00031 
00032 #include "CEGUI/Singleton.h"
00033 #include "CEGUI/String.h"
00034 #include <map>
00035 #include <vector>
00036 
00037 #if defined(_MSC_VER)
00038 #   pragma warning(push)
00039 #   pragma warning(disable : 4251)
00040 #endif
00041 
00042 // Start of CEGUI namespace section
00043 namespace CEGUI
00044 {
00045 
00046 class CEGUIEXPORT AnimationManager :
00047     public Singleton<AnimationManager>,
00048     public AllocatedObject<AnimationManager>
00049 {
00050 public:
00052     static const String XMLSchemaName;
00053 
00054     /*************************************************************************
00055         Construction and Destruction
00056     *************************************************************************/
00066     AnimationManager(void);
00067 
00068 
00076     ~AnimationManager(void);
00077 
00089     void addInterpolator(Interpolator* interpolator);
00090 
00095     void removeInterpolator(Interpolator* interpolator);
00096 
00101     Interpolator* getInterpolator(const String& type) const;
00102 
00110     Animation* createAnimation(const String& name = "");
00111 
00116     void destroyAnimation(Animation* animation);
00117 
00122     void destroyAnimation(const String& name);
00123     
00128     void destroyAllAnimations();
00129 
00134     Animation* getAnimation(const String& name) const;
00135 
00147     bool isAnimationPresent(const String& name) const;
00148 
00153     Animation* getAnimationAtIdx(size_t index) const;
00154 
00159     size_t getNumAnimations() const;
00160 
00168     AnimationInstance* instantiateAnimation(Animation* animation);
00169 
00177     AnimationInstance* instantiateAnimation(const String& name);
00178 
00183     void destroyAnimationInstance(AnimationInstance* instance);
00184 
00189     void destroyAllInstancesOfAnimation(Animation* animation);
00190     
00195     void destroyAllAnimationInstances();
00196 
00201     AnimationInstance* getAnimationInstanceAtIdx(size_t index) const;
00202 
00208     size_t getNumAnimationInstances() const;
00209 
00220     void autoStepInstances(float delta);
00221 
00234     void loadAnimationsFromXML(const String& filename,
00235                                const String& resourceGroup = "");
00236 
00245     void loadAnimationsFromString(const String& source);
00246 
00257     void writeAnimationDefinitionToStream(const Animation& animation, OutStream& out_stream) const;
00258 
00273     String getAnimationDefinitionAsString(const Animation& animation) const;
00274 
00283     static void setDefaultResourceGroup(const String& resourceGroup)
00284     {
00285         s_defaultResourceGroup = resourceGroup;
00286     }
00287 
00297     static const String& getDefaultResourceGroup()
00298     {
00299         return s_defaultResourceGroup;
00300     }
00301 
00302 private:
00303     typedef std::map<String, Interpolator*, std::less<String>
00304         CEGUI_MAP_ALLOC(String, Interpolator*)> InterpolatorMap;
00305     String generateUniqueAnimationName();
00306     
00308     InterpolatorMap d_interpolators;
00309     typedef std::vector<Interpolator*
00310         CEGUI_VECTOR_ALLOC(Interpolator*)> BasicInterpolatorList;
00312     BasicInterpolatorList d_basicInterpolators;
00313 
00314     typedef std::map<String, Animation*> AnimationMap;
00316     AnimationMap d_animations;
00317 
00318     typedef std::multimap<Animation*, AnimationInstance*, std::less<Animation*>
00319         CEGUI_MULTIMAP_ALLOC(Animation*, AnimationInstance*)> AnimationInstanceMap;
00321     AnimationInstanceMap d_animationInstances;
00323     static String s_defaultResourceGroup;
00325     static const String GeneratedAnimationNameBase;
00327     unsigned long d_uid_counter;
00328 };
00329 
00330 } // End of  CEGUI namespace section
00331 
00332 #if defined(_MSC_VER)
00333 #   pragma warning(pop)
00334 #endif
00335 
00336 #endif  // end of guard _CEGUIAnimationManager_h_
00337 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends