From 649fdb1c512e9608aa05c99a08b867c8758eeaf8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Jun 2013 19:25:09 +0300 Subject: Add support for monster look. --- src/resources/beinginfo.cpp | 21 +++++++++++++++++++++ src/resources/beinginfo.h | 6 ++++++ src/resources/monsterdb.cpp | 4 ++++ 3 files changed, 31 insertions(+) (limited to 'src/resources') diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index b1d6c1d0c..361dead4d 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -46,6 +46,7 @@ BeingInfo::BeingInfo() : | Map::BLOCKMASK_MONSTER | Map::BLOCKMASK_AIR | Map::BLOCKMASK_WATER), mBlockType(Map::BLOCKTYPE_CHARACTER), + mColors(nullptr), mTargetOffsetX(0), mTargetOffsetY(0), mMaxHP(0), @@ -151,3 +152,23 @@ void BeingInfo::init() empty->mMissEffectId = paths.getIntValue("missEffectId"); } } + +void BeingInfo::setColorsList(const std::string &name) +{ + if (name.empty()) + mColors = nullptr; + else + mColors = ColorDB::getColorsList(name); +} + +std::string BeingInfo::getColor(const int idx) const +{ + if (!mColors) + return std::string(); + + const std::map ::const_iterator + it = mColors->find(idx); + if (it == mColors->end()) + return std::string(); + return it->second.color; +} diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index e62dda149..d94e3db30 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -25,6 +25,7 @@ #include "actorsprite.h" +#include "resources/colordb.h" #include "resources/cursor.h" #include "resources/soundinfo.h" @@ -207,6 +208,10 @@ class BeingInfo final void setHeight(const int n) { mHeight = n; } + void setColorsList(const std::string &name); + + std::string getColor(const int idx) const; + static void init(); static void clear(); @@ -220,6 +225,7 @@ class BeingInfo final Attacks mAttacks; unsigned char mWalkMask; Map::BlockType mBlockType; + const std::map *mColors; int mTargetOffsetX; int mTargetOffsetY; int mMaxHP; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 3d6473fd6..9e8da1b44 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -112,12 +112,16 @@ void MonsterDB::loadXmlFile(const std::string &fileName) currentInfo->setMaxHP(XML::getProperty(monsterNode, "maxHP", 0)); + currentInfo->setSortOffsetY(XML::getProperty( monsterNode, "sortOffsetY", 0)); currentInfo->setDeadSortOffsetY(XML::getProperty( monsterNode, "deadSortOffsetY", 31)); + currentInfo->setColorsList(XML::getProperty(monsterNode, + "colors", "")); + unsigned char block = 0; std::string walkStr = XML::getProperty( monsterNode, "walkType", "walk"); -- cgit v1.2.3-60-g2f50