parent
3d4cfb793e
commit
65c1867f55
@ -1,55 +1,36 @@
|
|||||||
function EnterGame_connectToLoginServer()
|
function EnterGame_connectToLoginServer()
|
||||||
-- create login protocol
|
|
||||||
local protocolLogin = ProtocolLogin.create()
|
local protocolLogin = ProtocolLogin.create()
|
||||||
|
|
||||||
-- used to recreate enter game window
|
|
||||||
local recreateEnterGame = function()
|
local recreateEnterGame = function()
|
||||||
loadUI("/mainmenu/ui/entergamewindow.otui")
|
rootWidget:addChild(loadUI("/mainmenu/ui/entergamewindow.otui"))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- display loading message box
|
|
||||||
local loadBox = displayCancelBox("Please wait", "Connecting..")
|
local loadBox = displayCancelBox("Please wait", "Connecting..")
|
||||||
|
|
||||||
-- cancel loading callback
|
|
||||||
loadBox.onCancel = function(msgbox)
|
loadBox.onCancel = function(msgbox)
|
||||||
-- cancel protocol and reacreate enter game window
|
-- cancel protocol and reacreate enter game window
|
||||||
protocolLogin:cancel()
|
protocolLogin:cancelLogin()
|
||||||
recreateEnterGame()
|
recreateEnterGame()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- error callback
|
|
||||||
protocolLogin.onError = function(protocol, error)
|
protocolLogin.onError = function(protocol, error)
|
||||||
-- destroy loading message box
|
|
||||||
loadBox:destroy()
|
loadBox:destroy()
|
||||||
|
|
||||||
-- display error message
|
|
||||||
local errorBox = displayErrorBox("Login Error", error)
|
local errorBox = displayErrorBox("Login Error", error)
|
||||||
|
|
||||||
-- cancel protocol and reacreate enter game window
|
|
||||||
protocol:cancel()
|
|
||||||
errorBox.onOk = recreateEnterGame
|
errorBox.onOk = recreateEnterGame
|
||||||
end
|
end
|
||||||
|
|
||||||
-- motd callback
|
|
||||||
protocolLogin.onMotd = function(protocol, motd)
|
protocolLogin.onMotd = function(protocol, motd)
|
||||||
-- destroy loading message box
|
|
||||||
loadBox:destroy()
|
loadBox:destroy()
|
||||||
|
|
||||||
-- display motd
|
|
||||||
local motdNumber = string.sub(motd, 0, string.find(motd, "\n"))
|
local motdNumber = string.sub(motd, 0, string.find(motd, "\n"))
|
||||||
local motdText = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
|
local motdText = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
|
||||||
local motdBox = displayInfoBox("Message of the day", motdText)
|
displayInfoBox("Message of the day", motdText)
|
||||||
|
|
||||||
-- hide main menu
|
|
||||||
mainMenu.visible = false
|
mainMenu.visible = false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get account and password then login
|
|
||||||
local enterGameWindow = rootWidget:getChild("enterGameWindow")
|
local enterGameWindow = rootWidget:getChild("enterGameWindow")
|
||||||
local account = enterGameWindow:getChild("accountNameLineEdit").text
|
local account = enterGameWindow:getChild("accountNameLineEdit").text
|
||||||
local password = enterGameWindow:getChild("accountPasswordLineEdit").text
|
local password = enterGameWindow:getChild("accountPasswordLineEdit").text
|
||||||
protocolLogin:login(account, password)
|
protocolLogin:login(account, password)
|
||||||
|
|
||||||
-- destroy enter game window
|
|
||||||
enterGameWindow:destroy()
|
enterGameWindow:destroy()
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in new issue