Changeset 2896 for code/trunk/src/orxonox/gui/GUIManager.h
- Timestamp:
- Apr 6, 2009, 1:59:00 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/gui merged: 2796,2798-2801,2805,2807-2808,2811,2814-2817,2834,2840-2850,2853-2854,2859,2862-2863,2869,2875,2887,2892
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/gui/GUIManager.h
r2790 r2896 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Benjamin Knecht 26 26 * 27 27 */ … … 49 49 { 50 50 /** 51 @class GUIManager 51 52 @brief 52 Provides a simple interface to CEGUI with tolua methods and console commands 53 Provides a simple interface to CEGUI with tolua methods and console commands. It also acts as a key and mouse handler. 54 55 The GUIManager is a singleton and can be called anywhere when access on the GUI is needed. 56 Creation of the GUIManager is therefore not possible and the cunstructor is private. 57 58 Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler. 59 Those input events are then injected into CEGUI in Lua. 53 60 */ 54 61 class _OrxonoxExport GUIManager … … 59 66 // tolua_end 60 67 public: 68 /** 69 @enum State 70 The current state of the GUIManager. There should maybe be more (or we can omit this totally). 71 */ 61 72 enum State 62 73 { 63 Uninitialised, 64 Ready, 65 OnDisplay 74 Uninitialised, //!< Initial state of the GUIManager 75 Ready, //!< State after initialisation if ready 76 OnDisplay //!< State if GUI is displayed 66 77 }; 67 78 … … 70 81 71 82 bool initialise(Ogre::RenderWindow* renderWindow); 72 void loadScene(const std::string& name);73 void tick(float dt)74 {75 assert(guiSystem_);76 guiSystem_->injectTimePulse(dt);77 }78 void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export79 void hideGUI(); // tolua_export80 83 81 Ogre::Camera* getCamera() { return this->backgroundCamera_; }84 void update(const Clock& time); 82 85 83 static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)84 {85 getInstance().showGUI(name, sceneManager); 86 }86 void showGUI(const std::string& name); 87 void executeCode(const std::string& str); 88 89 void setCamera(Ogre::Camera* camera); 87 90 88 91 static GUIManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export … … 90 93 91 94 private: 92 GUIManager(const GUIManager& instance); 95 GUIManager(const GUIManager& instance); //!< private constructor (this is a singleton class) 93 96 97 void loadLuaCode(); 98 99 // keyHandler functions 94 100 void keyPressed (const KeyEvent& evt) 95 { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }101 { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); } 96 102 void keyReleased(const KeyEvent& evt) 97 { guiSystem_->injectKeyUp(evt.key); } 98 void keyHeld (const KeyEvent& evt) 99 { } 103 { guiSystem_->injectKeyUp(evt.key); } 104 void keyHeld (const KeyEvent& evt) { } 100 105 106 // mouseHandler functions 101 107 void mouseButtonPressed (MouseButtonCode::ByEnum id); 102 108 void mouseButtonReleased(MouseButtonCode::ByEnum id); 103 void mouseButtonHeld (MouseButtonCode::ByEnum id) 104 { } 109 void mouseButtonHeld (MouseButtonCode::ByEnum id) { } 105 110 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) 106 { guiSystem_->injectMouseMove(rel.x, rel.y); }111 { guiSystem_->injectMouseMove(rel.x, rel.y); } 107 112 void mouseScrolled (int abs, int rel) 108 { guiSystem_->injectMouseWheelChange(rel);}113 { guiSystem_->injectMouseWheelChange(rel);} 109 114 110 void tickInput(float dt) { } 111 void tickKey(float dt) { } 112 void tickMouse(float dt) { } 113 114 void loadScenes(); 115 116 //Ogre::SceneManager* emptySceneManager_; 117 Ogre::SceneManager* backgroundSceneManager_; 118 //Ogre::Camera* emptyCamera_; 119 Ogre::Camera* backgroundCamera_; 120 //Ogre::Viewport* viewport_; 121 Ogre::RenderWindow* renderWindow_; 122 CEGUI::OgreCEGUIRenderer* guiRenderer_; 123 CEGUI::ResourceProvider* resourceProvider_; 124 CEGUI::LuaScriptModule* scriptModule_; 125 CEGUI::DefaultLogger* ceguiLogger_; 126 CEGUI::System* guiSystem_; 127 CEGUI::Imageset* backgroundImage_; 128 lua_State* luaState_; 129 130 State state_; 115 void updateInput(float dt) { } 116 void updateKey (float dt) { } 117 void updateMouse(float dt) { } 131 118 132 119 static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button); 133 120 134 static GUIManager* singletonRef_s; 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 static GUIManager* singletonRef_s; //!< Singleton reference to GUIManager 135 132 }; // tolua_export 136 133 } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.