Changeset 6032
- Timestamp:
- Nov 4, 2009, 5:30:38 PM (15 years ago)
- Location:
- code/branches/menu
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/menu/data/gui/layouts/MainMenu.layout
r6024 r6032 1 1 <?xml version="1.0" ?> 2 2 <GUILayout> 3 <Window Type="TaharezLook/StaticImage" Name="orxonox/Background"> 4 <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/> 5 <Property Name="Image" Value="set:MainMenuBackground image:Background"/> 6 <Property Name="FrameEnabled" Value="set:true"/> 7 <Property Name="BackgroundEnabled" Value="set:false"/> 8 <Property Name="InheritsAlpha" Value="False" /> 9 3 <Window Type="DefaultWindow" Name="orxonox/MainMenuRootWindow"> 4 <Property Name="InheritsAlpha" Value="false"/> 10 5 <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton"> 11 6 <Property Name="UnifiedPosition" Value="{{0.11,0},{0.3,0}}"/> -
code/branches/menu/data/gui/scripts/InitialiseGUI.lua
r6024 r6032 19 19 root = nil 20 20 bShowsCursor = false 21 bHidePrevious = {} 21 22 22 23 -- loads the GUI with the specified filename … … 32 33 if table.getn(loadedGUIs) == 1 then 33 34 current = loadedGUIs[1] 34 showing = false35 35 end 36 36 -- hide new GUI as we do not want to show it accidentially … … 40 40 end 41 41 42 function showGUI(filename, bCursorVisible, ptr)43 gui = showGUI(filename, bCursorVisible)42 function showGUI(filename, hidePrevious, bCursorVisible, ptr) 43 gui = showGUI(filename, hidePrevious, bCursorVisible) 44 44 gui.overlay = ptr 45 45 end … … 47 47 -- shows the specified and loads it if not loaded already 48 48 -- be sure to set the global variable "filename" before calling this function 49 function showGUI(filename, bCursorVisible) 50 -- bCursorVisibile=false 49 function showGUI(filename, hidePrevious, bCursorVisible) 51 50 if bCursorVisible == nil then 52 cursorVisibility= true51 bCursorVisible = true 53 52 end 54 53 55 54 if root == nil then 56 root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow") 57 root:setProperty("Alpha", "0.0") 58 root:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0))) 59 system:setGUISheet(root) 55 setBackground("") 60 56 end 61 57 … … 65 61 end 66 62 63 debug("test") 64 debug(currentGUI.window:getName()) 65 debug(root:isChild(currentGUI.window)) 67 66 if(root:isChild(currentGUI.window)) then 67 debug("removing window") 68 68 root:removeChildWindow(currentGUI.window) 69 69 end … … 75 75 hideCursor() 76 76 end 77 cursorVisibility[filename]=bCursorVisible78 77 78 if find( activeSheets, filename ) ~= nil then 79 table.remove( activeSheets, find( activeSheets, filename ) ) 80 nrOfActiveSheets = nrOfActiveSheets - 1 81 end 79 82 nrOfActiveSheets = nrOfActiveSheets + 1 80 83 table.insert(activeSheets, filename) 81 84 activeSheets[nrOfActiveSheets] = filename 85 bHidePrevious[filename]=hidePrevious 86 cursorVisibility[filename] = bCursorVisible 82 87 88 if hidePrevious == true then 89 for i=1,nrOfActiveSheets-1 do 90 loadedGUIs[ activeSheets[i] ]:hide() 91 end 92 end 83 93 currentGUI:show() 84 showing = true85 94 return currentGUI 86 95 end … … 106 115 end 107 116 currentGUI:hide() 117 if bHidePrevious[filename] == true then 118 local i = nrOfActiveSheets-1 119 while i>0 do 120 loadedGUIs[ activeSheets[i] ]:show() 121 if bHidePrevious[filename]==true then 122 break 123 else 124 i=i-1 125 end 126 end 127 end 108 128 root:removeChildWindow(currentGUI.window) 109 showing = false 110 i=1 129 local i=1 111 130 while activeSheets[i] do 112 131 if activeSheets[i+1] == nil then … … 129 148 end 130 149 cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table 150 bHidePrevious[filename] = nil 131 151 end 152 153 function setBackground(filename) 154 local newroot 155 if root ~= nil then 156 root:rename("oldRootWindow") 157 end 158 if filename ~= "" then 159 newroot = winMgr:loadWindowLayout(filename .. ".layout") 160 newroot:rename("AbsoluteRootWindow") 161 system:setGUISheet(newroot) 162 else 163 newroot = winMgr:createWindow("DefaultWindow", "AbsoluteRootWindow") 164 newroot:setProperty("Alpha", "0.0") 165 newroot:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0))) 166 system:setGUISheet(newroot) 167 end 168 if root ~= nil then 169 local child 170 for i=0,root:getChildCount()-1 do 171 child = root:getChildAtIdx(i) 172 root:removeChildWindow(child) 173 newroot:addChildWindow(child) 174 end 175 winMgr:destroyWindow(root) 176 end 177 newroot:show() 178 root = newroot 179 end 180 181 function find(table, value) 182 local i=0 183 while table[i] ~= nil do 184 if table[i]==value then 185 return i 186 else 187 i=i+1 188 end 189 end 190 return nil 191 end -
code/branches/menu/src/libraries/core/GUIManager.cc
r6024 r6032 89 89 GUIManager* GUIManager::singletonPtr_s = 0; 90 90 91 SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, true);91 SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true); 92 92 SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User); 93 93 … … 210 210 For more details check out loadGUI_2.lua where the function presides. 211 211 */ 212 /*static*/ void GUIManager::showGUI(const std::string& name, bool showCursor)212 /*static*/ void GUIManager::showGUI(const std::string& name, bool hidePrevious, bool showCursor) 213 213 { 214 214 std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name); … … 220 220 InputManager::getInstance().enterState("guiMouseOnly"); 221 221 } 222 GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ")"); 222 COUT(0) << "showGUI" << endl; 223 GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ")"); 223 224 } 224 225 … … 227 228 Hack-ish. Needed for GUIOverlay. 228 229 */ 229 void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor)230 void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious, bool showCursor) 230 231 { 231 232 std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name); … … 237 238 InputManager::getInstance().enterState("guiMouseOnly"); 238 239 } 239 this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>( showCursor) + ", " + ptr + ")");240 this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")"); 240 241 } 241 242 … … 258 259 } 259 260 } 261 262 void GUIManager::setToggleMode(const bool& mode) 263 { 264 this->bToggleMode_ = mode; 265 this->executeCode("setToggleMode(" + multi_cast<std::string>(mode) + ")"); 266 } 267 268 void GUIManager::setBackground(const std::string& name) 269 { 270 this->executeCode("setBackground(\"" + name + "\")"); 271 } 260 272 261 273 void GUIManager::keyPressed(const KeyEvent& evt) -
code/branches/menu/src/libraries/core/GUIManager.h
r6024 r6032 68 68 void update(const Clock& time); 69 69 70 static void showGUI(const std::string& name, bool showCursor=true);71 void showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor=true);70 static void showGUI(const std::string& name, bool hidePrevious=false, bool showCursor=true); 71 void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true); 72 72 static void hideGUI(const std::string& name); 73 void setToggleMode(const bool& mode); 74 void setBackground(const std::string& name); 73 75 74 76 void setCamera(Ogre::Camera* camera); … … 111 113 112 114 static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager 115 bool bToggleMode_; 113 116 114 117 }; -
code/branches/menu/src/orxonox/gamestates/GSMainMenu.cc
r6024 r6032 82 82 { 83 83 // show main menu 84 GUIManager::getInstance().showGUI("MainMenu", false);84 GUIManager::getInstance().showGUI("MainMenu", true, false); 85 85 GUIManager::getInstance().setCamera(this->camera_); 86 GUIManager::getInstance().setBackground("MainMenuBackground"); 87 // GUIManager::getInstance().setBackground(""); 86 88 GraphicsManager::getInstance().setCamera(this->camera_); 87 89 … … 113 115 114 116 GUIManager::getInstance().setCamera(0); 117 GUIManager::getInstance().setBackground(""); 115 118 GUIManager::hideGUI("MainMenu"); 116 119 GraphicsManager::getInstance().setCamera(0);
Note: See TracChangeset
for help on using the changeset viewer.