Changeset 6537
- Timestamp:
- Mar 16, 2010, 1:49:16 PM (15 years ago)
- Location:
- code/branches/gamestate
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestate/data/gui/scripts/BasicGUI.lua
r6459 r6537 8 8 end 9 9 10 -- useless ?10 -- useless, even wrong? P is the class, not the object.. 11 11 P.overlay = nil 12 12 13 13 -- constructor of the GUI 14 function P:new(_filename, _ visible, _gui)14 function P:new(_filename, _gui, _visible) 15 15 local newElement = { 16 16 filename = _filename, … … 23 23 end 24 24 25 -- Override this function if you need to 25 26 function P:init() 26 -- this function is empty and intended for inheriting GUIs to use 27 end 28 29 -- Override this function if you need to 30 -- But don't forget to stick to the naming convention ("GUI_" .. self.filename) 31 function P:createInputState() 32 self.inputState = guiMgr:createInputState("GUI_" .. self.filename) 27 33 end 28 34 … … 41 47 function P:load() 42 48 self.window = winMgr:loadWindowLayout(self.filename .. ".layout") 49 self:createInputState() 43 50 self:init() 44 51 return self -
code/branches/gamestate/data/gui/scripts/DecisionPopup.lua
r6459 r6537 7 7 else 8 8 _G[_REQUIREDNAME] = P 9 end10 11 function P:init()12 9 end 13 10 -
code/branches/gamestate/data/gui/scripts/InGameMenu.lua
r6459 r6537 8 8 _G[_REQUIREDNAME] = P 9 9 end 10 11 12 function P:init()13 end14 15 10 16 11 -- events for ingamemenu -
code/branches/gamestate/data/gui/scripts/InfoPopup.lua
r6459 r6537 8 8 else 9 9 _G[_REQUIREDNAME] = P 10 end11 12 function P:init()13 10 end 14 11 … … 23 20 end 24 21 25 function P.setText( text)22 function P.setText(text) 26 23 winMgr:getWindow("orxonox/InfoPopup_text"):setText( text ) 27 24 end … … 39 36 -- events for ingamemenu 40 37 function P.close(e) 41 hideGUI( "InfoPopup")38 hideGUI(P.filename) 42 39 end 43 40 -
code/branches/gamestate/data/gui/scripts/InitialiseGUI.lua
r6417 r6537 1 winMgr = CEGUI.WindowManager:getSingleton() 2 guiMgr = orxonox.GUIManager:getInstance() 3 inputMgr = orxonox.InputManager:getInstance() 4 1 5 local schemeMgr = CEGUI.SchemeManager:getSingleton() 2 winMgr = CEGUI.WindowManager:getSingleton() 3 local logger = CEGUI.Logger:getSingleton() 4 local system = CEGUI.System:getSingleton() 5 local cursor = CEGUI.MouseCursor:getSingleton() 6 local system = CEGUI.System:getSingleton() 7 local cursor = CEGUI.MouseCursor:getSingleton() 6 8 7 9 schemeMgr:loadScheme("TaharezLookSkin.scheme") … … 87 89 else 88 90 if nrOfActiveSheets == 0 then 89 orxonox.InputManager:getInstance():enterState("guiMouseOnly")91 --orxonox.InputManager:getInstance():enterState("guiMouseOnly") 90 92 orxonox.HumanController:pauseControl() 91 93 end 92 94 end 95 orxonox.InputManager:getInstance():enterState(currentGUI.inputState) 96 93 97 nrOfActiveSheets = nrOfActiveSheets + 1 94 98 table.insert(activeSheets, filename) … … 161 165 bHidePrevious[filename] = nil 162 166 if nrOfActiveSheets == 0 then 163 orxonox.InputManager:getInstance():leaveState("guiMouseOnly")167 --orxonox.InputManager:getInstance():leaveState("guiMouseOnly") 164 168 orxonox.HumanController:resumeControl() 165 169 hideCursor() 166 170 end 171 orxonox.InputManager:getInstance():leaveState(currentGUI.inputState) 167 172 end 168 173 -
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() -
code/branches/gamestate/src/orxonox/gamestates/GSLevel.cc
r6417 r6537 69 69 { 70 70 gameInputState_ = InputManager::getInstance().createInputState("game"); 71 gameInputState_->setMouse Mode(MouseMode::Exclusive);71 gameInputState_->setMouseExclusive(TriBool::True); 72 72 gameInputState_->setHandler(KeyBinderManager::getInstance().getDefaultAsHandler()); 73 73 KeyBinderManager::getInstance().setToDefault(); 74 74 75 75 guiMouseOnlyInputState_ = InputManager::getInstance().createInputState("guiMouseOnly"); 76 guiMouseOnlyInputState_->setMouse Mode(MouseMode::Exclusive);77 guiMouseOnlyInputState_->setMouseHandler( GUIManager::getInstancePtr());76 guiMouseOnlyInputState_->setMouseExclusive(TriBool::True); 77 guiMouseOnlyInputState_->setMouseHandler(&GUIManager::getInstance()); 78 78 79 79 guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly"); 80 guiKeysOnlyInputState_->setKeyHandler( GUIManager::getInstancePtr());80 guiKeysOnlyInputState_->setKeyHandler(&GUIManager::getInstance()); 81 81 } 82 82 -
code/branches/gamestate/src/orxonox/gamestates/GSMainMenu.cc
r6417 r6537 53 53 RegisterRootObject(GSMainMenu); 54 54 inputState_ = InputManager::getInstance().createInputState("mainMenu"); 55 inputState_->setMouse Mode(MouseMode::Nonexclusive);56 inputState_->setHandler( GUIManager::getInstancePtr());55 inputState_->setMouseExclusive(TriBool::False); 56 inputState_->setHandler(&GUIManager::getInstance()); 57 57 inputState_->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler()); 58 58 inputState_->setJoyStickHandler(&InputHandler::EMPTY); … … 101 101 102 102 KeyBinderManager::getInstance().setToDefault(); 103 InputManager::getInstance().enterState("mainMenu");103 //InputManager::getInstance().enterState("mainMenu"); 104 104 105 105 this->setConfigValues(); … … 119 119 } 120 120 121 InputManager::getInstance().leaveState("mainMenu");121 //InputManager::getInstance().leaveState("mainMenu"); 122 122 123 123 GUIManager::getInstance().setCamera(0);
Note: See TracChangeset
for help on using the changeset viewer.