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

    r7887 r7922  
    55P.multiplayerMode = "startServer"
    66
    7 P.buttonList = {}
    87P.levelList = {}
    98P.itemList = {}
     
    1110
    1211function P.onLoad()
    13     P.multiplayerMode = "startServer" 
     12    P.multiplayerMode = "startServer"
    1413    local window = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
    1514    local button = tolua.cast(window,"CEGUI::Checkbox")
     
    1716    P.createLevelList()
    1817
    19     local item = {
     18    P:initButtons(1, 2)
     19
     20    P:setButton(1, 1, {
    2021            ["button"] = winMgr:getWindow("orxonox/HostMenuStartButton"),
    21             ["function"]  = P.HostMenuStartButton_clicked
    22     }
    23     P.buttonList[1] = item
     22            ["callback"]  = P.HostMenuStartButton_clicked
     23    })
    2424
    25     local item = {
     25    P:setButton(1, 2, {
    2626            ["button"] = winMgr:getWindow("orxonox/HostMenuBackButton"),
    27             ["function"]  = P.HostMenuBackButton_clicked
    28     }
    29     P.buttonList[2] = item
     27            ["callback"]  = P.HostMenuBackButton_clicked
     28    })
    3029end
    3130
     
    4443        P.createLevelList()
    4544    end
    46 
    47     P.oldindex = -2
    48     P.index = -1
    49 
    5045end
    5146
     
    9792end
    9893
    99 function P.HostMenuStartButton_clicked(e)   
     94function P.HostMenuStartButton_clicked(e)
    10095    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/HostMenuListbox"))
    10196    local choice = listbox:getFirstSelectedItem()
     
    119114end
    120115
    121 function P.onKeyPressed()
    122     buttonIteratorHelper(P.buttonList, code, P, 1, 2)
    123 end
    124 
    125116return P
Note: See TracChangeset for help on using the changeset viewer.