more fixes
This commit is contained in:
parent
7b34d9336a
commit
ff8cc88ec8
|
@ -1,12 +1,12 @@
|
|||
HotkeysManager = {}
|
||||
|
||||
local hotkeysManagerLoaded = false
|
||||
local hotkeysWindow
|
||||
local hotkeysButton
|
||||
local currentHotkeysList
|
||||
local hotkeyLabelSelectedOnList
|
||||
local currentItemPreview
|
||||
local itemWidget
|
||||
local messageBox
|
||||
local addHotkey
|
||||
local removeHotkey
|
||||
local hotkeyText
|
||||
|
@ -58,9 +58,11 @@ function HotkeysManager.init()
|
|||
itemWidget:setVisible(false)
|
||||
itemWidget:setFocusable(false)
|
||||
|
||||
HotkeysManager.load()
|
||||
|
||||
connect(currentHotkeysList, { onChildFocusChange = function (self, focusedChild) HotkeysManager.checkSelectedHotkey(focusedChild) end } )
|
||||
|
||||
hotkeysManagerLoaded = true
|
||||
|
||||
HotkeysManager.load()
|
||||
end
|
||||
|
||||
function HotkeysManager.load()
|
||||
|
@ -69,8 +71,7 @@ function HotkeysManager.load()
|
|||
local label
|
||||
if hotkeySettings ~= nil then
|
||||
for i, v in pairs(hotkeySettings) do
|
||||
label = HotkeysManager.addKeyCombo(nil, v.keyCombo, v)
|
||||
HotkeysManager.checkSelectedHotkey(label)
|
||||
HotkeysManager.addKeyCombo(nil, v.keyCombo, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -89,14 +90,15 @@ function HotkeysManager.save()
|
|||
end
|
||||
|
||||
function HotkeysManager.terminate()
|
||||
hotkeysManagerLoaded = false
|
||||
|
||||
Keyboard.unbindKeyDown('Ctrl+K')
|
||||
HotkeysManager.save()
|
||||
|
||||
currentHotkeysList = nil
|
||||
hotkeyLabelSelectedOnList = nil
|
||||
currentItemPreview = nil
|
||||
itemWidget = nil
|
||||
messageBox = nil
|
||||
|
||||
hotkeyList = nil
|
||||
addHotkey = nil
|
||||
removeHotkey = nil
|
||||
|
@ -109,6 +111,8 @@ function HotkeysManager.terminate()
|
|||
useOnTarget = nil
|
||||
useWith = nil
|
||||
|
||||
itemWidget:destroy()
|
||||
itemWidget = nil
|
||||
hotkeysWindow:destroy()
|
||||
hotkeysWindow = nil
|
||||
hotkeysButton:destroy()
|
||||
|
@ -146,7 +150,6 @@ function HotkeysManager.onChooseItemMouseRelease(self, mousePosition, mouseButto
|
|||
if clickedWidget:getClassName() == 'UIMap' then
|
||||
local tile = clickedWidget:getTile(mousePosition)
|
||||
if tile then
|
||||
local thing = tile:getTopMoveThing()
|
||||
local thing = tile:getTopMoveThing()
|
||||
if thing then
|
||||
item = thing:asItem()
|
||||
|
@ -172,7 +175,7 @@ function HotkeysManager.onChooseItemMouseRelease(self, mousePosition, mouseButto
|
|||
end
|
||||
|
||||
function HotkeysManager.startChooseItem()
|
||||
mouseGrabberWidget = createWidget('UIWidget')
|
||||
local mouseGrabberWidget = createWidget('UIWidget')
|
||||
mouseGrabberWidget:setVisible(false)
|
||||
mouseGrabberWidget:setFocusable(false)
|
||||
|
||||
|
@ -186,7 +189,7 @@ end
|
|||
|
||||
function HotkeysManager.clearObject()
|
||||
hotkeyLabelSelectedOnList.itemId = nil
|
||||
currentItemPreview:setItemId(0) -- TODO: item:clear()
|
||||
currentItemPreview:clearItem()
|
||||
HotkeysManager.changeUseType(HOTKEY_MANAGER_USEONSELF)
|
||||
HotkeysManager.sendAutomatically(false)
|
||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': ')
|
||||
|
@ -225,7 +228,10 @@ function HotkeysManager.addHotkey()
|
|||
widget:setWidth(64)
|
||||
widget:addAnchor(AnchorBottom, 'parent', AnchorBottom)
|
||||
widget:addAnchor(AnchorRight, 'parent', AnchorRight)
|
||||
widget.onClick = function (self) self:getParent():destroy() end
|
||||
widget.onClick = function (self)
|
||||
messageBox = nil
|
||||
self:getParent():destroy()
|
||||
end
|
||||
|
||||
widget = createWidget('Button', messageBox)
|
||||
widget:setId('addButton')
|
||||
|
@ -235,11 +241,12 @@ function HotkeysManager.addHotkey()
|
|||
widget:addAnchor(AnchorBottom, 'cancelButton', AnchorBottom)
|
||||
widget:addAnchor(AnchorRight, 'cancelButton', AnchorLeft)
|
||||
widget:setMarginRight(10)
|
||||
widget.onClick = function (self) HotkeysManager.addKeyCombo(self:getParent(), self:getParent():getChildById('comboPreview').keyCombo) end
|
||||
widget.onClick = function (self)
|
||||
messageBox = nil
|
||||
HotkeysManager.addKeyCombo(self:getParent(), self:getParent():getChildById('comboPreview').keyCombo)
|
||||
end
|
||||
|
||||
connect(messageBox, { onKeyDown = HotkeysManager.hotkeyCapture }, true)
|
||||
|
||||
widget = nil
|
||||
end
|
||||
|
||||
function HotkeysManager.addKeyCombo(messageBox, keyCombo, keySettings)
|
||||
|
@ -275,8 +282,6 @@ function HotkeysManager.addKeyCombo(messageBox, keyCombo, keySettings)
|
|||
messageBox:destroy()
|
||||
messageBox = nil
|
||||
end
|
||||
|
||||
return label
|
||||
end
|
||||
|
||||
function HotkeysManager.call(keyCombo)
|
||||
|
@ -305,6 +310,7 @@ function HotkeysManager.call(keyCombo)
|
|||
end
|
||||
|
||||
function HotkeysManager.checkSelectedHotkey(focused)
|
||||
if hotkeysManagerLoaded then
|
||||
hotkeyLabelSelectedOnList = focused
|
||||
|
||||
if hotkeyLabelSelectedOnList ~= nil then
|
||||
|
@ -355,6 +361,7 @@ function HotkeysManager.checkSelectedHotkey(focused)
|
|||
useWith:setChecked(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function HotkeysManager.changeUseType(useType, checked)
|
||||
if checked == nil or checked then
|
||||
|
|
Loading…
Reference in New Issue