diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-07-18 12:35:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-07-18 12:35:51 +0300 |
commit | 30a2658b93cebebeddf9aa9e7d9d37cc4fc80d3c (patch) | |
tree | 7d3b15f4e42b22e329c632d61e11a16ff0932b58 | |
parent | 923bd5817bad530de2652529eaf7f5366188034c (diff) | |
download | plus-30a2658b93cebebeddf9aa9e7d9d37cc4fc80d3c.tar.gz plus-30a2658b93cebebeddf9aa9e7d9d37cc4fc80d3c.tar.bz2 plus-30a2658b93cebebeddf9aa9e7d9d37cc4fc80d3c.tar.xz plus-30a2658b93cebebeddf9aa9e7d9d37cc4fc80d3c.zip |
add name offsets for npc and monster names.
New attributes: nameOffsetX, nameOffsetY
Example for monsters.xml:
<monster id="0" name="Piou" targetCursor="small" walkType="fly" nameOffsetX="10">
Example for npcs.xml:
<npc id="304" nameOffsetX="-10" nameOffsetY="-5">
-rw-r--r-- | src/being.cpp | 32 | ||||
-rw-r--r-- | src/resources/beinginfo.cpp | 2 | ||||
-rw-r--r-- | src/resources/beinginfo.h | 14 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 7 | ||||
-rw-r--r-- | src/resources/npcdb.cpp | 6 |
5 files changed, 50 insertions, 11 deletions
diff --git a/src/being.cpp b/src/being.cpp index e92dccaa3..fc0f9a9c3 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1551,16 +1551,18 @@ void Being::updateCoords() if (!mDispName) return; - // Monster names show above the sprite instead of below it - if (mType == MONSTER) + int offsetX = getPixelX(); + int offsetY = getPixelY(); + if (mInfo) { - mDispName->adviseXY(getPixelX(), - getPixelY() - getHeight() - mDispName->getHeight(), mMoveNames); - } - else - { - mDispName->adviseXY(getPixelX(), getPixelY(), mMoveNames); + offsetX += mInfo->getNameOffsetX(); + offsetY += mInfo->getNameOffsetY(); } + // Monster names show above the sprite instead of below it + if (mType == MONSTER) + offsetY += - getHeight() - mDispName->getHeight(); + + mDispName->adviseXY(offsetX, offsetY, mMoveNames); } void Being::optionChanged(const std::string &value) @@ -1654,8 +1656,18 @@ void Being::showName() font = gui->getSecureFont(); } - mDispName = new FlashText(displayName, getPixelX(), getPixelY(), - gcn::Graphics::CENTER, mNameColor, font); + if (mInfo) + { + mDispName = new FlashText(displayName, + getPixelX() + mInfo->getNameOffsetX(), + getPixelY() + mInfo->getNameOffsetY(), + gcn::Graphics::CENTER, mNameColor, font); + } + else + { + mDispName = new FlashText(displayName, getPixelX(), getPixelY(), + gcn::Graphics::CENTER, mNameColor, font); + } updateCoords(); } diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index f54673447..bd45ec9ed 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -49,6 +49,8 @@ BeingInfo::BeingInfo() : mColors(nullptr), mTargetOffsetX(0), mTargetOffsetY(0), + mNameOffsetX(0), + mNameOffsetY(0), mMaxHP(0), mSortOffsetY(0), mDeadSortOffsetY(31), diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index d94e3db30..c90e3296e 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -160,6 +160,18 @@ class BeingInfo final int getTargetOffsetY() const A_WARN_UNUSED { return mTargetOffsetY; } + void setNameOffsetX(const int n) + { mNameOffsetX = n; } + + int getNameOffsetX() const A_WARN_UNUSED + { return mNameOffsetX; } + + void setNameOffsetY(const int n) + { mNameOffsetY = n; } + + int getNameOffsetY() const A_WARN_UNUSED + { return mNameOffsetY; } + void setMaxHP(const int n) { mMaxHP = n; } @@ -228,6 +240,8 @@ class BeingInfo final const std::map <int, ColorDB::ItemColor> *mColors; int mTargetOffsetX; int mTargetOffsetY; + int mNameOffsetX; + int mNameOffsetY; int mMaxHP; int mSortOffsetY; int mDeadSortOffsetY; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 9e8da1b44..f3c81d52d 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -110,8 +110,13 @@ void MonsterDB::loadXmlFile(const std::string &fileName) currentInfo->setTargetOffsetY(XML::getProperty(monsterNode, "targetOffsetY", 0)); - currentInfo->setMaxHP(XML::getProperty(monsterNode, "maxHP", 0)); + currentInfo->setNameOffsetX(XML::getProperty(monsterNode, + "nameOffsetX", 0)); + + currentInfo->setNameOffsetY(XML::getProperty(monsterNode, + "nameOffsetY", 0)); + currentInfo->setMaxHP(XML::getProperty(monsterNode, "maxHP", 0)); currentInfo->setSortOffsetY(XML::getProperty( monsterNode, "sortOffsetY", 0)); diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index bafef22c8..103bbb805 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -102,6 +102,12 @@ void NPCDB::loadXmlFile(const std::string &fileName) currentInfo->setTargetOffsetY(XML::getProperty(npcNode, "targetOffsetY", 0)); + currentInfo->setNameOffsetX(XML::getProperty(npcNode, + "nameOffsetX", 0)); + + currentInfo->setNameOffsetY(XML::getProperty(npcNode, + "nameOffsetY", 0)); + currentInfo->setSortOffsetY(XML::getProperty(npcNode, "sortOffsetY", 0)); |