summaryrefslogtreecommitdiff
path: root/src/resources/itemdb.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-25 21:44:28 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-25 22:18:16 +0300
commitbadba244423ba8fccb246afaa8b1dd0c1448b370 (patch)
treed2f72ed78b3a3c9be195a2b33036c207b551066f /src/resources/itemdb.cpp
parent24e2ae34bfc9e6b96b890893ece422170fb7d42f (diff)
downloadplus-badba244423ba8fccb246afaa8b1dd0c1448b370.tar.gz
plus-badba244423ba8fccb246afaa8b1dd0c1448b370.tar.bz2
plus-badba244423ba8fccb246afaa8b1dd0c1448b370.tar.xz
plus-badba244423ba8fccb246afaa8b1dd0c1448b370.zip
Reorders sprites now depend on player direction.
Diffstat (limited to 'src/resources/itemdb.cpp')
-rw-r--r--src/resources/itemdb.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 22728525c..2d14ba687 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -55,7 +55,9 @@ static void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node);
static void loadSoundRef(ItemInfo *itemInfo, xmlNodePtr node);
static void loadFloorSprite(SpriteDisplay *display, xmlNodePtr node);
static void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode);
-static int parseSpriteName(std::string &name);
+static void loadOrderSprite(ItemInfo *itemInfo, xmlNodePtr node,
+ bool drawAfter);
+static int parseSpriteName(std::string name);
static int parseDirectionName(std::string name);
static char const *const fields[][2] =
@@ -293,9 +295,9 @@ void ItemDB::load()
itemInfo->setMissileParticleFile(missileParticle);
itemInfo->setHitEffectId(hitEffectId);
itemInfo->setCriticalHitEffectId(criticalEffectId);
- itemInfo->setDrawBefore(parseSpriteName(drawBefore));
- itemInfo->setDrawAfter(parseSpriteName(drawAfter));
- itemInfo->setDrawPriority(drawPriority);
+ itemInfo->setDrawBefore(-1, parseSpriteName(drawBefore));
+ itemInfo->setDrawAfter(-1, parseSpriteName(drawAfter));
+ itemInfo->setDrawPriority(-1, drawPriority);
itemInfo->setColorsList(colors);
std::string effect;
@@ -346,6 +348,14 @@ void ItemDB::load()
{
loadReplaceSprite(itemInfo, itemChild);
}
+ else if (xmlStrEqual(itemChild->name, BAD_CAST "drawAfter"))
+ {
+ loadOrderSprite(itemInfo, itemChild, true);
+ }
+ else if (xmlStrEqual(itemChild->name, BAD_CAST "drawBefore"))
+ {
+ loadOrderSprite(itemInfo, itemChild, false);
+ }
}
itemInfo->setDisplay(display);
@@ -471,7 +481,7 @@ const std::map<int, ItemInfo*> &ItemDB::getItemInfos()
return mItemInfos;
}
-int parseSpriteName(std::string &name)
+int parseSpriteName(std::string name)
{
int id = -1;
if (name == "shoes" || name == "boot" || name == "boots")
@@ -632,3 +642,17 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode)
}
}
}
+
+void loadOrderSprite(ItemInfo *itemInfo, xmlNodePtr node, bool drawAfter)
+{
+ int sprite = parseSpriteName(XML::getProperty(node, "name", ""));
+ int priority = XML::getProperty(node, "priority", 0);
+
+ int direction = parseDirectionName(XML::getProperty(
+ node, "direction", "all"));
+ if (drawAfter)
+ itemInfo->setDrawAfter(direction, sprite);
+ else
+ itemInfo->setDrawBefore(direction, sprite);
+ itemInfo->setDrawPriority(direction, priority);
+}