summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-18 12:35:51 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-18 12:35:51 +0300
commit30a2658b93cebebeddf9aa9e7d9d37cc4fc80d3c (patch)
tree7d3b15f4e42b22e329c632d61e11a16ff0932b58 /src/being.cpp
parent923bd5817bad530de2652529eaf7f5366188034c (diff)
downloadplus-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">
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp32
1 files changed, 22 insertions, 10 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();
}