Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 9, 2009, 1:56:36 PM (15 years ago)
Author:
dafrick
Message:

Some enhancements in KeyBindMenu.lua and InfoPopup, clear doesn't work, yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua

    r6281 r6283  
    5656
    5757    for k,v in pairs(commandList) do
     58        local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k)
     59        local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
    5860        local button = winMgr:createWindow("TaharezLook/Button", "orxonox/KeyBindPane/Binding" .. k .. "/Button")
    59         local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
    60         local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k)
     61        local clear = winMgr:createWindow("TaharezLook/Button", "orxonox/KeyBindPane/Binding" .. k .. "/Clear")
    6162       
    6263        line:setSize(CEGUI.UVector2(CEGUI.UDim(1,-13),CEGUI.UDim(0, lineHeight)))
     64        command:setSize(CEGUI.UVector2(CEGUI.UDim(0.55, 0), CEGUI.UDim(1, 0)))
    6365        button:setSize(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(1, 0)))
    64         command:setSize(CEGUI.UVector2(CEGUI.UDim(0.6, 0), CEGUI.UDim(1, 0)))
     66        clear:setSize(CEGUI.UVector2(CEGUI.UDim(0.05, 0),CEGUI.UDim(1,0)))
    6567       
    66         button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.6, 0),CEGUI.UDim(0, 0)))
     68        line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0),CEGUI.UDim(0, lineHeight*(k-1))))       
    6769        command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0),CEGUI.UDim(0, 0)))
    68         line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0),CEGUI.UDim(0, lineHeight*(k-1))))
     70        button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.55, 0),CEGUI.UDim(0, 0)))
     71        clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0.95, 0),CEGUI.UDim(0, 0)))
    6972       
     73        command:setText(nameList[k])
    7074        button:setText(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(v))
    71         command:setText(nameList[k])
    72        
     75        clear:setText("X")
     76
    7377        orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked")
     78        orxonox.KeyBinderManager:getInstance():subscribeEventHelper(clear, "Clicked", P.filename .. ".KeyBindClear_clicked")
    7479        --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked")
    7580       
    7681        line:addChildWindow(command)
    7782        line:addChildWindow(button)
     83        line:addChildWindow(clear)
    7884        window:addChildWindow(line)
    7985    end
     
    8389    local we = CEGUI.toWindowEventArgs(e)
    8490    local name = we.window:getName()
    85     commandNr = tonumber(string.match(name, "%d+"))
     91    buttonNr = tonumber(string.match(name, "%d+"))
    8692   
    8793    openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind)
    8894end
    8995
     96function P.KeyBindClear_clicked(e)
     97    local we = CEGUI.toWindowEventArgs(e)
     98    local name = we.window:getName()
     99    clearNr = tonumber(string.match(name, "%d+"))
     100   
     101   
     102end
     103
    90104function P.keybind()
    91     local funct = luaState:createLuaFunctor("InfoPopup:close()")
     105    local funct = luaState:createLuaFunctor("KeyBindMenu.callback(" .. buttonNr ..")")
    92106    orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct)
    93     orxonox.KeyBinderManager:getInstance():keybind(commandList[commandNr])
     107    orxonox.KeyBinderManager:getInstance():keybind(commandList[buttonNr])
     108end
     109
     110function P.callback(number)
     111    orxonox.KeyBinderManager:getInstance():registerKeybindCallback(0)
     112    local button = winMgr:getWindow("orxonox/KeyBindPane/Binding" .. number .. "/Button")
     113    button:setText(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[number]))
     114   
     115    InfoPopup.close()
    94116end
    95117
Note: See TracChangeset for help on using the changeset viewer.