Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 1, 2010, 3:00:19 PM (14 years ago)
Author:
dafrick
Message:

Merging menu branch to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/data/gui/scripts/SheetManager.lua

    r7403 r7689  
    55local activeMenuSheets = {size = 0, topSheetTuple = nil}
    66local menuSheetsRoot = guiMgr:getMenuRootWindow()
     7local bInGameConsoleClosed = false
     8local mainMenuLoaded = false
     9orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
    710
    811-----------------------
     
    6972
    7073    -- Count the number of sheets that don't need input till the first that does.
    71     local counter = noInputSheetCounter()
     74    local counter = noInputSheetIndex()
    7275    -- Pause game control if this is the first menu to be displayed
    7376    -- HUGE HACK?
     
    100103    menuSheetsRoot:addChildWindow(menuSheet.window)
    101104
     105    -- If sheet is the MainMenu
     106    if name == "MainMenu" then
     107        mainMenuLoaded = true
     108    end
     109
    102110    -- Handle input distribution
    103111    if bNoInput == false then
     
    118126        end
    119127    end
    120 
     128   
    121129    menuSheet:show()
     130    menuSheetsRoot:activate()
    122131
    123132    return menuSheet
     
    161170    activeMenuSheets.topSheetTuple = activeMenuSheets[activeMenuSheets.size]
    162171
     172    -- If sheet is the MainMenu
     173    if name == "MainMenu" then
     174        mainMenuLoaded = false
     175    end
     176
    163177    -- Leave the input state
    164178    if not sheetTuple.bNoInput then
     
    179193
    180194    -- Count the number of sheets that don't need input till the first that does.
    181     local counter = noInputSheetCounter()
     195    local counter = noInputSheetIndex()
    182196    -- Resume control if the last (non-noInput) menu is hidden
    183197    if counter == 0 then
     
    199213    -- HUGE, very HUGE hacks!
    200214
    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()
    203223
    204224    -- If the first sheet that needs input is the MainMenu.
    205     if counter == 1 and activeMenuSheets[1].sheet.name == "MainMenu" then
     225    if noInputSheetCounter() == 1 and activeMenuSheets[counter].sheet.name == "MainMenu" then
    206226        orxonox.execute("exit")
    207227    -- If there is at least one sheet that needs input.
     
    213233end
    214234
     235function 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()
     248end
     249
    215250function setBackgroundImage(imageSet, imageName)
    216251    guiMgr:setBackgroundImage(imageSet, imageName)
    217252end
    218253
     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        index = index - 1
     259    end
     260    return index
     261end
     262
    219263function noInputSheetCounter()
    220     -- Count the number of sheets that don't need input till the first that does.
     264    -- Count the number of sheets that do need input.
    221265    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
    224270    end
    225271    return counter
     272end
     273
     274function inGameConsoleClosed()
     275    bInGameConsoleClosed = not bInGameConsoleClosed;
    226276end
    227277
Note: See TracChangeset for help on using the changeset viewer.