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/SettingsMenu.lua

    r7689 r7922  
    44P.loadAlong = { "ControlsMenu", "AudioMenu", "GraphicsMenu" }
    55
    6 P.buttonList = {}
    7 
    86function P.onLoad()
    97    --"Gameplay" and "Multiplayer Options" are not integrated in the list
    108    --buttons are arranged in a 4x2 matrix. The lower-right element is not in the matrix!
    11     local item = {
     9    P:initButtons(4, 2)
     10
     11    P:setButton(1, 2, {
    1212            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/GraphicsButton"),
    13             ["function"]  = P.SettingsGraphicsButton_clicked
    14     }
    15     P.buttonList[2] = item
     13            ["callback"]  = P.SettingsGraphicsButton_clicked
     14    })
    1615
    17     local item = {
     16    P:setButton(2, 2, {
    1817            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/AudioButton"),
    19             ["function"]  = P.SettingsAudioButton_clicked
    20     }
    21     P.buttonList[4] = item
     18            ["callback"]  = P.SettingsAudioButton_clicked
     19    })
    2220
     21    P:setButton(3, 1, {
     22            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/ControlsButton"),
     23            ["callback"]  = P.SettingsControlsButton_clicked
     24    })
    2325
    24     local item = {
    25             ["button"] = winMgr:getWindow("orxonox/SettingsMenu/ControlsButton"),
    26             ["function"]  = P.SettingsControlsButton_clicked
    27     }
    28     P.buttonList[5] = item
     26    P:setButton(3, 2, {
     27            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/MiscellaneousButton"),
     28            ["callback"]  = P.SettingsMiscellaneousButton_clicked
     29    })
    2930
    30     local item = {
    31             ["button"] = winMgr:getWindow("orxonox/SettingsMenu/MiscellaneousButton"),
    32             ["function"]  = P.SettingsMiscellaneousButton_clicked
    33     }
    34     P.buttonList[6] = item
    35 
    36     local item = {
     31    P:setButton(4, 1, {
    3732            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/SettingsBackButton"),
    38             ["function"]  = P.SettingsBackButton_clicked
    39     }
    40     P.buttonList[7] = item
    41 
    42 end
    43 
    44 function P.onShow()
    45     --indices to iterate through buttonlist
    46     P.oldindex = 3
    47     P.index = 2
     33            ["callback"]  = P.SettingsBackButton_clicked
     34    })
    4835end
    4936
     
    7663end
    7764
    78 function P.onKeyPressed()
    79     buttonIteratorHelper(P.buttonList, code, P, 4, 2)
    80 end
    81 
    8265return P
    8366
Note: See TracChangeset for help on using the changeset viewer.