mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
More walk control optimization and fixes:
* Finished off the walking control optimization! (Should be smooth controlling now). * Fixed issue #151 * Fixed an issue with the character list. * Fixed a bug in the g_keyboard.isKeySetPressed function.
This commit is contained in:
@@ -231,17 +231,13 @@ function CharacterList.create(characters, account, otui)
|
||||
end
|
||||
|
||||
function CharacterList.destroy()
|
||||
charactersWindow:hide()
|
||||
CharacterList.hide(true)
|
||||
|
||||
if charactersWindow then
|
||||
characterList = nil
|
||||
charactersWindow:destroy()
|
||||
charactersWindow = nil
|
||||
end
|
||||
|
||||
if EnterGame and not g_game.isOnline() then
|
||||
EnterGame.show()
|
||||
end
|
||||
end
|
||||
|
||||
function CharacterList.show()
|
||||
@@ -252,8 +248,13 @@ function CharacterList.show()
|
||||
end
|
||||
end
|
||||
|
||||
function CharacterList.hide()
|
||||
function CharacterList.hide(showLogin)
|
||||
showLogin = showLogin or false
|
||||
charactersWindow:hide()
|
||||
|
||||
if showLogin and EnterGame and not g_game.isOnline() then
|
||||
EnterGame.show()
|
||||
end
|
||||
end
|
||||
|
||||
function CharacterList.showAgain()
|
||||
|
@@ -46,7 +46,7 @@ MainWindow
|
||||
size: 250 248
|
||||
visible: false
|
||||
@onEnter: CharacterList.doLogin()
|
||||
@onEscape: CharacterList.hide()
|
||||
@onEscape: CharacterList.hide(true)
|
||||
@onSetup: |
|
||||
g_keyboard.bindKeyPress('Up', function() self:getChildById('characters'):focusPreviousChild(KeyboardFocusReason) end, self)
|
||||
g_keyboard.bindKeyPress('Down', function() self:getChildById('characters'):focusNextChild(KeyboardFocusReason) end, self)
|
||||
@@ -113,4 +113,4 @@ MainWindow
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: CharacterList.destroy()
|
||||
@onClick: CharacterList.hide(true)
|
||||
|
@@ -196,9 +196,9 @@ function g_keyboard.isKeySetPressed(keys, all)
|
||||
local result = {}
|
||||
for k,v in pairs(keys) do
|
||||
if type(v) == 'string' then
|
||||
key = getKeyCode(v)
|
||||
v = getKeyCode(v)
|
||||
end
|
||||
if g_window.isKeyPressed(key) then
|
||||
if g_window.isKeyPressed(v) then
|
||||
if not all then
|
||||
return true
|
||||
end
|
||||
|
@@ -1,4 +1,4 @@
|
||||
WALK_AUTO_REPEAT_DELAY = 80
|
||||
WALK_AUTO_REPEAT_DELAY = 150
|
||||
|
||||
gameRootPanel = nil
|
||||
gameMapPanel = nil
|
||||
@@ -14,7 +14,7 @@ bottomSplitter = nil
|
||||
|
||||
lastWalkDir = nil
|
||||
arrowKeys = {
|
||||
[North] = "Up",
|
||||
[North] = 'Up',
|
||||
[South] = 'Down',
|
||||
[East] = 'Right',
|
||||
[West] = 'Left',
|
||||
@@ -182,7 +182,6 @@ function tryLogout()
|
||||
end
|
||||
|
||||
function smartWalk(defaultDir)
|
||||
--[[ TODO: Add walk event stack ]]
|
||||
local rebindKey = false
|
||||
local lastKey = arrowKeys[lastWalkDir]
|
||||
|
||||
@@ -229,11 +228,7 @@ function smartWalk(defaultDir)
|
||||
g_game.forceWalk(dir)
|
||||
end
|
||||
else
|
||||
--if g_game.getLocalPlayer():canWalk(dir) then
|
||||
g_game.walk(dir)
|
||||
--else
|
||||
|
||||
--end
|
||||
g_game.walk(dir)
|
||||
end
|
||||
|
||||
if rebindKey then
|
||||
@@ -284,7 +279,7 @@ function onUseWith(clickedWidget, mousePosition)
|
||||
if clickedWidget:getClassName() == 'UIMap' then
|
||||
local tile = clickedWidget:getTile(mousePosition)
|
||||
if tile then
|
||||
g_game.useWith(selectedThing, tile:getTopMultiUseThing())
|
||||
g_game.useWith(selectedThing, tile:getTopMultiUseThing(false))
|
||||
end
|
||||
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
||||
g_game.useWith(selectedThing, clickedWidget:getItem())
|
||||
|
Reference in New Issue
Block a user