Some particle stuff, far from done

This commit is contained in:
Henrique Santiago
2012-07-06 02:00:49 -03:00
parent 2b621cace6
commit 6a85c31a77
25 changed files with 645 additions and 39 deletions

View File

@@ -8,6 +8,7 @@ Module
load-later:
- client_skins
- client_locales
- client_particles
- client_topmenu
- client_background
//- client_about

View File

@@ -13,7 +13,7 @@ local localeComboBox
local function sendLocale(localeName)
local protocolGame = g_game.getProtocolGame()
if protocolGame then
protocolGame:sendExtendedOpcode(1, localeName)
protocolGame:sendExtendedOpcode(ExtendedLocales, localeName)
return true
end
return false
@@ -32,7 +32,7 @@ local function onGameStart()
sendLocale(currentLocale.name)
end
local function onServerSetLocale(protocol, opcode, buffer)
local function onExtendedLocales(protocol, opcode, buffer)
local locale = installedLocales[buffer]
if locale then
localeComboBox:setCurrentOption(locale.languageName)
@@ -63,7 +63,7 @@ function Locales.init()
localeComboBox.onOptionChange = onLocaleComboBoxOptionChange
end, false)
Extended.register(1, onServerSetLocale)
Extended.register(ExtendedLocales, onExtendedLocales)
connect(g_game, { onGameStart = onGameStart })
end
@@ -71,7 +71,7 @@ function Locales.terminate()
installedLocales = nil
currentLocale = nil
localeComboBox = nil
Extended.unregister(1)
Extended.unregister(ExtendedLocales)
disconnect(g_game, { onGameStart = onGameStart })
end

View File

@@ -0,0 +1,95 @@
Particles = { }
-- private variables
local particlesWindow
local particlesButton
-- private functions
local function onExtendedParticles(protocol, opcode, buffer)
end
-- public functions
function Particles.init()
particlesWindow = g_ui.displayUI('particles.otui')
particlesButton = TopMenu.addLeftButton('particlesButton', tr('Particles Manager'), 'particles.png', Particles.toggle)
local particlesList = particlesWindow:getChildById('particlesList')
g_keyboard.bindKeyPress('Up', function() particlesList:focusPreviousChild(KeyboardFocusReason) end, particlesWindow)
g_keyboard.bindKeyPress('Down', function() particlesList:focusNextChild(KeyboardFocusReason) end, particlesWindow)
Extended.register(ExtendedParticles, onExtendedParticles)
end
function Particles.terminate()
particlesWindow:destroy()
particlesWindow = nil
particlesButton:destroy()
particlesButton = nil
Extended.unregister(ExtendedParticles)
end
function Particles.show()
Particles.refreshList()
particlesWindow:show()
particlesWindow:raise()
particlesWindow:focus()
end
function Particles.hide()
particlesWindow:hide()
end
function Particles.toggle()
if particlesWindow:isVisible() then
Particles.hide()
else
Particles.show()
end
end
function Particles.refreshInfo()
local particlesList = particlesWindow:getChildById('particlesList')
local widget = particlesList:getFocusedChild()
local name = particlesWindow:getChildById('name')
name:setText(widget.effect:getName())
local location = particlesWindow:getChildById('location')
location:setText(widget.effect:getFile())
local description = particlesWindow:getChildById('description')
description:setText(widget.effect:getDescription())
end
function Particles.refreshList()
local particlesList = particlesWindow:getChildById('particlesList')
particlesList.onChildFocusChange = nil
particlesList:destroyChildren()
local firstChild = nil
local effects = g_particles.getEffectsTypes()
for name,effect in pairs(effects) do
local label = g_ui.createWidget('ParticlesListLabel', particlesList)
label:setText(name)
label.effect = effect
if not firstChild then
firstChild = label
end
end
particlesList.onChildFocusChange = Particles.refreshInfo
if firstChild then
firstChild:focus()
end
end
function Particles.start()
local particlesList = particlesWindow:getChildById('particlesList')
local focusedEffect = particlesList:getFocusedChild()
local preview = particlesWindow:getChildById('preview')
preview:addEffect(focusedEffect:getText())
end

View File

@@ -0,0 +1,17 @@
Module
name: client_particles
description: Manages particles systems
author: baxnie
website: www.otclient.info
dependencies:
- client_extended
- client_locales
- client_topmenu
@onLoad: |
dofile 'particles'
Particles.init()
@onUnload: |
Particles.terminate()

View File

@@ -0,0 +1,130 @@
ParticlesListLabel < Label
font: verdana-11px-monochrome
background-color: alpha
text-offset: 2 0
focusable: true
$focus:
background-color: #ffffff22
color: #ffffff
MainWindow
id: particlesWindow
!text: tr('Particles Manager')
size: 450 450
visible: false
@onEscape: Particles.hide()
TextList
id: particlesList
anchors.top: parent.top
anchors.left: parent.left
anchors.bottom: separator.top
width: 128
padding: 1
focusable: false
margin-bottom: 10
vertical-scrollbar: particlesListScrollBar
VerticalScrollBar
id: particlesListScrollBar
anchors.top: particlesList.top
anchors.bottom: particlesList.bottom
anchors.left: particlesList.right
step: 14
pixels-scroll: true
Label
!text: tr('Name')
anchors.top: parent.top
anchors.left: prev.right
margin-left: 10
FlatLabel
id: name
anchors.top: prev.bottom
anchors.left: prev.left
anchors.right: parent.right
margin-top: 3
Label
!text: tr('Location')
anchors.top: prev.bottom
anchors.left: prev.left
margin-top: 10
FlatLabel
id: location
anchors.top: prev.bottom
anchors.left: prev.left
anchors.right: parent.right
margin-top: 3
Label
!text: tr('Description')
anchors.top: prev.bottom
anchors.left: prev.left
margin-top: 10
FlatLabel
id: description
anchors.top: prev.bottom
anchors.left: prev.left
anchors.right: parent.right
margin-top: 3
Label
!text: tr('Preview')
anchors.top: prev.bottom
anchors.left: prev.left
margin-top: 10
ParticlesFlatPanel
id: preview
margin-top: 3
margin-bottom: 10
anchors.top: prev.bottom
anchors.bottom: next.top
anchors.left: prev.left
anchors.right: parent.right
reference: 10 10
Button
id: startButton
!text: tr('Start')
width: 64
anchors.bottom: separator.top
anchors.left: location.left
margin-bottom: 10
Button
id: pauseButton
!text: tr('Pause')
width: 64
anchors.bottom: prev.bottom
anchors.left: prev.right
margin-left: 5
Button
id: reloadButton
!text: tr('Reload')
width: 64
anchors.bottom: separator.top
anchors.right: parent.right
margin-bottom: 10
HorizontalSeparator
id: separator
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: next.top
margin-bottom: 10
Button
id: closeButton
!text: tr('Close')
width: 64
anchors.right: parent.right
anchors.bottom: parent.bottom
@onClick: Particles.hide()

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

View File

@@ -110,15 +110,25 @@ end
function Skins.loadSkin(skin)
local lowerName = string.lower(skin.name)
for i=1,#skin.fonts do
g_fonts.importFont('skins/' .. lowerName .. '/fonts/' .. skin.fonts[i])
if skin.fonts then
for i=1,#skin.fonts do
g_fonts.importFont('skins/' .. lowerName .. '/fonts/' .. skin.fonts[i])
if i == 1 then
g_fonts.setDefaultFont(skin.fonts[i])
if i == 1 then
g_fonts.setDefaultFont(skin.fonts[i])
end
end
end
for i=1,#skin.styles do
g_ui.importStyle('skins/' .. lowerName .. '/styles/' .. skin.styles[i])
if skin.styles then
for i=1,#skin.styles do
g_ui.importStyle('skins/' .. lowerName .. '/styles/' .. skin.styles[i])
end
end
if skin.particles then
for i=1,#skin.particles do
g_particles.importParticle('skins/' .. lowerName .. '/particles/' .. skin.particles[i])
end
end
end

View File

@@ -29,6 +29,10 @@ local skin = {
'miniwindow.otui',
'items.otui',
'creatures.otui'
},
particles = {
'shiny.otps'
}
}

View File

@@ -0,0 +1,52 @@
Particle
name: shiny_star
min-position-radius: 0
max-position-radius: 8
min-position-angle: 0
max-position-angle: 360
velocity: 4
min-velocity-angle: 0
max-velocity-angle: 360
particle-size: 4 4
texture: shiny_star.png
composition-mode: addition
Effect
name: Shiny3
description: 3 Shiny stars derping aroud
System
position: 0 0
Emitter
position: 0 0
delay: 0
duration: 0
burstRate: 0
burstCount: 3
particle-type: shiny_star
AttractionAffector
position: 0 0
acceleration: 2
Effect
name: Shiny5
description: 5 Shiny stars derping aroud
System
position: 0 0
Emitter
position: 0 0
delay: 0
duration: 0
burstRate: 0
burstCount: 5
particle-type: shiny_star
AttractionAffector
position: 0 0
acceleration: 2

View File

@@ -10,4 +10,8 @@ FlatPanel < Panel
ScrollableFlatPanel < ScrollablePanel
image-source: /images/panel_flat.png
image-border: 1
image-border: 1
ParticlesFlatPanel < Panel
image-source: /images/panel_flat.png
image-border: 1

View File

@@ -1,8 +1,6 @@
local skin = {
name = 'Example',
fonts = {},
styles = {
'topmenu.otui'
}

View File

@@ -186,7 +186,6 @@ SpeakChannelOrange = 12
SpeakMonsterSay = 13
SpeakMonsterYell = 14
FightOffensive = 1
FightBalanced = 2
FightDefensive = 3
@@ -194,6 +193,10 @@ FightDefensive = 3
DontChase = 0
ChaseOpponent = 1
ExtendedActivate = 0
ExtendedLocales = 1
ExtendedParticles = 2
-- @}
KeyCodeDescs = {