Changeset 6003
- Timestamp:
- Oct 28, 2009, 5:58:11 PM (15 years ago)
- Location:
- code/branches/ingamemenu
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ingamemenu/data/gui/layouts/MainMenu.layout
r5781 r6003 6 6 <Property Name="FrameEnabled" Value="set:true"/> 7 7 <Property Name="BackgroundEnabled" Value="set:false"/> 8 <Property Name="InheritsAlpha" Value="False" /> 8 9 9 10 <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton"> -
code/branches/ingamemenu/data/gui/layouts/QuestGUI.layout
r5781 r6003 6 6 <Property Name="FrameEnabled" Value="set:true"/> 7 7 <Property Name="BackgroundEnabled" Value="set:false"/> 8 <Property Name="InheritsAlpha" Value="False" /> 8 9 9 10 <Window Type="TaharezLook/Titlebar" Name="orxonox/QuestGUI/Title"> -
code/branches/ingamemenu/data/gui/scripts/InitialiseGUI.lua
r5781 r6003 14 14 15 15 loadedGUIs = {} 16 root = nil; 16 17 17 18 -- loads the GUI with the specified filename … … 43 44 -- be sure to set the global variable "filename" before calling this function 44 45 function showGUI(filename) 45 if current == nil or current.filename ~= filename then 46 current = loadedGUIs[filename] 47 if current == nil then 48 current = loadGUI(filename) 49 end 50 system:setGUISheet(current.window) 46 if root == nil then 47 root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow") 48 root:setProperty("Alpha", "0.0") 49 root:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0))) 50 system:setGUISheet(root) 51 51 end 52 current:show() 52 53 local currentGUI = loadedGUIs[filename] 54 if(currentGUI == nil) then 55 currentGUI = loadGUI(filename) 56 end 57 58 if(root:isChild(currentGUI.window)) then 59 root:removeChildWindow(currentGUI.window) 60 end 61 root:addChildWindow(currentGUI.window) 62 63 currentGUI:show() 53 64 showing = true 54 return current 55 end 56 57 function toggleGUI() 58 if showing == true then 59 current:hide() 60 cursor:hide() 61 showing = false 62 else 63 current:show() 64 cursor:show() 65 showing = true 66 end 67 return showing 65 return currentGUI 68 66 end 69 67 … … 77 75 78 76 function hideGUI(filename) 79 current = loadedGUIs[filename] 80 if current ~= nil then 81 current:hide() 77 local currentGUI = loadedGUIs[filename] 78 if currentGUI ~= nil then 79 currentGUI:hide() 80 root:removeChildWindow(currentGUI.window) 82 81 showing = false 83 82 end -
code/branches/ingamemenu/src/libraries/core/GUIManager.cc
r5929 r6003 53 53 #include "util/Exception.h" 54 54 #include "util/OrxAssert.h" 55 #include "ConsoleCommand.h" 55 56 #include "Core.h" 57 #include "input/InputManager.h" 56 58 #include "LuaState.h" 57 59 #include "PathConfig.h" … … 86 88 GUIManager* GUIManager::singletonPtr_s = 0; 87 89 90 SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User); 91 SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User); 92 88 93 /** 89 94 @brief … … 204 209 For more details check out loadGUI_2.lua where the function presides. 205 210 */ 206 void GUIManager::showGUI(const std::string& name) 207 { 208 this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_); 211 /*static*/ void GUIManager::showGUI(const std::string& name) 212 { 213 std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name); 214 if(result.second == false) //!< GUI already showing. 215 return; 216 if(GUIManager::getInstance().showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI. 217 { 218 GUIManager::getInstance().executeCode("showCursor()"); 219 InputManager::getInstance().enterState("guiMouseOnly"); 220 } 221 GUIManager::getInstance().executeCode("showGUI(\"" + name + "\")"); 222 } 223 224 /** 225 @brief 226 Hack-ish. Needed for GUIOverlay. 227 */ 228 void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr) 229 { 230 std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name); 231 if(result.second == false) //!< GUI already showing. 232 return; 233 if(this->showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI. 234 { 235 this->executeCode("showCursor()"); 236 InputManager::getInstance().enterState("guiMouseOnly"); 237 } 238 this->executeCode("showGUI(\"" + name + "\", " + ptr + ")"); 239 } 240 241 /** 242 @brief 243 Hides specified GUI. 244 @param name 245 The name of the GUI. 246 */ 247 /*static*/ void GUIManager::hideGUI(const std::string& name) 248 { 249 bool present = GUIManager::getInstance().showingGUIs_.erase(name); 250 if(!present) //!< If there was nothing to erase. 251 return; 252 GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")"); 253 if(GUIManager::getInstance().showingGUIs_.size() == 0) 254 { 255 GUIManager::getInstance().executeCode("hideCursor()"); 256 InputManager::getInstance().leaveState("guiMouseOnly"); 257 } 209 258 } 210 259 -
code/branches/ingamemenu/src/libraries/core/GUIManager.h
r5929 r6003 34 34 35 35 #include <map> 36 #include <set> 36 37 #include <string> 37 38 #include <CEGUIForwardRefs.h> … … 65 66 ~GUIManager(); 66 67 67 void update(const Clock& time); 68 void update(const Clock& time); 68 69 69 void showGUI(const std::string& name); 70 void executeCode(const std::string& str); 70 static void showGUI(const std::string& name); 71 void showGUIExtra(const std::string& name, const std::string& ptr); 72 static void hideGUI(const std::string& name); 71 73 72 74 void setCamera(Ogre::Camera* camera); … … 82 84 private: 83 85 GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class) 86 87 std::set<std::string> showingGUIs_; //!< Keeps track of all the GUIs that are currently showing. 88 89 void executeCode(const std::string& str); 84 90 85 91 // keyHandler functions -
code/branches/ingamemenu/src/modules/overlays/GUIOverlay.cc
r5980 r6003 73 73 out << reinterpret_cast<long>(this); 74 74 str = out.str(); 75 GUIManager::getInstance().executeCode("showCursor()"); 76 InputManager::getInstance().enterState("guiMouseOnly"); 77 GUIManager::getInstance().executeCode("showGUI(\"" + this->guiName_ + "\", " + str + ")"); 75 COUT(1) << "GUIManager ptr: " << str << std::endl; 76 GUIManager::getInstance().showGUIExtra(this->guiName_, str); 78 77 79 78 COUT(3) << "Showing GUI " << this->guiName_ << std::endl; … … 81 80 else 82 81 { 83 GUIManager::getInstance().executeCode("hideGUI(\"" + this->guiName_ + "\")"); 84 GUIManager::getInstance().executeCode("hideCursor()"); 85 InputManager::getInstance().leaveState("guiMouseOnly"); 82 GUIManager::hideGUI(this->guiName_); 86 83 COUT(3) << "Hiding GUI " << this->guiName_ << std::endl; 87 84 } -
code/branches/ingamemenu/src/orxonox/gamestates/GSGraphics.cc
r5929 r6003 64 64 void GSGraphics::activate() 65 65 { 66 // add console command to toggle GUI 67 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI")); 66 68 67 } 69 68 … … 78 77 } 79 78 80 /**81 @brief82 Toggles the visibility of the current GUI83 84 This function just executes a Lua function in the main script of the GUI by accessing the GUIManager.85 For more details on this function check out the Lua code.86 */87 void GSGraphics::toggleGUI()88 {89 GUIManager::getInstance().executeCode("toggleGUI()");90 }91 92 79 void GSGraphics::update(const Clock& time) 93 80 { -
code/branches/ingamemenu/src/orxonox/gamestates/GSGraphics.h
r5929 r6003 57 57 void update(const Clock& time); 58 58 59 void toggleGUI();60 61 59 private: 62 60 }; -
code/branches/ingamemenu/src/orxonox/gamestates/GSLevel.cc
r5966 r6003 101 101 if (show) 102 102 { 103 GUIManager::getInstance().showGUI("inGameTest"); 104 GUIManager::getInstance().executeCode("showCursor()"); 105 InputManager::getInstance().enterState("guiMouseOnly"); 103 GUIManager::showGUI("inGameTest"); 106 104 } 107 105 else 108 106 { 109 GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")"); 110 GUIManager::getInstance().executeCode("hideCursor()"); 111 InputManager::getInstance().leaveState("guiMouseOnly"); 107 GUIManager::hideGUI("inGameTest"); 112 108 } 113 109 } -
code/branches/ingamemenu/src/orxonox/gamestates/GSMainMenu.cc
r5929 r6003 82 82 { 83 83 // show main menu 84 GUIManager:: getInstance().showGUI("MainMenu");84 GUIManager::showGUI("MainMenu"); 85 85 GUIManager::getInstance().setCamera(this->camera_); 86 86 GraphicsManager::getInstance().setCamera(this->camera_); … … 111 111 112 112 InputManager::getInstance().leaveState("mainMenu"); 113 GUIManager::hideGUI("MainMenu"); 113 114 114 115 GUIManager::getInstance().setCamera(0); -
code/branches/ingamemenu/src/orxonox/pickup/PickupInventory.cc
r5781 r6003 86 86 { 87 87 if(PickupInventory::getSingleton()->isVisible()) { 88 GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")"); 89 GUIManager::getInstance().executeCode("hideCursor()"); 90 InputManager::getInstance().leaveState("guiMouseOnly"); 91 } 92 else 93 { 94 GUIManager::getInstance().showGUI("PickupInventory"); 95 GUIManager::getInstance().executeCode("showCursor()"); 96 InputManager::getInstance().enterState("guiMouseOnly"); 88 GUIManager::hideGUI("PickupInventory"); 89 } 90 else 91 { 92 GUIManager::showGUI("PickupInventory"); 97 93 } 98 94 PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible()); -
code/branches/ingamemenu/src/orxonox/pickup/PickupSpawner.cc
r5929 r6003 96 96 // & load the GUI itself too, along with some empty windows 97 97 // = even less delays 98 GUIManager:: getInstance().showGUI("PickupInventory");99 GUIManager:: getInstance().executeCode("hideGUI(\"PickupInventory\")");98 GUIManager::showGUI("PickupInventory"); 99 GUIManager::hideGUI("PickupInventory"); 100 100 PickupInventory::getSingleton(); 101 101 }
Note: See TracChangeset
for help on using the changeset viewer.