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/InputHandler.h" |
---|
47 | |
---|
48 | // tolua_begin |
---|
49 | namespace 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 InputHandler |
---|
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 | |
---|
109 | // mouseHandler functions |
---|
110 | void buttonPressed (MouseButtonCode::ByEnum id); |
---|
111 | void buttonReleased(MouseButtonCode::ByEnum id); |
---|
112 | void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize); |
---|
113 | void mouseScrolled (int abs, int rel); |
---|
114 | |
---|
115 | Ogre::RenderWindow* renderWindow_; //!< Ogre's render window to give CEGUI access to it |
---|
116 | CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine |
---|
117 | CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider |
---|
118 | CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua |
---|
119 | CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log |
---|
120 | CEGUI::System* guiSystem_; //!< CEGUI's main system |
---|
121 | lua_State* luaState_; //!< Lua state, access point to the Lua engine |
---|
122 | |
---|
123 | State state_; //!< reflects state of the GUIManager |
---|
124 | |
---|
125 | std::map<std::string, GUIOverlay*> guiOverlays_;//!< A list of all GUIOverlay's. |
---|
126 | |
---|
127 | static GUIManager* singletonRef_s; //!< Singleton reference to GUIManager |
---|
128 | |
---|
129 | }; // tolua_export |
---|
130 | } // tolua_export |
---|
131 | |
---|
132 | #endif /* _GUIManager_H__ */ |
---|