diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-06-22 21:47:53 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-06-22 21:47:53 +0200 |
commit | ba5b70974c5dfa0be3105e72a0a012455b28e7a9 (patch) | |
tree | b79f9f46cc30eb2a1196b79392831af144fabc22 /src/particle.cpp | |
parent | 852ff45c35c422b5264487669934b392a8657465 (diff) | |
download | mana-ba5b70974c5dfa0be3105e72a0a012455b28e7a9.tar.gz mana-ba5b70974c5dfa0be3105e72a0a012455b28e7a9.tar.bz2 mana-ba5b70974c5dfa0be3105e72a0a012455b28e7a9.tar.xz mana-ba5b70974c5dfa0be3105e72a0a012455b28e7a9.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.
Diffstat (limited to 'src/particle.cpp')
-rw-r--r-- | src/particle.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/particle.cpp b/src/particle.cpp index f147a9f2..4d6882be 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -24,6 +24,7 @@ #include "animationparticle.h" #include "configuration.h" +#include "resources/dye.h" #include "imageparticle.h" #include "log.h" #include "map.h" @@ -280,7 +281,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")) @@ -304,18 +310,20 @@ 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((const char*) - node->xmlChildrenNode->content); + std::string imageSrc = (const char*)node->xmlChildrenNode->content; + if (!imageSrc.empty() && !dyePalettes.empty()) + Dye::instantiate(imageSrc, dyePalettes); + Image *img= resman->getImage(imageSrc); newParticle = new ImageParticle(mMap, img); } @@ -346,7 +354,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, { ParticleEmitter *newEmitter; newEmitter = new ParticleEmitter(emitterNode, newParticle, mMap, - rotation); + rotation, dyePalettes); newParticle->addEmitter(newEmitter); } else if (xmlStrEqual(emitterNode->name, BAD_CAST "deatheffect")) |