Changeset 2875 for code/branches/gui/src/orxonox
- Timestamp:
- Mar 31, 2009, 2:14:09 PM (16 years ago)
- Location:
- code/branches/gui/src/orxonox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
r2869 r2875 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ... 26 * 25 * Benjamin Knecht 26 * 27 */ 28 29 /** 30 @file 31 @brief Implementation of Graphics GameState class. 27 32 */ 28 33 … … 71 76 } 72 77 78 /** 79 @brief 80 this function does nothing 81 82 Indeed. Here goes nothing. 83 */ 73 84 void GSGraphics::setConfigValues() 74 85 { 75 86 } 76 87 88 /** 89 @brief 90 This function is called when we enter this game state. 91 92 Since graphics is very important for our game this function does quite a lot: 93 \li starts graphics manager 94 \li loads debug overlay 95 \li manages render window 96 \li creates input manager 97 \li loads master key bindings 98 \li loads ingame console 99 \li loads GUI interface (GUIManager) 100 \li creates console command to toggle GUI 101 */ 77 102 void GSGraphics::activate() 78 103 { … … 90 115 Loader::open(debugOverlay_); 91 116 92 // Calls the InputManager which sets up the input devices.93 117 // The render window width and height are used to set up the mouse movement. 94 inputManager_ = new InputManager();95 118 size_t windowHnd = 0; 96 119 Ogre::RenderWindow* renderWindow = GraphicsManager::getInstance().getRenderWindow(); 97 120 renderWindow->getCustomAttribute("WINDOW", &windowHnd); 121 122 // Calls the InputManager which sets up the input devices. 123 inputManager_ = new InputManager(); 98 124 inputManager_->initialise(windowHnd, renderWindow->getWidth(), renderWindow->getHeight(), true); 99 125 126 // load master key bindings 100 127 masterInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("master", true); 101 128 masterKeyBinder_ = new KeyBinder(); … … 111 138 guiManager_->initialise(renderWindow); 112 139 140 // add console command to toggle GUI 113 141 FunctorMember<GSGraphics>* functor = createFunctor(&GSGraphics::toggleGUI); 114 142 functor->setObject(this); … … 116 144 CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_); 117 145 118 146 // enable master input 119 147 InputManager::getInstance().requestEnterState("master"); 120 148 } 121 149 150 /** 151 @brief 152 This function is called when the game state is left 153 154 Created references, input states and console commands are deleted. 155 */ 122 156 void GSGraphics::deactivate() 123 157 { … … 147 181 } 148 182 183 /** 184 @brief 185 Toggles the visibility of the current GUI 186 187 This function just executes a Lua function in the main script of the GUI by accessing the GUIManager. 188 For more details on this function check out the Lua code. 189 */ 149 190 void GSGraphics::toggleGUI() 150 191 { -
code/branches/gui/src/orxonox/gamestates/GSGraphics.h
r2869 r2875 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Benjamin Knecht (documentation) 26 26 * 27 27 */ 28 29 /** 30 @file 31 @brief Declaration of the Graphics GameState class. 32 */ 28 33 29 34 #ifndef _GSGraphics_H__ … … 36 41 namespace orxonox 37 42 { 43 /** 44 @class GSGraphics 45 @brief 46 Game state used when displaying graphics of any kind 47 48 This game state is only left out if we start a dedicated server where no graphics are present. 49 */ 38 50 class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener 39 51 { … … 55 67 56 68 // managed singletons 57 InputManager* inputManager_; 69 InputManager* inputManager_; //!< Reference to input management 58 70 InGameConsole* console_; 59 GUIManager* guiManager_; 60 GraphicsManager* graphicsManager_; 71 GUIManager* guiManager_; //!< Interface to GUI 72 GraphicsManager* graphicsManager_; //!< Interface to Ogre 61 73 62 KeyBinder* masterKeyBinder_; 63 SimpleInputState* masterInputState_; 74 KeyBinder* masterKeyBinder_; //!< Key binder for master key bindings 75 SimpleInputState* masterInputState_; //!< Special input state for master input 64 76 XMLFile* debugOverlay_; 65 ConsoleCommand* ccToggleGUI_; 77 ConsoleCommand* ccToggleGUI_; //!< Console command to toggle GUI 66 78 }; 67 79 } -
code/branches/gui/src/orxonox/gamestates/GSLevel.cc
r2869 r2875 24 24 * Co-authors: 25 25 * Fabian 'x3n' Landau 26 * Benjamin Knecht 26 27 * 27 28 */ … … 56 57 57 58 SetCommandLineArgument(level, "presentation.oxw").shortcut("l"); 58 SetConsoleCommand(GSLevel, showIngameGUI, true) .keybindMode(KeybindMode::OnPress).keybindMode(KeybindMode::OnRelease);59 SetConsoleCommand(GSLevel, showIngameGUI, true); 59 60 60 61 GSLevel::GSLevel(const std::string& name) -
code/branches/gui/src/orxonox/gamestates/GSLevel.h
r2869 r2875 23 23 * Reto Grieder 24 24 * Co-authors: 25 * ...25 * Benjamin Knecht 26 26 * 27 27 */ … … 64 64 Radar* radar_; //!< represents the Radar (not the HUD part) 65 65 XMLFile* startFile_; //!< current hard coded default level 66 CameraManager* cameraManager_; 67 LevelManager* levelManager_; 68 PlayerManager* playerManager_; 66 CameraManager* cameraManager_; //!< camera manager for this level 67 LevelManager* levelManager_; //!< global level manager 68 PlayerManager* playerManager_; //!< player manager for this level 69 69 70 70 //##### ConfigValues ##### -
code/branches/gui/src/orxonox/gui/GUIManager.cc
r2869 r2875 22 22 * Author: 23 23 * Reto Grieder 24 * Benjamin Knecht 24 25 * Co-authors: 25 * Benjamin Knecht26 * 26 27 * 27 28 */ … … 75 76 } 76 77 78 /** 79 @brief 80 Deconstructor of the GUIManager 81 82 Basically shuts down CEGUI and destroys the Lua engine and afterwards the interface to the Ogre engine. 83 */ 77 84 GUIManager::~GUIManager() 78 85 { … … 96 103 } 97 104 105 /** 106 @brief 107 Initialises the GUIManager by starting up CEGUI 108 @param renderWindow 109 Ogre's render window. Without this, the GUI cannot be displayed. 110 @return true if success, otherwise false 111 112 Before this call the GUIManager won't do anything, but can be accessed. 113 114 Creates the interface to Ogre, sets up the CEGUI renderer and the Lua script module together with the Lua engine. 115 The log is set up and connected to the CEGUILogger. 116 After Lua setup tolua++-elements are linked to Lua-state to give Lua access to C++-code. 117 Finally initial Lua code is executed (maybe we can do this with the CEGUI startup script automatically). 118 */ 98 119 bool GUIManager::initialise(Ogre::RenderWindow* renderWindow) 99 120 { … … 151 172 } 152 173 174 /** 175 @brief 176 Calls main Lua script 177 @todo 178 Replace loadGUI.lua with loadGUI_2.lua after merging this back to trunk. 179 However CEGUI is able to execute a startup script. We could maybe put this call in this startup code. 180 181 This function calls the main Lua script for our GUI. 182 183 Additionally we set the datapath variable in Lua. This is needed so Lua can access the data used for the GUI. 184 */ 153 185 void GUIManager::loadLuaCode() 154 186 { 155 187 try 156 188 { 189 // call main Lua script 157 190 this->scriptModule_->executeScriptFile("loadGUI_2.lua", "GUI"); 191 // set datapath for GUI data 158 192 lua_pushfstring(this->scriptModule_->getLuaState(), Core::getMediaPathString().c_str()); 159 193 lua_setglobal(this->scriptModule_->getLuaState(), "datapath"); … … 170 204 } 171 205 206 /** 207 @brief 208 used to tick the GUI 209 @param time 210 clock which provides time value for the GUI System 211 212 Ticking the GUI means updating it with a certain regularity. 213 The elapsed time since the last call is given in the time value provided by the clock. 214 This time value is then used to provide a fluent animation of the GUI. 215 */ 172 216 void GUIManager::update(const Clock& time) 173 217 { … … 176 220 } 177 221 222 /** 223 @brief 224 Executes Lua code 225 @param str 226 reference to string object holding the Lua code which is to be executed 227 228 This function gives total access to the GUI. You can execute ANY Lua code here. 229 */ 178 230 void GUIManager::executeCode(const std::string& str) 179 231 { … … 181 233 } 182 234 235 /** 236 @brief 237 Tells the GUIManager which SceneManager to use 238 @param camera 239 The current camera on which the GUI should be displayed on. 240 241 In fact the GUIManager needs the SceneManager and not the Camera to display the GUI. 242 This means the GUI is not bound to a camera but rather to the SceneManager. 243 Hidding the GUI when needed can therefore not be solved by just NOT setting the current camera. 244 */ 183 245 void GUIManager::setCamera(Ogre::Camera* camera) 184 246 { … … 186 248 } 187 249 250 /** 251 @brief 252 Debug function to give CEGUI the possibility to output on our console 253 @param 254 String to be displaed in CEGUI's name 255 256 This function should be removed as it only provides a quick (and dirty) possibility to access the output on the console. 257 CEGUI's output should be put into the cegui.log using the CEGUI Logger. 258 */ 188 259 void GUIManager::testOutput(std::string& str) 189 260 { … … 191 262 } 192 263 264 /** 265 @brief 266 Displays specified GUI on screen 267 @param name 268 The name of the GUI 269 270 The function executes the Lua function with the same name in case the GUIManager is ready. 271 For more details check out loadGUI_2.lua where the function presides. 272 */ 193 273 void GUIManager::showGUI(const std::string& name) 194 274 { … … 215 295 } 216 296 297 /** 298 @brief 299 Function receiving a mouse button pressed event. 300 @param id 301 ID of the mouse button which got pressed 302 303 This function is inherited by MouseHandler and injects the event into CEGUI. 304 It is for CEGUI to process the event. 305 */ 217 306 void GUIManager::mouseButtonPressed(MouseButtonCode::ByEnum id) 218 307 { … … 228 317 } 229 318 319 /** 320 @brief 321 Function receiving a mouse button released event. 322 @param id 323 ID of the mouse button which got released 324 325 This function is inherited by MouseHandler and injects the event into CEGUI. 326 It is for CEGUI to process the event. 327 */ 230 328 void GUIManager::mouseButtonReleased(MouseButtonCode::ByEnum id) 231 329 { … … 241 339 } 242 340 243 341 /** 342 @brief 343 converts mouse event code to CEGUI event code 344 @param button 345 code of the mouse button as we use it in Orxonox 346 @return 347 code of the mouse button as it is used by CEGUI 348 349 Simple convertion from mouse event code in Orxonox to the one used in CEGUI. 350 */ 244 351 inline CEGUI::MouseButton GUIManager::convertButton(MouseButtonCode::ByEnum button) 245 352 { -
code/branches/gui/src/orxonox/gui/GUIManager.h
r2853 r2875 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 … … 84 95 85 96 private: 86 GUIManager(const GUIManager& instance); 97 GUIManager(const GUIManager& instance); //!< private constructor (this is a singleton class) 87 98 88 99 void loadLuaCode(); 89 100 101 // keyHandler functions 90 102 void keyPressed (const KeyEvent& evt) 91 { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }103 { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); } 92 104 void keyReleased(const KeyEvent& evt) 93 { guiSystem_->injectKeyUp(evt.key); } 94 void keyHeld (const KeyEvent& evt) 95 { } 105 { guiSystem_->injectKeyUp(evt.key); } 106 void keyHeld (const KeyEvent& evt) { } 96 107 108 // mouseHandler functions 97 109 void mouseButtonPressed (MouseButtonCode::ByEnum id); 98 110 void mouseButtonReleased(MouseButtonCode::ByEnum id); 99 void mouseButtonHeld (MouseButtonCode::ByEnum id) 100 { } 111 void mouseButtonHeld (MouseButtonCode::ByEnum id) { } 101 112 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) 102 { guiSystem_->injectMouseMove(rel.x, rel.y); }113 { guiSystem_->injectMouseMove(rel.x, rel.y); } 103 114 void mouseScrolled (int abs, int rel) 104 { guiSystem_->injectMouseWheelChange(rel);}115 { guiSystem_->injectMouseWheelChange(rel);} 105 116 106 void updateInput(float dt) { } 107 void updateKey(float dt) { } 108 void updateMouse(float dt) { } 109 110 Ogre::RenderWindow* renderWindow_; 111 CEGUI::OgreCEGUIRenderer* guiRenderer_; 112 CEGUI::ResourceProvider* resourceProvider_; 113 CEGUI::LuaScriptModule* scriptModule_; 114 CEGUI::DefaultLogger* ceguiLogger_; 115 CEGUI::System* guiSystem_; 116 CEGUI::Imageset* backgroundImage_; 117 lua_State* luaState_; 118 119 State state_; 117 void updateInput(float dt) { } 118 void updateKey (float dt) { } 119 void updateMouse(float dt) { } 120 120 121 121 static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button); 122 122 123 static GUIManager* singletonRef_s; 123 Ogre::RenderWindow* renderWindow_; //!< Ogre's render window to give CEGUI access to it 124 CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine 125 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider 126 CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua 127 CEGUI::DefaultLogger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 128 CEGUI::System* guiSystem_; //!< CEGUI's main system 129 lua_State* luaState_; //!< Lua state, access point to the Lua engine 130 131 State state_; //!< reflects state of the GUIManager 132 133 static GUIManager* singletonRef_s; //!< Singleton reference to GUIManager 124 134 }; // tolua_export 125 135 } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.