mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 23:26:51 +01:00
new script engine, and things maybe be bugged for a while
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
-- some aliases
|
||||
loadUI = UI.load
|
||||
rootUI = UI.getRootContainer()
|
||||
|
||||
@@ -3,6 +3,6 @@ AnchorNone = 0
|
||||
AnchorTop = 1
|
||||
AnchorBottom = 2
|
||||
AnchorLeft = 3
|
||||
AnchorRight = 4
|
||||
AnchorRight = 4
|
||||
AnchorVerticalCenter = 5
|
||||
AnchorHorizontalCenter = 6
|
||||
@@ -1,4 +1,3 @@
|
||||
require 'aliases'
|
||||
require 'enums'
|
||||
require 'constants'
|
||||
require 'util'
|
||||
|
||||
require 'messagebox'
|
||||
@@ -10,17 +10,21 @@ function MessageBox.create(title, text, flags)
|
||||
setmetatable(box, MessageBox)
|
||||
|
||||
-- create messagebox window
|
||||
local window = UIWindow.new("messageBoxWindow", rootUI)
|
||||
local window = UIWindow.create()
|
||||
id = "messageBoxWindow"
|
||||
window.title = title
|
||||
window:centerIn(rootUI)
|
||||
window:setLocked()
|
||||
window:setLocked(true)
|
||||
rootUI:addChild(window)
|
||||
|
||||
-- create messagebox label
|
||||
local label = UILabel.new("messageBoxLabel", window)
|
||||
local label = UILabel.create()
|
||||
id = "messageBoxLabel"
|
||||
label.text = text
|
||||
label:addAnchor(AnchorHorizontalCenter, window, AnchorHorizontalCenter)
|
||||
label:addAnchor(AnchorTop, window, AnchorTop)
|
||||
label:setMargin(27, 0)
|
||||
label:addAnchor(AnchorHorizontalCenter, window.id, AnchorHorizontalCenter)
|
||||
label:addAnchor(AnchorTop, window.id, AnchorTop)
|
||||
--label:setMargin(27, 0)
|
||||
window:addChild(label)
|
||||
|
||||
-- set window size based on label size
|
||||
window.width = label.width + 40
|
||||
@@ -28,27 +32,29 @@ function MessageBox.create(title, text, flags)
|
||||
|
||||
-- setup messagebox first button
|
||||
local buttonText
|
||||
local button1 = UIButton.new("messageBoxButton1", window)
|
||||
button1:addAnchor(AnchorBottom, window, AnchorBottom)
|
||||
button1:addAnchor(AnchorRight, window, AnchorRight)
|
||||
button1:setMargin(10)
|
||||
local button1 = UIButton.new()
|
||||
id = "messageBoxButton1"
|
||||
button1:addAnchor(AnchorBottom, window.id, AnchorBottom)
|
||||
button1:addAnchor(AnchorRight, window.id, AnchorRight)
|
||||
--button1:setMargin(10)
|
||||
button1.width = 64
|
||||
window:addChild(button1)
|
||||
|
||||
if flags == MessageBoxOk then
|
||||
buttonText = "Ok"
|
||||
button1.text = "Ok"
|
||||
box.onOk = createEmptyFunction()
|
||||
button1.onClick = function()
|
||||
box.onOk()
|
||||
box:destroy()
|
||||
end
|
||||
elseif flags == MessageBoxCancel then
|
||||
buttonText = "Cancel"
|
||||
button1.text = "Cancel"
|
||||
box.onCancel = createEmptyFunction()
|
||||
button1.onClick = function()
|
||||
box.onCancel()
|
||||
box:destroy()
|
||||
end
|
||||
end
|
||||
button1.text = buttonText
|
||||
|
||||
box.window = window
|
||||
return box
|
||||
@@ -1,8 +0,0 @@
|
||||
title: Core
|
||||
notes: Core utilities used by other modules
|
||||
author: edubart
|
||||
version: 1
|
||||
website: https://github.com/edubart/otclient
|
||||
enabled: true
|
||||
script: core.lua
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
function EnterGame_connectToLoginServer()
|
||||
-- create login protocol
|
||||
local protocolLogin = ProtocolLogin.new()
|
||||
local protocolLogin = ProtocolLogin.create()
|
||||
print(ProtocolLogin_mt)
|
||||
print(Protocol_mt)
|
||||
print(getmetatable(protocolLogin))
|
||||
|
||||
-- used to recreate enter game window
|
||||
local recreateEnterGame = function()
|
||||
@@ -11,14 +14,14 @@ function EnterGame_connectToLoginServer()
|
||||
local loadBox = displayCancelBox("Please wait", "Connecting..")
|
||||
|
||||
-- cancel loading callback
|
||||
loadBox.onCancel = function()
|
||||
loadBox.onCancel = function(protocol)
|
||||
-- cancel protocol and reacreate enter game window
|
||||
protocolLogin:cancel()
|
||||
protocol:cancel()
|
||||
recreateEnterGame()
|
||||
end
|
||||
|
||||
-- error callback
|
||||
protocolLogin.onError = function(error)
|
||||
protocolLogin.onError = function(protocol, error)
|
||||
-- destroy loading message box
|
||||
loadBox:destroy()
|
||||
|
||||
@@ -26,12 +29,12 @@ function EnterGame_connectToLoginServer()
|
||||
local errorBox = displayErrorBox("Login Error", error)
|
||||
|
||||
-- cancel protocol and reacreate enter game window
|
||||
self.cancel()
|
||||
protocol.cancel()
|
||||
errorBox.onOk = recreateEnterGame
|
||||
end
|
||||
|
||||
-- motd callback
|
||||
protocolLogin.onMotd = function(motd)
|
||||
protocolLogin.onMotd = function(protocol, motd)
|
||||
-- destroy loading message box
|
||||
loadBox:destroy()
|
||||
|
||||
@@ -41,14 +44,14 @@ function EnterGame_connectToLoginServer()
|
||||
local motdBox = displayInfoBox("Message of the day", motdText)
|
||||
|
||||
-- cancel protocol and reacreate enter game window
|
||||
self.cancel()
|
||||
protocol.cancel()
|
||||
motdBox.onOk = recreateEnterGame
|
||||
end
|
||||
|
||||
-- get account and password then login
|
||||
local enterGameWindow = rootUI:child("enterGameWindow")
|
||||
local account = enterGameWindow:child("accountNameTextEdit").text
|
||||
local password = enterGameWindow:child("passwordTextEdit").text
|
||||
local enterGameWindow = rootUI:getChild("enterGameWindow")
|
||||
local account = enterGameWindow:getChild("accountNameTextEdit").text
|
||||
local password = enterGameWindow:getChild("passwordTextEdit").text
|
||||
protocolLogin:login(account, password)
|
||||
|
||||
-- destroy enter game window
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
require 'entergame'
|
||||
|
||||
function initializeApplication()
|
||||
mainMenu = loadUI("ui/mainmenu")
|
||||
mainMenu = loadUI("ui/mainmenu", rootUI)
|
||||
end
|
||||
|
||||
function terminateApplication()
|
||||
App.exit()
|
||||
exit()
|
||||
end
|
||||
|
||||
-- here is where everything starts
|
||||
if not initialized then
|
||||
initializeApplication()
|
||||
App.onClose = terminateApplication
|
||||
onClose = terminateApplication
|
||||
initialized = true
|
||||
end
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
title: Main menu
|
||||
notes: Used to create the main menu
|
||||
enabled: true
|
||||
#dependencies
|
||||
interface: 020
|
||||
author: edubart
|
||||
version: 0.2
|
||||
scripts:
|
||||
- menustate.lua
|
||||
- mainmenu.lua
|
||||
@@ -1,67 +1,54 @@
|
||||
%window#enterGameWindow
|
||||
title: Enter Game
|
||||
size: [236, 178]
|
||||
size: [236, 160]
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onLoad: self:setLocked()
|
||||
|
||||
%label#accountNameLabel
|
||||
skin: large
|
||||
text: Account name
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 18
|
||||
margin.top: 33
|
||||
margin.top: 28
|
||||
|
||||
%textEdit#accountNameTextEdit
|
||||
text: tibialua0
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin.left: 18
|
||||
margin.right: 18
|
||||
|
||||
%label#passwordLabel
|
||||
text: "Password:"
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 18
|
||||
margin.top: 62
|
||||
skin: large
|
||||
text: Password
|
||||
anchors.left: prev.left
|
||||
anchors.top: prev.bottom
|
||||
margin.top: 8
|
||||
|
||||
%label#createAccountLabel
|
||||
text: |
|
||||
If you don't have
|
||||
an account yet
|
||||
%textEdit#passwordTextEdit
|
||||
text: lua123456
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin.left: 18
|
||||
margin.top: 87
|
||||
|
||||
%button#createAccountButton
|
||||
text: Create Account
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.top: 94
|
||||
margin.left: 132
|
||||
onClick: displayErrorBox("Error", "Not implemented yet")
|
||||
margin.right: 18
|
||||
|
||||
%button#okButton
|
||||
text: Ok
|
||||
size: [43, 20]
|
||||
anchors.right: parent.right
|
||||
width: 64
|
||||
anchors.right: next.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 10
|
||||
margin.right: 66
|
||||
margin.bottom: 16
|
||||
margin.right: 16
|
||||
onClick: EnterGame_connectToLoginServer()
|
||||
|
||||
%button#cancelButton
|
||||
text: Cancel
|
||||
size: [43, 20]
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 10
|
||||
margin.right: 13
|
||||
onClick: self.parent:destroy()
|
||||
|
||||
%textEdit#accountNameTextEdit
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
margin.top: 32
|
||||
margin.right: 18
|
||||
|
||||
%textEdit#passwordTextEdit
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
margin.top: 61
|
||||
margin.right: 18
|
||||
margin.bottom: 16
|
||||
margin.right: 16
|
||||
onClick: function(self) rootUI:getChild("enterGameWindow"):destroy() end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
size: [244, 221]
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onLoad: self.locked = true
|
||||
onLoad: function(self) self:setLocked() end
|
||||
|
||||
%panel#infoPanel
|
||||
skin: flatPanel
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
%button#websiteButton
|
||||
text: Github Page
|
||||
size: [80,22]
|
||||
size: [88, 24]
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin.bottom: 9
|
||||
@@ -55,9 +55,9 @@
|
||||
|
||||
%button#okButton
|
||||
text: Ok
|
||||
size: [43, 20]
|
||||
size: [46, 24]
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.top: 191
|
||||
margin.left: 188
|
||||
onClick: self.parent:destroy()
|
||||
onClick: function(self) self.parent:destroy() end
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
%panel#mainMenu
|
||||
skin: roundedGridPanel
|
||||
size: [117, 171]
|
||||
size: [144, 162]
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin.left: 60
|
||||
@@ -17,33 +17,26 @@
|
||||
text: Enter Game
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 16
|
||||
onClick: UI.load("entergamewindow")
|
||||
|
||||
%button#accessAccountButton
|
||||
text: Access Account
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 46
|
||||
onClick: displayErrorBox("Error", "Not implemented yet")
|
||||
margin.top: 18
|
||||
onClick: loadUI("entergamewindow", rootUI)
|
||||
|
||||
%button#optionsButton
|
||||
text: Options
|
||||
anchors.top: parent.top
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 76
|
||||
onClick: UI.load("optionswindow")
|
||||
margin.top: 10
|
||||
onClick: loadUI("optionswindow", rootUI)
|
||||
|
||||
%button#infoButton
|
||||
text: Info
|
||||
anchors.top: parent.top
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 106
|
||||
onClick: UI.load("infowindow")
|
||||
margin.top: 10
|
||||
onClick: loadUI("infowindow", rootUI)
|
||||
|
||||
%button#exitGameButton
|
||||
text: Exit
|
||||
anchors.top: parent.top
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 136
|
||||
margin.top: 10
|
||||
onClick: terminateApplication()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
size: [286, 262]
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onLoad: self.locked = true
|
||||
onLoad: function(self) self:setLocked(true) end
|
||||
|
||||
# general
|
||||
%button#generalButton
|
||||
@@ -17,10 +17,10 @@
|
||||
text: |-
|
||||
Change general
|
||||
game options
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 117
|
||||
margin.top: 29
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
margin.left: 10
|
||||
margin.top: -2
|
||||
|
||||
# graphics
|
||||
%button#graphicsButton
|
||||
@@ -34,10 +34,10 @@
|
||||
text: |-
|
||||
Change graphics and
|
||||
performance settings
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 117
|
||||
margin.top: 62
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
margin.left: 10
|
||||
margin.top: -2
|
||||
|
||||
# console
|
||||
%button#consoleButton
|
||||
@@ -49,10 +49,10 @@
|
||||
|
||||
%label#consoleLabel
|
||||
text: Customise the console
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 117
|
||||
margin.top: 95
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
margin.left: 10
|
||||
margin.top: -2
|
||||
|
||||
# hotkeys
|
||||
%button#hotkeysButton
|
||||
@@ -64,10 +64,10 @@
|
||||
|
||||
%label#hotkeysLabel
|
||||
text: Edit your hotkey texts
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin.left: 117
|
||||
margin.top: 128
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
margin.left: 10
|
||||
margin.top: -2
|
||||
|
||||
%lineDecoration#middleSeparator
|
||||
anchors.left: parent.left
|
||||
@@ -89,10 +89,10 @@
|
||||
text: |
|
||||
Show the most recent
|
||||
Message of the Day
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin.left: 117
|
||||
margin.bottom: 56
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
margin.left: 10
|
||||
margin.top: -2
|
||||
|
||||
%lineDecoration#bottomSeparator
|
||||
anchors.left: parent.left
|
||||
@@ -110,4 +110,4 @@
|
||||
anchors.bottom: parent.bottom
|
||||
margin.right: 10
|
||||
margin.bottom: 13
|
||||
onClick: self.parent:destroy()
|
||||
onClick: function(self) self.parent:destroy() end
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
title: Message box
|
||||
notes: Functions for creating message boxes
|
||||
author: edubart
|
||||
version: 1
|
||||
website: https://github.com/edubart/otclient
|
||||
enabled: true
|
||||
script: messagebox.lua
|
||||
|
||||
Reference in New Issue
Block a user