diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-31 23:52:13 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-31 23:52:13 +0300 |
commit | e0803d8066297368d55b297089257a7e857b368a (patch) | |
tree | 407feeb028ec06332d5c4185b01af778e69e74db /src/resources | |
parent | 4fdc8519f954bf14f01b46c88fc2c0818a9c22b3 (diff) | |
download | manaplus-e0803d8066297368d55b297089257a7e857b368a.tar.gz manaplus-e0803d8066297368d55b297089257a7e857b368a.tar.bz2 manaplus-e0803d8066297368d55b297089257a7e857b368a.tar.xz manaplus-e0803d8066297368d55b297089257a7e857b368a.zip |
Add repeat attribute to xml sequence tag.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/spritedef.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 8c13c595c..ceefac845 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -245,7 +245,7 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode, } else if (xmlStrEqual(frameNode->name, BAD_CAST "sequence")) { - int start = XML::getProperty(frameNode, "start", -1); + const int start = XML::getProperty(frameNode, "start", -1); const int end = XML::getProperty(frameNode, "end", -1); if (start < 0 || end < 0) @@ -254,20 +254,33 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode, continue; } - while (end >= start) + int repeat = XML::getProperty(frameNode, "repeat", 1); + + if (repeat < 1) { - Image *img = imageSet->get(start + variant_offset); + logger->log1("No valid value for 'repeat'"); + continue; + } - if (!img) + while (repeat > 0) + { + int pos = start; + while (end >= pos) { - logger->log("No image at index %d", - start + variant_offset); - start++; - continue; + Image *img = imageSet->get(pos + variant_offset); + + if (!img) + { + logger->log("No image at index %d", + pos + variant_offset); + pos ++; + continue; + } + + animation->addFrame(img, delay, offsetX, offsetY); + pos ++; } - - animation->addFrame(img, delay, offsetX, offsetY); - start++; + repeat --; } } else if (xmlStrEqual(frameNode->name, BAD_CAST "end")) |