Fix a bug with autowalking & add prompt param for tryLogout.

(We don't want to be prompted when pressing Ctrl + Q or  Ctrl + L).
master
BeniS 11 years ago
parent c4adf2d817
commit 95abf2a1d2

@ -42,7 +42,8 @@ function init()
gameBottomPanel = gameRootPanel:getChildById('gameBottomPanel')
connect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })
logoutButton = modules.client_topmenu.addLeftButton('logoutButton', tr('Exit'), '/images/topbuttons/logout', tryLogout, true)
logoutButton = modules.client_topmenu.addLeftButton('logoutButton', tr('Exit'),
'/images/topbuttons/logout', tryLogout, true)
setupViewMode(0)
@ -104,8 +105,8 @@ function bindKeys()
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:zoomOut() end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+Q', tryLogout, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+L', tryLogout, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+Q', function() tryLogout(false) end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+L', function() tryLogout(false) end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+W', function() g_map.cleanTexts() modules.game_textmessage.clearMessages() end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+.', nextViewMode, gameRootPanel)
end
@ -228,7 +229,10 @@ function tryExit()
return true
end
function tryLogout()
function tryLogout(prompt)
if type(prompt) ~= "boolean" then
prompt = true
end
if not g_game.isOnline() then
exit()
return
@ -238,38 +242,41 @@ function tryLogout()
return
end
local msg, yesCallback
if not g_game.isConnectionOk() then
local yesCallback = function()
msg = 'Your connection is failing, if you logout now your character will be still online, do you want to force logout?'
yesCallback = function()
g_game.forceLogout()
if logoutWindow then
logoutWindow:destroy()
logoutWindow=nil
end
end
local noCallback = function()
logoutWindow:destroy()
logoutWindow=nil
end
logoutWindow = displayGeneralBox(tr('Logout'), tr('Your connection is failing, if you logout now your character will be still online, do you want to force logout?'), {
{ text=tr('Yes'), callback=yesCallback },
{ text=tr('No'), callback=noCallback },
anchor=AnchorHorizontalCenter}, yesCallback, noCallback)
else
local yesCallback = function()
msg = 'Are you sure you want to logout?'
yesCallback = function()
g_game.safeLogout()
logoutWindow:destroy()
logoutWindow=nil
end
local noCallback = function()
logoutWindow:destroy()
logoutWindow=nil
if logoutWindow then
logoutWindow:destroy()
logoutWindow=nil
end
end
end
logoutWindow = displayGeneralBox(tr('Logout'), tr('Are you sure you want to logout?'), {
local noCallback = function()
logoutWindow:destroy()
logoutWindow=nil
end
if prompt then
logoutWindow = displayGeneralBox(tr('Logout'), tr(msg), {
{ text=tr('Yes'), callback=yesCallback },
{ text=tr('No'), callback=noCallback },
anchor=AnchorHorizontalCenter}, yesCallback, noCallback)
else
yesCallback()
end
end

@ -72,7 +72,7 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
return false;
// last walk is not done yet
if(m_walkTimer.ticksElapsed() < getStepDuration())
if((m_walkTimer.ticksElapsed() < getStepDuration()) && !isAutoWalking())
return false;
// prewalk has a timeout, because for some reason that I don't know yet the server sometimes doesn't answer the prewalk
@ -83,7 +83,7 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
return false;
// cannot walk while already walking
if(m_walking && (!prewalkTimeouted || m_secondPreWalk))
if((m_walking && !isAutoWalking()) && (!prewalkTimeouted || m_secondPreWalk))
return false;
return true;

Loading…
Cancel
Save