summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-01-13 01:35:21 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-01-14 23:57:34 +0100
commit0abe26e7665a52440cf1ba0a5145f81f066e9ac3 (patch)
tree996ca1531256a75a736071672153c8fb2a5a3dc2
parent8fe3e11dfc111318c16f2e347bf353cbb04cd828 (diff)
downloadmana-client-0abe26e7665a52440cf1ba0a5145f81f066e9ac3.tar.gz
mana-client-0abe26e7665a52440cf1ba0a5145f81f066e9ac3.tar.bz2
mana-client-0abe26e7665a52440cf1ba0a5145f81f066e9ac3.tar.xz
mana-client-0abe26e7665a52440cf1ba0a5145f81f066e9ac3.zip
Fixed the chat bubbles position.
This issue was much nastier than it first sounded. The issue was happening when using a long weapon (like the scythe) with the SDL backend. The algorithm computing the sprite compound frames into one would then update the sprite height to a high value (127 in my case), leading to put the bubble too far away from the player. The algorithm not being in cause about the needed height, I noticed that the simplest way to set a good Y position of the text bubbles was to simply set a maximum. A config option can be added later. I also unified the way the position is computed in the being class. + Function description sentence removal requested by bjorn. Resolves: Mana-Mantis #447. Reviewed-by: bjorn.
-rw-r--r--src/being.cpp14
-rw-r--r--src/being.h5
2 files changed, 14 insertions, 5 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 887be37c..c7ee9083 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -172,6 +172,11 @@ void Being::setMoveSpeed(const Vector &speed)
Net::getPlayerHandler()->getPixelsPerTickMoveSpeed(speed);
}
+int Being::getSpeechTextYPosition() const
+{
+ return getPixelY() - std::min(getHeight(), 64) - 6;
+}
+
void Being::setPosition(const Vector &pos)
{
Actor::setPosition(pos);
@@ -179,8 +184,7 @@ void Being::setPosition(const Vector &pos)
updateCoords();
if (mText)
- mText->adviseXY((int)pos.x,
- (int)pos.y - getHeight() - mText->getHeight() - 6);
+ mText->adviseXY(getPixelX(), getSpeechTextYPosition());
}
void Being::setDestination(int dstX, int dstY)
@@ -299,7 +303,7 @@ void Being::setSpeech(const std::string &text, int time)
delete mText;
mText = new Text(mSpeech,
- getPixelX(), getPixelY() - getHeight(),
+ getPixelX(), getSpeechTextYPosition(),
gcn::Graphics::CENTER,
&userPalette->getColor(UserPalette::PARTICLE),
true);
@@ -897,7 +901,6 @@ void Being::logic()
void Being::drawSpeech(int offsetX, int offsetY)
{
const int px = getPixelX() - offsetX;
- const int py = getPixelY() - offsetY;
const int speech = config.getIntValue("speech");
// Draw speech above this being
@@ -921,7 +924,8 @@ void Being::drawSpeech(int offsetX, int offsetY)
mSpeechBubble->setText(mSpeech, showName);
mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2),
- py - getHeight() - (mSpeechBubble->getHeight()));
+ getSpeechTextYPosition()
+ - mSpeechBubble->getHeight() - offsetY);
mSpeechBubble->setVisible(true);
}
else if (mSpeechTime > 0 && speech == TEXT_OVERHEAD)
diff --git a/src/being.h b/src/being.h
index c6fd63ed..a7ba29fc 100644
--- a/src/being.h
+++ b/src/being.h
@@ -468,6 +468,11 @@ class Being : public ActorSprite, public EventListener
void updateColors();
+ /**
+ * Gets the advised Y chat text position.
+ */
+ int getSpeechTextYPosition() const;
+
BeingInfo *mInfo;
int mActionTime; /**< Time spent in current action. TODO: Remove use of it */