Changeset 6737 for code/branches/gamestates2/src
- Timestamp:
- Apr 16, 2010, 12:22:12 PM (15 years ago)
- Location:
- code/branches/gamestates2/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestates2/src/libraries/core/GUIManager.cc
r6736 r6737 42 42 #include <CEGUISystem.h> 43 43 #include <CEGUIWindow.h> 44 #include <CEGUIWindowManager.h> 44 45 #include <ogreceguirenderer/OgreCEGUIRenderer.h> 45 46 … … 147 148 guiSystem_->injectMousePosition((float)mousePosition.first, (float)mousePosition.second); 148 149 149 // Hide the mouse cursor unless playing in full screen mode 150 if (!GraphicsManager::getInstance().isFullScreen()) 151 CEGUI::MouseCursor::getSingleton().hide(); 152 153 // Initialise the basic Lua code 150 // Initialise the Lua framework and load the schemes 154 151 this->luaState_->doFile("InitialiseGUI.lua"); 152 153 // Create the root nodes 154 this->rootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("MenuWidgets/StaticImage", "AbsoluteRootWindow"); 155 this->rootWindow_->setProperty("FrameEnabled", "False"); 156 this->hudRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "HUDRootWindow"); 157 this->menuRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "MenuRootWindow"); 158 // And connect them 159 CEGUI::System::getSingleton().setGUISheet(this->rootWindow_); 160 this->rootWindow_->addChildWindow(this->hudRootWindow_); 161 this->rootWindow_->addChildWindow(this->menuRootWindow_); 162 163 // Set up the sheet manager in the Lua framework 164 this->luaState_->doFile("SheetManager.lua"); 155 165 } 156 166 … … 203 213 @param str 204 214 reference to string object holding the Lua code which is to be executed 205 206 This function gives total access to the GUI. You can execute ANY Lua code here.207 215 */ 208 216 void GUIManager::executeCode(const std::string& str) … … 217 225 void GUIManager::loadGUI(const std::string& name) 218 226 { 219 this->executeCode("load GUI(\"" + name + "\")");227 this->executeCode("loadSheet(\"" + name + "\")"); 220 228 } 221 229 … … 292 300 } 293 301 294 void GUIManager::setBackground(const std::string& name) 295 { 296 this->executeCode("setBackground(\"" + name + "\")"); 302 void GUIManager::setBackgroundImage(const std::string& imageSet, const std::string imageName) 303 { 304 if (imageSet.empty() || imageName.empty()) 305 this->setBackgroundImage("set: " + imageSet + " image: " + imageName); 306 else 307 this->setBackgroundImage(""); 308 } 309 310 void GUIManager::setBackgroundImage(const std::string& image) 311 { 312 if (image.empty()) 313 this->rootWindow_->setProperty("Alpha", "0.0"); 314 else 315 this->rootWindow_->setProperty("Alpha", "1.0"); 316 this->rootWindow_->setProperty("Image", image); 297 317 } 298 318 -
code/branches/gamestates2/src/libraries/core/GUIManager.h
r6736 r6737 79 79 static void hideGUI(const std::string& name); 80 80 void keyESC(); 81 void setBackground(const std::string& name); 81 void setBackgroundImage(const std::string& imageSet, const std::string imageName); // tolua_export 82 void setBackgroundImage(const std::string& image); 82 83 84 //! Creates a new InputState to be used with a GUI Sheet 83 85 const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export 86 87 //! Returns the root window for all menu sheets 88 CEGUI::Window* getMenuRootWindow() { return this->menuRootWindow_; } // tolua_export 89 //! Returns the root window for all HUD sheets 90 CEGUI::Window* getHUDRootWindow() { return this->hudRootWindow_; } // tolua_export 84 91 85 92 void setCamera(Ogre::Camera* camera); … … 120 127 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider 121 128 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 129 CEGUI::Window* rootWindow_; //!< Root node for all windows 130 CEGUI::Window* hudRootWindow_; //!< Root node for the HUD sheets 131 CEGUI::Window* menuRootWindow_; //!< Root node for the menu sheets (used by Lua) 122 132 std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each GUI 123 133 Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI -
code/branches/gamestates2/src/orxonox/overlays/GUISheet.cc
r6722 r6737 40 40 : BaseObject(creator) 41 41 , bShowOnLoad_(false) 42 , bShowCursor_(true)43 42 , bHidePrevious_(false) 43 , bHidePreviousSet_(false) 44 44 { 45 45 RegisterObject(GUISheet); … … 57 57 SUPER(GUISheet, XMLPort, xmlElement, mode); 58 58 59 XMLPortParam(GUISheet, "showOnLoad", setShowOnLoad, getShowOnLoad, xmlElement, mode); 60 XMLPortParam(GUISheet, "showCursor", setCursorVisibility, getCursorVisibility, xmlElement, mode); 61 XMLPortParam(GUISheet, "hidePrevious", setPreviousHiding, getPreviousHiding, xmlElement, mode); 62 XMLPortParam(GUISheet, "script", setScript, getScript, xmlElement, mode); 59 XMLPortParam(GUISheet, "showOnLoad", setShowOnLoad, getShowOnLoad, xmlElement, mode); 60 XMLPortParam(GUISheet, "hidePrevious", setPreviousHiding, getPreviousHiding, xmlElement, mode); 61 XMLPortParam(GUISheet, "sheetName", setSheetName, getSheetName, xmlElement, mode); 62 XMLPortParam(GUISheet, "backgroundImage", setBackgroundImage, getBackgroundImage, xmlElement, mode); 63 64 if (this->bShowOnLoad_) 65 this->show(); 63 66 } 64 67 65 68 void GUISheet::show() 66 69 { 67 GUIManager::showGUI(this->script_, this->bHidePrevious_); 70 GUIManager::getInstance().setBackgroundImage(this->backgroundImage_); 71 if (this->bHidePreviousSet_) 72 GUIManager::getInstance().showGUI(this->sheetName_, this->bHidePrevious_); 73 else 74 GUIManager::getInstance().showGUI(this->sheetName_); 68 75 } 69 76 70 77 void GUISheet::hide() 71 78 { 72 GUIManager::hideGUI(this->script_); 79 GUIManager::getInstance().hideGUI(this->sheetName_); 80 if (!this->backgroundImage_.empty()) 81 GUIManager::getInstance().setBackgroundImage(""); 73 82 } 74 83 75 void GUISheet::setS cript(const std::string& filename)84 void GUISheet::setSheetName(const std::string& name) 76 85 { 77 this->script_ = filename; 78 GUIManager::getInstance().loadGUI(this->script_); 79 if (this->bShowOnLoad_) 80 this->show(); 81 } 82 83 void GUISheet::setCursorVisibility(bool bShow) 84 { 85 this->bShowCursor_ = bShow; 86 // TODO: This call has no effect when already showing! 86 this->sheetName_ = name; 87 GUIManager::getInstance().loadGUI(this->sheetName_); 87 88 } 88 89 … … 90 91 { 91 92 this->bHidePrevious_ = bHide; 92 // TODO: This call has no effect when already showing! 93 this->bHidePreviousSet_ = true; 94 // Note: This call has no effect when already showing! 93 95 } 94 96 } -
code/branches/gamestates2/src/orxonox/overlays/GUISheet.h
r6595 r6737 49 49 void hide(); 50 50 51 void setS cript(const std::string& filename);52 inline const std::string& getS cript() const53 { return this->s cript_; }51 void setSheetName(const std::string& name); 52 inline const std::string& getSheetName() const 53 { return this->sheetName_; } 54 54 55 55 inline void setShowOnLoad(bool bShow) … … 58 58 { return this->bShowOnLoad_; } 59 59 60 void setCursorVisibility(bool bShow);61 inline bool getCursorVisibility() const62 { return this->bShowCursor_; }63 64 60 void setPreviousHiding(bool bHide); 65 61 inline bool getPreviousHiding() const 66 62 { return this->bHidePrevious_; } 67 63 64 void setBackgroundImage(const std::string& image) 65 { this->backgroundImage_ = image; } 66 inline const std::string& getBackgroundImage() const 67 { return this->backgroundImage_; } 68 68 69 private: 69 std::string s cript_;70 std::string sheetName_; 70 71 bool bShowOnLoad_; 71 bool bShowCursor_;72 72 bool bHidePrevious_; 73 bool bHidePreviousSet_; 74 std::string backgroundImage_; 73 75 }; 74 76 }
Note: See TracChangeset
for help on using the changeset viewer.