Changeset 8051 for code/branches/tutorial/data/gui/scripts/SheetManager.lua
- Timestamp:
- Mar 9, 2011, 11:27:05 AM (14 years ago)
- Location:
- code/branches/tutorial
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutorial
- Property svn:mergeinfo changed
/code/branches/usability merged: 8018-8041
- Property svn:mergeinfo changed
-
code/branches/tutorial/data/gui/scripts/SheetManager.lua
r8015 r8051 5 5 local activeMenuSheets = {size = 0, topSheetTuple = nil} 6 6 local menuSheetsRoot = guiMgr:getMenuRootWindow() 7 local bInGameConsoleClosed = false8 7 local mainMenuLoaded = false 9 orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed") 10 11 ----------------------- 12 --- Local functions --- 13 ----------------------- 14 15 local function hideCursor() 16 if cursor:isVisible() then 17 cursor:hide() 18 end 19 end 20 21 local function showCursor() 22 if not cursor:isVisible() and inputMgr:isMouseExclusive() then 23 cursor:show() 24 end 25 end 26 8 --orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed") 9 orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "Sized", "windowResized") 27 10 28 11 ------------------------ 29 12 --- Global functions --- 30 13 ------------------------ 14 15 function hideCursor() 16 if cursor:isVisible() then 17 cursor:hide() 18 end 19 end 20 21 function showCursor() 22 if not cursor:isVisible() and inputMgr:isMouseExclusive() then 23 cursor:show() 24 end 25 end 31 26 32 27 -- Loads the GUI with the specified name … … 93 88 ["sheet"] = menuSheet, 94 89 ["bHidePrevious"] = bHidePrevious, 95 ["bNoInput"] = bNoInput 90 ["bNoInput"] = bNoInput, 91 ["name"] = name 96 92 } 97 93 table.insert(activeMenuSheets, sheetTuple) -- indexed array access … … 135 131 if previous and previous.pressedEnter and menuSheet:hasSelection() == false then 136 132 menuSheet:setSelectionNear(1, 1) 133 end 134 135 if activeMenuSheets.size > 0 then 136 guiMgr:guisActiveChanged(true) 137 137 end 138 138 … … 207 207 end 208 208 209 if activeMenuSheets.size == 0 then 210 guiMgr:guisActiveChanged(false) 211 end 212 209 213 sheetTuple.sheet:quit() 210 214 end … … 220 224 -- HUGE, very HUGE hacks! 221 225 222 -- If the InGameConsole is active, ignore the ESC command. 223 if bInGameConsoleClosed == true then 224 bInGameConsoleClosed = false 225 return 226 end 227 228 -- Count the number of sheets that don't need input till the first that does. 226 -- Count the number of sheets that don't need input until the first that does. 229 227 local counter = noInputSheetIndex() 230 228 … … 240 238 end 241 239 242 function keyPressed(e) 243 local we = tolua.cast(e, "CEGUI::KeyEventArgs") 240 -- Function to navigate the GUI, is called by the GUIManager, whenever a relevant key is pressed. 241 -- The mode specifies the action to be taken. 242 function navigateGUI(mode) 244 243 local sheet = activeMenuSheets[activeMenuSheets.size] 245 code = tostring(we.scancode) 246 -- Some preprocessing 247 if not mainMenuLoaded and not sheet.bNoInput then 248 if code == "1" then 249 keyESC() 250 elseif code == "0"then 251 orxonox.CommandExecutor:execute("openConsole") 252 end 253 end 254 sheet.sheet:keyPressed() 244 sheet.sheet:keyPressed(mode) 245 end 246 247 function windowResized(e) 248 for name, sheet in pairs(loadedSheets) do 249 if orxonox.GraphicsManager:getInstance():isFullScreen() or sheet.tShowCursor == TriBool.False then 250 inputMgr:setMouseExclusive(sheet.inputState, TriBool.True) 251 else 252 inputMgr:setMouseExclusive(sheet.inputState, TriBool.False) 253 end 254 end 255 local sheetTuple = activeMenuSheets[activeMenuSheets.size] 256 if sheetTuple then 257 if orxonox.GraphicsManager:getInstance():isFullScreen() and sheetTuple.sheet.tShowCursor ~= TriBool.False then 258 showCursor() 259 else 260 hideCursor() 261 end 262 sheetTuple.sheet:windowResized() 263 end 255 264 end 256 265 … … 279 288 end 280 289 281 function inGameConsoleClosed() 282 bInGameConsoleClosed = not bInGameConsoleClosed; 290 function getGUIFirstActive(name, bHidePrevious, bNoInput) 291 local sheet = activeMenuSheets.topSheetTuple 292 -- If the topmost gui sheet has the input name 293 if sheet ~= nil and sheet.name == name then 294 guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, false); 295 else 296 guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, true); 297 end 283 298 end 284 299
Note: See TracChangeset
for help on using the changeset viewer.