From 99cb204d29a63bf5f4edb40b25f4fc1a6605fbd1 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Wed, 22 Jun 2011 21:47:53 +0200 Subject: Made possible to separate the dye colors and channels for particle effects. It is now possible to write, for instance: my-particle-file.xml|#cbcb78,345678 and in my-particle-file.xml: ... ... This will permit the use (and reuse) of generic particle files. Conflicts: src/particle.cpp src/particleemitter.cpp src/particleemitter.h src/simpleanimation.cpp --- src/simpleanimation.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/simpleanimation.cpp') diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index a952d792b..e3591f30c 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -28,6 +28,7 @@ #include "utils/stringutils.h" #include "resources/animation.h" +#include "resources/dye.h" #include "resources/image.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" @@ -43,13 +44,14 @@ SimpleAnimation::SimpleAnimation(Animation *animation): { } -SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode): +SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode, + const std::string& dyePalettes): mAnimation(new Animation), mAnimationTime(0), mAnimationPhase(0), mInitialized(false) { - initializeAnimation(animationNode); + initializeAnimation(animationNode, dyePalettes); if (mAnimation) mCurrentFrame = mAnimation->getFrame(0); else @@ -134,13 +136,21 @@ Image *SimpleAnimation::getCurrentImage() const return NULL; } -void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode) +void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode, + const std::string& dyePalettes) { mInitialized = false; if (!animationNode) return; + std::string imagePath = XML::getProperty(animationNode, + "imageset", ""); + + // Instanciate the dye coloration. + if (!imagePath.empty() && !dyePalettes.empty()) + Dye::instantiate(imagePath, dyePalettes); + ImageSet *imageset = ResourceManager::getInstance()->getImageSet( XML::getProperty(animationNode, "imageset", ""), XML::getProperty(animationNode, "width", 0), -- cgit v1.2.3-60-g2f50