Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 9, 2009, 11:17:14 PM (15 years ago)
Author:
dafrick
Message:

The KeyBindMenu now shows all Keybindings and allows for various manipulations.
For this the bookkeeping in KeyBinder has ben improved.
Also KeyEscape now can't be bound to other commands.

Location:
code/branches/presentation2/data/gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/data/gui/layouts/KeyBindMenu.layout

    r6292 r6311  
    11<?xml version="1.0" encoding="UTF-8"?>
    22
    3 
    43<GUILayout >
    5 
    64    <Window Type="DefaultWindow" Name="orxonox/KeyBindMenu/Background" >
    7 
    85        <Property Name="InheritsAlpha" Value="False" />
    9 
    106        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    11 
    127        <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
    13 
    148        <Window Type="TaharezLook/StaticText" Name="orxonox/KeyBindWindow" >
    15 
    169            <Property Name="Text" Value="Keybindings" />
    17 
    1810            <Property Name="Alpha" Value="0.8" />
    19 
    2011            <Property Name="InheritsAlpha" Value="False" />
    21 
    2212            <Property Name="HorzFormatting" Value="HorzCentred" />
    23 
    2413            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    25 
    2614            <Property Name="VertFormatting" Value="TopAligned" />
    2715            <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.25,0},{0.8,0},{0.6,0}}" />
    28 
    2916            <Window Type="TaharezLook/StaticText" Name="orxonox/KeyBindText" >
    3017                <Property Name="TextColours" Value="FF4444FF" />
     
    3522                <Property Name="UnifiedAreaRect" Value="{{0.041666,0},{0.15,0},{0.958333,0},{0.92,0}}" />
    3623                <Window Type="TaharezLook/ScrollablePane" Name="orxonox/KeyBindPane" >
    37 
    3824                    <Property Name="ContentArea" Value="l:0 t:0 r:0 b:0" />
    39 
    4025                    <Property Name="HorzStepSize" Value="0.1" />
    41 
    4226                    <Property Name="VertStepSize" Value="0.1" />
    43 
    4427                    <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    4528                    <Property Name="HorzOverlapSize" Value="0.01" />
    46 
    4729                    <Property Name="UnifiedAreaRect" Value="{{0.04,0},{0.005,0},{0.999,0},{0.99,0}}" />
    48 
    4930                    <Property Name="VertOverlapSize" Value="0.01" />
    50 
    5131                    <Property Name="HorzScrollPosition" Value="0" />
    52 
    5332                    <Property Name="VertScrollPosition" Value="0" />
    54 
    5533                </Window>
    56 
    5734            </Window>
    5835        </Window>
    59 
    6036        <Window Type="TaharezLook/Button" Name="orxonox/KeyBindBackButton" >
    61 
    6237            <Property Name="Text" Value="Back" />
    63 
    6438            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    65 
    6639            <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.625,0},{0.6,0},{0.675,0}}" />
    67 
    6840            <Event Name="Clicked" Function="KeyBindMenu.KeyBindBackButton_clicked"/>
    69 
    7041        </Window>
    71 
    7242    </Window>
    73 
    7443</GUILayout>
  • code/branches/presentation2/data/gui/scripts/GUITools.lua

    r6283 r6311  
    55end
    66
    7 function openInfoPopup(text, functionPtr, closeButton)
     7function openInfoPopup(text, functionPtr, closeButton, arguments)
    88    showGUI("InfoPopup", false, true)
    9     InfoPopup.execute(functionPtr)
     9    InfoPopup.execute(functionPtr, arguments)
    1010    InfoPopup.setText(text)
    1111    InfoPopup.setCloseButton(closeButton)
  • code/branches/presentation2/data/gui/scripts/InfoPopup.lua

    r6283 r6311  
    1515end
    1616
    17 function P.execute(functionPtr)
     17function P.execute(functionPtr, arguments)
    1818    if functionPtr ~= nil then
    19         functionPtr()
     19        if arguments ~= nil then
     20            functionPtr(arguments)
     21        else
     22            functionPtr()
     23        end
    2024    end
    2125end
  • code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua

    r6292 r6311  
    5252    table.insert(nameList, "Look Around")
    5353    table.insert(nameList, "Pause")
     54   
     55    linesList = {}
    5456
    55     local lineHeight = 30
     57    lineHeight = 35
     58    buttonWidth = 170
     59    clearWidth = 20
    5660   
    5761    local window = winMgr:getWindow("orxonox/KeyBindPane")
    5862
    5963    for k,v in pairs(commandList) do
    60         local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k)
    61         local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
    62         local button = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button")
    63         local clear = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Clear")
    64         local button2 = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button2")
    65         local clear2 = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Clear2")
    66         local add = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Add")
    67        
    68         line:setSize(CEGUI.UVector2(CEGUI.UDim(1, -13), CEGUI.UDim(0, lineHeight)))
    69         command:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(1, 0)))
    70         button:setSize(CEGUI.UVector2(CEGUI.UDim(0.25, 0), CEGUI.UDim(0.6, 0)))
    71         clear:setSize(CEGUI.UVector2(CEGUI.UDim(0.05, 0), CEGUI.UDim(0.6, 0)))
    72         button2:setSize(CEGUI.UVector2(CEGUI.UDim(0.25, 0), CEGUI.UDim(0.6, 0)))
    73         clear2:setSize(CEGUI.UVector2(CEGUI.UDim(0.05, 0), CEGUI.UDim(0.6, 0)))
    74         add:setSize(CEGUI.UVector2(CEGUI.UDim(0.05, 0), CEGUI.UDim(0.6, 0)))
    75        
    76         line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, lineHeight*(k-1))))       
    77         command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
    78         button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.25, 0), CEGUI.UDim(0.2, 0)))
    79         clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0.5, 0), CEGUI.UDim(0.2, 0)))
    80         button2:setPosition(CEGUI.UVector2(CEGUI.UDim(0.6, 0), CEGUI.UDim(0.2, 0)))
    81         clear2:setPosition(CEGUI.UVector2(CEGUI.UDim(0.85, 0), CEGUI.UDim(0.2, 0)))
    82         add:setPosition(CEGUI.UVector2(CEGUI.UDim(0.925, 0), CEGUI.UDim(0.2, 0)))
    83        
    84         command:setText(nameList[k])
    85         button:setText(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(v))
    86         clear:setText("X")
    87         button2:setText(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(v))
    88         clear2:setText("X")
    89         add:setText("+")
    90 
    91         orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked")
    92         orxonox.KeyBinderManager:getInstance():subscribeEventHelper(clear, "Clicked", P.filename .. ".KeyBindClear_clicked")
    93         orxonox.KeyBinderManager:getInstance():subscribeEventHelper(add, "Clicked", P.filename .. ".KeyBindAdd_clicked")
    94         --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked")
    95        
    96         line:addChildWindow(command)
    97         line:addChildWindow(button)
    98         line:addChildWindow(clear)
    99         line:addChildWindow(button2)
    100         line:addChildWindow(clear2)
    101         line:addChildWindow(add)
     64        local line = P.createLine(k)
     65        table.insert(linesList, line)
    10266        window:addChildWindow(line)
    10367    end
     68   
     69    local funct = luaState:createLuaFunctor("KeyBindMenu.callback()")
     70    orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct)
     71end
     72
     73function P.createLine(k)
     74    local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k)
     75    line:setHeight(CEGUI.UDim(0, lineHeight))
     76    line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, lineHeight*(k-1))))
     77   
     78    local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
     79    command:setSize(CEGUI.UVector2(CEGUI.UDim(0, 200), CEGUI.UDim(1, 0)))
     80    command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
     81    command:setText(nameList[k])
     82    line:addChildWindow(command)
     83   
     84    local plus = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Plus")
     85    plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(1, 0)))
     86    plus:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 200), CEGUI.UDim(0, 0)))
     87    plus:setText("+")
     88    orxonox.KeyBinderManager:getInstance():subscribeEventHelper(plus, "Clicked", P.filename .. ".KeyBindPlus_clicked")
     89    line:addChildWindow(plus)
     90   
     91    numButtons = orxonox.KeyBinderManager:getInstance():getCurrent():getNumberOfBindings(commandList[k]);
     92    for i=0,(numButtons-1) do
     93        local button = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button" .. i)
     94        button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.8, 0)))
     95        button:setPosition(CEGUI.UVector2(CEGUI.UDim(0, (i*(buttonWidth+clearWidth))+200+clearWidth), CEGUI.UDim(0.1, 0)))
     96        button:setText(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i))
     97        orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked")
     98        --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked")
     99        line:addChildWindow(button)
     100       
     101        local clear = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Clear" .. i)
     102        clear:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.8, 0)))
     103        clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0, (i*(buttonWidth+clearWidth)+buttonWidth)+200+clearWidth), CEGUI.UDim(0.1, 0)))
     104        clear:setText("X")
     105        orxonox.KeyBinderManager:getInstance():subscribeEventHelper(clear, "Clicked", P.filename .. ".KeyBindClear_clicked")
     106        line:addChildWindow(clear)
     107    end
     108   
     109    line:setWidth(CEGUI.UDim(0, 200+numButtons*(buttonWidth+clearWidth)+clearWidth))
     110   
     111    return line
    104112end
    105113
     
    107115    local we = CEGUI.toWindowEventArgs(e)
    108116    local name = we.window:getName()
    109     buttonNr = tonumber(string.match(name, "%d+"))
    110     openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind)
     117
     118    local match = string.gmatch(name, "%d+")
     119    local commandNr = tonumber(match())
     120    local buttonNr = tonumber(match())
     121   
     122    local arguments = {}
     123    arguments[1] = commandNr
     124    arguments[2] = buttonNr
     125    openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind, false, arguments)
     126end
     127
     128function P.KeyBindPlus_clicked(e)
     129    local we = CEGUI.toWindowEventArgs(e)
     130    local name = we.window:getName()
     131   
     132    local match = string.gmatch(name, "%d+")
     133    local commandNr = tonumber(match())
     134   
     135    local arguments = {}
     136    arguments[1] = commandNr
     137    openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind, false, arguments)
    111138end
    112139
     
    114141    local we = CEGUI.toWindowEventArgs(e)
    115142    local name = we.window:getName()
    116     clearNr = tonumber(string.match(name, "%d+"))
     143   
     144    local match = string.gmatch(name, "%d+")
     145    local commandNr = tonumber(match())
     146    local buttonNr = tonumber(match())
     147   
     148    orxonox.KeyBinderManager:getInstance():unbind(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[commandNr], buttonNr))
     149   
     150    P.callback()
    117151end
    118152
    119 function P.KeyBindAdd_clicked(e)
    120    
     153function P.keybind(arguments)
     154    local commandNr = arguments[1]
     155    local buttonNr = arguments[2]
     156    if buttonNr ~= nil then
     157        orxonox.KeyBinderManager:getInstance():unbind(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[commandNr], buttonNr))
     158    end
     159    orxonox.KeyBinderManager:getInstance():keybind(commandList[commandNr])
    121160end
    122161
    123 function P.keybind()
    124     local funct = luaState:createLuaFunctor("KeyBindMenu.callback(" .. buttonNr ..")")
    125     orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct)
    126     orxonox.KeyBinderManager:getInstance():keybind(commandList[buttonNr])
    127 end
     162function P.callback()
     163    while table.getn(linesList) ~= 0 do
     164        if linesList[1] ~= nil then
     165            winMgr:destroyWindow(linesList[1]:getName())
     166        end
     167        table.remove(linesList, 1)
     168    end
     169   
     170    linesList = {}
    128171
    129 function P.callback(number)
    130     orxonox.KeyBinderManager:getInstance():registerKeybindCallback(nil)
    131     local button = winMgr:getWindow("orxonox/KeyBindPane/Binding" .. number .. "/Button")
    132     button:setText(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[number]))
     172    window = winMgr:getWindow("orxonox/KeyBindPane")
     173    for q,w in pairs(commandList) do
     174        local line = P.createLine(q)
     175        table.insert(linesList, line)
     176        window:addChildWindow(line)
     177    end
    133178   
    134     InfoPopup.close()
     179    if(InfoPopup ~= nil) then
     180        InfoPopup.close()
     181    end
    135182end
    136183
Note: See TracChangeset for help on using the changeset viewer.