Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7670


Ignore:
Timestamp:
Nov 24, 2010, 8:58:13 PM (13 years ago)
Author:
dafrick
Message:

ESC behavior is once again correct.
Kind of hackish, though, but I guess there is really no good way around that seeing that the MainMenu is still a hack.

Location:
code/branches/menu/data/gui/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/menu/data/gui/scripts/InGameMenu.lua

    r6748 r7670  
    1212    orxonox.Game:getInstance():popState()
    1313    orxonox.Game:getInstance():popState()
    14     orxonox.Game:getInstance():requestState("mainmenu")
    1514    hideMenuSheet("InGameMenu")
    1615end
  • code/branches/menu/data/gui/scripts/SheetManager.lua

    r7649 r7670  
    66local menuSheetsRoot = guiMgr:getMenuRootWindow()
    77local bInGameConsoleClosed = false
     8local mainMenuLoaded = false
    89orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
    910
     
    7172
    7273    -- Count the number of sheets that don't need input till the first that does.
    73     local counter = noInputSheetCounter()
     74    local counter = noInputSheetIndex()
    7475    -- Pause game control if this is the first menu to be displayed
    7576    -- HUGE HACK?
     
    102103    menuSheetsRoot:addChildWindow(menuSheet.window)
    103104
     105    -- If sheet is the MainMenu
     106    if name == "MainMenu" then
     107        mainMenuLoaded = true
     108    end
     109
    104110    -- Handle input distribution
    105111    if bNoInput == false then
     
    120126        end
    121127    end
    122 
     128   
    123129    menuSheet:show()
    124130    menuSheetsRoot:activate()
     
    164170    activeMenuSheets.topSheetTuple = activeMenuSheets[activeMenuSheets.size]
    165171
     172    -- If sheet is the MainMenu
     173    if name == "MainMenu" then
     174        mainMenuLoaded = false
     175    end
     176
    166177    -- Leave the input state
    167178    if not sheetTuple.bNoInput then
     
    182193
    183194    -- Count the number of sheets that don't need input till the first that does.
    184     local counter = noInputSheetCounter()
     195    local counter = noInputSheetIndex()
    185196    -- Resume control if the last (non-noInput) menu is hidden
    186197    if counter == 0 then
     
    204215    -- If the InGameConsole is active, ignore the ESC command.
    205216    if bInGameConsoleClosed == true then
    206         bInGameConsoleClosed = falses
     217        bInGameConsoleClosed = false
    207218        return
    208219    end
    209220
    210221    -- Count the number of sheets that don't need input till the first that does.
    211     local counter = noInputSheetCounter()
     222    local counter = noInputSheetIndex()
    212223
    213224    -- If the first sheet that needs input is the MainMenu.
    214     if counter == 1 and activeMenuSheets[1].sheet.name == "MainMenu" then
     225    if noInputSheetCounter() == 1 and activeMenuSheets[counter].sheet.name == "MainMenu" then
    215226        orxonox.execute("exit")
    216227    -- If there is at least one sheet that needs input.
     
    226237    local sheet = activeMenuSheets[activeMenuSheets.size]
    227238    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
    228247    sheet.sheet:onKeyPressed()
    229248end
     
    233252end
    234253
     254function 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        cout(0, activeMenuSheets[index].sheet.name)
     259        index = index - 1
     260    end
     261    return index
     262end
     263
    235264function noInputSheetCounter()
    236     -- Count the number of sheets that don't need input till the first that does.
     265    -- Count the number of sheets that do need input.
    237266    local counter = activeMenuSheets.size
    238     while counter > 0 and activeMenuSheets[counter].bNoInput do
    239         counter = counter - 1
     267    for i = 1,activeMenuSheets.size do
     268        if activeMenuSheets[i].bNoInput then
     269            counter = counter - 1
     270        end
    240271    end
    241272    return counter
Note: See TracChangeset for help on using the changeset viewer.