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

    r7876 r7922  
    33local P = createMenuSheet("SingleplayerMenu")
    44
    5 P.buttonList = {}
    65P.levelList = {}
    76P.itemList = {}
     
    1514
    1615    --buttons are arranged in a 1x2 matrix
    17     local item = {
     16    P:initButtons(1, 2)
     17
     18    P:setButton(1, 1, {
    1819            ["button"] = winMgr:getWindow("orxonox/SingleplayerStartButton"),
    19             ["function"]  = P.SingleplayerStartButton_clicked
    20     }
    21     P.buttonList[1] = item
     20            ["callback"]  = P.SingleplayerStartButton_clicked
     21    })
    2222
    23     local item = {
     23    P:setButton(1, 2, {
    2424            ["button"] = winMgr:getWindow("orxonox/SingleplayerBackButton"),
    25             ["function"]  = P.SingleplayerBackButton_clicked
    26     }
    27     P.buttonList[2] = item
     25            ["callback"]  = P.SingleplayerBackButton_clicked
     26    })
    2827end
    2928
     
    6160end
    6261
    63 function P.onShow()
    64     --indices to iterate through buttonlist
    65     P.oldindex = -2
    66     P.index = -1
    67 end
    68 
    6962function P.SingleplayerStartButton_clicked(e)
    7063    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox"))
     
    9386end
    9487
    95 function P.onKeyPressed()
    96     buttonIteratorHelper(P.buttonList, code, P, 1, 2)
    97 end
    98 
    9988return P
    10089
Note: See TracChangeset for help on using the changeset viewer.