summaryrefslogtreecommitdiff
path: root/src/resources/spritedef.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-11-04 11:52:44 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-11-04 11:52:44 +0000
commit1923c5ae18c713fed8c37b84e4164ade6cf61a69 (patch)
tree5e96392047b5336fea18ce80efd96904e82bfebf /src/resources/spritedef.cpp
parent6942c7b9d3479e09697f074c1a6e848dec8af44e (diff)
downloadmana-1923c5ae18c713fed8c37b84e4164ade6cf61a69.tar.gz
mana-1923c5ae18c713fed8c37b84e4164ade6cf61a69.tar.bz2
mana-1923c5ae18c713fed8c37b84e4164ade6cf61a69.tar.xz
mana-1923c5ae18c713fed8c37b84e4164ade6cf61a69.zip
Tightened palette handling.
Diffstat (limited to 'src/resources/spritedef.cpp')
-rw-r--r--src/resources/spritedef.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 45a52d2e..de6f8d0b 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -25,14 +25,14 @@
#include "spritedef.h"
-#include "../log.h"
-
-#include "animation.h"
#include "action.h"
-#include "resourcemanager.h"
-#include "imageset.h"
+#include "animation.h"
+#include "dye.h"
#include "image.h"
+#include "imageset.h"
+#include "resourcemanager.h"
+#include "../log.h"
#include "../utils/xml.h"
Action*
@@ -53,7 +53,14 @@ SpriteDef *SpriteDef::load(std::string const &animationFile, int variant)
{
int size;
ResourceManager *resman = ResourceManager::getInstance();
- char *data = (char*) resman->loadFile(animationFile.c_str(), size);
+
+ std::string::size_type pos = animationFile.find('|');
+ std::string palettes;
+ if (pos != std::string::npos)
+ palettes = animationFile.substr(pos + 1);
+
+ char *data = (char*) resman->loadFile
+ (animationFile.substr(0, pos).c_str(), size);
if (!data) return NULL;
@@ -89,7 +96,7 @@ SpriteDef *SpriteDef::load(std::string const &animationFile, int variant)
{
if (xmlStrEqual(node->name, BAD_CAST "imageset"))
{
- def->loadImageSet(node);
+ def->loadImageSet(node, palettes);
}
else if (xmlStrEqual(node->name, BAD_CAST "action"))
{
@@ -125,13 +132,13 @@ void SpriteDef::substituteActions()
substituteAction(ACTION_DEAD, ACTION_HURT);
}
-void
-SpriteDef::loadImageSet(xmlNodePtr node)
+void SpriteDef::loadImageSet(xmlNodePtr node, std::string const &palettes)
{
int width = XML::getProperty(node, "width", 0);
int height = XML::getProperty(node, "height", 0);
std::string name = XML::getProperty(node, "name", "");
std::string imageSrc = XML::getProperty(node, "src", "");
+ Dye::instantiate(imageSrc, palettes);
ResourceManager *resman = ResourceManager::getInstance();
ImageSet *imageSet = resman->getImageSet(imageSrc, width, height);