summaryrefslogtreecommitdiff
path: root/src/gui/popups/speechbubble.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-16 14:43:47 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-16 14:43:47 +0300
commitbf3205aafa71fad7138e7be8a4b641907ec056ce (patch)
tree1ce5728058c09aeafafb4210cf0ecd89ab0e0397 /src/gui/popups/speechbubble.cpp
parentf03edb38328aa5ddb48e10198621bf2353096440 (diff)
downloadmanaverse-bf3205aafa71fad7138e7be8a4b641907ec056ce.tar.gz
manaverse-bf3205aafa71fad7138e7be8a4b641907ec056ce.tar.bz2
manaverse-bf3205aafa71fad7138e7be8a4b641907ec056ce.tar.xz
manaverse-bf3205aafa71fad7138e7be8a4b641907ec056ce.zip
add ability to show emotes in text over heads.
for this textbox replaces into browserbox in speechbubble.
Diffstat (limited to 'src/gui/popups/speechbubble.cpp')
-rw-r--r--src/gui/popups/speechbubble.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp
index ad043b9bf..3033b7923 100644
--- a/src/gui/popups/speechbubble.cpp
+++ b/src/gui/popups/speechbubble.cpp
@@ -25,6 +25,7 @@
#include "gui/sdlfont.h"
+#include "gui/widgets/browserbox.h"
#include "gui/widgets/label.h"
#include "gui/widgets/textbox.h"
@@ -36,14 +37,15 @@ SpeechBubble::SpeechBubble() :
Popup("Speech", "speechbubble.xml"),
mText(),
mCaption(new Label(this)),
- mSpeechBox(new TextBox(this))
+ mSpeechBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
+ "browserbox.xml"))
{
setContentSize(140, 46);
setMinWidth(29);
setMinHeight(29);
mCaption->setFont(boldFont);
- mSpeechBox->setEditable(false);
+// mSpeechBox->setEditable(false);
mSpeechBox->setOpaque(false);
mSpeechBox->setForegroundColorAll(getThemeColor(Theme::BUBBLE_TEXT),
getThemeColor(Theme::BUBBLE_TEXT_OUTLINE));
@@ -66,7 +68,7 @@ void SpeechBubble::setCaption(const std::string &name,
void SpeechBubble::setText(const std::string &text, const bool showName)
{
- if (text == mText && (mCaption->getWidth() <= mSpeechBox->getMinWidth()))
+ if (text == mText && (mCaption->getWidth() <= mSpeechBox->getWidth()))
return;
mSpeechBox->setForegroundColorAll(getThemeColor(Theme::BUBBLE_TEXT),
@@ -75,13 +77,14 @@ void SpeechBubble::setText(const std::string &text, const bool showName)
const int pad = mPadding;
const int pad2 = 2 * pad;
int width = mCaption->getWidth() + pad2;
- mSpeechBox->setTextWrapped(text, 130 > width ? 130 : width);
- const int speechWidth = mSpeechBox->getMinWidth() + pad2;
+ mSpeechBox->clearRows();
+ mSpeechBox->addRow(text);
+ const int speechWidth = mSpeechBox->getWidth() + pad2;
const int fontHeight = getFont()->getHeight();
const int nameHeight = showName ? mCaption->getHeight() + pad / 2 : 0;
- const int numRows = mSpeechBox->getNumberOfRows();
- const int height = (numRows * fontHeight) + nameHeight + pad;
+ const int numRows = 1;
+ const int height = fontHeight + nameHeight + pad;
if (width < speechWidth)
width = speechWidth;