* Also changed the 'use with crosshair' hotkey color.
master
BeniS 11 years ago
parent 95593964bb
commit 74ebd7f903

@ -63,6 +63,9 @@ HorizontalScrollBar < UIScrollBar
image-clip: 0 65 52 13 image-clip: 0 65 52 13
image-border: 1 image-border: 1
$disabled:
color: #bbbbbb88
UIButton UIButton
id: decrementButton id: decrementButton
anchors.top: parent.top anchors.top: parent.top

@ -8,7 +8,7 @@ HotkeyColors = {
itemUse = '#8888FF', itemUse = '#8888FF',
itemUseSelf = '#00FF00', itemUseSelf = '#00FF00',
itemUseTarget = '#FF0000', itemUseTarget = '#FF0000',
itemUseWith = '#CC0000', itemUseWith = '#F5B325',
} }
hotkeysManagerLoaded = false hotkeysManagerLoaded = false
@ -59,8 +59,10 @@ function init()
itemWidget:setVisible(false) itemWidget:setVisible(false)
itemWidget:setFocusable(false) itemWidget:setFocusable(false)
connect(g_game, { onGameStart = onGameStart, connect(g_game, {
onGameEnd = hide }) onGameStart = onGameStart,
onGameEnd = hide
})
connect(currentHotkeysList, { onChildFocusChange = function (self, focusedChild) checkSelectedHotkey(focusedChild) end } ) connect(currentHotkeysList, { onChildFocusChange = function (self, focusedChild) checkSelectedHotkey(focusedChild) end } )
hotkeysManagerLoaded = true hotkeysManagerLoaded = true
@ -69,8 +71,10 @@ end
function terminate() function terminate()
hotkeysManagerLoaded = false hotkeysManagerLoaded = false
disconnect(g_game, { onGameStart = onGameStart, disconnect(g_game, {
onGameEnd = hide }) onGameStart = onGameStart,
onGameEnd = hide
})
g_keyboard.unbindKeyDown('Ctrl+K') g_keyboard.unbindKeyDown('Ctrl+K')
for keyCombo,v in pairs(hotkeyList) do for keyCombo,v in pairs(hotkeyList) do
@ -84,12 +88,12 @@ function terminate()
end end
function load() function load()
local hotkeySettings = g_settings.getNode('HotkeysManager') or {} local hotkeySettings = g_settings.getNode('HotkeysManager')
if hotkeySettings ~= nil then local hasCombos = false
if not table.empty(hotkeySettings) then
local playerHotkeySettings = hotkeySettings[g_game.getLocalPlayer():getName()] local playerHotkeySettings = hotkeySettings[g_game.getLocalPlayer():getName()]
local hasCombos = false if not table.empty(playerHotkeySettings) then
if playerHotkeySettings ~= nil then
for k, setting in pairs(playerHotkeySettings) do for k, setting in pairs(playerHotkeySettings) do
addKeyCombo(nil, setting.keyCombo, setting) addKeyCombo(nil, setting.keyCombo, setting)
hasCombos = true hasCombos = true
@ -99,12 +103,7 @@ function load()
-- add default F keys combos -- add default F keys combos
if not hasCombos then if not hasCombos then
for i=1,12 do loadDefautComboKeys()
addKeyCombo(nil, 'F' .. i)
end
for i=1,4 do
addKeyCombo(nil, 'Shift+F' .. i)
end
end end
end end
@ -122,7 +121,7 @@ function save()
value = child.value value = child.value
}) })
end end
g_settings.setNode('HotkeysManager', hotkeySettings) g_settings.setNode('HotkeysManager', hotkeySettings)
end end
@ -150,7 +149,7 @@ function ok()
hide() hide()
end end
function cancel() function reload()
local children = currentHotkeysList:getChildren() local children = currentHotkeysList:getChildren()
for i=1,#children do for i=1,#children do
hotkeyList[children[i].keyCombo] = nil hotkeyList[children[i].keyCombo] = nil
@ -162,9 +161,18 @@ function cancel()
hide() hide()
end end
function loadDefautComboKeys()
for i=1,12 do
addKeyCombo(nil, 'F' .. i)
end
for i=1,4 do
addKeyCombo(nil, 'Shift+F' .. i)
end
end
-- private functions -- private functions
function onGameStart() function onGameStart()
load() reload()
end end
function onChooseItemMouseRelease(self, mousePosition, mouseButton) function onChooseItemMouseRelease(self, mousePosition, mouseButton)

@ -14,7 +14,7 @@ MainWindow
size: 340 410 size: 340 410
@onEnter: modules.game_hotkeys.ok() @onEnter: modules.game_hotkeys.ok()
@onEscape: modules.game_hotkeys.cancel() @onEscape: modules.game_hotkeys.reload()
Label Label
id: currentHotkeysLabel id: currentHotkeysLabel
@ -178,7 +178,7 @@ MainWindow
width: 64 width: 64
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
@onClick: modules.game_hotkeys.cancel() @onClick: modules.game_hotkeys.reload()
HotkeyAssignWindow < MainWindow HotkeyAssignWindow < MainWindow
id: assignWindow id: assignWindow

Loading…
Cancel
Save