Version 0.99 BETA

This commit is contained in:
OTCv8 2019-10-06 12:00:34 +02:00
parent b016c1dca4
commit bc977c268e
14 changed files with 115 additions and 17 deletions

View File

@ -313,12 +313,13 @@ function EnterGame.checkNewLogin()
if url ~= newLoginUrl then return end if url ~= newLoginUrl then return end
if err then return end if err then return end
if not data["qrcode"] 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.qrcode:setImageSourceBase64(data["qrcode"])
newLogin.code:setText(data["code"]) newLogin.code:setText(data["code"])
if enterGame:isHidden() then return end
if newLogin:isHidden() then
newLogin:show()
newLogin:raise()
end
end) end)
end end

View File

@ -26,6 +26,36 @@ Panel
!text: tr('Enable smart walking') !text: tr('Enable smart walking')
!tooltip: tr('Will detect when to use diagonal step based on the\nkeys you are pressing') !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 Label
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.left: parent.left anchors.left: parent.left

View File

@ -40,11 +40,14 @@ local defaultOptions = {
turnDelay = 30, turnDelay = 30,
hotkeyDelay = 30, hotkeyDelay = 30,
ignoreServerDirection = true,
realDirection = false,
wsadWalking = false, wsadWalking = false,
walkFirstStepDelay = 200, walkFirstStepDelay = 200,
walkTurnDelay = 100, walkTurnDelay = 100,
walkStairsDelay = 50, walkStairsDelay = 50,
walkTeleportDelay = 200 walkTeleportDelay = 200
} }
local optionsWindow local optionsWindow
@ -292,6 +295,12 @@ function setOption(key, value, force)
if modules.game_console and modules.game_console.consoleToggleChat:isChecked() ~= value then if modules.game_console and modules.game_console.consoleToggleChat:isChecked() ~= value then
modules.game_console.consoleToggleChat:setChecked(value) modules.game_console.consoleToggleChat:setChecked(value)
end 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 elseif key == 'walkFirstStepDelay' then
generalPanel:getChildById('walkFirstStepDelayLabel'):setText(tr('Walk delay after first step: %s ms', value)) generalPanel:getChildById('walkFirstStepDelayLabel'):setText(tr('Walk delay after first step: %s ms', value))
elseif key == 'walkTurnDelay' then elseif key == 'walkTurnDelay' then

View File

@ -187,6 +187,31 @@ function g_keyboard.isKeyPressed(key)
return g_window.isKeyPressed(key) return g_window.isKeyPressed(key)
end 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) function g_keyboard.isKeySetPressed(keys, all)
all = all or false all = all or false
local result = {} local result = {}

View File

@ -202,6 +202,7 @@ function enableChat(temporarily)
consoleTextEdit:setVisible(true) consoleTextEdit:setVisible(true)
consoleTextEdit:setText("") consoleTextEdit:setText("")
consoleTextEdit:focus()
g_keyboard.unbindKeyDown("Space") g_keyboard.unbindKeyDown("Space")
g_keyboard.unbindKeyDown("Enter") g_keyboard.unbindKeyDown("Enter")

View File

@ -8,7 +8,7 @@ end
function updateFeatures(version) function updateFeatures(version)
g_game.resetFeatures() g_game.resetFeatures()
if(version >= 770) then if(version >= 770) then
g_game.enableFeature(GameLooktypeU16); g_game.enableFeature(GameLooktypeU16);
g_game.enableFeature(GameMessageStatements); g_game.enableFeature(GameMessageStatements);

View File

@ -373,7 +373,7 @@ function addKeyCombo(keyCombo, keySettings, focus)
updateHotkeyLabel(hotkeyLabel) 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]) g_keyboard.bindKeyPress(keyCombo, boundCombosCallback[keyCombo])
end end
@ -392,6 +392,10 @@ function doKeyCombo(keyCombo)
return return
end end
end end
if modules.game_walking then
modules.game_walking.checkTurn()
end
local hotKey = hotkeyList[keyCombo] local hotKey = hotkeyList[keyCombo]
if not hotKey then return end if not hotKey then return end

View File

@ -65,7 +65,7 @@ function init()
end end
function bindKeys() function bindKeys()
gameRootPanel:setAutoRepeatDelay(20) gameRootPanel:setAutoRepeatDelay(10)
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() if g_game.getFeature(GameNoDebug) then return end gameMapPanel:zoomIn() end, gameRootPanel) g_keyboard.bindKeyPress('Ctrl+=', function() if g_game.getFeature(GameNoDebug) then return end gameMapPanel:zoomIn() end, gameRootPanel)

View File

@ -10,6 +10,7 @@ walkLock = 0
lastWalk = 0 lastWalk = 0
lastTurn = 0 lastTurn = 0
lastTurnDirection = 0 lastTurnDirection = 0
turnKeys = {}
function init() function init()
connect(LocalPlayer, { connect(LocalPlayer, {
@ -147,6 +148,7 @@ function unbindWalkKey(key)
end end
function bindTurnKey(key, dir) function bindTurnKey(key, dir)
turnKeys[key] = dir
local gameRootPanel = modules.game_interface.getRootPanel() local gameRootPanel = modules.game_interface.getRootPanel()
g_keyboard.bindKeyDown(key, function() turn(dir, false) end, gameRootPanel) g_keyboard.bindKeyDown(key, function() turn(dir, false) end, gameRootPanel)
g_keyboard.bindKeyPress(key, function() turn(dir, true) end, gameRootPanel) g_keyboard.bindKeyPress(key, function() turn(dir, true) end, gameRootPanel)
@ -154,6 +156,7 @@ function bindTurnKey(key, dir)
end end
function unbindTurnKey(key) function unbindTurnKey(key)
turnKeys[key] = nil
local gameRootPanel = modules.game_interface.getRootPanel() local gameRootPanel = modules.game_interface.getRootPanel()
g_keyboard.unbindKeyDown(key, gameRootPanel) g_keyboard.unbindKeyDown(key, gameRootPanel)
g_keyboard.unbindKeyPress(key, gameRootPanel) g_keyboard.unbindKeyPress(key, gameRootPanel)
@ -197,12 +200,14 @@ function changeWalkDir(dir, pop)
end end
function smartWalk(dir) function smartWalk(dir)
if g_keyboard.getModifiers() == KeyboardNoModifier then scheduleEvent(function()
local direction = smartWalkDir or dir if g_keyboard.getModifiers() == KeyboardNoModifier then
walk(direction) local direction = smartWalkDir or dir
return true walk(direction)
end return true
return false end
return false
end, 20)
end end
function canChangeFloorDown(pos) function canChangeFloorDown(pos)
@ -265,6 +270,7 @@ function walk(dir)
end end
if player:isWalkLocked() then if player:isWalkLocked() then
nextWalkDir = nil
return return
end end
@ -273,11 +279,16 @@ function walk(dir)
if ticksToNextWalk < 500 and lastWalkDir ~= dir then if ticksToNextWalk < 500 and lastWalkDir ~= dir then
nextWalkDir = dir nextWalkDir = dir
end 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 nextWalkDir = dir
end end
return return
end end
--if nextWalkDir ~= nil and lastFinishedStep + 200 < g_clock.millis() then
-- print("Cancel " .. nextWalkDir)
-- nextWalkDir = nil
--end
if nextWalkDir ~= nil and nextWalkDir ~= lastWalkDir then if nextWalkDir ~= nil and nextWalkDir ~= lastWalkDir then
dir = nextWalkDir dir = nextWalkDir
@ -308,6 +319,7 @@ function walk(dir)
local toTile = g_map.getTile(toPos) local toTile = g_map.getTile(toPos)
if walkLock >= g_clock.millis() and lastWalkDir == dir then if walkLock >= g_clock.millis() and lastWalkDir == dir then
nextWalkDir = nil
return return
end end
@ -346,13 +358,28 @@ function walk(dir)
end end
function turn(dir, repeated) 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) g_game.turn(dir)
changeWalkDir(dir) changeWalkDir(dir)
lastTurn = g_clock.millis() lastTurn = g_clock.millis()
if not repeated then if not repeated then
lastTurn = g_clock.millis() + 200 lastTurn = g_clock.millis() + 50
end end
lastTurnDirection = dir 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
end end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -25,6 +25,7 @@ type data.zip >> otclient_gl.exe
type data.zip >> otclient_dx.exe type data.zip >> otclient_dx.exe
``` ```
It will append data.zip archive to .exe file, `type` is windows equivalent of linux `cat`. 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. 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) ### WARNING: When using data.zip (also inside .exe), all files must be encrypted, otherwise otclient won't start (will display decryption error)