Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/netp6/src/orxonox/gui/GUIManager.h @ 4073

Last change on this file since 4073 was 3196, checked in by rgrieder, 16 years ago

Merged pch branch back to trunk.

  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Reto Grieder
24 *      Benjamin Knecht
25 *   Co-authors:
26 *      ...
27 *
28 */
29
30/**
31@file
32@brief
33    Declaration of the GUIManager class.
34*/
35
36#ifndef _GUIManager_H__
37#define _GUIManager_H__
38
39#include "OrxonoxPrereqs.h"
40
41#include <map>
42#include <string>
43#include <CEGUIForwardRefs.h>
44
45#include "util/OgreForwardRefs.h"
46#include "core/input/InputInterfaces.h"
47
48// tolua_begin
49namespace orxonox
50{
51    /**
52    @class GUIManager
53    @brief
54        Provides a simple interface to CEGUI with tolua methods and console commands. It also acts as a key and mouse handler.
55
56        The GUIManager is a singleton and can be called anywhere when access on the GUI is needed.
57        Creation of the GUIManager is therefore not possible and the cunstructor is private.
58
59        Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler.
60        Those input events are then injected into CEGUI in Lua.
61    */
62    class _OrxonoxExport GUIManager
63// tolua_end
64        : public KeyHandler, public MouseHandler
65// tolua_begin
66    {
67// tolua_end
68    public:
69        /**
70        @enum State
71            The current state of the GUIManager. There should maybe be more (or we can omit this totally).
72        */
73        enum State
74        {
75            Uninitialised,  //!< Initial state of the GUIManager
76            Ready,          //!< State after initialisation if ready
77            OnDisplay       //!< State if GUI is displayed
78        };
79
80        GUIManager();
81        ~GUIManager();
82
83        bool initialise(Ogre::RenderWindow* renderWindow);
84
85        void update(const Clock& time);
86
87        void showGUI(const std::string& name);
88        void executeCode(const std::string& str);
89
90        bool registerOverlay(const std::string& name, GUIOverlay* overlay); //!< Register a GUIOverlay with the GUIManager.
91        GUIOverlay* getOverlay(const std::string& name); // Get the GUIOverlay of the GUI with the given name.
92
93        void setCamera(Ogre::Camera* camera);
94
95        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
96        static GUIManager* getInstancePtr() { return singletonRef_s; }
97
98        void getLevelList(); //tolua_export
99
100    private:
101        GUIManager(const GUIManager& instance);                 //!< private constructor (this is a singleton class)
102
103        void loadLuaCode();
104
105        // keyHandler functions
106        void keyPressed (const KeyEvent& evt);
107        void keyReleased(const KeyEvent& evt);
108        void keyHeld    (const KeyEvent& evt) { }
109
110        // mouseHandler functions
111        void mouseButtonPressed (MouseButtonCode::ByEnum id);
112        void mouseButtonReleased(MouseButtonCode::ByEnum id);
113        void mouseButtonHeld    (MouseButtonCode::ByEnum id) { }
114        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
115        void mouseScrolled      (int abs, int rel);
116
117        void updateInput(float dt)  { }
118        void updateKey  (float dt)  { }
119        void updateMouse(float dt)  { }
120
121        Ogre::RenderWindow*         renderWindow_;      //!< Ogre's render window to give CEGUI access to it
122        CEGUI::OgreCEGUIRenderer*   guiRenderer_;       //!< CEGUI's interface to the Ogre Engine
123        CEGUI::ResourceProvider*    resourceProvider_;  //!< CEGUI's resource provider
124        CEGUI::LuaScriptModule*     scriptModule_;      //!< CEGUI's script module to use Lua
125        CEGUI::DefaultLogger*       ceguiLogger_;       //!< CEGUI's logger to be able to log CEGUI errors in our log
126        CEGUI::System*              guiSystem_;         //!< CEGUI's main system
127        lua_State*                  luaState_;          //!< Lua state, access point to the Lua engine
128
129        State                       state_;             //!< reflects state of the GUIManager
130
131        std::map<std::string, GUIOverlay*> guiOverlays_;//!< A list of all GUIOverlay's.
132
133        static GUIManager*          singletonRef_s;     //!< Singleton reference to GUIManager
134
135    }; // tolua_export
136} // tolua_export
137
138#endif /* _GUIManager_H__ */
Note: See TracBrowser for help on using the repository browser.