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 skipToNextCloseBrace(DataStreamPtr& chunk);
00055         void skipToNextOpenBrace(DataStreamPtr& chunk);
00056         
00057         int mLastViewportWidth, mLastViewportHeight;
00058         bool mViewportDimensionsChanged;
00059 
00060         bool parseChildren( DataStreamPtr& chunk, const String& line,
00061             Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL);
00062 
00063         typedef std::map<String, OverlayElementFactory*> FactoryMap;
00064         FactoryMap mFactories;
00065 
00066         ElementMap mInstances;
00067         ElementMap mTemplates;
00068 
00069         typedef std::set<String> LoadedScripts;
00070         LoadedScripts mLoadedScripts;
00071 
00072 
00073 
00074 
00075         ElementMap& getElementMap(bool isTemplate);
00076 
00077         OverlayElement* createOverlayElementImpl(const String& typeName, const String& instanceName, ElementMap& elementMap);
00078 
00079         OverlayElement* getOverlayElementImpl(const String& name, ElementMap& elementMap);
00080 
00081         void destroyOverlayElementImpl(const String& instanceName, ElementMap& elementMap);
00082 
00083         void destroyOverlayElementImpl(OverlayElement* pInstance, ElementMap& elementMap);
00084 
00085         void destroyAllOverlayElementsImpl(ElementMap& elementMap);
00086 
00087     public:
00088         OverlayManager();
00089         virtual ~OverlayManager();
00090 
00092         const StringVector& getScriptPatterns(void) const;
00094         void parseScript(DataStreamPtr& stream, const String& groupName);
00096         Real getLoadingOrder(void) const;
00097 
00099         Overlay* create(const String& name);
00103         Overlay* getByName(const String& name);
00105         void destroy(const String& name);
00107         void destroy(Overlay* overlay);
00109         void destroyAll(void);
00110         typedef MapIterator<OverlayMap> OverlayMapIterator;
00111         OverlayMapIterator getOverlayIterator(void);
00112 
00114         void _queueOverlaysForRendering(Camera* cam, RenderQueue* pQueue, Viewport *vp);
00115 
00120         bool hasViewportChanged(void) const;
00121 
00123         int getViewportHeight(void) const;
00124         
00126         int getViewportWidth(void) const;
00127         Real getViewportAspectRatio(void) const;
00128 
00129 
00137         OverlayElement* createOverlayElement(const String& typeName, const String& instanceName, bool isTemplate = false);
00138 
00140         OverlayElement* getOverlayElement(const String& name, bool isTemplate = false);
00141 
00147         void destroyOverlayElement(const String& instanceName, bool isTemplate = false);
00148 
00154         void destroyOverlayElement(OverlayElement* pInstance, bool isTemplate = false);
00155 
00161         void destroyAllOverlayElements(bool isTemplate = false);
00162 
00168         void addOverlayElementFactory(OverlayElementFactory* elemFactory);
00169 
00170         OverlayElement* createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isTemplate = false);
00176         OverlayElement* cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName);
00177 
00178         OverlayElement* createOverlayElementFromFactory(const String& typeName, const String& instanceName);
00179 
00180         typedef MapIterator<ElementMap> TemplateIterator;
00182         TemplateIterator getTemplateIterator ()
00183         {
00184             return TemplateIterator (mTemplates.begin (), mTemplates.end ()) ;
00185         }
00186         /* Returns whether the Element with the given name is a Template */
00187         bool isTemplate (String strName) const {
00188             return (mTemplates.find (strName) != mTemplates.end()) ;
00189         }
00190 
00191 
00207         static OverlayManager& getSingleton(void);
00223         static OverlayManager* getSingletonPtr(void);
00224     };
00225 
00226 
00227 
00228 }
00229 
00230 
00231 #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 Mar 12 14:37:45 2006