reorganize modules

This commit is contained in:
Eduardo Bart 2011-11-02 01:02:56 -02:00
parent 2304ff3529
commit 5ab0e6f2ac
60 changed files with 151 additions and 212 deletions

View File

@ -0,0 +1,22 @@
Background = { }
-- private variables
local background
-- public functions
function Background.create()
background = UI.loadAndDisplay('/background/background.otui')
end
function Background.destroy()
background:destroy()
background = nil
end
function Background.hide()
background:hide()
end
function Background.show()
background:show()
end

View File

@ -0,0 +1,18 @@
Module
name: background
description: Handles the background of the login screen
author: OTClient team
website: https://github.com/edubart/otclient
autoLoad: true
dependencies:
- core
- topmenu
onLoad: |
require 'background'
Background.create()
return true
onUnload:
Background.destroy()

View File

@ -1,13 +1,7 @@
MenuButton < Button
margin.bottom: 11
margin.left: 20
margin.right: 20
Panel Panel
id: mainMenuBackground id: background
image: image:
source: /mainmenu/ui/background.png source: /background/background.png
smooth: true smooth: true
fixed ratio: true fixed ratio: true
anchors.top: topMenu.bottom anchors.top: topMenu.bottom

View File

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

@ -3,7 +3,6 @@ Module
description: Console for executing lua functions description: Console for executing lua functions
author: OTClient team author: OTClient team
website: https://github.com/edubart/otclient website: https://github.com/edubart/otclient
version: 0.2
autoLoad: true autoLoad: true
dependencies: dependencies:
- core - core

View File

@ -7,19 +7,17 @@ Module
autoLoad: true autoLoad: true
dependencies: dependencies:
- core_fonts - core_fonts
- core_ui - core_styles
onLoad: | onLoad: |
require 'ext/table' require 'ext/table'
require 'ext/string' require 'ext/string'
require 'constants' require 'constants'
require 'util' require 'util'
require 'widget'
require 'messagebox/messagebox'
require 'dispatcher' require 'dispatcher'
require 'widget'
require 'ui'
require 'gfx'
require 'messagebox/messagebox'
return true return true
onUnload: |
rootWidget = nil

View File

@ -20,11 +20,3 @@ function UI.displayLocked(widget)
UI.root:addChild(widget) UI.root:addChild(widget)
UI.root:lockChild(widget) UI.root:lockChild(widget)
end end
importStyles('styles/buttons.otui')
importStyles('styles/labels.otui')
importStyles('styles/panels.otui')
importStyles('styles/separators.otui')
importStyles('styles/lineedits.otui')
importStyles('styles/windows.otui')
importStyles('styles/listboxes.otui')

View File

@ -3,8 +3,6 @@ Module
description: Contains fonts used by core description: Contains fonts used by core
author: OTClient team author: OTClient team
website: https://github.com/edubart/otclient website: https://github.com/edubart/otclient
version: 0.2
autoLoad: true
onLoad: | onLoad: |
importFont('verdana-11px-antialised') importFont('verdana-11px-antialised')
importFont('verdana-11px-monochrome') importFont('verdana-11px-monochrome')

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -1,7 +1,6 @@
Font Font
name: terminus-14px-bold name: terminus-14px-bold
height: 16 height: 16
spacing: 0 0
top margin: 2 top margin: 2
texture: terminus-14px-bold.png texture: terminus-14px-bold.png
glyph size: 16 16 glyph size: 16 16

View File

@ -1,7 +1,7 @@
Font Font
name: verdana-11px-antialised name: verdana-11px-antialised
height: 14
texture: verdana-11px-antialised.png texture: verdana-11px-antialised.png
height: 14
glyph size: 16 16 glyph size: 16 16
glyph widths: glyph widths:

View File

@ -1,7 +1,7 @@
Font Font
name: verdana-11px-monochrome name: verdana-11px-monochrome
height: 14
texture: verdana-11px-monochrome.png texture: verdana-11px-monochrome.png
height: 14
glyph size: 16 16 glyph size: 16 16
glyph widths: glyph widths:

View File

@ -1,7 +1,7 @@
Font Font
name: verdana-11px-rounded name: verdana-11px-rounded
height: 14
texture: verdana-11px-rounded.png texture: verdana-11px-rounded.png
height: 14
glyph size: 16 16 glyph size: 16 16
glyph widths: glyph widths:

View File

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

View File

Before

Width:  |  Height:  |  Size: 763 B

After

Width:  |  Height:  |  Size: 763 B

View File

Before

Width:  |  Height:  |  Size: 932 B

After

Width:  |  Height:  |  Size: 932 B

View File

Before

Width:  |  Height:  |  Size: 696 B

After

Width:  |  Height:  |  Size: 696 B

View File

Before

Width:  |  Height:  |  Size: 385 B

After

Width:  |  Height:  |  Size: 385 B

View File

Before

Width:  |  Height:  |  Size: 660 B

After

Width:  |  Height:  |  Size: 660 B

View File

Before

Width:  |  Height:  |  Size: 825 B

After

Width:  |  Height:  |  Size: 825 B

View File

Before

Width:  |  Height:  |  Size: 833 B

After

Width:  |  Height:  |  Size: 833 B

View File

Before

Width:  |  Height:  |  Size: 859 B

After

Width:  |  Height:  |  Size: 859 B

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 191 B

View File

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 325 B

View File

Before

Width:  |  Height:  |  Size: 151 B

After

Width:  |  Height:  |  Size: 151 B

View File

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 152 B

View File

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -5,18 +5,18 @@ Button < UIButton
size: 106 24 size: 106 24
text-translate: 0 0 text-translate: 0 0
border-image: border-image:
source: /core_ui/images/button.png source: /core_styles/images/button.png
border: 5 border: 5
state.hover: state.hover:
border-image: border-image:
source: /core_ui/images/button_hover.png source: /core_styles/images/button_hover.png
border: 5 border: 5
state.pressed: state.pressed:
text-translate: 1 1 text-translate: 1 1
border-image: border-image:
source: /core_ui/images/button_down.png source: /core_styles/images/button_down.png
border: 5 border: 5
state.disabled: state.disabled:
@ -28,13 +28,13 @@ TopButton < UIButton
size: 26 25 size: 26 25
text-translate: 0 0 text-translate: 0 0
border-image: border-image:
source: /core_ui/images/top_button.png source: /core_styles/images/top_button.png
size: 26 25 size: 26 25
border: 3 border: 3
state.hover: state.hover:
border-image: border-image:
source: /core_ui/images/top_button.png source: /core_styles/images/top_button.png
size: 26 25 size: 26 25
offset: 26 0 offset: 26 0
border: 3 border: 3
@ -42,7 +42,7 @@ TopButton < UIButton
state.pressed: state.pressed:
text-translate: 1 1 text-translate: 1 1
border-image: border-image:
source: /core_ui/images/top_button.png source: /core_styles/images/top_button.png
size: 26 25 size: 26 25
offset: 52 0 offset: 52 0
border: 3 border: 3

View File

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

View File

@ -0,0 +1,5 @@
TextList < UIWidget
layout: verticalBox
border-image:
source: /core_styles/images/panel_flat.png
border: 4

View File

@ -3,21 +3,21 @@ Panel < UIWidget
FlatPanel < Panel FlatPanel < Panel
border-image: border-image:
source: /core_ui/images/panel_flat.png source: /core_styles/images/panel_flat.png
border: 4 border: 4
TopPanel < Panel TopPanel < Panel
height: 34 height: 34
image: image:
source: /core_ui/images/top_panel.png source: /core_styles/images/top_panel.png
repeated: true repeated: true
RoundedPanel < Panel RoundedPanel < Panel
background-color: #ffffffdd background-color: #ffffffdd
border-image: border-image:
source: /core_ui/images/panel_rounded.png source: /core_styles/images/panel_rounded.png
border: 4 border: 4
RectPanel < UIWidget RectPanel < UIWidget
image: /core_ui/images/empty_rect.png image: /core_styles/images/empty_rect.png

View File

@ -1,6 +1,6 @@
HorizontalSeparator < UIWidget HorizontalSeparator < UIWidget
border-image: border-image:
source: /core_ui/images/horizontal_separator.png source: /core_styles/images/horizontal_separator.png
border.top: 2 border.top: 2
height: 2 height: 2
phantom: true phantom: true

View File

@ -6,7 +6,7 @@ Window < UIWindow
head height: 20 head height: 20
head text align: center head text align: center
border-image: border-image:
source: /core_ui/images/window.png source: /core_styles/images/window.png
border: 4 border: 4
border.top: 20 border.top: 20

View File

@ -1,13 +0,0 @@
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: |
require 'ui'
return true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

View File

@ -1,5 +0,0 @@
TextList < UIWidget
layout: verticalBox
border-image:
source: /core_ui/images/panel_flat.png
border: 4

View File

@ -56,7 +56,7 @@ function CharacterList.create(characters, premDays)
charactersWindow:destroy() charactersWindow:destroy()
end end
charactersWindow = UI.loadAndDisplay('/mainmenu/ui/charlist.otui') charactersWindow = UI.loadAndDisplay('/entergame/characterlist.otui')
characterList = charactersWindow:getChildById('characterList') characterList = charactersWindow:getChildById('characterList')
local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel') local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel')
charactersWindow.onKeyPress = onCharactersWindowKeyPress charactersWindow.onKeyPress = onCharactersWindowKeyPress
@ -89,7 +89,7 @@ function CharacterList.hide()
charactersWindow:hide() charactersWindow:hide()
end end
function CharacterList.close() function CharacterList.destroy()
CharacterList.hide() CharacterList.hide()
EnterGame.show() EnterGame.show()
end end

View File

@ -1,5 +1,5 @@
CharacterListLabel < Label CharacterListLabel < Label
image: /core_ui/images/empty_rect.png image: /core_styles/images/empty_rect.png
font: verdana-11px-monochrome font: verdana-11px-monochrome
background-color: #00000000 background-color: #00000000
offset: 2 0 offset: 2 0
@ -14,10 +14,10 @@ CharacterListLabel < Label
MainWindow MainWindow
id: charactersWindow id: charactersWindow
title: Charlist title: Character List
size: 250 250 size: 250 250
onEnter: CharacterList.doLogin() onEnter: CharacterList.doLogin()
onEscape: CharacterList.close() onEscape: CharacterList.destroy()
TextList TextList
id: characterList id: characterList
@ -65,4 +65,4 @@ MainWindow
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 16 margin.bottom: 16
margin.right: 16 margin.right: 16
onClick: CharacterList.close() onClick: CharacterList.destroy()

View File

@ -2,7 +2,7 @@ EnterGame = { }
-- private variables -- private variables
local loadBox local loadBox
local enterGameWindow local enterGame
local motdNumber local motdNumber
local motdMessage local motdMessage
@ -32,25 +32,26 @@ local function onCharacterList(protocol, characters, premDays)
end end
-- public functions -- public functions
function EnterGame.show() function EnterGame.create()
if not enterGameWindow then enterGame = UI.loadAndDisplay('/entergame/entergame.otui')
enterGameWindow = UI.loadAndDisplay('/mainmenu/ui/entergamewindow.otui')
end
enterGameWindow:show()
end
function EnterGame.hide()
enterGameWindow:hide()
end end
function EnterGame.destroy() function EnterGame.destroy()
enterGameWindow:destroy() enterGame:destroy()
enterGameWindow = nil enterGame = nil
end
function EnterGame.show()
enterGame:show()
end
function EnterGame.hide()
enterGame:hide()
end end
function EnterGame.doLogin() function EnterGame.doLogin()
EnterGame.account = enterGameWindow:getChildById('accountNameLineEdit'):getText() EnterGame.account = enterGame:getChildById('accountNameLineEdit'):getText()
EnterGame.password = enterGameWindow:getChildById('accountPasswordLineEdit'):getText() EnterGame.password = enterGame:getChildById('accountPasswordLineEdit'):getText()
EnterGame.hide() EnterGame.hide()
local protocolLogin = ProtocolLogin.create() local protocolLogin = ProtocolLogin.create()

View File

@ -0,0 +1,21 @@
Module
name: entergame
description: Manages enter game and character list windows
author: OTClient team
website: https://github.com/edubart/otclient
autoLoad: true
dependencies:
- core
- topmenu
- background
onLoad: |
require 'entergame'
require 'characterlist'
EnterGame.create()
return true
onUnload:
EnterGame.destroy()

View File

@ -1,9 +1,9 @@
MainWindow MainWindow
id: enterGameWindow id: enterGame
title: Enter Game title: Enter Game
size: 236 160 size: 236 160
onEnter: EnterGame.doLogin() onEnter: EnterGame.doLogin()
onEscape: function(self) self:destroy() end onEscape: EnterGame.hide()
LargerLabel LargerLabel
text: Account name text: Account name
@ -54,4 +54,4 @@ MainWindow
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 16 margin.bottom: 16
margin.right: 16 margin.right: 16
onClick: function(self) self:getParent():destroy() end onClick: EnterGame.hide()

View File

@ -35,7 +35,7 @@ end
-- public functions -- public functions
function Game.onLogin() function Game.onLogin()
MainMenu.hide() Background.hide()
CharacterList.destroyLoadBox() CharacterList.destroyLoadBox()
createMainInterface() createMainInterface()
end end
@ -53,7 +53,7 @@ function Game.onConnectionError(message)
end end
function Game.onLogout() function Game.onLogout()
MainMenu.show() Background.show()
CharacterList.show() CharacterList.show()
destroyMainInterface() destroyMainInterface()
end end

View File

@ -8,10 +8,10 @@ Module
dependencies: dependencies:
- core - core
- tibiafiles - tibiafiles
- topmenu
- entergame
- background
onLoad: | onLoad: |
require 'game' require 'game'
return true return true
onUnload: |
-- nothing yet

View File

@ -1,14 +1,10 @@
UIWidget UIWidget
id: gameRootInterface id: gameRootInterface
anchors.fill: parent anchors.fill: parent
anchors.top: topMenu.bottom
margin.top: 1
UIMap UIMap
id: gameMap id: gameMap
anchors.fill:parent anchors.fill:parent
margin.right: 200 margin.right: 200
Button
anchors.left: gameMap.right
anchors.top: parent.top
text: Logout
onClick: Game.logout(false)

View File

@ -1,15 +0,0 @@
Module
name: gfx
description: Contains utilities for generating graphics effects
author: OTClient team
website: https://github.com/edubart/otclient
version: 0.2
autoLoad: true
dependencies:
- core
onLoad: |
require 'gfx'
return true

View File

@ -1,22 +0,0 @@
MainMenu = { }
-- private variables
local mainMenu
-- public functions
function MainMenu.create()
mainMenu = UI.loadAndDisplay("/mainmenu/ui/mainmenu.otui")
end
function MainMenu.destroy()
mainMenu:destroy()
mainMenu = nil
end
function MainMenu.hide()
mainMenu:hide()
end
function MainMenu.show()
mainMenu:show()
end

View File

@ -1,27 +0,0 @@
Module
name: mainmenu
description: Create the game main menu
author: OTClient team
website: https://github.com/edubart/otclient
version: 0.2
autoLoad: true
dependencies:
- core
- topmenu
onLoad: |
require 'mainmenu'
require 'entergame'
require 'characterlist'
if not initialized then
MainMenu.create()
EnterGame.show()
initialized = true
end
return true
onUnload: |
MainMenu.destroy()
initialized = false

View File

@ -1,47 +0,0 @@
RoundedRectPanel
id: loginPanel
background-color: #000000e5
size: 192 164
anchors.centerIn: parent
margin.top: 64
opacity: 0
LargerLabel
text: Account name
anchors.left: parent.left
anchors.top: parent.top
margin.left: 16
margin.top: 12
LineEdit
id: accountNameLineEdit
text: otclient0
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin.left: 14
margin.right: 14
LargerLabel
text: Password
anchors.left: parent.left
anchors.top: prev.bottom
margin.left: 16
margin.top: 8
PasswordLineEdit
id: accountPasswordLineEdit
text: 123456
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin.left: 14
margin.right: 14
Button
id: loginButton
text: Login
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
margin.bottom: 20
onClick: EnterGame.doLogin()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -1 +1 @@
--UI.loadAndDisplayLocked('/mainmenu/ui/charlist.otui') -- place any code for testing purposes here

View File

@ -6,6 +6,7 @@ TopPanel
focusable: false focusable: false
TopButton TopButton
id: settingsButton
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
margin.top: 3 margin.top: 3
@ -13,7 +14,7 @@ TopPanel
UIWidget UIWidget
size: 16 16 size: 16 16
image: /core_ui/icons/settings.png image: /core_styles/icons/settings.png
anchors.centerIn: parent anchors.centerIn: parent
phantom: true phantom: true
@ -21,10 +22,11 @@ TopPanel
anchors.top: prev.top anchors.top: prev.top
anchors.left: prev.right anchors.left: prev.right
margin.left: 6 margin.left: 6
onClick: EnterGame.show()
UIWidget UIWidget
size: 16 16 size: 16 16
image: /core_ui/icons/login.png image: /core_styles/icons/login.png
anchors.centerIn: parent anchors.centerIn: parent
phantom: true phantom: true
@ -33,9 +35,15 @@ TopPanel
anchors.right: parent.right anchors.right: parent.right
margin.top: 3 margin.top: 3
margin.right: 6 margin.right: 6
onClick: |
if Game.isOnline() then
Game.logout(false)
else
exit()
end
UIWidget UIWidget
size: 16 16 size: 16 16
image: /core_ui/icons/logout.png image: /core_styles/icons/logout.png
anchors.centerIn: parent anchors.centerIn: parent
phantom: true phantom: true