2011-07-17 08:56:57 +02:00
|
|
|
function EnterGame_connectToLoginServer()
|
2011-07-27 01:13:27 +02:00
|
|
|
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
|
|
|
|
|
2011-07-27 01:13:27 +02:00
|
|
|
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
|
|
|
|
|
2011-07-27 01:13:27 +02:00
|
|
|
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))
|
2011-08-16 14:47:30 +02:00
|
|
|
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
|