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-14 04:09:11 +02:00
local enterGameWindow = rootWidget:getChild("enterGameWindow")
2011-08-20 22:30:41 +02:00
local account = enterGameWindow:getChild("accountNameLineEdit"):getText()
local password = enterGameWindow:getChild("accountPasswordLineEdit"):getText()
2011-07-17 08:56:57 +02:00
protocolLogin:login(account, password)
enterGameWindow:destroy()
end