optimizations and fixes
This commit is contained in:
parent
37f3f904c7
commit
458cdcc23e
|
@ -109,6 +109,10 @@ function Console.destroy()
|
||||||
consolePanel = nil
|
consolePanel = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Console.setLineEditText(text)
|
||||||
|
consoleLineEdit:setText(text)
|
||||||
|
end
|
||||||
|
|
||||||
function Console.addTab(name, focus)
|
function Console.addTab(name, focus)
|
||||||
local tab = consoleTabBar:addTab(name)
|
local tab = consoleTabBar:addTab(name)
|
||||||
if focus then
|
if focus then
|
||||||
|
|
|
@ -5,8 +5,19 @@ local hotkeysButton
|
||||||
local currentHotkeysList
|
local currentHotkeysList
|
||||||
local hotkeyLabelSelectedOnList
|
local hotkeyLabelSelectedOnList
|
||||||
local currentItemPreview
|
local currentItemPreview
|
||||||
local hotkeyList = {}
|
|
||||||
local itemWidget
|
local itemWidget
|
||||||
|
local messageBox
|
||||||
|
local addHotkey
|
||||||
|
local removeHotkey
|
||||||
|
local hotkeyText
|
||||||
|
local hotKeyTextLabel
|
||||||
|
local sendAutomatically
|
||||||
|
local selectObjectButton
|
||||||
|
local clearObjectButton
|
||||||
|
local useOnSelf
|
||||||
|
local useOnTarget
|
||||||
|
local useWith
|
||||||
|
local hotkeyList = {}
|
||||||
|
|
||||||
HOTKEY_MANAGER_USEONSELF = 1
|
HOTKEY_MANAGER_USEONSELF = 1
|
||||||
HOTKEY_MANAGER_USEONTARGET = 2
|
HOTKEY_MANAGER_USEONTARGET = 2
|
||||||
|
@ -23,14 +34,24 @@ local hotkeyColors = {
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
function HotkeysManager.init()
|
function HotkeysManager.init()
|
||||||
hotkeysWindow = displayUI('hotkeys_manager.otui')
|
hotkeysWindow = displayUI('hotkeys_manager.otui')
|
||||||
|
|
||||||
hotkeysWindow:setVisible(false)
|
hotkeysWindow:setVisible(false)
|
||||||
hotkeysButton = TopMenu.addButton('hotkeysButton', 'Hotkeys (Ctrl+K)', '/game_hotkeys/icon.png', HotkeysManager.toggle)
|
hotkeysButton = TopMenu.addButton('hotkeysButton', 'Hotkeys (Ctrl+K)', '/game_hotkeys/icon.png', HotkeysManager.toggle)
|
||||||
Keyboard.bindKeyDown('Ctrl+K', HotkeysManager.toggle)
|
Keyboard.bindKeyDown('Ctrl+K', HotkeysManager.toggle)
|
||||||
|
|
||||||
currentHotkeysList = hotkeysWindow:getChildById('currentHotkeys')
|
currentHotkeysList = hotkeysWindow:getChildById('currentHotkeys')
|
||||||
currentItemPreview = hotkeysWindow:getChildById('itemPreview')
|
currentItemPreview = hotkeysWindow:getChildById('itemPreview')
|
||||||
|
addHotkey = hotkeysWindow:getChildById('addHotkey')
|
||||||
|
removeHotkey = hotkeysWindow:getChildById('removeHotkey')
|
||||||
|
hotkeyText = hotkeysWindow:getChildById('hotkeyText')
|
||||||
|
hotKeyTextLabel = hotkeysWindow:getChildById('hotKeyTextLabel')
|
||||||
|
sendAutomatically = hotkeysWindow:getChildById('sendAutomatically')
|
||||||
|
selectObjectButton = hotkeysWindow:getChildById('selectObjectButton')
|
||||||
|
clearObjectButton = hotkeysWindow:getChildById('clearObjectButton')
|
||||||
|
useOnSelf = hotkeysWindow:getChildById('useOnSelf')
|
||||||
|
useOnTarget = hotkeysWindow:getChildById('useOnTarget')
|
||||||
|
useWith = hotkeysWindow:getChildById('useWith')
|
||||||
|
|
||||||
itemWidget = createWidget('UIItem')
|
itemWidget = createWidget('UIItem')
|
||||||
itemWidget:setVirtual(true)
|
itemWidget:setVirtual(true)
|
||||||
|
@ -38,16 +59,20 @@ function HotkeysManager.init()
|
||||||
itemWidget:setFocusable(false)
|
itemWidget:setFocusable(false)
|
||||||
|
|
||||||
HotkeysManager.load()
|
HotkeysManager.load()
|
||||||
|
|
||||||
|
connect(currentHotkeysList, { onChildFocusChange = function (self, focusedChild) HotkeysManager.checkSelectedHotkey(focusedChild) end } )
|
||||||
end
|
end
|
||||||
|
|
||||||
function HotkeysManager.load()
|
function HotkeysManager.load()
|
||||||
local hotkeySettings = Settings.getNode('HotkeysManager')
|
local hotkeySettings = Settings.getNode('HotkeysManager')
|
||||||
|
|
||||||
for i, v in pairs(hotkeySettings) do
|
local label
|
||||||
HotkeysManager.addKeyCombo(nil, v.keyCombo, v)
|
if hotkeySettings ~= nil then
|
||||||
|
for i, v in pairs(hotkeySettings) do
|
||||||
|
label = HotkeysManager.addKeyCombo(nil, v.keyCombo, v)
|
||||||
|
HotkeysManager.checkSelectedHotkey(label)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
HotkeysManager.checkSelectedHotkey()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function HotkeysManager.save()
|
function HotkeysManager.save()
|
||||||
|
@ -64,34 +89,52 @@ function HotkeysManager.save()
|
||||||
end
|
end
|
||||||
|
|
||||||
function HotkeysManager.terminate()
|
function HotkeysManager.terminate()
|
||||||
Keyboard.unbindKeyDown('Ctrl+K')
|
Keyboard.unbindKeyDown('Ctrl+K')
|
||||||
HotkeysManager.save()
|
HotkeysManager.save()
|
||||||
hotkeysWindow:destroy()
|
|
||||||
hotkeysWindow = nil
|
currentHotkeysList = nil
|
||||||
hotkeysButton:destroy()
|
hotkeyLabelSelectedOnList = nil
|
||||||
hotkeysButton = nil
|
currentItemPreview = nil
|
||||||
|
itemWidget = nil
|
||||||
|
messageBox = nil
|
||||||
|
hotkeyList = nil
|
||||||
|
addHotkey = nil
|
||||||
|
removeHotkey = nil
|
||||||
|
hotkeyText = nil
|
||||||
|
hotKeyTextLabel = nil
|
||||||
|
sendAutomatically = nil
|
||||||
|
selectObjectButton = nil
|
||||||
|
clearObjectButton = nil
|
||||||
|
useOnSelf = nil
|
||||||
|
useOnTarget = nil
|
||||||
|
useWith = nil
|
||||||
|
|
||||||
|
hotkeysWindow:destroy()
|
||||||
|
hotkeysWindow = nil
|
||||||
|
hotkeysButton:destroy()
|
||||||
|
hotkeysButton = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function HotkeysManager.toggle()
|
function HotkeysManager.toggle()
|
||||||
if hotkeysWindow:isVisible() then
|
if hotkeysWindow:isVisible() then
|
||||||
HotkeysManager.hide()
|
HotkeysManager.hide()
|
||||||
else
|
else
|
||||||
HotkeysManager.show()
|
HotkeysManager.show()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function HotkeysManager.show()
|
function HotkeysManager.show()
|
||||||
if Game.isOnline() then
|
if Game.isOnline() then
|
||||||
hotkeysWindow:grabKeyboard()
|
hotkeysWindow:grabKeyboard()
|
||||||
hotkeysWindow:show()
|
hotkeysWindow:show()
|
||||||
hotkeysWindow:lock()
|
hotkeysWindow:lock()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function HotkeysManager.hide()
|
function HotkeysManager.hide()
|
||||||
hotkeysWindow:ungrabKeyboard()
|
hotkeysWindow:ungrabKeyboard()
|
||||||
hotkeysWindow:unlock()
|
hotkeysWindow:unlock()
|
||||||
hotkeysWindow:hide()
|
hotkeysWindow:hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- private functions
|
-- private functions
|
||||||
|
@ -104,11 +147,9 @@ function HotkeysManager.onChooseItemMouseRelease(self, mousePosition, mouseButto
|
||||||
local tile = clickedWidget:getTile(mousePosition)
|
local tile = clickedWidget:getTile(mousePosition)
|
||||||
if tile then
|
if tile then
|
||||||
local thing = tile:getTopMoveThing()
|
local thing = tile:getTopMoveThing()
|
||||||
if thing then
|
local thing = tile:getTopMoveThing()
|
||||||
local uiitem = thing:asItem()
|
if thing then
|
||||||
if uiitem then
|
item = thing:asItem()
|
||||||
item = uiitem:getItem()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
||||||
|
@ -121,7 +162,7 @@ function HotkeysManager.onChooseItemMouseRelease(self, mousePosition, mouseButto
|
||||||
currentItemPreview:setItemId(item:getId())
|
currentItemPreview:setItemId(item:getId())
|
||||||
hotkeyLabelSelectedOnList.itemId = item:getId()
|
hotkeyLabelSelectedOnList.itemId = item:getId()
|
||||||
HotkeysManager.changeUseType(HOTKEY_MANAGER_USEONSELF)
|
HotkeysManager.changeUseType(HOTKEY_MANAGER_USEONSELF)
|
||||||
HotkeysManager.checkSelectedHotkey()
|
HotkeysManager.checkSelectedHotkey(hotkeyLabelSelectedOnList)
|
||||||
HotkeysManager:show()
|
HotkeysManager:show()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,59 +186,64 @@ end
|
||||||
|
|
||||||
function HotkeysManager.clearObject()
|
function HotkeysManager.clearObject()
|
||||||
hotkeyLabelSelectedOnList.itemId = nil
|
hotkeyLabelSelectedOnList.itemId = nil
|
||||||
currentItemPreview:setItemId(0) --TODO: call :clear() after get it binded
|
currentItemPreview:setItemId(0) -- TODO: item:clear()
|
||||||
HotkeysManager.changeUseType(HOTKEY_MANAGER_USEONSELF)
|
HotkeysManager.changeUseType(HOTKEY_MANAGER_USEONSELF)
|
||||||
HotkeysManager.sendAutomatically(false)
|
HotkeysManager.sendAutomatically(false)
|
||||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': ')
|
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': ')
|
||||||
|
|
||||||
HotkeysManager.checkSelectedHotkey()
|
HotkeysManager.checkSelectedHotkey(hotkeyLabelSelectedOnList)
|
||||||
end
|
end
|
||||||
|
|
||||||
function HotkeysManager.addHotkey()
|
function HotkeysManager.addHotkey()
|
||||||
local messageBox = createWidget('MainWindow', hotkeysWindow)
|
local widget
|
||||||
|
|
||||||
|
messageBox = createWidget('MainWindow', hotkeysWindow)
|
||||||
messageBox:setId('assignWindow')
|
messageBox:setId('assignWindow')
|
||||||
messageBox:setText('Button Assign')
|
messageBox:setText('Button Assign')
|
||||||
messageBox:setWidth(420)
|
messageBox:setWidth(420)
|
||||||
messageBox:setHeight(140)
|
messageBox:setHeight(140)
|
||||||
messageBox:setDragable(false)
|
messageBox:setDragable(false)
|
||||||
|
|
||||||
local label = createWidget('Label', messageBox)
|
widget = createWidget('Label', messageBox)
|
||||||
label:setText('Please, press the key you wish to add onto your hotkeys manager')
|
widget:setText('Please, press the key you wish to add onto your hotkeys manager')
|
||||||
label:resizeToText()
|
widget:resizeToText()
|
||||||
label:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter)
|
widget:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter)
|
||||||
label:addAnchor(AnchorTop, 'parent', AnchorTop)
|
widget:addAnchor(AnchorTop, 'parent', AnchorTop)
|
||||||
|
|
||||||
local label = createWidget('Label', messageBox)
|
widget = createWidget('Label', messageBox)
|
||||||
label:setId('comboPreview')
|
widget:setId('comboPreview')
|
||||||
label:setText('Current hotkey to add: None')
|
widget:setText('Current hotkey to add: None')
|
||||||
label.keyCombo = ''
|
widget.keyCombo = ''
|
||||||
label:resizeToText()
|
widget:resizeToText()
|
||||||
label:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter)
|
widget:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter)
|
||||||
label:addAnchor(AnchorTop, 'prev', AnchorBottom)
|
widget:addAnchor(AnchorTop, 'prev', AnchorBottom)
|
||||||
label:setMarginTop(20)
|
widget:setMarginTop(20)
|
||||||
|
|
||||||
local button = createWidget('Button', messageBox)
|
widget = createWidget('Button', messageBox)
|
||||||
button:setId('cancelButton')
|
widget:setId('cancelButton')
|
||||||
button:setText('Cancel')
|
widget:setText('Cancel')
|
||||||
button:setWidth(64)
|
widget:setWidth(64)
|
||||||
button:addAnchor(AnchorBottom, 'parent', AnchorBottom)
|
widget:addAnchor(AnchorBottom, 'parent', AnchorBottom)
|
||||||
button:addAnchor(AnchorRight, 'parent', AnchorRight)
|
widget:addAnchor(AnchorRight, 'parent', AnchorRight)
|
||||||
button.onClick = function () messageBox:destroy() end
|
widget.onClick = function (self) self:getParent():destroy() end
|
||||||
|
|
||||||
local button = createWidget('Button', messageBox)
|
widget = createWidget('Button', messageBox)
|
||||||
button:setId('addButton')
|
widget:setId('addButton')
|
||||||
button:setText('Add')
|
widget:setText('Add')
|
||||||
button:setWidth(64)
|
widget:setWidth(64)
|
||||||
button:disable()
|
widget:disable()
|
||||||
button:addAnchor(AnchorBottom, 'cancelButton', AnchorBottom)
|
widget:addAnchor(AnchorBottom, 'cancelButton', AnchorBottom)
|
||||||
button:addAnchor(AnchorRight, 'cancelButton', AnchorLeft)
|
widget:addAnchor(AnchorRight, 'cancelButton', AnchorLeft)
|
||||||
button:setMarginRight(10)
|
widget:setMarginRight(10)
|
||||||
button.onClick = function () HotkeysManager.addKeyCombo(messageBox, label.keyCombo) end
|
widget.onClick = function (self) 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)
|
||||||
|
local label = nil
|
||||||
if currentHotkeysList:getChildById(keyCombo) == nil then
|
if currentHotkeysList:getChildById(keyCombo) == nil then
|
||||||
local label = createWidget('HotkeyListLabel', currentHotkeysList)
|
local label = createWidget('HotkeyListLabel', currentHotkeysList)
|
||||||
label:setId(keyCombo)
|
label:setId(keyCombo)
|
||||||
|
@ -218,17 +264,19 @@ function HotkeysManager.addKeyCombo(messageBox, keyCombo, keySettings)
|
||||||
label.useType = HOTKEY_MANAGER_USEONSELF
|
label.useType = HOTKEY_MANAGER_USEONSELF
|
||||||
label.value = ''
|
label.value = ''
|
||||||
end
|
end
|
||||||
connect(label, { onClick = function () HotkeysManager.checkSelectedHotkey() return true end } )
|
|
||||||
|
|
||||||
HotkeysManager.checkSelectedHotkey()
|
HotkeysManager.checkSelectedHotkey(label)
|
||||||
|
|
||||||
hotkeyList[keyCombo] = label
|
hotkeyList[keyCombo] = label
|
||||||
Keyboard.bindKeyDown(keyCombo, function () HotkeysManager.call(keyCombo) end)
|
Keyboard.bindKeyPress(keyCombo, function () HotkeysManager.call(keyCombo) end, nil, 350)
|
||||||
end
|
end
|
||||||
|
|
||||||
if messageBox then
|
if messageBox then
|
||||||
messageBox:destroy()
|
messageBox:destroy()
|
||||||
end
|
messageBox = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return label
|
||||||
end
|
end
|
||||||
|
|
||||||
function HotkeysManager.call(keyCombo)
|
function HotkeysManager.call(keyCombo)
|
||||||
|
@ -238,15 +286,15 @@ function HotkeysManager.call(keyCombo)
|
||||||
if hotKey.autoSend then
|
if hotKey.autoSend then
|
||||||
Game.talk(hotKey.value)
|
Game.talk(hotKey.value)
|
||||||
else
|
else
|
||||||
rootWidget:getChildById('gameRootInterface'):getChildById('gameBottomPanel'):getChildById('consolePanel'):getChildById('consoleLineEdit'):setText(hotKey.value)
|
Console.setLineEditText(hotKey.value)
|
||||||
end
|
end
|
||||||
elseif hotKey.itemId ~= nil then
|
elseif hotKey.itemId ~= nil then
|
||||||
if hotKey.useType == HOTKEY_MANAGER_USEONSELF then
|
if hotKey.useType == HOTKEY_MANAGER_USEONSELF then
|
||||||
Game.useInventoryItem(hotKey.itemId, Game.getLocalPlayer())
|
Game.useInventoryItemWith(hotKey.itemId, Game.getLocalPlayer())
|
||||||
elseif hotKey.useType == HOTKEY_MANAGER_USEONTARGET then
|
elseif hotKey.useType == HOTKEY_MANAGER_USEONTARGET then
|
||||||
local attackingCreature = Game.getLocalPlayer():getAttackingCreature()
|
local attackingCreature = Game.getLocalPlayer():getAttackingCreature()
|
||||||
if attackingCreature then
|
if attackingCreature then
|
||||||
Game.useInventoryItem(hotKey.itemId, attackingCreature)
|
Game.useInventoryItemWith(hotKey.itemId, attackingCreature)
|
||||||
end
|
end
|
||||||
elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then
|
elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then
|
||||||
itemWidget:setItemId(hotKey.itemId)
|
itemWidget:setItemId(hotKey.itemId)
|
||||||
|
@ -256,62 +304,55 @@ function HotkeysManager.call(keyCombo)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function HotkeysManager.checkSelectedHotkey()
|
function HotkeysManager.checkSelectedHotkey(focused)
|
||||||
hotkeyLabelSelectedOnList = nil
|
hotkeyLabelSelectedOnList = focused
|
||||||
for i = 1, currentHotkeysList:getChildCount() do
|
|
||||||
local child = currentHotkeysList:getChildByIndex(i)
|
|
||||||
if child:isFocused() then
|
|
||||||
hotkeyLabelSelectedOnList = child
|
|
||||||
break -- stop looping
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if hotkeyLabelSelectedOnList ~= nil then
|
if hotkeyLabelSelectedOnList ~= nil then
|
||||||
hotkeysWindow:getChildById('removeHotkey'):enable()
|
removeHotkey:enable()
|
||||||
|
|
||||||
if hotkeyLabelSelectedOnList.itemId == nil then
|
if hotkeyLabelSelectedOnList.itemId == nil then
|
||||||
hotkeysWindow:getChildById('hotkeyText'):enable()
|
hotkeyText:enable()
|
||||||
hotkeysWindow:getChildById('hotKeyTextLabel'):enable()
|
hotKeyTextLabel:enable()
|
||||||
hotkeysWindow:getChildById('hotkeyText'):setText(hotkeyLabelSelectedOnList.value)
|
hotkeyText:setText(hotkeyLabelSelectedOnList.value)
|
||||||
|
|
||||||
if hotkeyLabelSelectedOnList.value ~= '' then
|
if hotkeyLabelSelectedOnList.value ~= '' then
|
||||||
hotkeysWindow:getChildById('sendAutomatically'):enable()
|
sendAutomatically:enable()
|
||||||
else
|
else
|
||||||
hotkeysWindow:getChildById('sendAutomatically'):disable()
|
sendAutomatically:disable()
|
||||||
end
|
end
|
||||||
|
|
||||||
hotkeysWindow:getChildById('selectObjectButton'):enable()
|
selectObjectButton:enable()
|
||||||
hotkeysWindow:getChildById('clearObjectButton'):disable()
|
clearObjectButton:disable()
|
||||||
|
|
||||||
currentItemPreview:setItemId(0)
|
currentItemPreview:setItemId(0)
|
||||||
else
|
else
|
||||||
hotkeysWindow:getChildById('hotkeyText'):clearText()
|
hotkeyText:clearText()
|
||||||
hotkeysWindow:getChildById('hotkeyText'):disable()
|
hotkeyText:disable()
|
||||||
hotkeysWindow:getChildById('hotKeyTextLabel'):disable()
|
hotKeyTextLabel:disable()
|
||||||
hotkeysWindow:getChildById('sendAutomatically'):disable()
|
sendAutomatically:disable()
|
||||||
|
|
||||||
hotkeysWindow:getChildById('selectObjectButton'):disable()
|
selectObjectButton:disable()
|
||||||
hotkeysWindow:getChildById('clearObjectButton'):enable()
|
clearObjectButton:enable()
|
||||||
|
|
||||||
currentItemPreview:setItemId(hotkeyLabelSelectedOnList.itemId)
|
currentItemPreview:setItemId(hotkeyLabelSelectedOnList.itemId)
|
||||||
end
|
end
|
||||||
HotkeysManager.changeUseType(hotkeyLabelSelectedOnList.useType)
|
HotkeysManager.changeUseType(hotkeyLabelSelectedOnList.useType)
|
||||||
else
|
else
|
||||||
hotkeysWindow:getChildById('hotkeyText'):clearText()
|
hotkeyText:clearText()
|
||||||
hotkeysWindow:getChildById('removeHotkey'):disable()
|
removeHotkey:disable()
|
||||||
hotkeysWindow:getChildById('hotkeyText'):disable()
|
hotkeyText:disable()
|
||||||
hotkeysWindow:getChildById('sendAutomatically'):disable()
|
sendAutomatically:disable()
|
||||||
hotkeysWindow:getChildById('sendAutomatically'):setChecked(false)
|
sendAutomatically:setChecked(false)
|
||||||
|
|
||||||
currentItemPreview:setItemId(0)
|
currentItemPreview:setItemId(0)
|
||||||
hotkeysWindow:getChildById('selectObjectButton'):disable()
|
selectObjectButton:disable()
|
||||||
hotkeysWindow:getChildById('clearObjectButton'):disable()
|
clearObjectButton:disable()
|
||||||
hotkeysWindow:getChildById('useOnSelf'):disable()
|
useOnSelf:disable()
|
||||||
hotkeysWindow:getChildById('useOnTarget'):disable()
|
useOnTarget:disable()
|
||||||
hotkeysWindow:getChildById('useWith'):disable()
|
useWith:disable()
|
||||||
hotkeysWindow:getChildById('useOnSelf'):setChecked(false)
|
useOnSelf:setChecked(false)
|
||||||
hotkeysWindow:getChildById('useOnTarget'):setChecked(false)
|
useOnTarget:setChecked(false)
|
||||||
hotkeysWindow:getChildById('useWith'):setChecked(false)
|
useWith:setChecked(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -319,49 +360,49 @@ function HotkeysManager.changeUseType(useType, checked)
|
||||||
if checked == nil or checked then
|
if checked == nil or checked then
|
||||||
hotkeyLabelSelectedOnList.useType = useType
|
hotkeyLabelSelectedOnList.useType = useType
|
||||||
if hotkeyLabelSelectedOnList.itemId ~= nil and currentItemPreview:getItem():isMultiUse() then
|
if hotkeyLabelSelectedOnList.itemId ~= nil and currentItemPreview:getItem():isMultiUse() then
|
||||||
hotkeysWindow:getChildById('useOnSelf'):enable()
|
useOnSelf:enable()
|
||||||
hotkeysWindow:getChildById('useOnTarget'):enable()
|
useOnTarget:enable()
|
||||||
hotkeysWindow:getChildById('useWith'):enable()
|
useWith:enable()
|
||||||
|
|
||||||
if useType == HOTKEY_MANAGER_USEONSELF then
|
if useType == HOTKEY_MANAGER_USEONSELF then
|
||||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object on yourself)')
|
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object on yourself)')
|
||||||
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUseSelf)
|
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUseSelf)
|
||||||
hotkeysWindow:getChildById('useOnSelf'):setChecked(true)
|
useOnSelf:setChecked(true)
|
||||||
hotkeysWindow:getChildById('useOnTarget'):setChecked(false)
|
useOnTarget:setChecked(false)
|
||||||
hotkeysWindow:getChildById('useWith'):setChecked(false)
|
useWith:setChecked(false)
|
||||||
elseif useType == HOTKEY_MANAGER_USEONTARGET then
|
elseif useType == HOTKEY_MANAGER_USEONTARGET then
|
||||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object on target)')
|
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object on target)')
|
||||||
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUseTarget)
|
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUseTarget)
|
||||||
hotkeysWindow:getChildById('useOnSelf'):setChecked(false)
|
useOnSelf:setChecked(false)
|
||||||
hotkeysWindow:getChildById('useOnTarget'):setChecked(true)
|
useOnTarget:setChecked(true)
|
||||||
hotkeysWindow:getChildById('useWith'):setChecked(false)
|
useWith:setChecked(false)
|
||||||
elseif useType == HOTKEY_MANAGER_USEWITH then
|
elseif useType == HOTKEY_MANAGER_USEWITH then
|
||||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object with crosshair)')
|
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object with crosshair)')
|
||||||
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUseWith)
|
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUseWith)
|
||||||
|
|
||||||
hotkeysWindow:getChildById('useOnSelf'):setChecked(false)
|
useOnSelf:setChecked(false)
|
||||||
hotkeysWindow:getChildById('useOnTarget'):setChecked(false)
|
useOnTarget:setChecked(false)
|
||||||
hotkeysWindow:getChildById('useWith'):setChecked(true)
|
useWith:setChecked(true)
|
||||||
end
|
end
|
||||||
elseif hotkeyLabelSelectedOnList.itemId ~= nil and not currentItemPreview:getItem():isMultiUse() then
|
elseif hotkeyLabelSelectedOnList.itemId ~= nil and not currentItemPreview:getItem():isMultiUse() then
|
||||||
hotkeysWindow:getChildById('useOnSelf'):disable()
|
useOnSelf:disable()
|
||||||
hotkeysWindow:getChildById('useOnTarget'):disable()
|
useOnTarget:disable()
|
||||||
hotkeysWindow:getChildById('useWith'):disable()
|
useWith:disable()
|
||||||
|
|
||||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object)')
|
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo .. ': (use object)')
|
||||||
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUse)
|
hotkeyLabelSelectedOnList:setColor(hotkeyColors.itemUse)
|
||||||
|
|
||||||
hotkeysWindow:getChildById('useOnSelf'):setChecked(false)
|
useOnSelf:setChecked(false)
|
||||||
hotkeysWindow:getChildById('useOnTarget'):setChecked(false)
|
useOnTarget:setChecked(false)
|
||||||
hotkeysWindow:getChildById('useWith'):setChecked(false)
|
useWith:setChecked(false)
|
||||||
else
|
else
|
||||||
hotkeysWindow:getChildById('useOnSelf'):disable()
|
useOnSelf:disable()
|
||||||
hotkeysWindow:getChildById('useOnTarget'):disable()
|
useOnTarget:disable()
|
||||||
hotkeysWindow:getChildById('useWith'):disable()
|
useWith:disable()
|
||||||
|
|
||||||
hotkeysWindow:getChildById('useOnSelf'):setChecked(false)
|
useOnSelf:setChecked(false)
|
||||||
hotkeysWindow:getChildById('useOnTarget'):setChecked(false)
|
useOnTarget:setChecked(false)
|
||||||
hotkeysWindow:getChildById('useWith'):setChecked(false)
|
useWith:setChecked(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -369,21 +410,22 @@ end
|
||||||
function HotkeysManager.removeHotkey()
|
function HotkeysManager.removeHotkey()
|
||||||
if hotkeyLabelSelectedOnList ~= nil then
|
if hotkeyLabelSelectedOnList ~= nil then
|
||||||
hotkeyList[hotkeyLabelSelectedOnList.keyCombo] = nil
|
hotkeyList[hotkeyLabelSelectedOnList.keyCombo] = nil
|
||||||
Keyboard.unbindKeyDown(hotkeyLabelSelectedOnList.keyCombo)
|
Keyboard.unbindKeyPress(hotkeyLabelSelectedOnList.keyCombo)
|
||||||
hotkeyLabelSelectedOnList:destroy()
|
hotkeyLabelSelectedOnList:destroy()
|
||||||
HotkeysManager.checkSelectedHotkey()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function HotkeysManager.onHotkeyTextChange(id, value)
|
function HotkeysManager.onHotkeyTextChange(id, value)
|
||||||
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo ..': ' .. value)
|
if hotkeyLabelSelectedOnList ~= nil and hotkeyLabelSelectedOnList.keyCombo ~= nil then
|
||||||
hotkeyLabelSelectedOnList.value = value
|
hotkeyLabelSelectedOnList:setText(hotkeyLabelSelectedOnList.keyCombo ..': ' .. value)
|
||||||
|
hotkeyLabelSelectedOnList.value = value
|
||||||
if value ~= '' then
|
|
||||||
hotkeysWindow:getChildById('sendAutomatically'):enable()
|
if value ~= '' then
|
||||||
else
|
sendAutomatically:enable()
|
||||||
hotkeysWindow:getChildById('sendAutomatically'):disable()
|
else
|
||||||
hotkeysWindow:getChildById('sendAutomatically'):setChecked(false)
|
sendAutomatically:disable()
|
||||||
|
sendAutomatically:setChecked(false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue