mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 20:43:26 +02:00
protocol via script
This commit is contained in:
@@ -43,6 +43,7 @@ window#enterGameWindow
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 10
|
||||
margin.right: 66
|
||||
onClick: enterGame_onOkClicked()
|
||||
|
||||
button#cancelButton
|
||||
text: Cancel
|
||||
|
@@ -12,6 +12,43 @@ function onApplicationClose()
|
||||
App.exit()
|
||||
end
|
||||
|
||||
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()
|
||||
|
Reference in New Issue
Block a user