Add error code to onError protocol event

This commit is contained in:
Eduardo Bart
2012-07-09 19:45:34 -03:00
parent 59f75d996e
commit e7691b873b
7 changed files with 30 additions and 22 deletions

View File

@@ -123,7 +123,7 @@ function onGameLoginError(message)
end
end
function onGameConnectionError(message)
function onGameConnectionError(code, message)
CharacterList.destroyLoadBox()
errorBox = displayErrorBox(tr("Login Error"), message)
errorBox.onOk = function()

View File

@@ -7,21 +7,14 @@ local motdButton
local enterGameButton
-- private functions
local function clearAccountFields()
enterGame:getChildById('accountNameTextEdit'):clearText()
enterGame:getChildById('accountPasswordTextEdit'):clearText()
enterGame:getChildById('accountNameTextEdit'):focus()
g_settings.remove('account')
g_settings.remove('password')
end
local function onError(protocol, message, connectionError)
local function onError(protocol, message, errorCode)
loadBox:destroy()
loadBox = nil
if not connectionError then
clearAccountFields()
if not errorCode then
EnterGame.clearAccountFields()
end
local errorBox = displayErrorBox(tr('Login Error'), message)
connect(errorBox, { onOk = EnterGame.show })
end
@@ -38,7 +31,7 @@ local function onCharacterList(protocol, characters, premDays)
g_settings.set('password', g_crypt.encrypt(G.password))
g_settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
else
clearAccountFields()
EnterGame.clearAccountFields()
end
loadBox:destroy()
@@ -123,6 +116,15 @@ function EnterGame.openWindow()
end
end
function EnterGame.clearAccountFields()
enterGame:getChildById('accountNameTextEdit'):clearText()
enterGame:getChildById('accountPasswordTextEdit'):clearText()
enterGame:getChildById('accountNameTextEdit'):focus()
g_settings.remove('account')
g_settings.remove('password')
end
function EnterGame.doLogin()
G.account = enterGame:getChildById('accountNameTextEdit'):getText()
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()