parent
2b621cace6
commit
6a85c31a77
@ -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
|
@ -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()
|
@ -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()
|
After Width: | Height: | Size: 571 B |
@ -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
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2012 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.
|
||||
*/
|
||||
|
||||
#include "particleeffect.h"
|
||||
|
||||
ParticleEffectType::ParticleEffectType()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool ParticleEffectType::load(const OTMLNodePtr& node)
|
||||
{
|
||||
m_node = node;
|
||||
for(const OTMLNodePtr& childNode : node->children()) {
|
||||
if(childNode->tag() == "name") {
|
||||
setName(childNode->value());
|
||||
}
|
||||
else if(childNode->tag() == "description") {
|
||||
setDescription(childNode->value());
|
||||
}
|
||||
}
|
||||
return !m_name.empty();
|
||||
}
|
||||
|
||||
bool ParticleEffect::load(const ParticleEffectTypePtr& effectType)
|
||||
{
|
||||
if(!effectType)
|
||||
return false;
|
||||
|
||||
for(const OTMLNodePtr& childNode : effectType->getNode()->children()) {
|
||||
if(childNode->tag() == "System") {
|
||||
ParticleSystemPtr system = ParticleSystemPtr(new ParticleSystem);
|
||||
if(system->load(childNode)) {
|
||||
m_systems.push_back(system);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticleEffect::render()
|
||||
{
|
||||
for(auto it = m_systems.begin(), end = m_systems.end(); it != end; ++it)
|
||||
(*it)->render();
|
||||
}
|
||||
|
||||
void ParticleEffect::update()
|
||||
{
|
||||
for(auto it = m_systems.begin(), end = m_systems.end(); it != end;) {
|
||||
const ParticleSystemPtr& system = *it;
|
||||
|
||||
if(system->hasFinished()) {
|
||||
it = m_systems.erase(it);
|
||||
continue;
|
||||
}
|
||||
|
||||
system->update();
|
||||
++it;
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2012 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 PARTICLEEFFECT_H
|
||||
#define PARTICLEEFFECT_H
|
||||
|
||||
#include "declarations.h"
|
||||
#include "particlesystem.h"
|
||||
#include <framework/luascript/luaobject.h>
|
||||
#include <framework/otml/otml.h>
|
||||
|
||||
class ParticleEffectType : public LuaObject
|
||||
{
|
||||
public:
|
||||
ParticleEffectType();
|
||||
|
||||
bool load(const OTMLNodePtr& node);
|
||||
|
||||
void setName(const std::string& name) { m_name = name; }
|
||||
void setFile(const std::string& file) { m_file = file; }
|
||||
void setDescription(const std::string& description) { m_description = description; }
|
||||
|
||||
std::string getName() { return m_name; }
|
||||
std::string getFile() { return m_file; }
|
||||
std::string getDescription() { return m_description; }
|
||||
OTMLNodePtr getNode() { return m_node; }
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
std::string m_file;
|
||||
std::string m_description;
|
||||
OTMLNodePtr m_node;
|
||||
};
|
||||
|
||||
class ParticleEffect : public LuaObject
|
||||
{
|
||||
public:
|
||||
ParticleEffect() {}
|
||||
|
||||
bool load(const ParticleEffectTypePtr& effectType);
|
||||
bool hasFinished() { return m_systems.size() == 0; }
|
||||
void render();
|
||||
void update();
|
||||
|
||||
private:
|
||||
std::vector<ParticleSystemPtr> m_systems;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2012 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.
|
||||
*/
|
||||
|
||||
#include "uiparticles.h"
|
||||
#include <framework/graphics/particlemanager.h>
|
||||
|
||||
void UIParticles::drawSelf(Fw::DrawPane drawPane)
|
||||
{
|
||||
if((drawPane & Fw::ForegroundPane) == 0)
|
||||
return;
|
||||
|
||||
for(auto it = m_effects.begin(), end = m_effects.end(); it != end; ++it)
|
||||
(*it)->render();
|
||||
}
|
||||
|
||||
void UIParticles::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
|
||||
{
|
||||
UIWidget::onStyleApply(styleName, styleNode);
|
||||
|
||||
/*for(const OTMLNodePtr& node : styleNode->children()) {
|
||||
if(node->tag() == "reference")
|
||||
setItemId(node->value<int>());
|
||||
else if(node->tag() == "item-count")
|
||||
setItemCount(node->value<int>());
|
||||
else if(node->tag() == "virtual")
|
||||
setVirtual(node->value<bool>());
|
||||
}*/
|
||||
}
|
||||
|
||||
void UIParticles::addEffect(const std::string& name)
|
||||
{
|
||||
ParticleEffectPtr effect = g_particles.createEffect(name);
|
||||
if(effect)
|
||||
m_effects.push_back(effect);
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2012 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 UIPARTICLES_H
|
||||
#define UIPARTICLES_H
|
||||
|
||||
#include <framework/graphics/particleeffect.h>
|
||||
#include <framework/ui/uiwidget.h>
|
||||
|
||||
class UIParticles : public UIWidget
|
||||
{
|
||||
public:
|
||||
void drawSelf(Fw::DrawPane drawPane);
|
||||
|
||||
void addEffect(const std::string& name);
|
||||
|
||||
void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
|
||||
|
||||
private:
|
||||
std::vector<ParticleEffectPtr> m_effects;
|
||||
};
|
||||
|
||||
#endif // UIPARTICLES_H
|
Loading…
Reference in new issue