mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 15:26:49 +01:00
logout improvments
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
-- private variables
|
||||
local showCharacterListOnLogout = true
|
||||
|
||||
-- private functions
|
||||
local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardCtrlModifier then
|
||||
@@ -8,7 +5,7 @@ local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers)
|
||||
CharacterList.show()
|
||||
return true
|
||||
elseif keyCode == KeyQ then
|
||||
Game.logout()
|
||||
Game.logout(false)
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -35,21 +32,20 @@ function Game.onLogin()
|
||||
createMainInterface()
|
||||
end
|
||||
|
||||
function Game.onLoginError(message)
|
||||
CharacterList.destroyLoadBox()
|
||||
local errorBox = displayErrorBox("Login Error", "Login error: " .. message)
|
||||
errorBox.onOk = CharacterList.show
|
||||
end
|
||||
|
||||
function Game.onConnectionError(message)
|
||||
CharacterList.destroyLoadBox()
|
||||
local errorBox = displayErrorBox("Login Error", "Connection error: " .. message)
|
||||
errorBox.onOk = CharacterList.show
|
||||
showCharacterListOnLogout = false
|
||||
end
|
||||
|
||||
function Game.onLogout()
|
||||
MainMenu.show()
|
||||
|
||||
if showCharacterListOnLogout then
|
||||
CharacterList.show()
|
||||
else
|
||||
showCharacterListOnLogout = true
|
||||
end
|
||||
|
||||
CharacterList.show()
|
||||
destroyMainInterface()
|
||||
end
|
||||
|
||||
@@ -10,4 +10,4 @@ UIWidget
|
||||
anchors.left: gameMap.right
|
||||
anchors.top: parent.top
|
||||
text: Logout
|
||||
onClick: Game.logout()
|
||||
onClick: Game.logout(false)
|
||||
@@ -17,15 +17,26 @@ local function onCharactersWindowKeyPress(self, keyCode, keyChar, keyboardModifi
|
||||
return false
|
||||
end
|
||||
|
||||
local function tryLogin(charInfo)
|
||||
CharacterList.hide()
|
||||
local function tryLogin(charInfo, tries)
|
||||
tries = tries or 1
|
||||
|
||||
if Game.isOnline() then
|
||||
Game.logout()
|
||||
scheduleEvent(function() tryLogin(charInfo) end, 250)
|
||||
if tries > 4 then
|
||||
CharacterList.destroyLoadBox()
|
||||
displayErrorBox('Error', 'Could not logout.')
|
||||
return
|
||||
end
|
||||
|
||||
if Game.isOnline() then
|
||||
Game.logout(false)
|
||||
if tries == 1 then
|
||||
loadBox = displayCancelBox('Please wait', 'Loggin out...')
|
||||
end
|
||||
scheduleEvent(function() tryLogin(charInfo, tries+1) end, 250)
|
||||
return
|
||||
end
|
||||
|
||||
CharacterList.destroyLoadBox()
|
||||
|
||||
Game.loginWorld(EnterGame.account, EnterGame.password, charInfo.worldHost, charInfo.worldPort, charInfo.characterName)
|
||||
|
||||
loadBox = displayCancelBox('Please wait', 'Connecting to game server...')
|
||||
@@ -79,8 +90,10 @@ function CharacterList.hide()
|
||||
end
|
||||
|
||||
function CharacterList.show()
|
||||
charactersWindow:show()
|
||||
charactersWindow:lock()
|
||||
if not loadBox then
|
||||
charactersWindow:show()
|
||||
charactersWindow:lock()
|
||||
end
|
||||
end
|
||||
|
||||
function CharacterList.doLogin()
|
||||
@@ -89,6 +102,7 @@ function CharacterList.doLogin()
|
||||
local charInfo = { worldHost = selected.worldHost,
|
||||
worldPort = selected.worldPort,
|
||||
characterName = selected.characterName }
|
||||
CharacterList.hide()
|
||||
tryLogin(charInfo)
|
||||
else
|
||||
displayErrorBox('Error', 'You must select a character to login!')
|
||||
|
||||
Reference in New Issue
Block a user