parent
b1a881eb06
commit
ab7394f357
@ -0,0 +1,11 @@
|
||||
rootUI = UI.getRootContainer()
|
||||
|
||||
-- AnchorPoint
|
||||
AnchorNone = 0
|
||||
AnchorTop = 1
|
||||
AnchorBottom = 2
|
||||
AnchorLeft = 3
|
||||
AnchorRight = 4
|
||||
AnchorVerticalCenter = 5
|
||||
AnchorHorizontalCenter = 6
|
||||
|
@ -0,0 +1,3 @@
|
||||
require 'constants'
|
||||
require 'util'
|
||||
require 'messagebox'
|
@ -0,0 +1,86 @@
|
||||
MessageBox = {}
|
||||
MessageBox.__index = MessageBox
|
||||
|
||||
-- messagebox flags
|
||||
MessageBoxOk = 1
|
||||
MessageBoxCancel = 2
|
||||
|
||||
function MessageBox.create(title, text, flags)
|
||||
local box = {}
|
||||
setmetatable(box, MessageBox)
|
||||
|
||||
-- create messagebox window
|
||||
local window = UIWindow.new("messageBoxWindow", rootUI)
|
||||
window.title = title
|
||||
window:centerIn(rootUI)
|
||||
window:setLocked()
|
||||
|
||||
-- create messagebox label
|
||||
local label = UILabel.new("messageBoxLabel", window)
|
||||
label.text = text
|
||||
label:addAnchor(AnchorHorizontalCenter, window, AnchorHorizontalCenter)
|
||||
label:addAnchor(AnchorTop, window, AnchorTop)
|
||||
label:setMargin(27, 0)
|
||||
|
||||
-- set window size based on label size
|
||||
window.width = label.width + 40
|
||||
window.height = label.height + 64
|
||||
|
||||
-- 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)
|
||||
|
||||
if flags == MessageBoxOk then
|
||||
buttonText = "Ok"
|
||||
box.onOk = createEmptyFunction()
|
||||
button1.onClick = function()
|
||||
box.onOk()
|
||||
box:destroy()
|
||||
end
|
||||
elseif flags == MessageBoxCancel then
|
||||
buttonText = "Cancel"
|
||||
box.onCancel = createEmptyFunction()
|
||||
button1.onClick = function()
|
||||
box.onCancel()
|
||||
box:destroy()
|
||||
end
|
||||
end
|
||||
button1.text = buttonText
|
||||
|
||||
box.window = window
|
||||
return box
|
||||
end
|
||||
|
||||
function MessageBox:destroy()
|
||||
if self.onDestroy then
|
||||
self.onDestroy()
|
||||
self.onDestroy = nil
|
||||
end
|
||||
if self.window then
|
||||
self.window:destroy()
|
||||
self.window = nil
|
||||
end
|
||||
self.onOk = nil
|
||||
self.onCancel = nil
|
||||
end
|
||||
|
||||
-- shortcuts for creating message boxes
|
||||
function displayMessageBox(title, text, flags)
|
||||
return MessageBox.create(title, text, flags)
|
||||
end
|
||||
|
||||
function displayErrorBox(title, text)
|
||||
return MessageBox.create(title, text, MessageBoxOk)
|
||||
end
|
||||
|
||||
function displayInfoBox(title, text)
|
||||
return MessageBox.create(title, text, MessageBoxOk)
|
||||
end
|
||||
|
||||
function displayCancelBox(title, text)
|
||||
return MessageBox.create(title, text, MessageBoxCancel)
|
||||
end
|
||||
|
@ -0,0 +1,9 @@
|
||||
title: Core
|
||||
description: Core utilities used by other modules
|
||||
author: otclient
|
||||
version: 1
|
||||
website: https://github.com/edubart/otclient
|
||||
enabled: true
|
||||
dependencies: [core_fonts, core_styles]
|
||||
script: core.lua
|
||||
|
@ -0,0 +1,5 @@
|
||||
function createEmptyFunction()
|
||||
local emptyFunction = function() end
|
||||
return emptyFunction
|
||||
end
|
||||
|
@ -0,0 +1,4 @@
|
||||
-- load default fonts
|
||||
App.loadFont("fonts/helvetica-11px")
|
||||
App.loadFont("fonts/helvetica-11px-bold")
|
||||
|
@ -0,0 +1,9 @@
|
||||
glyph-height: 14
|
||||
glyph-spacing: 1 1
|
||||
top-margin: 2
|
||||
image: helvetica-11px-bold.png
|
||||
image-glyph-size: 16 16
|
||||
|
||||
glyph-widths:
|
||||
32: 4
|
||||
|
After Width: | Height: | Size: 8.3 KiB |
@ -0,0 +1,9 @@
|
||||
glyph-height: 14
|
||||
glyph-spacing: 1 1
|
||||
top-margin: 1
|
||||
image: helvetica-11px.png
|
||||
image-glyph-size: 16 16
|
||||
|
||||
glyph-widths:
|
||||
32: 4
|
||||
|
After Width: | Height: | Size: 8.1 KiB |
@ -0,0 +1,9 @@
|
||||
title: Fonts
|
||||
description: Fonts package
|
||||
author: otclient
|
||||
version: 1
|
||||
website: https://github.com/edubart/otclient
|
||||
enabled: true
|
||||
dependencies: []
|
||||
script: fonts.lua
|
||||
|
@ -0,0 +1,9 @@
|
||||
title: Core styles
|
||||
description: Core styles used by other modules
|
||||
author: otclient
|
||||
version: 1
|
||||
website: https://github.com/edubart/otclient
|
||||
enabled: true
|
||||
dependencies: [core_fonts]
|
||||
script: styles.lua
|
||||
|
@ -0,0 +1,12 @@
|
||||
-- set default font
|
||||
App.setDefaultFont("helvetica-11px")
|
||||
App.setDefaultFontColor(Color("#f0ad4dff"))
|
||||
|
||||
-- load styles
|
||||
App.loadStyle("styles/utilities")
|
||||
App.loadStyle("styles/panels")
|
||||
App.loadStyle("styles/buttons")
|
||||
App.loadStyle("styles/labels")
|
||||
App.loadStyle("styles/textedits")
|
||||
App.loadStyle("styles/windows")
|
||||
App.loadStyle("styles/linedecorations")
|
After Width: | Height: | Size: 825 B |
After Width: | Height: | Size: 833 B |
After Width: | Height: | Size: 859 B |
@ -0,0 +1,25 @@
|
||||
button
|
||||
font: helvetica-11px-bold
|
||||
font-color: #f0ad4dff
|
||||
size: 106 24
|
||||
bordered-image: { source: button_standard.png; border: 5 }
|
||||
|
||||
button:hover
|
||||
bordered-image: { source: tibia_flash/button_standard_hover.png; border: 5 }
|
||||
|
||||
button:down
|
||||
text-translate: 1 1
|
||||
bordered-image: { source: tibia_flash/button_standard_down.png; border: 5 }
|
||||
|
||||
button.small
|
||||
width: 64
|
||||
|
||||
button.large
|
||||
width: 144
|
||||
|
||||
button.notImplemented
|
||||
onClick: displayErrorBox("Error", "Not implemented yet")
|
||||
|
||||
button.closeParent
|
||||
onClick: self.parent:destroy()
|
||||
|
@ -0,0 +1,57 @@
|
||||
function EnterGame_connectToLoginServer()
|
||||
-- create login protocol
|
||||
local protocolLogin = ProtocolLogin.new()
|
||||
|
||||
-- used to recreate enter game window
|
||||
local recreateEnterGame = function()
|
||||
loadUI("ui/entergamewindow")
|
||||
end
|
||||
|
||||
-- display loading message box
|
||||
local loadBox = displayCancelBox("Please wait", "Connecting..")
|
||||
|
||||
-- cancel loading callback
|
||||
loadBox.onCancel = function()
|
||||
-- cancel protocol and reacreate enter game window
|
||||
protocolLogin:cancel()
|
||||
recreateEnterGame()
|
||||
end
|
||||
|
||||
-- error callback
|
||||
protocolLogin.onError = function(error)
|
||||
-- destroy loading message box
|
||||
loadBox:destroy()
|
||||
|
||||
-- display error message
|
||||
local errorBox = displayErrorBox("Login Error", error)
|
||||
|
||||
-- cancel protocol and reacreate enter game window
|
||||
self.cancel()
|
||||
errorBox.onOk = recreateEnterGame
|
||||
end
|
||||
|
||||
-- motd callback
|
||||
protocolLogin.onMotd = function(motd)
|
||||
-- destroy loading message box
|
||||
loadBox:destroy()
|
||||
|
||||
-- display motd
|
||||
local motdNumber = string.sub(motd, 0, string.find(motd, "\n"))
|
||||
local motdText = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd))
|
||||
local motdBox = displayInfoBox("Message of the day", motdText)
|
||||
|
||||
-- cancel protocol and reacreate enter game window
|
||||
self.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
|
||||
protocolLogin:login(account, password)
|
||||
|
||||
-- destroy enter game window
|
||||
enterGameWindow:destroy()
|
||||
end
|
||||
|
@ -0,0 +1,16 @@
|
||||
require 'entergame'
|
||||
|
||||
function initializeApplication()
|
||||
mainMenu = loadUI("ui/mainmenu")
|
||||
end
|
||||
|
||||
function terminateApplication()
|
||||
App.exit()
|
||||
end
|
||||
|
||||
-- here is where everything starts
|
||||
if not initialized then
|
||||
initializeApplication()
|
||||
App.onClose = terminateApplication
|
||||
initialized = true
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
title: Main menu
|
||||
description: Used to create the main menu
|
||||
author: otclient
|
||||
version: 1
|
||||
website: https://github.com/edubart/otclient
|
||||
enabled: true
|
||||
dependencies: [core]
|
||||
script: init.lua
|
||||
|
After Width: | Height: | Size: 1.9 MiB |
@ -0,0 +1,53 @@
|
||||
window#enterGameWindow
|
||||
title: Enter Game
|
||||
size: 236 178
|
||||
anchor.centerIn: parent
|
||||
lockOnLoad: true
|
||||
|
||||
%label
|
||||
text: Account name
|
||||
position: 18 33
|
||||
|
||||
%label
|
||||
text: "Password:"
|
||||
position: 18 62
|
||||
|
||||
%label
|
||||
text: |
|
||||
If you don't have
|
||||
an account yet
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin: 87 18
|
||||
|
||||
%button.notImplemented
|
||||
text: Create Account
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
margin: 94 18
|
||||
|
||||
%button.small
|
||||
text: Ok
|
||||
anchors.bottomRight: parent.bottomRight
|
||||
margin: 10 66
|
||||
onClick: EnterGame_connectToLoginServer()
|
||||
|
||||
%button.small.closeParent
|
||||
text: Cancel
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
margin: 10 13
|
||||
|
||||
%textEdit#accountNameTextEdit
|
||||
text: tibialua0
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
margin: 32 18
|
||||
|
||||
%textEdit#passwordTextEdit
|
||||
text: lua123456
|
||||
text-hidden: true
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
margin: 61 18
|
||||
|
@ -0,0 +1,54 @@
|
||||
%window#infoWindow
|
||||
title: Info
|
||||
size: 244 221
|
||||
anchor.centerIn: parent
|
||||
lockOnLoad: true
|
||||
|
||||
%panel.flat
|
||||
size: 208 129
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin: 32 18
|
||||
|
||||
%label
|
||||
align: center
|
||||
text: |-
|
||||
OTClient
|
||||
Version 0.2.0
|
||||
Created by edubart
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
margin.top: 20
|
||||
|
||||
%element.bottomSeparator
|
||||
size: 190 2
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin: 83 9
|
||||
|
||||
%label
|
||||
text: Official Website
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
margin: 14 9
|
||||
|
||||
%button
|
||||
text: Github Page
|
||||
size: 80 22
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
margin: 9
|
||||
|
||||
%element.bottomSeparator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 40 13
|
||||
|
||||
%button.closeParent
|
||||
text: Ok
|
||||
size: 43 20
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin: 191 188
|
||||
|
@ -0,0 +1,37 @@
|
||||
%panel#mainBackground
|
||||
image: { source: background.png; antialised: true }
|
||||
anchor.fill: parent
|
||||
|
||||
%panel#mainMenuPanel.flat
|
||||
size: 117 171
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
margin: 70 60
|
||||
|
||||
button
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 6
|
||||
|
||||
%button.first
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 16
|
||||
text: Enter Game
|
||||
onClick: loadUI("entergamewindow")
|
||||
|
||||
%button.notImplemented
|
||||
text: Access Account
|
||||
|
||||
%button
|
||||
text: Options
|
||||
onClick: loadUI("optionswindow")
|
||||
|
||||
%button
|
||||
text: Info
|
||||
onClick: loadUI("infowindow")
|
||||
|
||||
%button
|
||||
text: Exit
|
||||
onClick: terminateApplication()
|
||||
|
@ -0,0 +1,82 @@
|
||||
%window#optionsWindow
|
||||
title: Options
|
||||
size: 286 262
|
||||
anchor.centerIn: parent
|
||||
lockOnLoad: true
|
||||
|
||||
panel
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin.left: 18
|
||||
margin.top: 3
|
||||
height: 30
|
||||
|
||||
button
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin.top: 3
|
||||
onClick: displayErrorBox("Error", "Not implemented yet")
|
||||
|
||||
label
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin.top: 99
|
||||
|
||||
%panel
|
||||
anchors.top: parent.top
|
||||
margin.top: 29
|
||||
|
||||
%button { text: General }
|
||||
%label { text: "Change general\ngame options" }
|
||||
|
||||
%panel
|
||||
%button { text: Graphics }
|
||||
%label { text: "Change graphics and\nperformance settings" }
|
||||
|
||||
%panel
|
||||
%button { text: Console }
|
||||
%label { text: Customise the console }
|
||||
|
||||
%panel
|
||||
%button { text: Hotkeys }
|
||||
%label { text: Edit your hotkey texts }
|
||||
|
||||
%element.horizontalSeparator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 97 18
|
||||
|
||||
%panel
|
||||
anchors.top: ~
|
||||
anchors.bottom: parent.bottom
|
||||
margin.top: 29
|
||||
|
||||
%button
|
||||
text: Motd
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 60 18
|
||||
|
||||
%label
|
||||
text: |
|
||||
Show the most recent
|
||||
Message of the Day
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 56 117
|
||||
|
||||
%element.horizontalSeparator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 40 13
|
||||
|
||||
%button.closeParent
|
||||
text: Ok
|
||||
size: 43 20
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin: 13 10
|
||||
|
@ -1,75 +0,0 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LUAFUNCTIONS_H
|
||||
#define LUAFUNCTIONS_H
|
||||
|
||||
#include <global.h>
|
||||
#include <script/scriptable.h>
|
||||
|
||||
void registerLuaFunctions();
|
||||
|
||||
// App
|
||||
int lua_App_exit();
|
||||
|
||||
// UI
|
||||
int lua_UI_load();
|
||||
int lua_UI_getRootContainer();
|
||||
|
||||
// UIElement
|
||||
int lua_UIElement_getId();
|
||||
int lua_UIElement_setId();
|
||||
int lua_UIElement_isEnabled();
|
||||
int lua_UIElement_setEnabled();
|
||||
int lua_UIElement_isVisible();
|
||||
int lua_UIElement_setVisible();
|
||||
int lua_UIElement_isFocused();
|
||||
int lua_UIElement_setFocused();
|
||||
int lua_UIElement_getParent();
|
||||
int lua_UIElement_setParent();
|
||||
int lua_UIElement_setLocked();
|
||||
int lua_UIElement_destroy();
|
||||
void lua_UIElement_onLoad();
|
||||
void lua_UIElement_onDestroy();
|
||||
|
||||
// UIContainer
|
||||
int lua_UIContainer_getChild();
|
||||
int lua_UIContainer_getChildren();
|
||||
|
||||
// UILabel
|
||||
int lua_UILabel_setText();
|
||||
int lua_UILabel_getText();
|
||||
|
||||
// UITextEdit
|
||||
int lua_UITextEdit_setText();
|
||||
int lua_UITextEdit_getText();
|
||||
|
||||
// UIButton
|
||||
void lua_UIButton_onClick();
|
||||
|
||||
// UIWindow
|
||||
int lua_UIWindow_setTitle();
|
||||
int lua_UIWindow_getTitle();
|
||||
|
||||
#endif // LUAFUNCTIONS_H
|
Loading…
Reference in new issue