[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> |
---|
[2800] | 42 | #include "core/Clock.h" |
---|
[1638] | 43 | #include "core/input/InputInterfaces.h" |
---|
| 44 | |
---|
[2710] | 45 | // Forward declaration |
---|
| 46 | namespace CEGUI { class DefaultLogger; } |
---|
| 47 | |
---|
| 48 | // tolua_begin |
---|
| 49 | namespace orxonox |
---|
| 50 | { |
---|
[1638] | 51 | /** |
---|
| 52 | @brief |
---|
| 53 | Provides a simple interface to CEGUI with tolua methods and console commands |
---|
| 54 | */ |
---|
[2710] | 55 | class _OrxonoxExport GUIManager |
---|
| 56 | // tolua_end |
---|
| 57 | : public KeyHandler, public MouseHandler |
---|
| 58 | // tolua_begin |
---|
[1638] | 59 | { |
---|
[2710] | 60 | // tolua_end |
---|
[1638] | 61 | public: |
---|
| 62 | enum State |
---|
| 63 | { |
---|
| 64 | Uninitialised, |
---|
| 65 | Ready, |
---|
| 66 | OnDisplay |
---|
| 67 | }; |
---|
| 68 | |
---|
[1646] | 69 | GUIManager(); |
---|
| 70 | ~GUIManager(); |
---|
| 71 | |
---|
[1686] | 72 | bool initialise(Ogre::RenderWindow* renderWindow); |
---|
[2790] | 73 | void loadScene(const std::string& name); |
---|
[2800] | 74 | void update(const Clock& time) |
---|
[1647] | 75 | { |
---|
| 76 | assert(guiSystem_); |
---|
[2800] | 77 | guiSystem_->injectTimePulse(time.getDeltaTime()); |
---|
[1647] | 78 | } |
---|
[1640] | 79 | void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export |
---|
[1661] | 80 | void hideGUI(); // tolua_export |
---|
[1638] | 81 | |
---|
[1640] | 82 | Ogre::Camera* getCamera() { return this->backgroundCamera_; } |
---|
| 83 | |
---|
| 84 | static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground) |
---|
[1638] | 85 | { |
---|
[1640] | 86 | getInstance().showGUI(name, sceneManager); |
---|
[1638] | 87 | } |
---|
| 88 | |
---|
[1646] | 89 | static GUIManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export |
---|
| 90 | static GUIManager* getInstancePtr() { return singletonRef_s; } |
---|
| 91 | |
---|
[1638] | 92 | private: |
---|
| 93 | GUIManager(const GUIManager& instance); |
---|
| 94 | |
---|
| 95 | void keyPressed (const KeyEvent& evt) |
---|
| 96 | { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); } |
---|
| 97 | void keyReleased(const KeyEvent& evt) |
---|
| 98 | { guiSystem_->injectKeyUp(evt.key); } |
---|
| 99 | void keyHeld (const KeyEvent& evt) |
---|
| 100 | { } |
---|
| 101 | |
---|
[1887] | 102 | void mouseButtonPressed (MouseButtonCode::ByEnum id); |
---|
| 103 | void mouseButtonReleased(MouseButtonCode::ByEnum id); |
---|
| 104 | void mouseButtonHeld (MouseButtonCode::ByEnum id) |
---|
[1638] | 105 | { } |
---|
| 106 | void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) |
---|
| 107 | { guiSystem_->injectMouseMove(rel.x, rel.y); } |
---|
| 108 | void mouseScrolled (int abs, int rel) |
---|
| 109 | { guiSystem_->injectMouseWheelChange(rel);} |
---|
| 110 | |
---|
[2800] | 111 | void updateInput(float dt) { } |
---|
| 112 | void updateKey(float dt) { } |
---|
| 113 | void updateMouse(float dt) { } |
---|
[1638] | 114 | |
---|
| 115 | void loadScenes(); |
---|
| 116 | |
---|
[1640] | 117 | //Ogre::SceneManager* emptySceneManager_; |
---|
[1638] | 118 | Ogre::SceneManager* backgroundSceneManager_; |
---|
[1640] | 119 | //Ogre::Camera* emptyCamera_; |
---|
[1638] | 120 | Ogre::Camera* backgroundCamera_; |
---|
[1640] | 121 | //Ogre::Viewport* viewport_; |
---|
[1638] | 122 | Ogre::RenderWindow* renderWindow_; |
---|
| 123 | CEGUI::OgreCEGUIRenderer* guiRenderer_; |
---|
| 124 | CEGUI::ResourceProvider* resourceProvider_; |
---|
| 125 | CEGUI::LuaScriptModule* scriptModule_; |
---|
[2710] | 126 | CEGUI::DefaultLogger* ceguiLogger_; |
---|
[1638] | 127 | CEGUI::System* guiSystem_; |
---|
| 128 | CEGUI::Imageset* backgroundImage_; |
---|
[1646] | 129 | lua_State* luaState_; |
---|
[1638] | 130 | |
---|
| 131 | State state_; |
---|
| 132 | |
---|
[1887] | 133 | static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button); |
---|
[1638] | 134 | |
---|
[1646] | 135 | static GUIManager* singletonRef_s; |
---|
[1638] | 136 | }; // tolua_export |
---|
| 137 | } // tolua_export |
---|
| 138 | |
---|
| 139 | #endif /* _GUIManager_H__ */ |
---|