Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 20, 2011, 12:47:57 AM (14 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/MainMenu.lua

    r7689 r7922  
    44P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" }
    55
    6 P.buttonList = {}
    7 
    86function P.onLoad()
    97    --buttons are arranged in a 6x1 Matrix (list)
    10     local item = {
     8    P:initButtons(6, 1)
     9
     10    P:setButton(1, 1, {
    1111            ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"),
    12             ["function"]  = P.QuickGameTestButton_clicked
    13     }
    14     table.insert(P.buttonList,item)
     12            ["callback"]  = P.QuickGameTestButton_clicked
     13    })
    1514
    16     item = {
     15    P:setButton(2, 1, {
    1716            ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"),
    18             ["function"]  = P.SingleplayerButton_clicked
    19     }
    20     table.insert(P.buttonList,item)
     17            ["callback"]  = P.SingleplayerButton_clicked
     18    })
    2119
    22     item = {
     20    P:setButton(3, 1, {
    2321            ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"),
    24             ["function"]  = P.MultiplayerButton_clicked
    25     }
    26     table.insert(P.buttonList,item)
     22            ["callback"]  = P.MultiplayerButton_clicked
     23    })
    2724
    28     item = {
     25    P:setButton(4, 1, {
    2926            ["button"] = winMgr:getWindow("orxonox/SettingsButton"),
    30             ["function"]  = P.SettingsButton_clicked
    31     }
    32     table.insert(P.buttonList,item)
     27            ["callback"]  = P.SettingsButton_clicked
     28    })
    3329
    34     item = {
     30    P:setButton(5, 1, {
    3531            ["button"] = winMgr:getWindow("orxonox/CreditsButton"),
    36             ["function"]  = P.CreditsButton_clicked
    37     }
    38     table.insert(P.buttonList,item)
     32            ["callback"]  = P.CreditsButton_clicked
     33    })
    3934
    40     item = {
     35    P:setButton(6, 1, {
    4136            ["button"] = winMgr:getWindow("orxonox/ExitButton"),
    42             ["function"]  = P.ExitButton_clicked
    43     }
    44     table.insert(P.buttonList,item)
    45 end
    46 
    47 function P.onShow()
    48     --indices to iterate through buttonlist
    49     P.oldindex = -2
    50     P.index = -1
     37            ["callback"]  = P.ExitButton_clicked
     38    })
    5139end
    5240
     
    7765end
    7866
    79 function P.onKeyPressed()
    80     buttonIteratorHelper(P.buttonList, code, P, 6, 1)
    81 end
    82 
    8367return P
    8468
Note: See TracChangeset for help on using the changeset viewer.