Changeset 3327 for code/trunk/src/orxonox
- Timestamp:
- Jul 19, 2009, 5:31:02 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 1 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core4 merged: 3269,3271-3275,3278,3285,3290-3294,3310
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/GraphicsManager.cc
r3323 r3327 63 63 #include "core/Game.h" 64 64 #include "core/GameMode.h" 65 #include "core/WindowEventListener.h" 65 66 #include "tools/ParticleInterface.h" 66 #include "interfaces/WindowEventListener.h"67 67 68 68 // HACK! … … 73 73 using boost::shared_ptr; 74 74 75 class _OrxonoxExport OgreWindowEventListener : public Ogre::WindowEventListener 76 { 77 void windowResized (Ogre::RenderWindow* rw); 78 void windowFocusChange (Ogre::RenderWindow* rw); 79 void windowClosed (Ogre::RenderWindow* rw); 80 //void windowMoved (Ogre::RenderWindow* rw); 75 class OgreWindowEventListener : public Ogre::WindowEventListener 76 { 77 public: 78 void windowResized (Ogre::RenderWindow* rw) 79 { orxonox::WindowEventListener::resizeWindow(rw->getWidth(), rw->getHeight()); } 80 void windowFocusChange (Ogre::RenderWindow* rw) 81 { orxonox::WindowEventListener::changeWindowFocus(); } 82 void windowClosed (Ogre::RenderWindow* rw) 83 { orxonox::Game::getInstance().stop(); } 84 void windowMoved (Ogre::RenderWindow* rw) 85 { orxonox::WindowEventListener::moveWindow(); } 81 86 }; 82 87 … … 347 352 348 353 this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox"); 354 this->ogreWindowEventListener_->windowResized(renderWindow_); 349 355 350 356 Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, ogreWindowEventListener_); … … 418 424 this->renderWindow_->writeContentsToTimestampedFile(Core::getLogPathString() + "screenShot_", ".jpg"); 419 425 } 420 421 422 /****** OgreWindowEventListener ******/423 424 void OgreWindowEventListener::windowResized(Ogre::RenderWindow* rw)425 {426 for (ObjectList<orxonox::WindowEventListener>::iterator it427 = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)428 it->windowResized(rw->getWidth(), rw->getHeight());429 }430 void OgreWindowEventListener::windowFocusChange(Ogre::RenderWindow* rw)431 {432 for (ObjectList<orxonox::WindowEventListener>::iterator it433 = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)434 it->windowFocusChanged();435 }436 void OgreWindowEventListener::windowClosed(Ogre::RenderWindow* rw)437 {438 Game::getInstance().stop();439 }440 426 } -
code/trunk/src/orxonox/OrxonoxPrereqs.h
r3280 r3327 92 92 class Level; 93 93 class Scene; 94 class Tickable; 94 95 95 96 class AddQuest; -
code/trunk/src/orxonox/gamestates/GSGraphics.cc
r3280 r3327 38 38 #include <OgreRenderWindow.h> 39 39 40 #include " core/ConfigValueIncludes.h"40 #include "util/Convert.h" 41 41 #include "core/Clock.h" 42 #include "core/CommandExecutor.h" 42 43 #include "core/ConsoleCommand.h" 43 44 #include "core/Core.h" 44 #include "core/CoreIncludes.h"45 45 #include "core/Game.h" 46 46 #include "core/GameMode.h" 47 47 #include "core/input/InputManager.h" 48 48 #include "core/input/KeyBinder.h" 49 #include "core/input/ SimpleInputState.h"49 #include "core/input/InputState.h" 50 50 #include "core/Loader.h" 51 51 #include "core/XMLFile.h" … … 70 70 , debugOverlay_(0) 71 71 { 72 RegisterRootObject(GSGraphics);73 72 } 74 73 75 74 GSGraphics::~GSGraphics() 76 {77 }78 79 /**80 @brief81 this function does nothing82 83 Indeed. Here goes nothing.84 */85 void GSGraphics::setConfigValues()86 75 { 87 76 } … … 106 95 GameMode::setShowsGraphics(true); 107 96 108 setConfigValues();109 110 97 // Load OGRE including the render window 111 98 this->graphicsManager_ = new GraphicsManager(); … … 122 109 123 110 // Calls the InputManager which sets up the input devices. 124 inputManager_ = new InputManager(); 125 inputManager_->initialise(windowHnd, renderWindow->getWidth(), renderWindow->getHeight(), true); 111 inputManager_ = new InputManager(windowHnd); 126 112 127 113 // load master key bindings 128 masterInputState_ = InputManager::getInstance().createInputState <SimpleInputState>("master", true);114 masterInputState_ = InputManager::getInstance().createInputState("master", true); 129 115 masterKeyBinder_ = new KeyBinder(); 130 116 masterKeyBinder_->loadBindings("masterKeybindings.ini"); … … 136 122 // Load the InGameConsole 137 123 console_ = new InGameConsole(); 138 console_->initialise( renderWindow->getWidth(), renderWindow->getHeight());124 console_->initialise(); 139 125 140 126 // load the CEGUI interface … … 149 135 150 136 // enable master input 151 InputManager::getInstance(). requestEnterState("master");137 InputManager::getInstance().enterState("master"); 152 138 } 153 139 … … 169 155 170 156 masterInputState_->setHandler(0); 171 InputManager::getInstance(). requestDestroyState("master");157 InputManager::getInstance().destroyState("master"); 172 158 delete this->masterKeyBinder_; 173 159 … … 232 218 this->graphicsManager_->update(time); 233 219 } 234 235 /**236 @brief237 Window has resized.238 @param rw239 The render window it occured in240 @note241 GraphicsManager has a render window stored itself. This is the same242 as rw. But we have to be careful when using multiple render windows!243 */244 void GSGraphics::windowResized(unsigned int newWidth, unsigned int newHeight)245 {246 // OIS needs this under linux even if we only use relative input measurement.247 if (this->inputManager_)248 this->inputManager_->setWindowExtents(newWidth, newHeight);249 }250 251 /**252 @brief253 Window focus has changed.254 @param rw255 The render window it occured in256 */257 void GSGraphics::windowFocusChanged()258 {259 // instruct InputManager to clear the buffers (core library so we cannot use the interface)260 if (this->inputManager_)261 this->inputManager_->clearBuffers();262 }263 264 220 } -
code/trunk/src/orxonox/gamestates/GSGraphics.h
r3280 r3327 37 37 38 38 #include "OrxonoxPrereqs.h" 39 40 39 #include "core/GameState.h" 41 #include "interfaces/WindowEventListener.h"42 40 43 41 namespace orxonox … … 49 47 This game state is only left out if we start a dedicated server where no graphics are present. 50 48 */ 51 class _OrxonoxExport GSGraphics : public GameState , public WindowEventListener49 class _OrxonoxExport GSGraphics : public GameState 52 50 { 53 51 public: 54 52 GSGraphics(const GameStateConstrParams& params); 55 53 ~GSGraphics(); 56 void setConfigValues();57 54 58 55 void activate(); … … 63 60 64 61 private: 65 // Window events from WindowEventListener66 void windowResized(unsigned int newWidth, unsigned int newHeight);67 void windowFocusChanged();68 69 62 // managed singletons 70 63 InputManager* inputManager_; //!< Reference to input management … … 75 68 76 69 KeyBinder* masterKeyBinder_; //!< Key binder for master key bindings 77 SimpleInputState*masterInputState_; //!< Special input state for master input70 InputState* masterInputState_; //!< Special input state for master input 78 71 XMLFile* debugOverlay_; 79 72 ConsoleCommand* ccToggleGUI_; //!< Console command to toggle GUI -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r3280 r3327 31 31 32 32 #include "core/input/InputManager.h" 33 #include "core/input/ SimpleInputState.h"33 #include "core/input/InputState.h" 34 34 #include "core/input/KeyBinder.h" 35 35 #include "core/Clock.h" … … 90 90 if (GameMode::showsGraphics()) 91 91 { 92 gameInputState_ = InputManager::getInstance().createInputState <SimpleInputState>("game");92 gameInputState_ = InputManager::getInstance().createInputState("game"); 93 93 keyBinder_ = new KeyBinder(); 94 94 keyBinder_->loadBindings("keybindings.ini"); 95 95 gameInputState_->setHandler(keyBinder_); 96 96 97 guiMouseOnlyInputState_ = InputManager::getInstance().createInputState <SimpleInputState>("guiMouseOnly");97 guiMouseOnlyInputState_ = InputManager::getInstance().createInputState("guiMouseOnly"); 98 98 guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr()); 99 99 100 guiKeysOnlyInputState_ = InputManager::getInstance().createInputState <SimpleInputState>("guiKeysOnly");100 guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly"); 101 101 guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr()); 102 102 … … 134 134 135 135 // level is loaded: we can start capturing the input 136 InputManager::getInstance(). requestEnterState("game");136 InputManager::getInstance().enterState("game"); 137 137 } 138 138 } … … 144 144 GUIManager::getInstance().showGUI("inGameTest"); 145 145 GUIManager::getInstance().executeCode("showCursor()"); 146 InputManager::getInstance(). requestEnterState("guiMouseOnly");146 InputManager::getInstance().enterState("guiMouseOnly"); 147 147 } 148 148 else … … 150 150 GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")"); 151 151 GUIManager::getInstance().executeCode("hideCursor()"); 152 InputManager::getInstance(). requestLeaveState("guiMouseOnly");152 InputManager::getInstance().leaveState("guiMouseOnly"); 153 153 } 154 154 } … … 178 178 179 179 if (GameMode::showsGraphics()) 180 InputManager::getInstance(). requestLeaveState("game");180 InputManager::getInstance().leaveState("game"); 181 181 182 182 if (GameMode::isMaster()) … … 218 218 guiMouseOnlyInputState_->setHandler(0); 219 219 guiKeysOnlyInputState_->setHandler(0); 220 InputManager::getInstance(). requestDestroyState("game");220 InputManager::getInstance().destroyState("game"); 221 221 if (this->keyBinder_) 222 222 { … … 286 286 { 287 287 COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl; 288 InputManager::getInstance(). requestEnterState("detector");288 InputManager::getInstance().enterState("detector"); 289 289 bindingString = command; 290 290 bTemporarySaved = bTemporary; … … 301 301 COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl; 302 302 this->keyBinder_->setBinding(bindingString, name, bTemporarySaved); 303 InputManager::getInstance(). requestLeaveState("detector");303 InputManager::getInstance().leaveState("detector"); 304 304 bound = true; 305 305 } -
code/trunk/src/orxonox/gamestates/GSLevel.h
r3280 r3327 63 63 64 64 KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings 65 SimpleInputState*gameInputState_; //!< input state for normal ingame playing66 SimpleInputState*guiMouseOnlyInputState_; //!< input state if we only need the mouse to use the GUI67 SimpleInputState*guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI65 InputState* gameInputState_; //!< input state for normal ingame playing 66 InputState* guiMouseOnlyInputState_; //!< input state if we only need the mouse to use the GUI 67 InputState* guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI 68 68 Radar* radar_; //!< represents the Radar (not the HUD part) 69 69 CameraManager* cameraManager_; //!< camera manager for this level -
code/trunk/src/orxonox/gamestates/GSMainMenu.cc
r3280 r3327 32 32 33 33 #include "core/input/InputManager.h" 34 #include "core/input/ SimpleInputState.h"34 #include "core/input/InputState.h" 35 35 #include "core/Game.h" 36 36 #include "core/Clock.h" … … 57 57 void GSMainMenu::activate() 58 58 { 59 inputState_ = InputManager::getInstance().createInputState <SimpleInputState>("mainMenu");59 inputState_ = InputManager::getInstance().createInputState("mainMenu"); 60 60 inputState_->setHandler(GUIManager::getInstancePtr()); 61 inputState_->setJoyStickHandler(&Input Manager::EMPTY_HANDLER);61 inputState_->setJoyStickHandler(&InputHandler::EMPTY); 62 62 63 63 // create an empty Scene … … 96 96 } 97 97 98 InputManager::getInstance(). requestEnterState("mainMenu");98 InputManager::getInstance().enterState("mainMenu"); 99 99 100 100 this->ambient_ = new SoundMainMenu(); … … 106 106 delete this->ambient_; 107 107 108 InputManager::getInstance(). requestLeaveState("mainMenu");109 InputManager::getInstance(). requestDestroyState("mainMenu");108 InputManager::getInstance().leaveState("mainMenu"); 109 InputManager::getInstance().destroyState("mainMenu"); 110 110 111 111 GUIManager::getInstance().setCamera(0); -
code/trunk/src/orxonox/gamestates/GSMainMenu.h
r3280 r3327 53 53 54 54 private: 55 SimpleInputState*inputState_;55 InputState* inputState_; 56 56 Scene* scene_; 57 57 Ogre::Camera* camera_; -
code/trunk/src/orxonox/gui/GUIManager.cc
r3287 r3327 69 69 void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard) 70 70 { 71 int orxonoxLevel ;71 int orxonoxLevel = CEGUI::Standard; 72 72 switch (level) 73 73 { … … 366 366 void GUIManager::keyPressed(const KeyEvent& evt) 367 367 { 368 guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); 368 guiSystem_->injectKeyDown(evt.getKeyCode()); 369 guiSystem_->injectChar(evt.getText()); 369 370 } 370 371 void GUIManager::keyReleased(const KeyEvent& evt) 371 372 { 372 guiSystem_->injectKeyUp(evt. key);373 guiSystem_->injectKeyUp(evt.getKeyCode()); 373 374 } 374 375 … … 382 383 It is for CEGUI to process the event. 383 384 */ 384 void GUIManager:: mouseButtonPressed(MouseButtonCode::ByEnum id)385 void GUIManager::buttonPressed(MouseButtonCode::ByEnum id) 385 386 { 386 387 try … … 404 405 It is for CEGUI to process the event. 405 406 */ 406 void GUIManager:: mouseButtonReleased(MouseButtonCode::ByEnum id)407 void GUIManager::buttonReleased(MouseButtonCode::ByEnum id) 407 408 { 408 409 try -
code/trunk/src/orxonox/gui/GUIManager.h
r3280 r3327 44 44 45 45 #include "util/OgreForwardRefs.h" 46 #include "core/input/Input Interfaces.h"46 #include "core/input/InputHandler.h" 47 47 48 48 // tolua_begin … … 62 62 class _OrxonoxExport GUIManager 63 63 // tolua_end 64 : public KeyHandler, public MouseHandler64 : public InputHandler 65 65 // tolua_begin 66 66 { … … 106 106 void keyPressed (const KeyEvent& evt); 107 107 void keyReleased(const KeyEvent& evt); 108 void keyHeld (const KeyEvent& evt) { }109 108 110 109 // mouseHandler functions 111 void mouseButtonPressed (MouseButtonCode::ByEnum id); 112 void mouseButtonReleased(MouseButtonCode::ByEnum id); 113 void mouseButtonHeld (MouseButtonCode::ByEnum id) { } 114 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize); 115 void mouseScrolled (int abs, int rel); 116 117 void updateInput(float dt) { } 118 void updateKey (float dt) { } 119 void updateMouse(float dt) { } 110 void buttonPressed (MouseButtonCode::ByEnum id); 111 void buttonReleased(MouseButtonCode::ByEnum id); 112 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize); 113 void mouseScrolled (int abs, int rel); 120 114 121 115 Ogre::RenderWindow* renderWindow_; //!< Ogre's render window to give CEGUI access to it -
code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
r3196 r3327 40 40 #include "Tickable.h" 41 41 #include "TimeFactorListener.h" 42 #include "WindowEventListener.h"43 42 44 43 #include "core/CoreIncludes.h" … … 103 102 104 103 //---------------------------- 105 // WindowEventListener106 //----------------------------107 /**108 @brief Constructor for the WindowEventListener.109 */110 WindowEventListener::WindowEventListener()111 {112 RegisterRootObject(WindowEventListener);113 }114 115 //----------------------------116 104 // Rewardable 117 105 //---------------------------- -
code/trunk/src/orxonox/objects/pickup/PickupInventory.cc
r3196 r3327 88 88 GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")"); 89 89 GUIManager::getInstance().executeCode("hideCursor()"); 90 InputManager::getInstance(). requestLeaveState("guiMouseOnly");90 InputManager::getInstance().leaveState("guiMouseOnly"); 91 91 } 92 92 else … … 94 94 GUIManager::getInstance().showGUI("PickupInventory"); 95 95 GUIManager::getInstance().executeCode("showCursor()"); 96 InputManager::getInstance(). requestEnterState("guiMouseOnly");96 InputManager::getInstance().enterState("guiMouseOnly"); 97 97 } 98 98 PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible()); -
code/trunk/src/orxonox/overlays/GUIOverlay.cc
r3301 r3327 70 70 str = out.str(); 71 71 GUIManager::getInstance().executeCode("showCursor()"); 72 InputManager::getInstance(). requestEnterState("guiMouseOnly");72 InputManager::getInstance().enterState("guiMouseOnly"); 73 73 GUIManager::getInstance().executeCode("showGUI(\"" + this->guiName_ + "\", " + str + ")"); 74 74 } … … 77 77 GUIManager::getInstance().executeCode("hideGUI(\"" + this->guiName_ + "\")"); 78 78 GUIManager::getInstance().executeCode("hideCursor()"); 79 InputManager::getInstance(). requestLeaveState("guiMouseOnly");79 InputManager::getInstance().leaveState("guiMouseOnly"); 80 80 } 81 81 } -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r3301 r3327 47 47 #include "core/XMLPort.h" 48 48 #include "core/ConsoleCommand.h" 49 #include "GraphicsManager.h"50 49 51 50 namespace orxonox … … 81 80 82 81 // Get aspect ratio from the render window. Later on, we get informed automatically 83 Ogre::RenderWindow* defaultWindow = GraphicsManager::getInstance().getRenderWindow(); 84 this->windowAspectRatio_ = static_cast<float>(defaultWindow->getWidth()) / defaultWindow->getHeight(); 82 this->windowAspectRatio_ = static_cast<float>(this->getWindowWidth()) / this->getWindowHeight(); 85 83 this->sizeCorrectionChanged(); 86 84 -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r3196 r3327 42 42 #include "util/OgreForwardRefs.h" 43 43 #include "core/BaseObject.h" 44 #include " interfaces/WindowEventListener.h"44 #include "core/WindowEventListener.h" 45 45 46 46 namespace orxonox -
code/trunk/src/orxonox/overlays/console/InGameConsole.cc
r3301 r3327 49 49 #include "core/ConsoleCommand.h" 50 50 #include "core/input/InputManager.h" 51 #include "core/input/ SimpleInputState.h"51 #include "core/input/InputState.h" 52 52 #include "core/input/InputBuffer.h" 53 53 … … 98 98 99 99 // destroy the input state previously created (InputBuffer gets destroyed by the Shell) 100 InputManager::getInstance(). requestDestroyState("console");100 InputManager::getInstance().destroyState("console"); 101 101 102 102 Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr(); … … 158 158 if (bHidesAllInput_) 159 159 { 160 inputState_->setMouseHandler(&Input Manager::EMPTY_HANDLER);161 inputState_->setJoyStickHandler(&Input Manager::EMPTY_HANDLER);160 inputState_->setMouseHandler(&InputHandler::EMPTY); 161 inputState_->setJoyStickHandler(&InputHandler::EMPTY); 162 162 } 163 163 else … … 172 172 @brief Initializes the InGameConsole. 173 173 */ 174 void InGameConsole::initialise( int windowWidth, int windowHeight)174 void InGameConsole::initialise() 175 175 { 176 176 // create the corresponding input state 177 inputState_ = InputManager::getInstance().createInputState <SimpleInputState>("console", false, false, InputStatePriority::Console);177 inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console); 178 178 inputState_->setKeyHandler(Shell::getInstance().getInputBuffer()); 179 179 bHidesAllInputChanged(); … … 248 248 this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_); 249 249 250 this->windowResized( windowWidth, windowHeight);250 this->windowResized(this->getWindowWidth(), this->getWindowWidth()); 251 251 252 252 // move overlay "above" the top edge of the screen … … 507 507 { 508 508 this->bActive_ = true; 509 InputManager::getInstance(). requestEnterState("console");509 InputManager::getInstance().enterState("console"); 510 510 Shell::getInstance().registerListener(this); 511 511 … … 529 529 { 530 530 this->bActive_ = false; 531 InputManager::getInstance(). requestLeaveState("console");531 InputManager::getInstance().leaveState("console"); 532 532 Shell::getInstance().unregisterListener(this); 533 533 -
code/trunk/src/orxonox/overlays/console/InGameConsole.h
r3196 r3327 36 36 #include "util/OgreForwardRefs.h" 37 37 #include "core/Shell.h" 38 #include " interfaces/WindowEventListener.h"38 #include "core/WindowEventListener.h" 39 39 40 40 namespace orxonox … … 46 46 ~InGameConsole(); 47 47 48 void initialise( int windowWidth, int windowHeight);48 void initialise(); 49 49 void destroy(); 50 50 void setConfigValues(); … … 101 101 102 102 // input related 103 SimpleInputState* inputState_;103 InputState* inputState_; 104 104 105 105 // config values
Note: See TracChangeset
for help on using the changeset viewer.