add a new folder structure redesign organized by packages

This commit is contained in:
Eduardo Bart
2011-07-17 08:52:20 -03:00
parent b1a881eb06
commit ab7394f357
56 changed files with 586 additions and 212 deletions

View File

@@ -0,0 +1,11 @@
rootUI = UI.getRootContainer()
-- AnchorPoint
AnchorNone = 0
AnchorTop = 1
AnchorBottom = 2
AnchorLeft = 3
AnchorRight = 4
AnchorVerticalCenter = 5
AnchorHorizontalCenter = 6

3
packages/core/core.lua Normal file
View File

@@ -0,0 +1,3 @@
require 'constants'
require 'util'
require 'messagebox'

View File

@@ -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

View File

@@ -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

5
packages/core/util.lua Normal file
View File

@@ -0,0 +1,5 @@
function createEmptyFunction()
local emptyFunction = function() end
return emptyFunction
end

View File

@@ -0,0 +1,4 @@
-- load default fonts
App.loadFont("fonts/helvetica-11px")
App.loadFont("fonts/helvetica-11px-bold")

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@@ -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

View File

@@ -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

View File

@@ -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")

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

View File

@@ -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()

View File

View File

View File

View File

@@ -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

View File

@@ -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

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

@@ -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

View File

@@ -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

View File

@@ -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()

View File

@@ -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