summaryrefslogtreecommitdiff
path: root/src/gui/popups
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
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')
-rw-r--r--src/gui/popups/speechbubble.cpp17
-rw-r--r--src/gui/popups/speechbubble.h4
2 files changed, 12 insertions, 9 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;
diff --git a/src/gui/popups/speechbubble.h b/src/gui/popups/speechbubble.h
index 6b7c705bb..496b3d71c 100644
--- a/src/gui/popups/speechbubble.h
+++ b/src/gui/popups/speechbubble.h
@@ -29,7 +29,7 @@
#include "gui/widgets/popup.h"
class Label;
-class TextBox;
+class BrowserBox;
class SpeechBubble final : public Popup
{
@@ -60,7 +60,7 @@ class SpeechBubble final : public Popup
private:
std::string mText;
Label *mCaption;
- TextBox *mSpeechBox;
+ BrowserBox *mSpeechBox;
};
#endif // GUI_POPUPS_SPEECHBUBBLE_H