a lot of changes in modules

This commit is contained in:
Eduardo Bart
2012-02-06 17:19:47 -02:00
parent add8505a5b
commit 88301c329a
50 changed files with 488 additions and 322 deletions

View File

@@ -42,11 +42,11 @@ local function tryLogin(charInfo, tries)
Game.loginWorld(EnterGame.account, EnterGame.password, charInfo.worldHost, charInfo.worldPort, charInfo.characterName)
loadBox = displayCancelBox('Please wait', 'Connecting to game server...')
function loadBox.onCancel()
loadBox = nil
Game.cancelLogin()
CharacterList.show()
end
connect(loadBox, { onCancel = function()
loadBox = nil
Game.cancelLogin()
CharacterList.show()
end })
-- save last used character
Settings.set('lastUsedCharacter', charInfo.characterName)

View File

@@ -8,7 +8,6 @@ local motdMessage
local motdButton
local enterGameButton
-- private functions
local function clearAccountFields()
enterGame:getChildById('accountNameLineEdit'):clearText()
@@ -20,11 +19,13 @@ end
local function onError(protocol, message, connectionError)
loadBox:destroy()
loadBox = nil
if not connectionError then
clearAccountFields()
end
local errorBox = displayErrorBox('Login Error', message)
errorBox.onOk = EnterGame.show
connect(errorBox, { onOk = EnterGame.show })
end
local function onMotd(protocol, motd)
@@ -43,13 +44,15 @@ local function onCharacterList(protocol, characters, premDays)
end
loadBox:destroy()
loadBox = nil
CharacterList.create(characters, premDays)
local lastMotdNumber = Settings.getNumber("motd")
if motdNumber and motdNumber ~= lastMotdNumber then
Settings.set("motd", motdNumber)
local motdBox = displayInfoBox("Message of the day", motdMessage)
motdBox.onOk = CharacterList.show
connect(motdBox, { onOk = CharacterList.show })
CharacterList.hide()
end
end
@@ -76,8 +79,13 @@ function EnterGame.init()
enterGame:getChildById('rememberPasswordBox'):setChecked(#account > 0)
enterGame:getChildById('accountNameLineEdit'):focus()
if #account > 0 and autologin then
addEvent(EnterGame.doLogin)
-- only open entergame when app starts
if not g_app.isRunning() then
if #account > 0 and autologin then
addEvent(EnterGame.doLogin)
end
else
enterGame:hide()
end
end
@@ -124,10 +132,11 @@ function EnterGame.doLogin()
protocolLogin.onCharacterList = onCharacterList
loadBox = displayCancelBox('Please wait', 'Connecting to login server...')
loadBox.onCancel = function(msgbox)
protocolLogin:cancelLogin()
EnterGame.show()
end
connect(loadBox, { onCancel = function(msgbox)
loadBox = nil
protocolLogin:cancelLogin()
EnterGame.show()
end })
protocolLogin:login(EnterGame.host, EnterGame.port, EnterGame.account, EnterGame.password)
end

View File

@@ -3,6 +3,8 @@ Module
description: Manages enter game and character list windows
author: OTClient team
website: https://github.com/edubart/otclient
autoload: true
autoload-antecedence: 150
onLoad: |
dofile 'entergame'