diff options
-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")) |