tibia-client/modules/mainmenu/entergame.lua

57 lines
1.5 KiB
Lua
Raw Normal View History

EnterGame = { }
2011-08-26 20:00:22 +02:00
-- private variables
local password
local loadBox
local enterGameWindow
-- private functions
local function onError(protocol, error)
loadBox:destroy()
local errorBox = displayErrorBox('Login Error', error)
2011-08-30 00:34:15 +02:00
errorBox.onOk = EnterGame.create
2011-08-26 20:00:22 +02:00
end
local function onMotd(protocol, motd)
loadBox:destroy()
local motdNumber = string.sub(motd, 0, string.find(motd, "\n"))
local motdMessage = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
2011-08-26 20:44:18 +02:00
if motdNumber ~= Configs.get("motd") then
displayInfoBox("Message of the day", motdMessage)
Configs.set("motd", motdNumber)
end
end
local function onCharacterList(protocol, characters, premDays)
CharacterList.create(characters, premDays)
end
-- public functions
function EnterGame.create()
enterGameWindow = UI.loadAndDisplayLocked('/mainmenu/ui/entergamewindow.otui')
2011-08-26 20:44:18 +02:00
end
2011-08-26 20:00:22 +02:00
function EnterGame.destroy()
enterGameWindow:destroy()
enterGameWindow = nil
end
2011-07-17 08:56:57 +02:00
function EnterGame.doLogin()
EnterGame.account = enterGameWindow:getChildById('accountNameLineEdit'):getText()
EnterGame.password = enterGameWindow:getChildById('accountPasswordLineEdit'):getText()
EnterGame.destroy()
2011-07-17 08:56:57 +02:00
local protocolLogin = ProtocolLogin.create()
protocolLogin.onError = onError
protocolLogin.onMotd = onMotd
protocolLogin.onCharacterList = onCharacterList
2011-07-17 08:56:57 +02:00
loadBox = displayCancelBox('Please wait', 'Connecting to login server...')
2011-07-27 01:55:39 +02:00
loadBox.onCancel = function(msgbox)
2011-08-16 06:24:20 +02:00
protocolLogin:cancelLogin()
EnterGame.create()
2011-07-17 08:56:57 +02:00
end
protocolLogin:login(EnterGame.account, EnterGame.password)
2011-07-17 08:56:57 +02:00
end