diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-05-02 14:43:40 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-05-06 22:21:57 -0600 |
commit | 9baedc27191c82bbf1fedee2a7e738bc5b267c0e (patch) | |
tree | f0986c6839d1e79b402d5d4ec36e4994741955ea /src/resources/itemdb.cpp | |
parent | 844e9a7a72faca6a212e788a3adc45e17f41dca6 (diff) | |
download | mana-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.tar.gz mana-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.tar.bz2 mana-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.tar.xz mana-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.zip |
Add support for floor item sprites
This commit adds a sprite hierarchy (Sprite->ImageSprite,AnimatedSprite,CompundSprite;
CompoundSprite,Actor->ActorSprite;ActorSprite->Being,FloorItem) to collect common
functionailty into new base classes which will make other Mantis tickets easier to do.
Also allows monsters to use particle effects.
Reviewed-by: Bertram
Diffstat (limited to 'src/resources/itemdb.cpp')
-rw-r--r-- | src/resources/itemdb.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 4638f00e..57df6143 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -46,6 +46,7 @@ namespace // Forward declarations static void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node); static void loadSoundRef(ItemInfo *itemInfo, xmlNodePtr node); +static void loadFloorSprite(SpriteDisplay *display, xmlNodePtr node); static char const *const fields[][2] = { @@ -114,7 +115,7 @@ void ItemDB::load() mUnknown = new ItemInfo; mUnknown->setName(_("Unknown item")); - mUnknown->setImageName(""); + mUnknown->setDisplay(SpriteDisplay()); mUnknown->setSprite("error.xml", GENDER_MALE); mUnknown->setSprite("error.xml", GENDER_FEMALE); @@ -154,9 +155,11 @@ void ItemDB::load() int attackRange = XML::getProperty(node, "attack-range", 0); std::string missileParticle = XML::getProperty(node, "missile-particle", ""); + SpriteDisplay display; + display.image = image; + ItemInfo *itemInfo = new ItemInfo; itemInfo->setId(id); - itemInfo->setImageName(image); itemInfo->setName(name.empty() ? _("unnamed") : name); itemInfo->setDescription(description); itemInfo->setType(itemTypeFromString(typeStr)); @@ -202,8 +205,14 @@ void ItemDB::load() { loadSoundRef(itemInfo, itemChild); } + else if (xmlStrEqual(itemChild->name, BAD_CAST "floor")) + { + loadFloorSprite(&display, itemChild); + } } + itemInfo->setDisplay(display); + mItemInfos[id] = itemInfo; if (!name.empty()) { @@ -334,3 +343,22 @@ void loadSoundRef(ItemInfo *itemInfo, xmlNodePtr node) event.c_str()); } } + +void loadFloorSprite(SpriteDisplay *display, xmlNodePtr floorNode) +{ + for_each_xml_child_node(spriteNode, floorNode) + { + if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) + { + SpriteReference *currentSprite = new SpriteReference; + currentSprite->sprite = (const char*)spriteNode->xmlChildrenNode->content; + currentSprite->variant = XML::getProperty(spriteNode, "variant", 0); + display->sprites.push_back(currentSprite); + } + else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) + { + std::string particlefx = (const char*)spriteNode->xmlChildrenNode->content; + display->particles.push_back(particlefx); + } + } +} |