summaryrefslogtreecommitdiff
path: root/src/particle.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-06-22 21:47:53 +0200
committerAndrei Karas <akaras@inbox.ru>2011-06-23 12:46:37 +0300
commit99cb204d29a63bf5f4edb40b25f4fc1a6605fbd1 (patch)
treee6dc5588927460dbda4dccb002fb1e9c48823088 /src/particle.cpp
parent493cc14facb80c6c86c57ef379131e56a0161215 (diff)
downloadplus-99cb204d29a63bf5f4edb40b25f4fc1a6605fbd1.tar.gz
plus-99cb204d29a63bf5f4edb40b25f4fc1a6605fbd1.tar.bz2
plus-99cb204d29a63bf5f4edb40b25f4fc1a6605fbd1.tar.xz
plus-99cb204d29a63bf5f4edb40b25f4fc1a6605fbd1.zip
Made possible to separate the dye colors and channels
for particle effects. It is now possible to write, for instance: <particlefx>my-particle-file.xml|#cbcb78,345678</particlefx> and in my-particle-file.xml: ... <property image="my-image.png|W" /> ... This will permit the use (and reuse) of generic particle files. Conflicts: src/particle.cpp src/particleemitter.cpp src/particleemitter.h src/simpleanimation.cpp
Diffstat (limited to 'src/particle.cpp')
-rw-r--r--src/particle.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/particle.cpp b/src/particle.cpp
index ecc68e6cc..eca9307ea 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -25,6 +25,7 @@
#include "animationparticle.h"
#include "configuration.h"
+#include "resources/dye.h"
#include "imageparticle.h"
#include "log.h"
#include "map.h"
@@ -282,7 +283,12 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
{
Particle *newParticle = NULL;
- XML::Document doc(particleEffectFile);
+ std::string::size_type pos = particleEffectFile.find('|');
+ std::string dyePalettes;
+ if (pos != std::string::npos)
+ dyePalettes = particleEffectFile.substr(pos + 1);
+
+ XML::Document doc(particleEffectFile.substr(0, pos));
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "effect"))
@@ -306,19 +312,22 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
// Animation
if ((node = XML::findFirstChildByName(effectChildNode, "animation")))
{
- newParticle = new AnimationParticle(mMap, node);
+ newParticle = new AnimationParticle(mMap, node, dyePalettes);
}
// Rotational
else if ((node = XML::findFirstChildByName(
effectChildNode, "rotation")))
{
- newParticle = new RotationalParticle(mMap, node);
+ newParticle = new RotationalParticle(mMap, node, dyePalettes);
}
// Image
else if ((node = XML::findFirstChildByName(effectChildNode, "image")))
{
- Image *img = resman->getImage(reinterpret_cast<const char*>(
- node->xmlChildrenNode->content));
+ std::string imageSrc = reinterpret_cast<const char*>(
+ node->xmlChildrenNode->content);
+ if (!imageSrc.empty() && !dyePalettes.empty())
+ Dye::instantiate(imageSrc, dyePalettes);
+ Image *img = resman->getImage(imageSrc);
newParticle = new ImageParticle(mMap, img);
}
@@ -353,8 +362,8 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
if (xmlStrEqual(emitterNode->name, BAD_CAST "emitter"))
{
ParticleEmitter *newEmitter;
- newEmitter = new ParticleEmitter(
- emitterNode, newParticle, mMap, rotation);
+ newEmitter = new ParticleEmitter(emitterNode, newParticle,
+ mMap, rotation, dyePalettes);
newParticle->addEmitter(newEmitter);
}
else if (xmlStrEqual(emitterNode->name, BAD_CAST "deatheffect"))