merge total remake

This commit is contained in:
Eduardo Bart
2011-08-13 23:09:11 -03:00
parent 0af7856475
commit 55862b07ad
253 changed files with 6777 additions and 8463 deletions

View File

@@ -0,0 +1,8 @@
-- AnchorPoint
AnchorNone = 0
AnchorTop = 1
AnchorBottom = 2
AnchorLeft = 3
AnchorRight = 4
AnchorVerticalCenter = 5
AnchorHorizontalCenter = 6

23
modules/core/core.otmod Normal file
View File

@@ -0,0 +1,23 @@
Module
name: core
description: Contains lua classes, functions and constants used by other modules
author: OTClient team
website: https://github.com/edubart/otclient
version: 0.2
autoLoad: true
dependencies:
- core_fonts
- core_ui
onLoad: |
require 'constants'
require 'util'
require 'widget'
require 'messagebox'
rootWidget = getRootWidget()
return true
onUnload: |
rootWidget = nil

View File

@@ -0,0 +1,92 @@
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.create()
window.id = "messageBoxWindow"
window.title = title
window:centerIn("parent")
--window:setLocked(true)
rootWidget:addChild(window)
-- create messagebox label
local label = UILabel.create()
label.id = "messageBoxLabel"
label.text = text
label:addAnchor(AnchorHorizontalCenter, window.id, AnchorHorizontalCenter)
label:addAnchor(AnchorTop, window.id, AnchorTop)
label:setMargin(27, 0)
label:resizeToText()
window:addChild(label)
-- set window size based on label size
window.width = label.width + 60
window.height = label.height + 64
-- setup messagebox first button
local button1 = UIButton.create()
button1.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
button1.text = "Ok"
box.onOk = createEmptyFunction()
button1.onClick = function()
box.onOk()
box:destroy()
end
elseif flags == MessageBoxCancel then
button1.text = "Cancel"
box.onCancel = createEmptyFunction()
button1.onClick = function()
box.onCancel()
box:destroy()
end
end
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

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

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

19
modules/core/widget.lua Normal file
View File

@@ -0,0 +1,19 @@
function UIWidget:setMargin(...)
local params = {...}
if #params == 1 then
self.marginTop = params[1]
self.marginRight = params[1]
self.marginBottom = params[1]
self.marginLeft = params[1]
elseif #params == 2 then
self.marginTop = params[1]
self.marginRight = params[2]
self.marginBottom = params[1]
self.marginLeft = params[2]
elseif #params == 4 then
self.marginTop = params[1]
self.marginRight = params[2]
self.marginBottom = params[3]
self.marginLeft = params[4]
end
end

View File

@@ -0,0 +1,17 @@
Module
name: core_fonts
description: Contains fonts used by core
author: OTClient team
website: https://github.com/edubart/otclient
version: 0.2
autoLoad: true
onLoad: |
importFont('helvetica-11px-bold')
importFont('helvetica-11px')
importFont('helvetica-12px-bold')
importFont('helvetica-12px')
importFont('helvetica-14px-bold')
setDefaultFont('helvetica-12px')
return true

View File

@@ -0,0 +1,12 @@
Font
name: helvetica-11px-bold
height: 14
spacing: 1 1
top margin: 2
texture: helvetica-11px-bold.png
glyph size: 16 16
glyph widths:
32: 4
65: 8

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -0,0 +1,11 @@
Font
name: helvetica-11px
height: 14
spacing: 1 1
top margin: 1
texture: helvetica-11px.png
glyph size: 16 16
glyph widths:
32: 4

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@@ -0,0 +1,12 @@
Font
name: helvetica-12px-bold
height: 16
spacing: 1 1
top margin: 2
texture: helvetica-12px-bold.png
glyph size: 18 18
glyph widths:
32: 4
65: 9

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@@ -0,0 +1,11 @@
Font
name: helvetica-12px
height: 15
spacing: 1 1
top margin: 1
texture: helvetica-12px.png
glyph size: 16 16
glyph widths:
32: 4
65: 8

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@@ -0,0 +1,12 @@
Font
name: helvetica-14px-bold
height: 16
spacing: 1 1
top margin: 2
texture: helvetica-14px-bold.png
glyph size: 20 20
glyph widths:
32: 4
65: 9

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,19 @@
Button < UIButton
font: helvetica-11px-bold
color: 240 173 77 255
size: 106 24
border-image:
source: /core_ui/images/button.png
border: 5
state.hover:
border-image:
source: /core_ui/images/button_hover.png
border: 5
state.down:
text-translate: 1 1
border-image:
source: /core_ui/images/button_down.png
border: 5

View File

@@ -0,0 +1,18 @@
Module
name: core_ui
description: Contains ui styles used by other modules
author: OTClient team
website: https://github.com/edubart/otclient
version: 0.2
autoLoad: true
dependencies:
- core_fonts
onLoad: |
importStyles('buttons.otui')
importStyles('labels.otui')
importStyles('panels.otui')
importStyles('separators.otui')
importStyles('lineedits.otui')
importStyles('windows.otui')
return true

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -0,0 +1,5 @@
Label < UILabel
LargerLabel < Label
font: helvetica-12px-bold

View File

@@ -0,0 +1,7 @@
LineEdit < UILineEdit
size: 86 20
text-margin: 3
border-image:
source: /core_ui/images/panel_flat.png
border: 1

View File

@@ -0,0 +1,11 @@
Panel < UIWidget
FlatPanel < Panel
border-image:
source: /core_ui/images/panel_flat.png
border: 4
RoundedGridPanel < Panel
border-image:
source: /core_ui/images/panel_rounded.png
border: 4

View File

@@ -0,0 +1,4 @@
HorizontalSeparator < UIWidget
border-image:
source: /core_ui/images/horizontal_separator.png
border.top: 2

View File

@@ -0,0 +1,20 @@
Window < UIWindow
size: 200 100
head:
height: 20
border-image:
source: /core_ui/images/window.png
size: 256 19
border: 4
border.bottom: 3
body:
border-image:
source: /core_ui/images/window.png
size: 256 237
offset: 0 19
border: 4
border.top: 0
MainWindow < Window
anchors.centerIn: parent

View File

@@ -0,0 +1,55 @@
function EnterGame_connectToLoginServer()
-- create login protocol
local protocolLogin = ProtocolLogin.create()
-- used to recreate enter game window
local recreateEnterGame = function()
loadUI("/mainmenu/ui/entergamewindow.otui")
end
-- display loading message box
local loadBox = displayCancelBox("Please wait", "Connecting..")
-- cancel loading callback
loadBox.onCancel = function(msgbox)
-- cancel protocol and reacreate enter game window
protocolLogin:cancel()
recreateEnterGame()
end
-- error callback
protocolLogin.onError = function(protocol, error)
-- destroy loading message box
loadBox:destroy()
-- display error message
local errorBox = displayErrorBox("Login Error", error)
-- cancel protocol and reacreate enter game window
protocol:cancel()
errorBox.onOk = recreateEnterGame
end
-- motd callback
protocolLogin.onMotd = function(protocol, 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)
-- hide main menu
mainMenu.visible = false
end
-- get account and password then login
local enterGameWindow = rootWidget:getChild("enterGameWindow")
local account = enterGameWindow:getChild("accountNameLineEdit").text
local password = enterGameWindow:getChild("accountPasswordLineEdit").text
protocolLogin:login(account, password)
-- destroy enter game window
enterGameWindow:destroy()
end

View File

@@ -0,0 +1,26 @@
Module
name: mainmenu
description: Create the game mainmenu, where everything starts
author: OTClient team
website: https://github.com/edubart/otclient
version: 0.2
autoLoad: true
dependencies:
- core
onLoad: |
require('entergame')
if not initialized then
mainMenu = loadUI("/mainmenu/ui/mainmenu.otui")
getRootWidget():addChild(mainMenu)
initialized = true
end
return true
onUnload: |
mainMenu:destroy()
mainMenu = nil
initialized = false

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

@@ -0,0 +1,53 @@
MainWindow
id: enterGameWindow
title: Enter Game
size: 236 160
LargerLabel
text: Account name
anchors.left: parent.left
anchors.top: parent.top
margin.left: 18
margin.top: 28
LineEdit
id: accountNameLineEdit
text: otclient0
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin.left: 18
margin.right: 18
LargerLabel
text: Password
anchors.left: prev.left
anchors.top: prev.bottom
margin.top: 8
LineEdit
id: accountPasswordLineEdit
text: 123456
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin.left: 18
margin.right: 18
Button
text: Ok
width: 64
anchors.right: next.left
anchors.bottom: parent.bottom
margin.bottom: 16
margin.right: 16
onClick: EnterGame_connectToLoginServer()
Button
text: Cancel
width: 64
anchors.right: parent.right
anchors.bottom: parent.bottom
margin.bottom: 16
margin.right: 16
onClick: function(self) self.parent:destroy() end

View File

@@ -0,0 +1,60 @@
MainWindow
id: infoWindow
title: Info
size: 244 221
FlatPanel
size: 208 129
anchors.left: parent.left
anchors.top: parent.top
margin.top: 32
margin.left: 18
Label
align: center
text: |-
OTClient
Version 0.2.0
Created by edubart
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
margin.top: 20
HorizontalSeparator
size: 190 2
anchors.left: parent.left
anchors.top: parent.top
margin.top: 83
margin.left: 9
Label
text: Official Website
anchors.left: parent.left
anchors.bottom: parent.bottom
margin.bottom: 14
margin.left: 9
Button
text: Github Page
size: 88 24
anchors.right: parent.right
anchors.bottom: parent.bottom
margin.bottom: 9
margin.right: 9
HorizontalSeparator
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
margin.bottom: 40
margin.left: 13
margin.right: 13
Button
text: Ok
size: 46 24
anchors.left: parent.left
anchors.top: parent.top
margin.top: 191
margin.left: 188
onClick: function(self) self.parent:destroy() end

View File

@@ -0,0 +1,47 @@
Panel
skin: mainMenuBackground
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
Panel
id: mainMenu
skin: roundedGridPanel
size: 144 162
anchors.left: parent.left
anchors.bottom: parent.bottom
margin.left: 60
margin.bottom: 70
Button
id: enterGameButton
text: Enter Game
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
margin.top: 18
onClick: rootWidget:addChild(loadUI("entergamewindow"))
Button
id: optionsButton
text: Options
anchors.top: prev.bottom
anchors.horizontalCenter: parent.horizontalCenter
margin.top: 10
onClick: rootWidget:addChild(loadUI("optionswindow"))
Button
id: infoButton
text: Info
anchors.top: prev.bottom
anchors.horizontalCenter: parent.horizontalCenter
margin.top: 10
onClick: rootWidget:addChild(loadUI("infowindow"))
Button
id: exitGameButton
text: Exit
anchors.top: prev.bottom
anchors.horizontalCenter: parent.horizontalCenter
margin.top: 10
onClick: exit()

View File

@@ -0,0 +1,38 @@
MenuButton < Button
anchors.top: prev.bottom
anchors.horizontalCenter: parent.horizontalCenter
margin.top: 10
Panel
id: mainMenuBackground
image:
source: /mainmenu/ui/background.png
smooth: true
anchors.fill: parent
RoundedGridPanel
id: mainMenu
size: 144 162
anchors.left: parent.left
anchors.bottom: parent.bottom
margin.left: 60
margin.bottom: 70
MenuButton
text: Enter Game
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
margin.top: 18
onClick: rootWidget:addChild(loadUI("/mainmenu/ui/entergamewindow.otui"))
MenuButton
text: Options
onClick: rootWidget:addChild(loadUI("/mainmenu/ui/optionswindow.otui"))
MenuButton
text: Info
onClick: rootWidget:addChild(loadUI("/mainmenu/ui/infowindow.otui"))
MenuButton
text: Exit
onClick: exit()

View File

@@ -0,0 +1,112 @@
MainWindow
id: optionsWindow
title: Options
size: 286 262
// general
Button
text: General
anchors.left: parent.left
anchors.top: parent.top
margin.left: 18
margin.top: 32
onClick: displayErrorBox("Error", "Not implemented yet")
Label
text: |-
Change general
game options
anchors.left: prev.right
anchors.top: prev.top
margin.left: 10
margin.top: -2
// graphics
Button
text: Graphics
anchors.left: parent.left
anchors.top: parent.top
margin.left: 18
margin.top: 65
Label
text: |-
Change graphics and
performance settings
anchors.left: prev.right
anchors.top: prev.top
margin.left: 10
margin.top: -2
// console
Button
text: Console
anchors.left: parent.left
anchors.top: parent.top
margin.left: 18
margin.top: 98
Label
text: Customise the console
anchors.left: prev.right
anchors.top: prev.top
margin.left: 10
margin.top: -2
// hotkeys
Button
text: Hotkeys
anchors.left: parent.left
anchors.top: parent.top
margin.left: 18
margin.top: 131
Label
text: Edit your hotkey texts
anchors.left: prev.right
anchors.top: prev.top
margin.left: 10
margin.top: -2
HorizontalSeparator
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
margin.bottom: 97
margin.left: 18
margin.right: 18
// motd
Button
text: Motd
anchors.left: parent.left
anchors.bottom: parent.bottom
margin.left: 18
margin.bottom: 60
Label
text: |
Show the most recent
Message of the Day
anchors.left: prev.right
anchors.top: prev.top
margin.left: 10
margin.top: -2
HorizontalSeparator
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
margin.bottom: 40
margin.left: 13
margin.right: 13
// ok button
Button
text: Ok
size: 43 20
anchors.right: parent.right
anchors.bottom: parent.bottom
margin.right: 10
margin.bottom: 13
onClick: function(self) self.parent:destroy() end

1
modules/tibiafiles Submodule

Submodule modules/tibiafiles added at 8bb3b7d6d8