Changeset 6595 for code/branches/gamestates2/src
- Timestamp:
- Mar 22, 2010, 2:47:10 PM (15 years ago)
- Location:
- code/branches/gamestates2
- Files:
-
- 21 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestates2
- Property svn:mergeinfo changed
/code/branches/gamestate merged: 6441-6442,6459,6537,6544-6546,6548,6564,6566-6567,6569,6571-6572
- Property svn:mergeinfo changed
-
code/branches/gamestates2/src/libraries/core/Core.cc
r6417 r6595 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/gamestates2/src/libraries/core/Core.h
r6417 r6595 38 38 #include "util/ScopeGuard.h" 39 39 #include "util/Singleton.h" 40 #include " core/OrxonoxClass.h"40 #include "OrxonoxClass.h" 41 41 42 42 namespace orxonox -
code/branches/gamestates2/src/libraries/core/GUIManager.cc
r6502 r6595 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((float)mousePosition.first, (float)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((float)mousePosition.first, (float)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 … … 208 210 } 209 211 212 /** Loads a GUI sheet by Lua script 213 @param name 214 The name of the GUI (like the script name, but without the extension) 215 */ 216 void GUIManager::loadGUI(const std::string& name) 217 { 218 this->executeCode("loadGUI(\"" + name + "\")"); 219 } 220 210 221 /** 211 222 @brief … … 240 251 { 241 252 GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")"); 253 } 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(); 242 279 } 243 280 -
code/branches/gamestates2/src/libraries/core/GUIManager.h
r6417 r6595 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 69 74 void preUpdate(const Clock& time); 70 75 76 void loadGUI(const std::string& name); 71 77 static void showGUI(const std::string& name, bool hidePrevious=false, bool showCursor=true); 72 78 void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true); … … 75 81 void setBackground(const std::string& name); 76 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 77 85 void setCamera(Ogre::Camera* camera); 78 86 Ogre::Camera* getCamera() { return this->camera_; } 79 80 static GUIManager* getInstancePtr() { return singletonPtr_s; }81 87 82 88 inline void setPlayer(const std::string& guiname, PlayerInfo* player) … … 87 93 // TODO: Temporary hack because the tolua exported CEGUI method does not seem to work 88 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 89 97 90 98 private: … … 102 110 void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize); 103 111 void mouseScrolled (int abs, int rel); 104 105 112 scoped_ptr<CEGUI::OgreCEGUIRenderer> guiRenderer_; //!< CEGUI's interface to the Ogre Engine 106 113 scoped_ptr<LuaState> luaState_; //!< LuaState, access point to the Lua engine … … 108 115 scoped_ptr<CEGUI::System> guiSystem_; //!< CEGUI's main system 109 116 shared_ptr<ResourceInfo> rootFileInfo_; //!< Resource information about the root script 110 Ogre::RenderWindow* renderWindow_; //!< Ogre's render window to give CEGUI access to it111 117 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider 112 118 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 113 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 114 120 Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI 115 121 116 122 static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager 117 bool bShowIngameGUI_;118 123 119 124 }; // tolua_export -
code/branches/gamestates2/src/libraries/core/Game.h
r6417 r6595 50 50 #include "util/ScopeGuard.h" 51 51 #include "util/Singleton.h" 52 #include " core/OrxonoxClass.h"52 #include "OrxonoxClass.h" 53 53 54 54 /** -
code/branches/gamestates2/src/libraries/core/IOConsole.cc
r6422 r6595 35 35 #include "util/Clock.h" 36 36 #include "util/Math.h" 37 #include " core/Game.h"38 #include " core/input/InputBuffer.h"37 #include "Game.h" 38 #include "input/InputBuffer.h" 39 39 40 40 // ########################## -
code/branches/gamestates2/src/libraries/core/IOConsole.h
r6417 r6595 37 37 #include <vector> 38 38 #include "util/Singleton.h" 39 #include " core/Shell.h"39 #include "Shell.h" 40 40 41 41 #ifdef ORXONOX_PLATFORM_UNIX -
code/branches/gamestates2/src/libraries/core/LuaState.h
r6417 r6595 40 40 41 41 #include "util/ScopeGuard.h" 42 #include " core/Functor.h"42 #include "Functor.h" 43 43 #include "ToluaInterface.h" 44 44 -
code/branches/gamestates2/src/libraries/core/Template.cc
r6417 r6595 33 33 34 34 #include "util/Debug.h" 35 #include " core/CoreIncludes.h"36 #include " core/XMLPort.h"35 #include "CoreIncludes.h" 36 #include "XMLPort.h" 37 37 38 38 namespace orxonox -
code/branches/gamestates2/src/libraries/core/input/InputManager.cc
r6422 r6595 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/gamestates2/src/libraries/core/input/InputManager.h
r6417 r6595 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/gamestates2/src/libraries/core/input/InputState.cc
r6417 r6595 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/gamestates2/src/libraries/core/input/InputState.h
r5929 r6595 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/gamestates2/src/libraries/network/TrafficControl.h
r6417 r6595 34 34 #include <list> 35 35 #include <map> 36 #include " network/ClientConnectionListener.h"36 #include "ClientConnectionListener.h" 37 37 38 38 namespace orxonox { -
code/branches/gamestates2/src/libraries/util/Serialise.h
r6417 r6595 35 35 #define _Serialise_H__ 36 36 37 #include "UtilPrereqs.h" 38 37 39 #include <cstring> 38 #include " util/Math.h"39 #include " util/mbool.h"40 #include "Math.h" 41 #include "mbool.h" 40 42 41 43 namespace orxonox{ -
code/branches/gamestates2/src/modules/questsystem/QuestGUI.cc
r6417 r6595 109 109 110 110 //! Create root window. 111 this->rootWindow_ = this->windowManager_->createWindow(" TaharezLook/ScrollablePane", "QuestGUI/Quests");111 this->rootWindow_ = this->windowManager_->createWindow("MenuWidgets/ScrollablePane", "QuestGUI/Quests"); 112 112 this->rootWindow_->setSize(CEGUI::UVector2(CEGUI::UDim(1, 0),CEGUI::UDim(1, 0))); 113 113 … … 161 161 Get a CEGUI Window to use. 162 162 Windows that are no longer used are collected with giveWindow, and are given out again with getWindow, so save some time recreating new windows everytime. 163 The retreived window is of type " TaharezLook/TabButton".164 @return 165 Returns a CEGUI Window of type " TaharezLook/TabButton".163 The retreived window is of type "MenuWidgets/TabButton". 164 @return 165 Returns a CEGUI Window of type "MenuWidgets/TabButton". 166 166 */ 167 167 CEGUI::Window* QuestGUI::getWindow(void) … … 177 177 std::ostringstream stream; 178 178 stream << "QuestGUI/Quests/EmptyWindows/" << this->windows_.size()+1; 179 return this->windowManager_->createWindow(" TaharezLook/TabButton", stream.str());179 return this->windowManager_->createWindow("MenuWidgets/TabButton", stream.str()); 180 180 } 181 181 -
code/branches/gamestates2/src/modules/questsystem/QuestGUINode.cc
r6502 r6595 160 160 stream << this->window_->getName() << "/Details"; 161 161 const QuestDescription* description = this->item_->getDescription(); 162 this->details_ = this->gui_->getWindowManager()->createWindow(" TaharezLook/FrameWindow", stream.str());162 this->details_ = this->gui_->getWindowManager()->createWindow("MenuWidgets/FrameWindow", stream.str()); 163 163 this->details_->setSize(CEGUI::UVector2(CEGUI::UDim(0.7f, 0),CEGUI::UDim(0.7f, 0))); 164 164 this->details_->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1f, 0),CEGUI::UDim(0.1f, 0))); … … 171 171 //! Create a ScrollablePane. 172 172 stream << "/Scrollable"; 173 CEGUI::Window* window = this->gui_->getWindowManager()->createWindow(" TaharezLook/ScrollablePane", stream.str());173 CEGUI::Window* window = this->gui_->getWindowManager()->createWindow("MenuWidgets/ScrollablePane", stream.str()); 174 174 window->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -2*QuestGUINode::BORDER_WIDTH),CEGUI::UDim(1.0, -QuestGUINode::TITLE_HEIGHT))); 175 175 window->setPosition(CEGUI::UVector2(CEGUI::UDim(0, (float)QuestGUINode::BORDER_WIDTH),CEGUI::UDim(0, (float)QuestGUINode::TITLE_HEIGHT))); … … 185 185 stream.str(""); 186 186 stream << this->details_->getName() << "/Status"; 187 CEGUI::Window* statusWindow = this->gui_->getWindowManager()->createWindow(" TaharezLook/StaticText", stream.str());187 CEGUI::Window* statusWindow = this->gui_->getWindowManager()->createWindow("MenuWidgets/StaticText", stream.str()); 188 188 window->addChildWindow(statusWindow); 189 189 std::string status; … … 214 214 stream << this->details_->getName() << "/Description"; 215 215 stream << "/Title"; 216 CEGUI::Window* descriptionWindowTitle = this->gui_->getWindowManager()->createWindow(" TaharezLook/StaticText", stream.str());216 CEGUI::Window* descriptionWindowTitle = this->gui_->getWindowManager()->createWindow("MenuWidgets/StaticText", stream.str()); 217 217 window->addChildWindow(descriptionWindowTitle); 218 218 descriptionWindowTitle->setProperty("HorzFormatting", "HorzCentred"); … … 227 227 stream.str(""); 228 228 stream << this->details_->getName() << "/Description"; 229 CEGUI::Window* descriptionWindow = this->gui_->getWindowManager()->createWindow(" TaharezLook/StaticText", stream.str());229 CEGUI::Window* descriptionWindow = this->gui_->getWindowManager()->createWindow("MenuWidgets/StaticText", stream.str()); 230 230 window->addChildWindow(descriptionWindow); 231 231 descriptionWindow->setProperty("HorzFormatting", "WordWrapLeftAligned"); … … 250 250 stream.str(""); 251 251 stream << this->details_->getName() << "/Hints/Title"; 252 CEGUI::Window* hintsTitle = this->gui_->getWindowManager()->createWindow(" TaharezLook/StaticText", stream.str());252 CEGUI::Window* hintsTitle = this->gui_->getWindowManager()->createWindow("MenuWidgets/StaticText", stream.str()); 253 253 window->addChildWindow(hintsTitle); 254 254 hintsTitle->setProperty("HorzFormatting", "HorzCentred"); -
code/branches/gamestates2/src/orxonox/gamestates/GSLevel.cc
r6417 r6595 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/gamestates2/src/orxonox/gamestates/GSMainMenu.cc
r6417 r6595 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); -
code/branches/gamestates2/src/orxonox/overlays/CMakeLists.txt
r5929 r6595 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 GUISheet.cc 2 3 OrxonoxOverlay.cc 3 4 OverlayGroup.cc
Note: See TracChangeset
for help on using the changeset viewer.