Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreOverlayManager.h

Go to the documentation of this file.
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-2005 The OGRE Team
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 */
00025 #ifndef __OverlayManager_H__
00026 #define __OverlayManager_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 #include "OgreSingleton.h"
00030 #include "OgreStringVector.h"
00031 #include "OgreOverlay.h"
00032 #include "OgreScriptLoader.h"
00033 
00034 namespace Ogre {
00035 
00041     class _OgreExport OverlayManager : public Singleton<OverlayManager>, public ScriptLoader
00042     {
00043     public:
00044         typedef std::map<String, Overlay*> OverlayMap;
00045         typedef std::map<String, OverlayElement*> ElementMap;
00046     protected:
00047         OverlayMap mOverlayMap;
00048         StringVector mScriptPatterns;
00049 
00050         void parseNewElement( DataStreamPtr& chunk, String& elemType, String& elemName, 
00051             bool isContainer, Overlay* pOverlay, bool isTemplate, String templateName = String(""), OverlayContainer* container = 0);
00052         void parseAttrib( const String& line, Overlay* pOverlay);
00053         void parseElementAttrib( const String& line, Overlay* pOverlay, OverlayElement* pElement );
00054         void parseNewMesh(DataStreamPtr& chunk, String& meshName, String& entityName, Overlay* pOverlay);
00055         void skipToNextCloseBrace(DataStreamPtr& chunk);
00056         void skipToNextOpenBrace(DataStreamPtr& chunk);
00057         
00058         int mLastViewportWidth, mLastViewportHeight;
00059         bool mViewportDimensionsChanged;
00060 
00061         bool parseChildren( DataStreamPtr& chunk, const String& line,
00062             Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL);
00063 
00064         typedef std::map<String, OverlayElementFactory*> FactoryMap;
00065         FactoryMap mFactories;
00066 
00067         ElementMap mInstances;
00068         ElementMap mTemplates;
00069 
00070         typedef std::set<String> LoadedScripts;
00071         LoadedScripts mLoadedScripts;
00072 
00073 
00074 
00075 
00076         ElementMap& getElementMap(bool isTemplate);
00077 
00078         OverlayElement* createOverlayElementImpl(const String& typeName, const String& instanceName, ElementMap& elementMap);
00079 
00080         OverlayElement* getOverlayElementImpl(const String& name, ElementMap& elementMap);
00081 
00082         void destroyOverlayElementImpl(const String& instanceName, ElementMap& elementMap);
00083 
00084         void destroyOverlayElementImpl(OverlayElement* pInstance, ElementMap& elementMap);
00085 
00086         void destroyAllOverlayElementsImpl(ElementMap& elementMap);
00087 
00088     public:
00089         OverlayManager();
00090         virtual ~OverlayManager();
00091 
00093         const StringVector& getScriptPatterns(void) const;
00095         void parseScript(DataStreamPtr& stream, const String& groupName);
00097         Real getLoadingOrder(void) const;
00098 
00100         Overlay* create(const String& name);
00104         Overlay* getByName(const String& name);
00106         void destroy(const String& name);
00108         void destroy(Overlay* overlay);
00110         void destroyAll(void);
00111         typedef MapIterator<OverlayMap> OverlayMapIterator;
00112         OverlayMapIterator getOverlayIterator(void);
00113 
00115         void _queueOverlaysForRendering(Camera* cam, RenderQueue* pQueue, Viewport *vp);
00116 
00121         bool hasViewportChanged(void) const;
00122 
00124         int getViewportHeight(void) const;
00125         
00127         int getViewportWidth(void) const;
00128         Real getViewportAspectRatio(void) const;
00129 
00130 
00138         OverlayElement* createOverlayElement(const String& typeName, const String& instanceName, bool isTemplate = false);
00139 
00141         OverlayElement* getOverlayElement(const String& name, bool isTemplate = false);
00142 
00148         void destroyOverlayElement(const String& instanceName, bool isTemplate = false);
00149 
00155         void destroyOverlayElement(OverlayElement* pInstance, bool isTemplate = false);
00156 
00162         void destroyAllOverlayElements(bool isTemplate = false);
00163 
00169         void addOverlayElementFactory(OverlayElementFactory* elemFactory);
00170 
00171         OverlayElement* createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isTemplate = false);
00177         OverlayElement* cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName);
00178 
00179         OverlayElement* createOverlayElementFromFactory(const String& typeName, const String& instanceName);
00180 
00181         typedef MapIterator<ElementMap> TemplateIterator;
00183         TemplateIterator getTemplateIterator ()
00184         {
00185             return TemplateIterator (mTemplates.begin (), mTemplates.end ()) ;
00186         }
00187         /* Returns whether the Element with the given name is a Template */
00188         bool isTemplate (String strName) const {
00189             return (mTemplates.find (strName) != mTemplates.end()) ;
00190         }
00191 
00192 
00208         static OverlayManager& getSingleton(void);
00224         static OverlayManager* getSingletonPtr(void);
00225     };
00226 
00227 
00228 
00229 }
00230 
00231 
00232 #endif 

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Feb 12 12:59:49 2006