Changeset 6537 for code/branches/gamestate/src/libraries
- Timestamp:
- Mar 16, 2010, 1:49:16 PM (15 years ago)
- Location:
- code/branches/gamestate/src/libraries
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestate/src/libraries/core/Core.cc
r6417 r6537 225 225 226 226 // Load the CEGUI interface 227 guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow(), 228 inputManager_->getMousePosition(), graphicsManager_->isFullScreen())); 227 guiManager_.reset(new GUIManager(inputManager_->getMousePosition())); 229 228 230 229 bGraphicsLoaded_ = true; -
code/branches/gamestate/src/libraries/core/GUIManager.cc
r6441 r6537 57 57 #include "ConsoleCommand.h" 58 58 #include "Core.h" 59 #include "GraphicsManager.h" 59 60 #include "LuaState.h" 60 61 #include "PathConfig.h" 61 62 #include "Resource.h" 63 #include "input/InputManager.h" 64 #include "input/InputState.h" 65 #include "input/KeyBinderManager.h" 62 66 63 67 namespace orxonox … … 108 112 @return true if success, otherwise false 109 113 */ 110 GUIManager::GUIManager(Ogre::RenderWindow* renderWindow, const std::pair<int, int>& mousePosition, bool bFullScreen) 111 : renderWindow_(renderWindow) 112 , resourceProvider_(0) 114 GUIManager::GUIManager(const std::pair<int, int>& mousePosition) 115 : resourceProvider_(NULL) 113 116 , camera_(NULL) 114 , bShowIngameGUI_(false)115 117 { 116 118 using namespace CEGUI; … … 119 121 120 122 // Note: No SceneManager specified yet 121 guiRenderer_.reset(new OgreCEGUIRenderer( renderWindow_, Ogre::RENDER_QUEUE_OVERLAY, false, 3000));123 guiRenderer_.reset(new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000)); 122 124 resourceProvider_ = guiRenderer_->createResourceProvider(); 123 125 resourceProvider_->setDefaultResourceGroup("GUI"); … … 141 143 guiSystem_.reset(new System(guiRenderer_.get(), resourceProvider_, 0, scriptModule_.get())); 142 144 145 // Align CEGUI mouse with OIS mouse 146 guiSystem_->injectMousePosition(mousePosition.first, mousePosition.second); 147 148 // Hide the mouse cursor unless playing in full screen mode 149 if (!GraphicsManager::getInstance().isFullScreen()) 150 CEGUI::MouseCursor::getSingleton().hide(); 151 143 152 // Initialise the basic Lua code 144 153 this->luaState_->doFile("InitialiseGUI.lua"); 145 146 // Align CEGUI mouse with OIS mouse147 guiSystem_->injectMousePosition(mousePosition.first, mousePosition.second);148 149 // Hide the mouse cursor unless playing in full screen mode150 if (!bFullScreen)151 CEGUI::MouseCursor::getSingleton().hide();152 154 } 153 155 … … 251 253 } 252 254 255 const std::string& GUIManager::createInputState(const std::string& name, TriBool::Value showMouse, TriBool::Value useKeyboard, bool bBlockJoyStick) 256 { 257 InputState* state = InputManager::getInstance().createInputState(name); 258 259 if (GraphicsManager::getInstance().isFullScreen() && showMouse == TriBool::True || 260 !GraphicsManager::getInstance().isFullScreen() && showMouse == TriBool::False) 261 state->setMouseExclusive(TriBool::True); 262 else 263 state->setMouseExclusive(TriBool::Dontcare); 264 265 if (showMouse == TriBool::True) 266 state->setMouseHandler(this); 267 else if (showMouse == TriBool::False) 268 state->setMouseHandler(&InputHandler::EMPTY); 269 270 if (useKeyboard == TriBool::True) 271 state->setKeyHandler(this); 272 else if (useKeyboard == TriBool::False) 273 state->setKeyHandler(&InputHandler::EMPTY); 274 275 if (bBlockJoyStick) 276 state->setJoyStickHandler(&InputHandler::EMPTY); 277 278 return state->getName(); 279 } 280 253 281 void GUIManager::keyESC() 254 282 { -
code/branches/gamestate/src/libraries/core/GUIManager.h
r6441 r6537 41 41 42 42 #include "util/OgreForwardRefs.h" 43 #include "util/TriBool.h" 43 44 #include "util/Singleton.h" 44 45 #include "input/InputHandler.h" 46 47 // Tolua includes (have to be relative to the current directory) 48 /* 49 $cfile "../util/TriBool.h" // tolua_export 50 */ 45 51 46 52 namespace orxonox // tolua_export … … 54 60 55 61 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 62 58 63 Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler. … … 64 69 friend class Singleton<GUIManager>; 65 70 public: 66 GUIManager( Ogre::RenderWindow* renderWindow, const std::pair<int, int>& mousePosition, bool bFullScreen);71 GUIManager(const std::pair<int, int>& mousePosition); 67 72 ~GUIManager(); 68 73 … … 76 81 void setBackground(const std::string& name); 77 82 83 const std::string& createInputState(const std::string& name, TriBool::Value showMouse = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export 84 78 85 void setCamera(Ogre::Camera* camera); 79 86 Ogre::Camera* getCamera() { return this->camera_; } 80 81 static GUIManager* getInstancePtr() { return singletonPtr_s; }82 87 83 88 inline void setPlayer(const std::string& guiname, PlayerInfo* player) … … 88 93 // TODO: Temporary hack because the tolua exported CEGUI method does not seem to work 89 94 static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); //tolua_export 95 96 static GUIManager& getInstance() { return Singleton<GUIManager>::getInstance(); } // tolua_export 90 97 91 98 private: … … 103 110 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize); 104 111 void mouseScrolled (int abs, int rel); 105 106 112 scoped_ptr<CEGUI::OgreCEGUIRenderer> guiRenderer_; //!< CEGUI's interface to the Ogre Engine 107 113 scoped_ptr<LuaState> luaState_; //!< LuaState, access point to the Lua engine … … 109 115 scoped_ptr<CEGUI::System> guiSystem_; //!< CEGUI's main system 110 116 shared_ptr<ResourceInfo> rootFileInfo_; //!< Resource information about the root script 111 Ogre::RenderWindow* renderWindow_; //!< Ogre's render window to give CEGUI access to it112 117 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider 113 118 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 114 std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each gui119 std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each GUI 115 120 Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI 116 121 117 122 static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager 118 bool bShowIngameGUI_;119 123 120 124 }; // tolua_export -
code/branches/gamestate/src/libraries/core/input/InputManager.cc
r6422 r6537 87 87 , oisInputManager_(0) 88 88 , devices_(2) 89 , mouseMode_(MouseMode::Nonexclusive)89 , exclusiveMouse_(TriBool::False) 90 90 , emptyState_(0) 91 91 , calibratorCallbackHandler_(0) … … 98 98 99 99 if (GraphicsManager::getInstance().isFullScreen()) 100 mouseMode_ = MouseMode::Exclusive;100 exclusiveMouse_ = TriBool::True; 101 101 this->loadDevices(); 102 102 … … 155 155 paramList.insert(std::make_pair("w32_keyboard", "DISCL_FOREGROUND")); 156 156 paramList.insert(std::make_pair("w32_mouse", "DISCL_FOREGROUND")); 157 if ( mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen())157 if (exclusiveMouse_ == TriBool::True || GraphicsManager::getInstance().isFullScreen()) 158 158 { 159 159 // Disable Windows key plus special keys (like play, stop, next, etc.) … … 168 168 paramList.insert(std::make_pair("XAutoRepeatOn", "true")); 169 169 170 if ( mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen())170 if (exclusiveMouse_ == TriBool::True || GraphicsManager::getInstance().isFullScreen()) 171 171 { 172 172 if (CommandLineParser::getValue("keyboard_no_grab").getBool()) … … 504 504 505 505 // Check whether we have to change the mouse mode 506 MouseMode::Value requestedMode = MouseMode::Dontcare;506 TriBool::Value requestedMode = TriBool::Dontcare; 507 507 std::vector<InputState*>& mouseStates = devices_[InputDeviceEnumerator::Mouse]->getStateListRef(); 508 508 if (mouseStates.empty()) 509 requestedMode = MouseMode::Nonexclusive;509 requestedMode = TriBool::False; 510 510 else 511 requestedMode = mouseStates.front()->getMouse Mode();512 if (requestedMode != MouseMode::Dontcare && mouseMode_ != requestedMode)513 { 514 mouseMode_ = requestedMode;511 requestedMode = mouseStates.front()->getMouseExclusive(); 512 if (requestedMode != TriBool::Dontcare && exclusiveMouse_ != requestedMode) 513 { 514 exclusiveMouse_ = requestedMode; 515 515 if (!GraphicsManager::getInstance().isFullScreen()) 516 516 this->reloadInternal(); -
code/branches/gamestate/src/libraries/core/input/InputManager.h
r6417 r6537 38 38 39 39 #include "util/Singleton.h" 40 #include "util/TriBool.h" 40 41 #include "core/WindowEventListener.h" 41 42 #include "InputState.h" … … 159 160 - The removal process is being postponed if InputManager::preUpdate() is currently running. 160 161 */ 161 bool destroyState(const std::string& name); 162 bool destroyState(const std::string& name); // tolua_export 162 163 163 164 //------------------------------- … … 196 197 OIS::InputManager* oisInputManager_; //!< OIS input manager 197 198 std::vector<InputDevice*> devices_; //!< List of all input devices (keyboard, mouse, joy sticks) 198 MouseMode::Value mouseMode_;//!< Currently applied mouse mode199 TriBool::Value exclusiveMouse_; //!< Currently applied mouse mode 199 200 200 201 // some internally handled states and handlers -
code/branches/gamestate/src/libraries/core/input/InputState.cc
r6417 r6537 37 37 , bAlwaysGetsInput_(bAlwaysGetsInput) 38 38 , bTransparent_(bTransparent) 39 , mouseMode_(MouseMode::Dontcare)39 , exclusiveMouse_(TriBool::Dontcare) 40 40 , bExpired_(true) 41 41 , handlers_(2) -
code/branches/gamestate/src/libraries/core/input/InputState.h
r5929 r6537 37 37 38 38 #include "util/OrxEnum.h" 39 #include "util/TriBool.h" 39 40 #include "InputHandler.h" 40 41 #include "JoyStickQuantityListener.h" … … 56 57 }; 57 58 58 namespace MouseMode59 {60 enum Value61 {62 Exclusive,63 Nonexclusive,64 Dontcare65 };66 }67 59 68 60 /** … … 73 65 that stack and only the top one gets the input events. This is done for 74 66 every device (keyboard, mouse, all joy sticks) separately to allow 75 for in tance keyboard input capturing for the console while you can still67 for instance keyboard input capturing for the console while you can still 76 68 steer a ship with the mouse. 77 69 There are two exceptions to this behaviour though: … … 83 75 the state will always receive input as long as it is activated. 84 76 - Note: If you mark an InputState with both parameters on, then it will 85 not influence on y other InputState at all.77 not influence only other InputState at all. 86 78 87 79 @par Priorities … … 95 87 @par Exclusive/Non-Exclusive mouse Mode 96 88 You can select a specific mouse mode that tells whether the application 97 should have exclusive access to it or not.89 should have exclusive access to it or not. 98 90 When in non-exclusive mode, you can move the mouse out of the window 99 91 like with any other normal window (only for windowed mode!). … … 130 122 void setHandler (InputHandler* handler); 131 123 132 void setMouse Mode(MouseMode::Value value) { mouseMode_ = value; this->bExpired_ = true; }133 MouseMode::Value getMouseMode() const { return mouseMode_; }124 void setMouseExclusive(TriBool::Value value) { exclusiveMouse_ = value; this->bExpired_ = true; } 125 TriBool::Value getMouseExclusive() const { return exclusiveMouse_; } 134 126 135 127 //! Returns the name of the state (which is unique!) … … 184 176 const bool bAlwaysGetsInput_; //!< See class declaration for explanation 185 177 const bool bTransparent_; //!< See class declaration for explanation 186 MouseMode::Value mouseMode_;//!< See class declaration for explanation178 TriBool::Value exclusiveMouse_; //!< See class declaration for explanation 187 179 int priority_; //!< Current priority (might change) 188 180 bool bExpired_; //!< See hasExpired()
Note: See TracChangeset
for help on using the changeset viewer.