From ba5b70974c5dfa0be3105e72a0a012455b28e7a9 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. --- 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 24a17ce7..c6dc1efe 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -26,6 +26,7 @@ #include "log.h" #include "resources/animation.h" +#include "resources/dye.h" #include "resources/image.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" @@ -39,13 +40,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); mCurrentFrame = mAnimation->getFrame(0); } @@ -116,13 +118,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