Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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-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
    00046     {
    00047     public:
    00048         typedef std::map<String, Overlay*> OverlayMap;
    00049         typedef std::map<String, OverlayElement*> ElementMap;
    00050     protected:
    00051         OverlayMap mOverlayMap;
    00052         StringVector mScriptPatterns;
    00053
    00054         void parseNewElement( DataStreamPtr& chunk, String& elemType, String& elemName,
    00055             bool isContainer, Overlay* pOverlay, bool isTemplate, String templateName = String(""), OverlayContainer* container = 0);
    00056         void parseAttrib( const String& line, Overlay* pOverlay);
    00057         void parseElementAttrib( const String& line, Overlay* pOverlay, OverlayElement* pElement );
    00058         void skipToNextCloseBrace(DataStreamPtr& chunk);
    00059         void skipToNextOpenBrace(DataStreamPtr& chunk);
    00060
    00061         int mLastViewportWidth, mLastViewportHeight;
    00062         bool mViewportDimensionsChanged;
    00063
    00064         bool parseChildren( DataStreamPtr& chunk, const String& line,
    00065             Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL);
    00066
    00067         typedef std::map<String, OverlayElementFactory*> FactoryMap;
    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
    00174         OverlayElement* createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isTemplate = false);
    00180         OverlayElement* cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName);
    00181
    00182         OverlayElement* createOverlayElementFromFactory(const String& typeName, const String& instanceName);
    00183
    00184         typedef MapIterator<ElementMap> TemplateIterator;
    00186         TemplateIterator getTemplateIterator ()
    00187         {
    00188             return TemplateIterator (mTemplates.begin (), mTemplates.end ()) ;
    00189         }
    00190         /* Returns whether the Element with the given name is a Template */
    00191         bool isTemplate (String strName) const {
    00192             return (mTemplates.find (strName) != mTemplates.end()) ;
    00193         }
    00194
    00195
    00211         static OverlayManager& getSingleton(void);
    00227         static OverlayManager* getSingletonPtr(void);
    00228     };
    00229
    00230
    00231
    00232 }
    00233
    00234
    00235 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Mar 6 09:46:26 2008