Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pch/src/orxonox/gui/GUIManager.h @ 3143

Last change on this file since 3143 was 3143, checked in by rgrieder, 15 years ago

Dependency reductions in the GUIManager.

  • 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 <OgrePrerequisites.h>
44#include <CEGUIForwardRefs.h>
45
46#include "core/input/InputInterfaces.h"
47
48// Forward declaration
49namespace CEGUI { class DefaultLogger; }
50
51// tolua_begin
52namespace orxonox
53{
54    /**
55    @class GUIManager
56    @brief
57        Provides a simple interface to CEGUI with tolua methods and console commands. It also acts as a key and mouse handler.
58
59        The GUIManager is a singleton and can be called anywhere when access on the GUI is needed.
60        Creation of the GUIManager is therefore not possible and the cunstructor is private.
61
62        Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler.
63        Those input events are then injected into CEGUI in Lua.
64    */
65    class _OrxonoxExport GUIManager
66// tolua_end
67        : public KeyHandler, public MouseHandler
68// tolua_begin
69    {
70// tolua_end
71    public:
72        /**
73        @enum State
74            The current state of the GUIManager. There should maybe be more (or we can omit this totally).
75        */
76        enum State
77        {
78            Uninitialised,  //!< Initial state of the GUIManager
79            Ready,          //!< State after initialisation if ready
80            OnDisplay       //!< State if GUI is displayed
81        };
82
83        GUIManager();
84        ~GUIManager();
85
86        bool initialise(Ogre::RenderWindow* renderWindow);
87
88        void update(const Clock& time);
89
90        void showGUI(const std::string& name);
91        void executeCode(const std::string& str);
92
93        bool registerOverlay(std::string name, GUIOverlay* overlay); //!< Register a GUIOverlay with the GUIManager.
94        GUIOverlay* getOverlay(std::string name); // Get the GUIOverlay of the GUI with the given name.
95
96        void setCamera(Ogre::Camera* camera);
97
98        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
99        static GUIManager* getInstancePtr() { return singletonRef_s; }
100
101        void getLevelList(); //tolua_export
102
103    private:
104        GUIManager(const GUIManager& instance);                 //!< private constructor (this is a singleton class)
105
106        void loadLuaCode();
107
108        // keyHandler functions
109        void keyPressed (const KeyEvent& evt);
110        void keyReleased(const KeyEvent& evt);
111        void keyHeld    (const KeyEvent& evt) { }
112
113        // mouseHandler functions
114        void mouseButtonPressed (MouseButtonCode::ByEnum id);
115        void mouseButtonReleased(MouseButtonCode::ByEnum id);
116        void mouseButtonHeld    (MouseButtonCode::ByEnum id) { }
117        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
118        void mouseScrolled      (int abs, int rel);
119
120        void updateInput(float dt)  { }
121        void updateKey  (float dt)  { }
122        void updateMouse(float dt)  { }
123
124        Ogre::RenderWindow*         renderWindow_;      //!< Ogre's render window to give CEGUI access to it
125        CEGUI::OgreCEGUIRenderer*   guiRenderer_;       //!< CEGUI's interface to the Ogre Engine
126        CEGUI::ResourceProvider*    resourceProvider_;  //!< CEGUI's resource provider
127        CEGUI::LuaScriptModule*     scriptModule_;      //!< CEGUI's script module to use Lua
128        CEGUI::DefaultLogger*       ceguiLogger_;       //!< CEGUI's logger to be able to log CEGUI errors in our log
129        CEGUI::System*              guiSystem_;         //!< CEGUI's main system
130        lua_State*                  luaState_;          //!< Lua state, access point to the Lua engine
131
132        State                       state_;             //!< reflects state of the GUIManager
133
134        std::map<std::string, GUIOverlay*> guiOverlays_;//!< A list of all GUIOverlay's.
135
136        static GUIManager*          singletonRef_s;     //!< Singleton reference to GUIManager
137
138    }; // tolua_export
139} // tolua_export
140
141#endif /* _GUIManager_H__ */
Note: See TracBrowser for help on using the repository browser.