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