- Timestamp:
- Dec 9, 2009, 1:56:36 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua
r6281 r6283 56 56 57 57 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") 58 60 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") 61 62 62 63 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))) 63 65 button:setSize(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(1, 0))) 64 c ommand: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))) 65 67 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)))) 67 69 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))) 69 72 73 command:setText(nameList[k]) 70 74 button:setText(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(v)) 71 c ommand:setText(nameList[k])72 75 clear:setText("X") 76 73 77 orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked") 78 orxonox.KeyBinderManager:getInstance():subscribeEventHelper(clear, "Clicked", P.filename .. ".KeyBindClear_clicked") 74 79 --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked") 75 80 76 81 line:addChildWindow(command) 77 82 line:addChildWindow(button) 83 line:addChildWindow(clear) 78 84 window:addChildWindow(line) 79 85 end … … 83 89 local we = CEGUI.toWindowEventArgs(e) 84 90 local name = we.window:getName() 85 commandNr = tonumber(string.match(name, "%d+"))91 buttonNr = tonumber(string.match(name, "%d+")) 86 92 87 93 openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind) 88 94 end 89 95 96 function 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 102 end 103 90 104 function P.keybind() 91 local funct = luaState:createLuaFunctor(" InfoPopup:close()")105 local funct = luaState:createLuaFunctor("KeyBindMenu.callback(" .. buttonNr ..")") 92 106 orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct) 93 orxonox.KeyBinderManager:getInstance():keybind(commandList[commandNr]) 107 orxonox.KeyBinderManager:getInstance():keybind(commandList[buttonNr]) 108 end 109 110 function 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() 94 116 end 95 117
Note: See TracChangeset
for help on using the changeset viewer.