00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright (c) 2000-2006 Torus Knot Software Ltd 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 00024 You may alternatively use this source under the terms of a specific version of 00025 the OGRE Unrestricted License provided you have obtained such a license from 00026 Torus Knot Software Ltd. 00027 ----------------------------------------------------------------------------- 00028 */ 00029 #ifndef __OverlayManager_H__ 00030 #define __OverlayManager_H__ 00031 00032 #include "OgrePrerequisites.h" 00033 #include "OgreSingleton.h" 00034 #include "OgreStringVector.h" 00035 #include "OgreOverlay.h" 00036 #include "OgreScriptLoader.h" 00037 00038 namespace Ogre { 00039 00045 class _OgreExport OverlayManager : public Singleton<OverlayManager>, public ScriptLoader, public OverlayAlloc 00046 { 00047 public: 00048 typedef std::map<String, Overlay*> OverlayMap; 00049 typedef std::map<String, OverlayElement*> ElementMap; 00050 typedef std::map<String, OverlayElementFactory*> FactoryMap; 00051 protected: 00052 OverlayMap mOverlayMap; 00053 StringVector mScriptPatterns; 00054 00055 void parseNewElement( DataStreamPtr& chunk, String& elemType, String& elemName, 00056 bool isContainer, Overlay* pOverlay, bool isTemplate, String templateName = String(""), OverlayContainer* container = 0); 00057 void parseAttrib( const String& line, Overlay* pOverlay); 00058 void parseElementAttrib( const String& line, Overlay* pOverlay, OverlayElement* pElement ); 00059 void skipToNextCloseBrace(DataStreamPtr& chunk); 00060 void skipToNextOpenBrace(DataStreamPtr& chunk); 00061 00062 int mLastViewportWidth, mLastViewportHeight; 00063 bool mViewportDimensionsChanged; 00064 00065 bool parseChildren( DataStreamPtr& chunk, const String& line, 00066 Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL); 00067 00068 FactoryMap mFactories; 00069 00070 ElementMap mInstances; 00071 ElementMap mTemplates; 00072 00073 typedef std::set<String> LoadedScripts; 00074 LoadedScripts mLoadedScripts; 00075 00076 00077 00078 00079 ElementMap& getElementMap(bool isTemplate); 00080 00081 OverlayElement* createOverlayElementImpl(const String& typeName, const String& instanceName, ElementMap& elementMap); 00082 00083 OverlayElement* getOverlayElementImpl(const String& name, ElementMap& elementMap); 00084 00085 void destroyOverlayElementImpl(const String& instanceName, ElementMap& elementMap); 00086 00087 void destroyOverlayElementImpl(OverlayElement* pInstance, ElementMap& elementMap); 00088 00089 void destroyAllOverlayElementsImpl(ElementMap& elementMap); 00090 00091 public: 00092 OverlayManager(); 00093 virtual ~OverlayManager(); 00094 00096 const StringVector& getScriptPatterns(void) const; 00098 void parseScript(DataStreamPtr& stream, const String& groupName); 00100 Real getLoadingOrder(void) const; 00101 00103 Overlay* create(const String& name); 00107 Overlay* getByName(const String& name); 00109 void destroy(const String& name); 00111 void destroy(Overlay* overlay); 00113 void destroyAll(void); 00114 typedef MapIterator<OverlayMap> OverlayMapIterator; 00115 OverlayMapIterator getOverlayIterator(void); 00116 00118 void _queueOverlaysForRendering(Camera* cam, RenderQueue* pQueue, Viewport *vp); 00119 00124 bool hasViewportChanged(void) const; 00125 00127 int getViewportHeight(void) const; 00128 00130 int getViewportWidth(void) const; 00131 Real getViewportAspectRatio(void) const; 00132 00133 00141 OverlayElement* createOverlayElement(const String& typeName, const String& instanceName, bool isTemplate = false); 00142 00144 OverlayElement* getOverlayElement(const String& name, bool isTemplate = false); 00145 00151 void destroyOverlayElement(const String& instanceName, bool isTemplate = false); 00152 00158 void destroyOverlayElement(OverlayElement* pInstance, bool isTemplate = false); 00159 00165 void destroyAllOverlayElements(bool isTemplate = false); 00166 00172 void addOverlayElementFactory(OverlayElementFactory* elemFactory); 00173 00175 const FactoryMap& getOverlayElementFactoryMap() const { 00176 return mFactories; 00177 } 00178 00179 OverlayElement* createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isTemplate = false); 00185 OverlayElement* cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName); 00186 00187 OverlayElement* createOverlayElementFromFactory(const String& typeName, const String& instanceName); 00188 00189 typedef MapIterator<ElementMap> TemplateIterator; 00191 TemplateIterator getTemplateIterator () 00192 { 00193 return TemplateIterator (mTemplates.begin (), mTemplates.end ()) ; 00194 } 00195 /* Returns whether the Element with the given name is a Template */ 00196 bool isTemplate (String strName) const { 00197 return (mTemplates.find (strName) != mTemplates.end()) ; 00198 } 00199 00200 00216 static OverlayManager& getSingleton(void); 00232 static OverlayManager* getSingletonPtr(void); 00233 }; 00234 00235 00236 00237 } 00238 00239 00240 #endif
Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:24 2009