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-2012 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef __OverlayManager_H__ 00029 #define __OverlayManager_H__ 00030 00031 #include "OgrePrerequisites.h" 00032 #include "OgreSingleton.h" 00033 #include "OgreStringVector.h" 00034 #include "OgreOverlay.h" 00035 #include "OgreScriptLoader.h" 00036 #include "OgreFrustum.h" 00037 00038 namespace Ogre { 00039 00051 class _OgreExport OverlayManager : public Singleton<OverlayManager>, public ScriptLoader, public OverlayAlloc 00052 { 00053 public: 00054 typedef map<String, Overlay*>::type OverlayMap; 00055 typedef map<String, OverlayElement*>::type ElementMap; 00056 typedef map<String, OverlayElementFactory*>::type FactoryMap; 00057 protected: 00058 OverlayMap mOverlayMap; 00059 StringVector mScriptPatterns; 00060 00061 void parseNewElement( DataStreamPtr& chunk, String& elemType, String& elemName, 00062 bool isContainer, Overlay* pOverlay, bool isTemplate, String templateName = String(""), OverlayContainer* container = 0); 00063 void parseAttrib( const String& line, Overlay* pOverlay); 00064 void parseElementAttrib( const String& line, Overlay* pOverlay, OverlayElement* pElement ); 00065 void skipToNextCloseBrace(DataStreamPtr& chunk); 00066 void skipToNextOpenBrace(DataStreamPtr& chunk); 00067 00068 int mLastViewportWidth, mLastViewportHeight; 00069 bool mViewportDimensionsChanged; 00070 OrientationMode mLastViewportOrientationMode; 00071 00072 bool parseChildren( DataStreamPtr& chunk, const String& line, 00073 Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL); 00074 00075 FactoryMap mFactories; 00076 00077 ElementMap mInstances; 00078 ElementMap mTemplates; 00079 00080 typedef set<String>::type LoadedScripts; 00081 LoadedScripts mLoadedScripts; 00082 00083 00084 00085 00086 ElementMap& getElementMap(bool isTemplate); 00087 00088 OverlayElement* createOverlayElementImpl(const String& typeName, const String& instanceName, ElementMap& elementMap); 00089 00090 OverlayElement* getOverlayElementImpl(const String& name, ElementMap& elementMap); 00091 00092 bool hasOverlayElementImpl(const String& name, ElementMap& elementMap); 00093 00094 void destroyOverlayElementImpl(const String& instanceName, ElementMap& elementMap); 00095 00096 void destroyOverlayElementImpl(OverlayElement* pInstance, ElementMap& elementMap); 00097 00098 void destroyAllOverlayElementsImpl(ElementMap& elementMap); 00099 00100 public: 00101 OverlayManager(); 00102 virtual ~OverlayManager(); 00103 00105 const StringVector& getScriptPatterns(void) const; 00107 void parseScript(DataStreamPtr& stream, const String& groupName); 00109 Real getLoadingOrder(void) const; 00110 00112 Overlay* create(const String& name); 00116 Overlay* getByName(const String& name); 00118 void destroy(const String& name); 00120 void destroy(Overlay* overlay); 00122 void destroyAll(void); 00123 typedef MapIterator<OverlayMap> OverlayMapIterator; 00124 OverlayMapIterator getOverlayIterator(void); 00125 00127 void _queueOverlaysForRendering(Camera* cam, RenderQueue* pQueue, Viewport *vp); 00128 00133 bool hasViewportChanged(void) const; 00134 00136 int getViewportHeight(void) const; 00137 00139 int getViewportWidth(void) const; 00140 Real getViewportAspectRatio(void) const; 00141 00143 OrientationMode getViewportOrientationMode(void) const; 00144 00152 OverlayElement* createOverlayElement(const String& typeName, const String& instanceName, bool isTemplate = false); 00153 00155 OverlayElement* getOverlayElement(const String& name, bool isTemplate = false); 00156 00158 bool hasOverlayElement(const String& name, bool isTemplate = false); 00159 00165 void destroyOverlayElement(const String& instanceName, bool isTemplate = false); 00166 00172 void destroyOverlayElement(OverlayElement* pInstance, bool isTemplate = false); 00173 00179 void destroyAllOverlayElements(bool isTemplate = false); 00180 00186 void addOverlayElementFactory(OverlayElementFactory* elemFactory); 00187 00189 const FactoryMap& getOverlayElementFactoryMap() const { 00190 return mFactories; 00191 } 00192 00193 OverlayElement* createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isTemplate = false); 00199 OverlayElement* cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName); 00200 00201 OverlayElement* createOverlayElementFromFactory(const String& typeName, const String& instanceName); 00202 00203 typedef MapIterator<ElementMap> TemplateIterator; 00205 TemplateIterator getTemplateIterator () 00206 { 00207 return TemplateIterator (mTemplates.begin (), mTemplates.end ()) ; 00208 } 00209 /* Returns whether the Element with the given name is a Template */ 00210 bool isTemplate (String strName) const { 00211 return (mTemplates.find (strName) != mTemplates.end()) ; 00212 } 00213 00214 00230 static OverlayManager& getSingleton(void); 00246 static OverlayManager* getSingletonPtr(void); 00247 }; 00248 00249 00253 } 00254 00255 00256 #endif
Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:25 2012