Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 20, 2011, 12:47:57 AM (13 years ago)
Author:
landauf
Message:

implemented new keyboard control of menu buttons with these new features:

  • more intuitive placement of buttons in table (row/column format instead of linear index)
  • no need to overwrite onShow() and onKeyPressed() functions, no need for P.buttonList
  • highlights the selected button in a different layout than mouse hovering
  • remembers the selection while moving through the menu hierarchy, but resets it if the menu is closed
  • allows preselected button (for example "Yes" in decision popup)
  • when opening a menu, the first selected button is not always the upper left, but instead depends on the pressed key (e.g. the 'up' key selects the button at the bottom, while the 'down' key selects the button at the top. once a button is selected, the keys behave as usual)

+ fixed wrong callback function in ingame menu

File:
1 edited

Legend:

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

    r7877 r7922  
    44P.loadAlong = { "DecisionPopup" }
    55
    6 P.buttonList = {}
    7 
    86function P.onLoad()
    9     P.multiplayerMode = "startClient" 
     7    P.multiplayerMode = "startClient"
    108
    119    --button are arranged in a 4x1 matrix, the left lower item is nil
    12     local item = {
     10    P:initButtons(4, 1)
     11
     12    P:setButton(1, 1, {
    1313            ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReturnButton"),
    14             ["function"]  = P.button_settings_clicked
    15     }
    16     P.buttonList[1] = item
     14            ["callback"]  = P.button_return_clicked
     15    })
    1716
    18     local item = {
     17    P:setButton(2, 1, {
    1918            ["button"] = winMgr:getWindow("orxonox/InGameMenu_MainMenuButton"),
    20             ["function"]  = P.button_mainmenu_clicked
    21     }
    22     P.buttonList[2] = item
     19            ["callback"]  = P.button_mainmenu_clicked
     20    })
    2321
    24     local item = {
     22    P:setButton(3, 1, {
    2523            ["button"] = winMgr:getWindow("orxonox/InGameMenu_SettingsButton"),
    26             ["function"]  = P.button_settings_clicked
    27     }
    28     P.buttonList[3] = item
     24            ["callback"]  = P.button_settings_clicked
     25    })
    2926
    30     local item = {
     27    P:setButton(4, 1, {
    3128            ["button"] = winMgr:getWindow("orxonox/InGameMenu_QuitButton"),
    32             ["function"]  = P.button_quit_clicked
    33     }
    34     P.buttonList[4] = item
    35 
     29            ["callback"]  = P.button_quit_clicked
     30    })
    3631end
    3732
    3833function P.onShow()
    39     --indices to iterate through buttonlist
    40     P.oldindex = -2
    41     P.index = -1
     34    if P:hasSelection() == false then
     35        P:setSelection(1, 1)
     36    end
    4237end
    4338
     
    6459        hideMenuSheet("InGameMenu")
    6560        orxonox.execute("exit")
    66     else 
     61    else
    6762        P.onShow()
    6863    end
    6964end
    7065
    71 function P.onKeyPressed()
    72     buttonIteratorHelper(P.buttonList, code, P, 4, 1)
    73 end
    74 
    7566return P
    7667
Note: See TracChangeset for help on using the changeset viewer.