diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-05-17 21:58:00 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-05-17 22:00:17 -0600 |
commit | 36832f3a5378f739da7040f0711b7101dbc2af02 (patch) | |
tree | d53ccf51b07a1189465fd0d700ac95555515d4c6 /src/resources | |
parent | 3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d (diff) | |
download | mana-36832f3a5378f739da7040f0711b7101dbc2af02.tar.gz mana-36832f3a5378f739da7040f0711b7101dbc2af02.tar.bz2 mana-36832f3a5378f739da7040f0711b7101dbc2af02.tar.xz mana-36832f3a5378f739da7040f0711b7101dbc2af02.zip |
Add support for different target cursor sizes for NPCs
Moves the parsing logic for the size strings into BeingInfo to
share the code.
Reviewed-by: Freeyorp
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/beinginfo.cpp | 18 | ||||
-rw-r--r-- | src/resources/beinginfo.h | 2 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 27 | ||||
-rw-r--r-- | src/resources/npcdb.cpp | 5 |
4 files changed, 28 insertions, 24 deletions
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 30b4f86f..66addde9 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -21,6 +21,8 @@ #include "resources/beinginfo.h" +#include "log.h" + #include "utils/dtor.h" #include "utils/gettext.h" @@ -51,6 +53,22 @@ void BeingInfo::setDisplay(SpriteDisplay display) mDisplay = display; } +void BeingInfo::setTargetCursorSize(const std::string &size) +{ + if (size == "small") + setTargetCursorSize(ActorSprite::TC_SMALL); + else if (size == "medium") + setTargetCursorSize(ActorSprite::TC_MEDIUM); + else if (size == "large") + setTargetCursorSize(ActorSprite::TC_LARGE); + else + { + logger->log("Unknown target cursor type \"%s\" for %s - using medium " + "sized one", size.c_str(), getName().c_str()); + setTargetCursorSize(ActorSprite::TC_MEDIUM); + } +} + void BeingInfo::addSound(SoundEvent event, const std::string &filename) { if (mSounds.find(event) == mSounds.end()) diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index def5426e..8485ac6c 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -83,6 +83,8 @@ class BeingInfo const SpriteDisplay &getDisplay() const { return mDisplay; } + void setTargetCursorSize(const std::string &size); + void setTargetCursorSize(ActorSprite::TargetCursorSize targetSize) { mTargetCursorSize = targetSize; } diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index c70cee94..da89302d 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -23,14 +23,14 @@ #include "log.h" +#include "net/net.h" + #include "resources/beinginfo.h" #include "utils/dtor.h" #include "utils/gettext.h" #include "utils/xml.h" -#include "net/net.h" - #define OLD_TMWATHENA_OFFSET 1002 namespace @@ -74,27 +74,8 @@ void MonsterDB::load() currentInfo->setName(XML::getProperty(monsterNode, "name", _("unnamed"))); - std::string targetCursor; - targetCursor = XML::getProperty(monsterNode, "targetCursor", "medium"); - if (targetCursor == "small") - { - currentInfo->setTargetCursorSize(ActorSprite::TC_SMALL); - } - else if (targetCursor == "medium") - { - currentInfo->setTargetCursorSize(ActorSprite::TC_MEDIUM); - } - else if (targetCursor == "large") - { - currentInfo->setTargetCursorSize(ActorSprite::TC_LARGE); - } - else - { - logger->log("MonsterDB: Unknown target cursor type \"%s\" for %s -" - "using medium sized one", - targetCursor.c_str(), currentInfo->getName().c_str()); - currentInfo->setTargetCursorSize(ActorSprite::TC_MEDIUM); - } + currentInfo->setTargetCursorSize(XML::getProperty(monsterNode, + "targetCursor", "medium")); SpriteDisplay display; diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 72a89748..03581e13 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -63,8 +63,11 @@ void NPCDB::load() } BeingInfo *currentInfo = new BeingInfo; - SpriteDisplay display; + currentInfo->setTargetCursorSize(XML::getProperty(npcNode, + "targetCursor", "medium")); + + SpriteDisplay display; for_each_xml_child_node(spriteNode, npcNode) { if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) |