tibia-client/modules/mainmenu/entergame.lua

40 lines
1.3 KiB
Lua
Raw Normal View History

2011-07-17 08:56:57 +02:00
function EnterGame_connectToLoginServer()
local protocolLogin = ProtocolLogin.create()
2011-07-17 08:56:57 +02:00
local recreateEnterGame = function()
2011-08-16 06:24:20 +02:00
rootWidget:addChild(loadUI("/mainmenu/ui/entergamewindow.otui"))
2011-07-17 08:56:57 +02:00
end
local loadBox = displayCancelBox("Please wait", "Connecting..")
2011-07-27 01:55:39 +02:00
loadBox.onCancel = function(msgbox)
2011-07-17 08:56:57 +02:00
-- cancel protocol and reacreate enter game window
2011-08-16 06:24:20 +02:00
protocolLogin:cancelLogin()
2011-07-17 08:56:57 +02:00
recreateEnterGame()
end
protocolLogin.onError = function(protocol, error)
2011-07-17 08:56:57 +02:00
loadBox:destroy()
local errorBox = displayErrorBox("Login Error", error)
errorBox.onOk = recreateEnterGame
end
protocolLogin.onMotd = function(protocol, motd)
2011-07-17 08:56:57 +02:00
loadBox:destroy()
local motdNumber = string.sub(motd, 0, string.find(motd, "\n"))
local motdText = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
if motdNumber ~= Configs.get("motd") then
displayInfoBox("Message of the day", motdText)
Configs.set("motd", motdNumber)
end
mainMenu:hide()
2011-07-17 08:56:57 +02:00
end
2011-08-21 23:49:31 +02:00
local enterGameWindow = rootWidget:getChildById("enterGameWindow")
local account = enterGameWindow:getChildById("accountNameLineEdit"):getText()
local password = enterGameWindow:getChildById("accountPasswordLineEdit"):getText()
2011-07-17 08:56:57 +02:00
protocolLogin:login(account, password)
enterGameWindow:destroy()
end