From d067d7da8e6ee333a4941d4fe6ee9eb926d37f00 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 10 Feb 2009 17:24:57 -0700 Subject: Added two more options for displaying speech overhead (don't show it at all and show speech bubbles without names). Since a checkbox won't work any more for all of these modes, it's now a slider. Signed-off-by: Ira Rice --- src/gui/speechbubble.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/gui/speechbubble.cpp') diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index f8c69e87..7a191c37 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -74,20 +74,28 @@ void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color) mCaption->setForegroundColor(color); } -void SpeechBubble::setText(std::string mText) +void SpeechBubble::setText(std::string mText, bool showName) { - int width = mCaption->getWidth() + 3; + int width = mCaption->getWidth(); mSpeechBox->setTextWrapped(mText, 130 > width ? 130 : width); const int fontHeight = getFont()->getHeight(); - const int numRows = mSpeechBox->getNumberOfRows() + 1; + const int numRows = showName ? mSpeechBox->getNumberOfRows() + 1 : + mSpeechBox->getNumberOfRows(); + int yPos = showName ? fontHeight + 3 : 3; + int height = (numRows * fontHeight); if (width < mSpeechBox->getMinWidth()) width = mSpeechBox->getMinWidth(); - setContentSize(width + fontHeight, (numRows * fontHeight) + 6); - mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, width + 5, - (numRows * fontHeight))); + if (numRows == 1) + { + yPos = (fontHeight / 4) + 3; + height = ((3 * fontHeight) / 2) + 1; + } + + setContentSize(width + fontHeight, height + 6); + mSpeechArea->setDimension(gcn::Rectangle(4, yPos, width + 5, height)); } unsigned int SpeechBubble::getNumRows() -- cgit v1.2.3-70-g09d2