Skip to content

Commit

Permalink
improve: refactor walking for better responsivenes (#1028)
Browse files Browse the repository at this point in the history
* fix: schedule next walk event for smoother turning

* Better walking

* Fix diagonals incorrect prewalk

* fix scrollbar option anchor

* Add feature for prewalk and lower option delays for better experience

* Change key repeat to 10ms
  • Loading branch information
nekiro authored Jan 16, 2025
1 parent 28ecde8 commit 4b97a68
Show file tree
Hide file tree
Showing 17 changed files with 298 additions and 212 deletions.
33 changes: 17 additions & 16 deletions modules/client_options/data_options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,28 @@ return {
g_app.setDrawTexts(value)
end
},
walkFirstStepDelay = {
value = 250,
action = function(value, options, controller, panels, extraWidgets)
panels.generalPanel:recursiveGetChildById('walkFirstStepDelay'):setText(string.format(
'Walk Delay after first step: %sms', value))
g_game.setWalkFirstStepDelay(value)
end
},
walkTurnDelay = {
value = 100,
action = function(value, options, controller, panels, extraWidgets)
panels.generalPanel:recursiveGetChildById('walkTurnDelay'):setText(string.format(
'Walk delay after turn: %sms',
value))
g_game.setWalkTurnDelay(value)
end
},
turnDelay = {
walkTeleportDelay = {
value = 50,
action = function(value, options, controller, panels, extraWidgets)
panels.generalPanel:recursiveGetChildById('turnDelay'):setText(string.format('Turn delay: %sms', value))
panels.generalPanel:recursiveGetChildById('walkTeleportDelay'):setText(string.format(
'Walk delay after teleport: %sms',
value))
end
},
walkStairsDelay = {
value = 50,
action = function(value, options, controller, panels, extraWidgets)
panels.generalPanel:recursiveGetChildById('walkStairsDelay'):setText(string.format(
'Walk delay after floor change: %sms',
value))
end
},
hotkeyDelay = {
Expand Down Expand Up @@ -418,7 +419,7 @@ return {
end
end
},
showExpiryInInvetory = {
showExpiryInInvetory = {
value = true,
event = nil,
action = function(value, options, controller, panels, extraWidgets)
Expand All @@ -431,7 +432,7 @@ return {
end, 100)
end
},
showExpiryInContainers = {
showExpiryInContainers = {
value = true,
event = nil,
action = function(value, options, controller, panels, extraWidgets)
Expand Down Expand Up @@ -463,10 +464,10 @@ return {
end, 100)
end
},
autoSwitchPreset = false,
listKeybindsPanel = {
autoSwitchPreset = false,
listKeybindsPanel = {
action = function(value, options, controller, panels, extraWidgets)
listKeybindsComboBox(value)
end
},
}
}
1 change: 1 addition & 0 deletions modules/client_options/options.otui
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ OptionScaleScroll < Label
id: valueBar
step: 1
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
margin-right: 3
width: 174
@onValueChange: |
Expand Down
28 changes: 14 additions & 14 deletions modules/client_options/styles/controls/general.otui
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ UIWidget
height: 22

OptionScaleScroll
id: walkFirstStepDelay
!text: tr('Walk Delay after first step: 50ms')
id: walkTurnDelay
!text: tr('Walk delay after turn: 50ms')
anchors.fill: parent
&minimumScrollValue: 50
&minimumScrollValue: 10
&maximumScrollValue: 500
&scrollSize: 21
@onSetup: |
local value = modules.client_options.getOption('walkFirstStepDelay')
self:setText(tr('Walk Delay after first step: %dms', value))
local value = modules.client_options.getOption('walkTurnDelay')
self:setText(tr('Walk delay after turn: %dms', value))

SmallReversedQtPanel
anchors.left: parent.left
Expand All @@ -132,14 +132,14 @@ UIWidget
height: 22

OptionScaleScroll
id: walkTurnDelay
!text: tr('Walk delay after turn: 50ms')
id: walkTeleportDelay
!text: tr('Walk delay after teleport: 200ms')
anchors.fill: parent
&minimumScrollValue: 50
&maximumScrollValue: 500
&scrollSize: 21
@onSetup: |
local value = modules.client_options.getOption('walkTurnDelay')
local value = modules.client_options.getOption('walkTeleportDelay')
self:setText(tr('Walk delay after turn: %dms', value))

SmallReversedQtPanel
Expand All @@ -150,15 +150,15 @@ UIWidget
height: 22

OptionScaleScroll
id: turnDelay
!text: tr('Turn delay: 30ms')
id: walkStairsDelay
!text: tr('Walk delay after floor change: 200ms')
anchors.fill: parent
&minimumScrollValue: 30
&maximumScrollValue: 250
&minimumScrollValue: 50
&maximumScrollValue: 500
&scrollSize: 21
@onSetup: |
local value = modules.client_options.getOption('turnDelay')
self:setText(tr('Turn delay: %dms', value))
local value = modules.client_options.getOption('walkStairsDelay')
self:setText(tr('Walk delay after turn: %dms', value))

QtButton
id: hotkeysButton
Expand Down
5 changes: 3 additions & 2 deletions modules/game_features/features.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ controller:registerEvents(g_game, {
-- g_game.enableFeature(GameNegativeOffset)
-- g_game.enableFeature(GameWingsAurasEffectsShader)
-- g_game.enableFeature(GameAllowCustomBotScripts)


g_game.enableFeature(GameAllowPreWalk)
g_game.enableFeature(GameFormatCreatureName)

if version >= 750 then
Expand Down Expand Up @@ -226,7 +227,7 @@ controller:registerEvents(g_game, {
end

if version >= 1314 then
g_game.disableFeature(GameTournamentPackets)
g_game.disableFeature(GameTournamentPackets)
g_game.enableFeature(GameDynamicForgeVariables)
end

Expand Down
Loading

0 comments on commit 4b97a68

Please sign in to comment.