Changeset 7689 for code/trunk/data/gui/scripts/SheetManager.lua
- Timestamp:
- Dec 1, 2010, 3:00:19 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/menu merged: 7587-7588,7594,7607-7608,7649,7663,7670-7671,7687
- Property svn:mergeinfo changed
-
code/trunk/data/gui/scripts/SheetManager.lua
r7403 r7689 5 5 local activeMenuSheets = {size = 0, topSheetTuple = nil} 6 6 local menuSheetsRoot = guiMgr:getMenuRootWindow() 7 local bInGameConsoleClosed = false 8 local mainMenuLoaded = false 9 orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed") 7 10 8 11 ----------------------- … … 69 72 70 73 -- Count the number of sheets that don't need input till the first that does. 71 local counter = noInputSheet Counter()74 local counter = noInputSheetIndex() 72 75 -- Pause game control if this is the first menu to be displayed 73 76 -- HUGE HACK? … … 100 103 menuSheetsRoot:addChildWindow(menuSheet.window) 101 104 105 -- If sheet is the MainMenu 106 if name == "MainMenu" then 107 mainMenuLoaded = true 108 end 109 102 110 -- Handle input distribution 103 111 if bNoInput == false then … … 118 126 end 119 127 end 120 128 121 129 menuSheet:show() 130 menuSheetsRoot:activate() 122 131 123 132 return menuSheet … … 161 170 activeMenuSheets.topSheetTuple = activeMenuSheets[activeMenuSheets.size] 162 171 172 -- If sheet is the MainMenu 173 if name == "MainMenu" then 174 mainMenuLoaded = false 175 end 176 163 177 -- Leave the input state 164 178 if not sheetTuple.bNoInput then … … 179 193 180 194 -- Count the number of sheets that don't need input till the first that does. 181 local counter = noInputSheet Counter()195 local counter = noInputSheetIndex() 182 196 -- Resume control if the last (non-noInput) menu is hidden 183 197 if counter == 0 then … … 199 213 -- HUGE, very HUGE hacks! 200 214 201 -- Count the number of sheets that don't need input till the first that does. 202 local counter = noInputSheetCounter() 215 -- If the InGameConsole is active, ignore the ESC command. 216 if bInGameConsoleClosed == true then 217 bInGameConsoleClosed = false 218 return 219 end 220 221 -- Count the number of sheets that don't need input till the first that does. 222 local counter = noInputSheetIndex() 203 223 204 224 -- If the first sheet that needs input is the MainMenu. 205 if counter == 1 and activeMenuSheets[1].sheet.name == "MainMenu" then225 if noInputSheetCounter() == 1 and activeMenuSheets[counter].sheet.name == "MainMenu" then 206 226 orxonox.execute("exit") 207 227 -- If there is at least one sheet that needs input. … … 213 233 end 214 234 235 function keyPressed(e) 236 local we = tolua.cast(e, "CEGUI::KeyEventArgs") 237 local sheet = activeMenuSheets[activeMenuSheets.size] 238 code = tostring(we.scancode) 239 -- Some preprocessing 240 if not mainMenuLoaded and not sheet.bNoInput then 241 if code == "1" then 242 keyESC() 243 elseif code == "0"then 244 orxonox.CommandExecutor:execute("openConsole") 245 end 246 end 247 sheet.sheet:onKeyPressed() 248 end 249 215 250 function setBackgroundImage(imageSet, imageName) 216 251 guiMgr:setBackgroundImage(imageSet, imageName) 217 252 end 218 253 254 function noInputSheetIndex() 255 -- Count the number of sheets that don't need input till the first that does. 256 local index = activeMenuSheets.size 257 while index > 0 and activeMenuSheets[index].bNoInput do 258 index = index - 1 259 end 260 return index 261 end 262 219 263 function noInputSheetCounter() 220 -- Count the number of sheets that do n't need input till the first that does.264 -- Count the number of sheets that do need input. 221 265 local counter = activeMenuSheets.size 222 while counter > 0 and activeMenuSheets[counter].bNoInput do 223 counter = counter - 1 266 for i = 1,activeMenuSheets.size do 267 if activeMenuSheets[i].bNoInput then 268 counter = counter - 1 269 end 224 270 end 225 271 return counter 272 end 273 274 function inGameConsoleClosed() 275 bInGameConsoleClosed = not bInGameConsoleClosed; 226 276 end 227 277
Note: See TracChangeset
for help on using the changeset viewer.