Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6324


Ignore:
Timestamp:
Dec 11, 2009, 5:24:32 PM (14 years ago)
Author:
dafrick
Message:

Improved KeyBindMenu further. This is the final version for the presentation, unless there are some complaints.

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

Legend:

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

    r6311 r6324  
    1313            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    1414            <Property Name="VertFormatting" Value="TopAligned" />
    15             <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.25,0},{0.8,0},{0.6,0}}" />
    16             <Window Type="TaharezLook/StaticText" Name="orxonox/KeyBindText" >
     15            <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.1,0},{0.9,0},{0.8,0}}" />
     16            <Window Type="TaharezLook/StaticText" Name="orxonox/KeyBindWrapper" >
    1717                <Property Name="TextColours" Value="FF4444FF" />
    1818                <Property Name="InheritsAlpha" Value="False" />
     
    2020                <Property Name="HorzFormatting" Value="HorzCentred" />
    2121                <Property Name="VertFormatting" Value="TopAligned" />
    22                 <Property Name="UnifiedAreaRect" Value="{{0.041666,0},{0.15,0},{0.958333,0},{0.92,0}}" />
     22                    <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0.95,0},{0.95,0}}" />
    2323                <Window Type="TaharezLook/ScrollablePane" Name="orxonox/KeyBindPane" >
    2424                    <Property Name="ContentArea" Value="l:0 t:0 r:0 b:0" />
     
    2727                    <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    2828                    <Property Name="HorzOverlapSize" Value="0.01" />
    29                     <Property Name="UnifiedAreaRect" Value="{{0.04,0},{0.005,0},{0.999,0},{0.99,0}}" />
     29                    <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
    3030                    <Property Name="VertOverlapSize" Value="0.01" />
    3131                    <Property Name="HorzScrollPosition" Value="0" />
     
    3737            <Property Name="Text" Value="Back" />
    3838            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    39             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.625,0},{0.6,0},{0.675,0}}" />
     39            <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.825,0},{0.6,0},{0.875,0}}" />
    4040            <Event Name="Clicked" Function="KeyBindMenu.KeyBindBackButton_clicked"/>
    4141        </Window>
  • code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua

    r6311 r6324  
    5656
    5757    lineHeight = 35
     58    commandWidth = 200
    5859    buttonWidth = 170
    5960    clearWidth = 20
    60    
     61    spaceWidth = 10
     62   
     63    P.createLines()
     64   
     65    local funct = luaState:createLuaFunctor("KeyBindMenu.callback()")
     66    orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct)
     67end
     68
     69
     70function P.KeyNameNiceifier(key)
     71    local name = string.sub(key, string.find(key, '%.(.*)')+1)
     72    local group = string.sub(key, string.find(key, '(.*)%.'))
     73    group = string.sub(group,1,string.len(group)-1)
     74    if( group == "Keys") then
     75        return "Key " .. string.sub(name, string.find(name, 'Key(.*)')+3)
     76    elseif( group == "MouseButtons") then
     77        return "Mouse " .. name
     78    end
     79    return key
     80end
     81
     82function P.createLine(k)
     83    local offset = 0
     84    local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k)
     85    line:setHeight(CEGUI.UDim(0, lineHeight))
     86    line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, lineHeight*(k-1))))
     87   
     88    local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
     89    command:setSize(CEGUI.UVector2(CEGUI.UDim(0, commandWidth), CEGUI.UDim(0.9, 0)))
     90    command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
     91    command:setText(nameList[k])
     92    line:addChildWindow(command)
     93    offset = offset + commandWidth + spaceWidth
     94   
     95    local plus = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Plus")
     96    plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.7, 0)))
     97    plus:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
     98    plus:setText("+")
     99    orxonox.KeyBinderManager:getInstance():subscribeEventHelper(plus, "Clicked", P.filename .. ".KeyBindPlus_clicked")
     100    line:addChildWindow(plus)
     101    offset = offset + clearWidth + spaceWidth
     102   
     103    local numButtons = orxonox.KeyBinderManager:getInstance():getCurrent():getNumberOfBindings(commandList[k]);
     104    for i=0,(numButtons-1) do
     105        local button = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button" .. i)
     106        button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.7, 0)))
     107        button:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
     108        local name = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i)
     109        name = P.KeyNameNiceifier(name)
     110        button:setText(name)
     111        orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked")
     112        --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked")
     113        line:addChildWindow(button)
     114        offset = offset + buttonWidth
     115       
     116        local clear = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Clear" .. i)
     117        clear:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.7, 0)))
     118        clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0, (i*(buttonWidth+clearWidth+spaceWidth)+buttonWidth)+commandWidth+clearWidth+2*spaceWidth), CEGUI.UDim(0.15, 0)))
     119        clear:setText("X")
     120        orxonox.KeyBinderManager:getInstance():subscribeEventHelper(clear, "Clicked", P.filename .. ".KeyBindClear_clicked")
     121        line:addChildWindow(clear)
     122        offset = offset + clearWidth + spaceWidth
     123    end
     124   
     125    line:setWidth(CEGUI.UDim(0, offset+clearWidth))
     126   
     127    return line
     128end
     129
     130function P.createLines()
     131
    61132    local window = winMgr:getWindow("orxonox/KeyBindPane")
    62133
     
    66137        window:addChildWindow(line)
    67138    end
    68    
    69     local funct = luaState:createLuaFunctor("KeyBindMenu.callback()")
    70     orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct)
    71 end
    72 
    73 function 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
     139
    112140end
    113141
     
    170198    linesList = {}
    171199
    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
     200    P.createLines()
    178201   
    179202    if(InfoPopup ~= nil) then
Note: See TracChangeset for help on using the changeset viewer.