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 06:24:20 +02:00
|
|
|
displayInfoBox("Message of the day", motdText)
|
2011-08-14 04:09:11 +02:00
|
|
|
mainMenu.visible = false
|
2011-07-17 08:56:57 +02:00
|
|
|
end
|
|
|
|
|
2011-08-14 04:09:11 +02:00
|
|
|
local enterGameWindow = rootWidget:getChild("enterGameWindow")
|
|
|
|
local account = enterGameWindow:getChild("accountNameLineEdit").text
|
|
|
|
local password = enterGameWindow:getChild("accountPasswordLineEdit").text
|
2011-07-17 08:56:57 +02:00
|
|
|
protocolLogin:login(account, password)
|
|
|
|
|
|
|
|
enterGameWindow:destroy()
|
|
|
|
end
|