Changeset 2907 for code/branches/questsystem5/src/orxonox/gui/GUIManager.h
- Timestamp:
- Apr 8, 2009, 12:36:08 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/gui/GUIManager.h
r2710 r2907 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 tick(float dt)73 {74 assert(guiSystem_);75 guiSystem_->injectTimePulse(dt);76 }77 void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export78 void hideGUI(); // tolua_export79 83 80 Ogre::Camera* getCamera() { return this->backgroundCamera_; }84 void update(const Clock& time); 81 85 82 static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)83 {84 getInstance().showGUI(name, sceneManager); 85 }86 void showGUI(const std::string& name); 87 void executeCode(const std::string& str); 88 89 void setCamera(Ogre::Camera* camera); 86 90 87 91 static GUIManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export … … 89 93 90 94 private: 91 GUIManager(const GUIManager& instance); 95 GUIManager(const GUIManager& instance); //!< private constructor (this is a singleton class) 92 96 97 void loadLuaCode(); 98 99 // keyHandler functions 93 100 void keyPressed (const KeyEvent& evt) 94 { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }101 { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); } 95 102 void keyReleased(const KeyEvent& evt) 96 { guiSystem_->injectKeyUp(evt.key); } 97 void keyHeld (const KeyEvent& evt) 98 { } 103 { guiSystem_->injectKeyUp(evt.key); } 104 void keyHeld (const KeyEvent& evt) { } 99 105 106 // mouseHandler functions 100 107 void mouseButtonPressed (MouseButtonCode::ByEnum id); 101 108 void mouseButtonReleased(MouseButtonCode::ByEnum id); 102 void mouseButtonHeld (MouseButtonCode::ByEnum id) 103 { } 109 void mouseButtonHeld (MouseButtonCode::ByEnum id) { } 104 110 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) 105 { guiSystem_->injectMouseMove(rel.x, rel.y); }111 { guiSystem_->injectMouseMove(rel.x, rel.y); } 106 112 void mouseScrolled (int abs, int rel) 107 { guiSystem_->injectMouseWheelChange(rel);}113 { guiSystem_->injectMouseWheelChange(rel);} 108 114 109 void tickInput(float dt) { } 110 void tickKey(float dt) { } 111 void tickMouse(float dt) { } 112 113 void loadScenes(); 114 115 //Ogre::SceneManager* emptySceneManager_; 116 Ogre::SceneManager* backgroundSceneManager_; 117 //Ogre::Camera* emptyCamera_; 118 Ogre::Camera* backgroundCamera_; 119 //Ogre::Viewport* viewport_; 120 Ogre::RenderWindow* renderWindow_; 121 CEGUI::OgreCEGUIRenderer* guiRenderer_; 122 CEGUI::ResourceProvider* resourceProvider_; 123 CEGUI::LuaScriptModule* scriptModule_; 124 CEGUI::DefaultLogger* ceguiLogger_; 125 CEGUI::System* guiSystem_; 126 CEGUI::Imageset* backgroundImage_; 127 lua_State* luaState_; 128 129 State state_; 115 void updateInput(float dt) { } 116 void updateKey (float dt) { } 117 void updateMouse(float dt) { } 130 118 131 119 static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button); 132 120 133 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 134 132 }; // tolua_export 135 133 } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.