Add turn and hotkey delay
This commit is contained in:
parent
2095951e07
commit
d889b5aaf2
|
@ -38,11 +38,51 @@ Panel
|
||||||
id: displayText
|
id: displayText
|
||||||
!text: tr('Display text messages')
|
!text: tr('Display text messages')
|
||||||
|
|
||||||
|
Label
|
||||||
|
id: turnDelayLabel
|
||||||
|
!text: tr('Turn delay: %sms', 30)
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 12
|
||||||
|
@onSetup: |
|
||||||
|
local value = modules.client_options.getOption('turnDelay')
|
||||||
|
self:setText(tr('Turn delay: %dms', value))
|
||||||
|
|
||||||
|
OptionScrollbar
|
||||||
|
id: turnDelay
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 3
|
||||||
|
minimum: 30
|
||||||
|
maximum: 250
|
||||||
|
|
||||||
|
Label
|
||||||
|
id: hotkeyDelayLabel
|
||||||
|
!text: tr('Hotkey delay: %dms', 30)
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 12
|
||||||
|
@onSetup: |
|
||||||
|
local value = modules.client_options.getOption('hotkeyDelay')
|
||||||
|
self:setText(tr('Hotkey delay: %dms', value))
|
||||||
|
|
||||||
|
OptionScrollbar
|
||||||
|
id: hotkeyDelay
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 3
|
||||||
|
minimum: 30
|
||||||
|
maximum: 250
|
||||||
|
|
||||||
Button
|
Button
|
||||||
id: changeLocale
|
id: changeLocale
|
||||||
!text: tr('Change language')
|
!text: tr('Change language')
|
||||||
@onClick: modules.client_locales.createWindow()
|
@onClick: modules.client_locales.createWindow()
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.left: prev.left
|
anchors.left: prev.left
|
||||||
margin-top: 5
|
margin-top: 12
|
||||||
width: 120
|
width: 120
|
||||||
|
|
|
@ -26,7 +26,9 @@ local defaultOptions = {
|
||||||
displayNames = true,
|
displayNames = true,
|
||||||
displayHealth = true,
|
displayHealth = true,
|
||||||
displayText = true,
|
displayText = true,
|
||||||
dontStretchShrink = false
|
dontStretchShrink = false,
|
||||||
|
turnDelay = 50,
|
||||||
|
hotkeyDelay = 50,
|
||||||
}
|
}
|
||||||
|
|
||||||
local optionsWindow
|
local optionsWindow
|
||||||
|
@ -228,6 +230,10 @@ function setOption(key, value, force)
|
||||||
addEvent(function()
|
addEvent(function()
|
||||||
modules.game_interface.updateStretchShrink()
|
modules.game_interface.updateStretchShrink()
|
||||||
end)
|
end)
|
||||||
|
elseif key == 'turnDelay' then
|
||||||
|
generalPanel:getChildById('turnDelayLabel'):setText(tr('Turn delay: %sms', value))
|
||||||
|
elseif key == 'hotkeyDelay' then
|
||||||
|
generalPanel:getChildById('hotkeyDelayLabel'):setText(tr('Hotkey delay: %sms', value))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- change value for keybind updates
|
-- change value for keybind updates
|
||||||
|
|
|
@ -36,6 +36,7 @@ useRadioGroup = nil
|
||||||
currentHotkeys = nil
|
currentHotkeys = nil
|
||||||
boundCombosCallback = {}
|
boundCombosCallback = {}
|
||||||
hotkeysList = {}
|
hotkeysList = {}
|
||||||
|
lastHotkeyTime = g_clock.millis()
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
function init()
|
function init()
|
||||||
|
@ -374,6 +375,12 @@ function doKeyCombo(keyCombo)
|
||||||
if not g_game.isOnline() then return end
|
if not g_game.isOnline() then return end
|
||||||
local hotKey = hotkeyList[keyCombo]
|
local hotKey = hotkeyList[keyCombo]
|
||||||
if not hotKey then return end
|
if not hotKey then return end
|
||||||
|
|
||||||
|
if g_clock.millis() - lastHotkeyTime < modules.client_options.getOption('hotkeyDelay') then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
lastHotkeyTime = g_clock.millis()
|
||||||
|
|
||||||
if hotKey.itemId == nil then
|
if hotKey.itemId == nil then
|
||||||
if not hotKey.value or #hotKey.value == 0 then return end
|
if not hotKey.value or #hotKey.value == 0 then return end
|
||||||
if hotKey.autoSend then
|
if hotKey.autoSend then
|
||||||
|
|
|
@ -17,6 +17,7 @@ smartWalkDirs = {}
|
||||||
smartWalkDir = nil
|
smartWalkDir = nil
|
||||||
walkFunction = nil
|
walkFunction = nil
|
||||||
hookedMenuOptions = {}
|
hookedMenuOptions = {}
|
||||||
|
lastDirTime = g_clock.millis()
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
g_ui.importStyle('styles/countwindow')
|
g_ui.importStyle('styles/countwindow')
|
||||||
|
@ -80,14 +81,15 @@ function bindKeys()
|
||||||
bindWalkKey('Numpad4', West)
|
bindWalkKey('Numpad4', West)
|
||||||
bindWalkKey('Numpad7', NorthWest)
|
bindWalkKey('Numpad7', NorthWest)
|
||||||
|
|
||||||
g_keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
|
bindTurnKey('Ctrl+Up', North)
|
||||||
g_keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
|
bindTurnKey('Ctrl+Right', East)
|
||||||
g_keyboard.bindKeyPress('Ctrl+Down', function() g_game.turn(South) changeWalkDir(South) end, gameRootPanel)
|
bindTurnKey('Ctrl+Down', South)
|
||||||
g_keyboard.bindKeyPress('Ctrl+Left', function() g_game.turn(West) changeWalkDir(West) end, gameRootPanel)
|
bindTurnKey('Ctrl+Left', West)
|
||||||
g_keyboard.bindKeyPress('Ctrl+Numpad8', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
|
bindTurnKey('Ctrl+Numpad8', North)
|
||||||
g_keyboard.bindKeyPress('Ctrl+Numpad6', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
|
bindTurnKey('Ctrl+Numpad6', East)
|
||||||
g_keyboard.bindKeyPress('Ctrl+Numpad2', function() g_game.turn(South) changeWalkDir(South) end, gameRootPanel)
|
bindTurnKey('Ctrl+Numpad2', South)
|
||||||
g_keyboard.bindKeyPress('Ctrl+Numpad4', function() g_game.turn(West) changeWalkDir(West) end, gameRootPanel)
|
bindTurnKey('Ctrl+Numpad4', West)
|
||||||
|
|
||||||
g_keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel)
|
g_keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel)
|
||||||
g_keyboard.bindKeyPress('Ctrl+=', function() gameMapPanel:zoomIn() end, gameRootPanel)
|
g_keyboard.bindKeyPress('Ctrl+=', function() gameMapPanel:zoomIn() end, gameRootPanel)
|
||||||
g_keyboard.bindKeyPress('Ctrl+-', function() gameMapPanel:zoomOut() end, gameRootPanel)
|
g_keyboard.bindKeyPress('Ctrl+-', function() gameMapPanel:zoomOut() end, gameRootPanel)
|
||||||
|
@ -109,6 +111,19 @@ function unbindWalkKey(key)
|
||||||
g_keyboard.unbindKeyPress(key, gameRootPanel)
|
g_keyboard.unbindKeyPress(key, gameRootPanel)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function bindTurnKey(key, dir)
|
||||||
|
local function callback(widget, code, repeatTicks)
|
||||||
|
if g_clock.millis() - lastDirTime >= modules.client_options.getOption('turnDelay') then
|
||||||
|
g_game.turn(dir)
|
||||||
|
changeWalkDir(dir)
|
||||||
|
|
||||||
|
lastDirTime = g_clock.millis()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
g_keyboard.bindKeyPress(key, callback, gameRootPanel)
|
||||||
|
end
|
||||||
|
|
||||||
function terminate()
|
function terminate()
|
||||||
hide()
|
hide()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue