[1638] | 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 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | @file |
---|
| 31 | @brief Declaration of the GUIManager class. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | #ifndef _GUIManager_H__ |
---|
| 35 | #define _GUIManager_H__ |
---|
| 36 | |
---|
| 37 | #include "OrxonoxPrereqs.h" |
---|
| 38 | #include <OgrePrerequisites.h> |
---|
| 39 | #include <CEGUIForwardRefs.h> |
---|
| 40 | #include <CEGUIInputEvent.h> |
---|
| 41 | #include <CEGUISystem.h> |
---|
| 42 | #include "core/input/InputInterfaces.h" |
---|
| 43 | |
---|
| 44 | namespace orxonox // tolua_export |
---|
| 45 | { // tolua_export |
---|
| 46 | /** |
---|
| 47 | @brief |
---|
| 48 | Provides a simple interface to CEGUI with tolua methods and console commands |
---|
| 49 | */ |
---|
| 50 | class _OrxonoxExport GUIManager : public KeyHandler, public MouseHandler |
---|
| 51 | /* |
---|
| 52 | class GUIManager { // tolua_export |
---|
| 53 | */ |
---|
| 54 | { |
---|
| 55 | public: |
---|
| 56 | enum State |
---|
| 57 | { |
---|
| 58 | Uninitialised, |
---|
| 59 | Ready, |
---|
| 60 | OnDisplay |
---|
| 61 | }; |
---|
| 62 | |
---|
[1646] | 63 | GUIManager(); |
---|
| 64 | ~GUIManager(); |
---|
| 65 | |
---|
[1686] | 66 | bool initialise(Ogre::RenderWindow* renderWindow); |
---|
[1647] | 67 | void tick(float dt) |
---|
| 68 | { |
---|
| 69 | assert(guiSystem_); |
---|
| 70 | guiSystem_->injectTimePulse(dt); |
---|
| 71 | } |
---|
[1640] | 72 | void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export |
---|
[1661] | 73 | void hideGUI(); // tolua_export |
---|
[1638] | 74 | |
---|
[1640] | 75 | Ogre::Camera* getCamera() { return this->backgroundCamera_; } |
---|
| 76 | |
---|
| 77 | static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground) |
---|
[1638] | 78 | { |
---|
[1640] | 79 | getInstance().showGUI(name, sceneManager); |
---|
[1638] | 80 | } |
---|
| 81 | |
---|
[1646] | 82 | static GUIManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export |
---|
| 83 | static GUIManager* getInstancePtr() { return singletonRef_s; } |
---|
| 84 | |
---|
[1638] | 85 | private: |
---|
| 86 | GUIManager(const GUIManager& instance); |
---|
| 87 | |
---|
| 88 | void keyPressed (const KeyEvent& evt) |
---|
| 89 | { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); } |
---|
| 90 | void keyReleased(const KeyEvent& evt) |
---|
| 91 | { guiSystem_->injectKeyUp(evt.key); } |
---|
| 92 | void keyHeld (const KeyEvent& evt) |
---|
| 93 | { } |
---|
| 94 | |
---|
| 95 | void mouseButtonPressed (MouseButton::Enum id); |
---|
| 96 | void mouseButtonReleased(MouseButton::Enum id); |
---|
| 97 | void mouseButtonHeld (MouseButton::Enum id) |
---|
| 98 | { } |
---|
| 99 | void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) |
---|
| 100 | { guiSystem_->injectMouseMove(rel.x, rel.y); } |
---|
| 101 | void mouseScrolled (int abs, int rel) |
---|
| 102 | { guiSystem_->injectMouseWheelChange(rel);} |
---|
| 103 | |
---|
| 104 | void tickInput(float dt) { } |
---|
[1641] | 105 | void tickKey(float dt) { } |
---|
| 106 | void tickMouse(float dt) { } |
---|
[1638] | 107 | |
---|
| 108 | void loadScenes(); |
---|
| 109 | |
---|
[1640] | 110 | //Ogre::SceneManager* emptySceneManager_; |
---|
[1638] | 111 | Ogre::SceneManager* backgroundSceneManager_; |
---|
[1640] | 112 | //Ogre::Camera* emptyCamera_; |
---|
[1638] | 113 | Ogre::Camera* backgroundCamera_; |
---|
[1640] | 114 | //Ogre::Viewport* viewport_; |
---|
[1638] | 115 | Ogre::RenderWindow* renderWindow_; |
---|
| 116 | CEGUI::OgreCEGUIRenderer* guiRenderer_; |
---|
| 117 | CEGUI::ResourceProvider* resourceProvider_; |
---|
| 118 | CEGUI::LuaScriptModule* scriptModule_; |
---|
| 119 | CEGUI::System* guiSystem_; |
---|
| 120 | CEGUI::Imageset* backgroundImage_; |
---|
[1646] | 121 | lua_State* luaState_; |
---|
[1638] | 122 | |
---|
| 123 | State state_; |
---|
| 124 | |
---|
[1646] | 125 | static CEGUI::MouseButton convertButton(MouseButton::Enum button); |
---|
[1638] | 126 | |
---|
[1646] | 127 | static GUIManager* singletonRef_s; |
---|
[1638] | 128 | }; // tolua_export |
---|
| 129 | } // tolua_export |
---|
| 130 | |
---|
| 131 | #endif /* _GUIManager_H__ */ |
---|