tibia-client/data/modules/mainmenu/menustate.lua

58 lines
1.6 KiB
Lua
Raw Normal View History

-- menu state
function onEnterMenuState()
2011-05-19 19:11:05 +02:00
mainMenu = UI.load("mainmenu.yml")
end
function onLeaveMenuState()
end
function onApplicationClose()
onLeaveMenuState()
App.exit()
end
2011-05-31 03:55:34 +02:00
function enterGame_onOkClicked()
local enterGameWindow = UI.getRootContainer():child("enterGameWindow")
enterGameWindow.visible = false
local loadMessageBox = messageBox("Please wait", "Connecting..")
loadMessageBox.onDestroy = function()
--TODO: cancel protocol
enterGameWindow.visible = true
protocolLogin = nil
end
protocolLogin = ProtocolLogin.new()
protocolLogin.onError = function(error)
loadMessageBox.onDestroy = nil
loadMessageBox:destroy()
local msgBox = messageBox("Login Error", error)
msgBox.onDestroy = function()
enterGameWindow.visible = true
end
protocolLogin = nil
end
protocolLogin.onMotd = function(motd)
loadMessageBox.onDestroy = nil
loadMessageBox:destroy()
local msgBox = messageBox("Message of the day", motd)
msgBox.onDestroy = function()
enterGameWindow.visible = true
end
protocolLogin = nil
end
local account = enterGameWindow:child("accountNameTextEdit").text
local password = enterGameWindow:child("passwordTextEdit").text
protocolLogin:login(account, password)
end
-- here is where everything starts
if not initialStateLoaded then
onEnterMenuState()
2011-05-03 00:48:41 +02:00
App.onClose = onApplicationClose
initialStateLoaded = true
2011-05-01 20:47:35 +02:00
end