diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index ae72a9e..bd1d233 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -313,12 +313,13 @@ function EnterGame.checkNewLogin() if url ~= newLoginUrl then return end if err then return end if not data["qrcode"] then return end - if newLogin:isHidden() then - newLogin:show() - enterGame:raise() - end newLogin.qrcode:setImageSourceBase64(data["qrcode"]) newLogin.code:setText(data["code"]) + if enterGame:isHidden() then return end + if newLogin:isHidden() then + newLogin:show() + newLogin:raise() + end end) end diff --git a/modules/client_options/game.otui b/modules/client_options/game.otui index 8a0eaa0..558df41 100644 --- a/modules/client_options/game.otui +++ b/modules/client_options/game.otui @@ -26,6 +26,36 @@ Panel !text: tr('Enable smart walking') !tooltip: tr('Will detect when to use diagonal step based on the\nkeys you are pressing') + OptionCheckBox + id: ignoreServerDirection + !text: tr('Ignore server direction') + !tooltip: tr('Doesn\'t change direction when walk is canceled') + + OptionCheckBox + id: realDirection + !text: tr('Show real direction') + !tooltip: tr('Shows real creature direction while it\'s walking') + + Label + anchors.top: prev.bottom + anchors.left: parent.left + anchors.right: parent.right + id: hotkeyDelayLabel + margin-top: 10 + !tooltip: tr('Give you some time to make a turn while walking if you press many keys simultaneously') + @onSetup: | + local value = modules.client_options.getOption('hotkeyDelay') + self:setText(tr('Hotkey delay: %s ms', value)) + + OptionScrollbar + id: hotkeyDelay + anchors.top: prev.bottom + anchors.left: parent.left + anchors.right: parent.right + margin-top: 3 + minimum: 5 + maximum: 50 + Label anchors.top: prev.bottom anchors.left: parent.left diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 49e8b4a..f96c6c2 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -40,11 +40,14 @@ local defaultOptions = { turnDelay = 30, hotkeyDelay = 30, + ignoreServerDirection = true, + realDirection = false, + wsadWalking = false, walkFirstStepDelay = 200, walkTurnDelay = 100, walkStairsDelay = 50, - walkTeleportDelay = 200 + walkTeleportDelay = 200 } local optionsWindow @@ -292,6 +295,12 @@ function setOption(key, value, force) if modules.game_console and modules.game_console.consoleToggleChat:isChecked() ~= value then modules.game_console.consoleToggleChat:setChecked(value) end + elseif key == 'ignoreServerDirection' then + g_game.ignoreServerDirection(value) + elseif key == 'realDirection' then + g_game.showRealDirection(value) + elseif key == 'hotkeyDelay' then + generalPanel:getChildById('hotkeyDelayLabel'):setText(tr('Hotkey delay: %s ms', value)) elseif key == 'walkFirstStepDelay' then generalPanel:getChildById('walkFirstStepDelayLabel'):setText(tr('Walk delay after first step: %s ms', value)) elseif key == 'walkTurnDelay' then diff --git a/modules/corelib/keyboard.lua b/modules/corelib/keyboard.lua index 04f6eb4..463fe1e 100644 --- a/modules/corelib/keyboard.lua +++ b/modules/corelib/keyboard.lua @@ -187,6 +187,31 @@ function g_keyboard.isKeyPressed(key) return g_window.isKeyPressed(key) end +function g_keyboard.areKeysPressed(keyComboDesc) + for i,currentKeyDesc in ipairs(keyComboDesc:split('+')) do + for keyCode, keyDesc in pairs(KeyCodeDescs) do + if keyDesc:lower() == currentKeyDesc:trim():lower() then + if keyDesc:lower() == "ctrl" then + if not g_keyboard.isCtrlPressed() then + return false + end + elseif keyDesc:lower() == "shift" then + if not g_keyboard.isShiftPressed() then + return false + end + elseif keyDesc:lower() == "alt" then + if not g_keyboard.isAltPressed() then + return false + end + elseif not g_window.isKeyPressed(keyCode) then + return false + end + end + end + end + return true +end + function g_keyboard.isKeySetPressed(keys, all) all = all or false local result = {} diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 2cfac2a..8c5c0bd 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -202,6 +202,7 @@ function enableChat(temporarily) consoleTextEdit:setVisible(true) consoleTextEdit:setText("") + consoleTextEdit:focus() g_keyboard.unbindKeyDown("Space") g_keyboard.unbindKeyDown("Enter") diff --git a/modules/game_features/features.lua b/modules/game_features/features.lua index 9b0b882..c2eeba0 100644 --- a/modules/game_features/features.lua +++ b/modules/game_features/features.lua @@ -8,7 +8,7 @@ end function updateFeatures(version) g_game.resetFeatures() - + if(version >= 770) then g_game.enableFeature(GameLooktypeU16); g_game.enableFeature(GameMessageStatements); diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index c0d4052..305749a 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -373,7 +373,7 @@ function addKeyCombo(keyCombo, keySettings, focus) updateHotkeyLabel(hotkeyLabel) - boundCombosCallback[keyCombo] = function() doKeyCombo(keyCombo) end + boundCombosCallback[keyCombo] = function() scheduleEvent(function() doKeyCombo(keyCombo) end, g_settings.getNumber('hotkeyDelay')) end g_keyboard.bindKeyPress(keyCombo, boundCombosCallback[keyCombo]) end @@ -392,6 +392,10 @@ function doKeyCombo(keyCombo) return end end + if modules.game_walking then + modules.game_walking.checkTurn() + end + local hotKey = hotkeyList[keyCombo] if not hotKey then return end diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index 107abaa..e68c501 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -65,7 +65,7 @@ function init() end function bindKeys() - gameRootPanel:setAutoRepeatDelay(20) + gameRootPanel:setAutoRepeatDelay(10) g_keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel) g_keyboard.bindKeyPress('Ctrl+=', function() if g_game.getFeature(GameNoDebug) then return end gameMapPanel:zoomIn() end, gameRootPanel) diff --git a/modules/game_walking/walking.lua b/modules/game_walking/walking.lua index 6b4cb23..0c337ee 100644 --- a/modules/game_walking/walking.lua +++ b/modules/game_walking/walking.lua @@ -10,6 +10,7 @@ walkLock = 0 lastWalk = 0 lastTurn = 0 lastTurnDirection = 0 +turnKeys = {} function init() connect(LocalPlayer, { @@ -147,6 +148,7 @@ function unbindWalkKey(key) end function bindTurnKey(key, dir) + turnKeys[key] = dir local gameRootPanel = modules.game_interface.getRootPanel() g_keyboard.bindKeyDown(key, function() turn(dir, false) end, gameRootPanel) g_keyboard.bindKeyPress(key, function() turn(dir, true) end, gameRootPanel) @@ -154,6 +156,7 @@ function bindTurnKey(key, dir) end function unbindTurnKey(key) + turnKeys[key] = nil local gameRootPanel = modules.game_interface.getRootPanel() g_keyboard.unbindKeyDown(key, gameRootPanel) g_keyboard.unbindKeyPress(key, gameRootPanel) @@ -197,12 +200,14 @@ function changeWalkDir(dir, pop) end function smartWalk(dir) - if g_keyboard.getModifiers() == KeyboardNoModifier then - local direction = smartWalkDir or dir - walk(direction) - return true - end - return false + scheduleEvent(function() + if g_keyboard.getModifiers() == KeyboardNoModifier then + local direction = smartWalkDir or dir + walk(direction) + return true + end + return false + end, 20) end function canChangeFloorDown(pos) @@ -265,6 +270,7 @@ function walk(dir) end if player:isWalkLocked() then + nextWalkDir = nil return end @@ -273,11 +279,16 @@ function walk(dir) if ticksToNextWalk < 500 and lastWalkDir ~= dir then nextWalkDir = dir end - if ticksToNextWalk < 20 and lastFinishedStep + 400 > g_clock.millis() and nextWalkDir == nil then -- clicked walk 20 ms too early, try to execute again as soon possible to keep smooth walking + if ticksToNextWalk < 30 and lastFinishedStep + 400 > g_clock.millis() and nextWalkDir == nil then -- clicked walk 20 ms too early, try to execute again as soon possible to keep smooth walking nextWalkDir = dir end return end + + --if nextWalkDir ~= nil and lastFinishedStep + 200 < g_clock.millis() then + -- print("Cancel " .. nextWalkDir) + -- nextWalkDir = nil + --end if nextWalkDir ~= nil and nextWalkDir ~= lastWalkDir then dir = nextWalkDir @@ -308,6 +319,7 @@ function walk(dir) local toTile = g_map.getTile(toPos) if walkLock >= g_clock.millis() and lastWalkDir == dir then + nextWalkDir = nil return end @@ -346,13 +358,28 @@ function walk(dir) end function turn(dir, repeated) - if not repeated or (lastTurnDirection == dir and lastTurn + 50 < g_clock.millis()) then + local player = g_game.getLocalPlayer() + if player:isWalking() and player:getWalkDirection() == dir then + return + end + + if not repeated or (lastTurn + 100 < g_clock.millis()) then g_game.turn(dir) changeWalkDir(dir) lastTurn = g_clock.millis() if not repeated then - lastTurn = g_clock.millis() + 200 + lastTurn = g_clock.millis() + 50 end lastTurnDirection = dir + nextWalkDir = nil + player:lockWalk(150) + end +end + +function checkTurn() + for keys, direction in pairs(turnKeys) do + if g_keyboard.areKeysPressed(keys) then + turn(direction, false) + end end end diff --git a/otclient_dx.exe b/otclient_dx.exe index 584a931..08ddb82 100644 Binary files a/otclient_dx.exe and b/otclient_dx.exe differ diff --git a/otclient_gl.exe b/otclient_gl.exe index 99ebaad..84e67f9 100644 Binary files a/otclient_gl.exe and b/otclient_gl.exe differ diff --git a/pdb/otclient_dx.pdb b/pdb/otclient_dx.pdb index c534b95..18436e5 100644 Binary files a/pdb/otclient_dx.pdb and b/pdb/otclient_dx.pdb differ diff --git a/pdb/otclient_gl.pdb b/pdb/otclient_gl.pdb index 543ee0f..86fe1c6 100644 Binary files a/pdb/otclient_gl.pdb and b/pdb/otclient_gl.pdb differ diff --git a/tutorials/Updater_encryption_compression.md b/tutorials/Updater_encryption_compression.md index f328c1a..c8fc7e7 100644 --- a/tutorials/Updater_encryption_compression.md +++ b/tutorials/Updater_encryption_compression.md @@ -25,6 +25,7 @@ type data.zip >> otclient_gl.exe type data.zip >> otclient_dx.exe ``` It will append data.zip archive to .exe file, `type` is windows equivalent of linux `cat`. + 9. Remove data.zip, send otclient_gl.exe, otclient_dx.exe, libEGL.dll, libGLESv2.dll and d3dcompiler_46.dll to players. ### WARNING: When using data.zip (also inside .exe), all files must be encrypted, otherwise otclient won't start (will display decryption error)