summaryrefslogtreecommitdiff
path: root/src
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
parentf03edb38328aa5ddb48e10198621bf2353096440 (diff)
downloadmv-bf3205aafa71fad7138e7be8a4b641907ec056ce.tar.gz
mv-bf3205aafa71fad7138e7be8a4b641907ec056ce.tar.bz2
mv-bf3205aafa71fad7138e7be8a4b641907ec056ce.tar.xz
mv-bf3205aafa71fad7138e7be8a4b641907ec056ce.zip
add ability to show emotes in text over heads.
for this textbox replaces into browserbox in speechbubble.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp10
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/gui/popups/speechbubble.cpp17
-rw-r--r--src/gui/popups/speechbubble.h4
-rw-r--r--src/gui/widgets/browserbox.cpp7
-rw-r--r--src/gui/widgets/browserbox.h3
6 files changed, 32 insertions, 11 deletions
diff --git a/src/client.cpp b/src/client.cpp
index e2ce0af74..b16ad2a22 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -2899,8 +2899,16 @@ void Client::checkConfigVersion()
config.setValue("showDidYouKnow", false);
#endif
}
+ if (version < 5)
+ {
+ if (config.getIntValue("speech") == Being::TEXT_OVERHEAD)
+ {
+ config.setValue("speech", static_cast<int>(
+ Being::NO_NAME_IN_BUBBLE));
+ }
+ }
- config.setValue("cfgver", 4);
+ config.setValue("cfgver", 5);
}
Window *Client::openErrorDialog(const std::string &header,
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 06cb40b5f..360e6e469 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -78,7 +78,7 @@ DefaultsData* getConfigDefaults()
AddDEF("speechBubbleAlpha", 1.0F);
AddDEF("MostUsedServerName0", "server.themanaworld.org");
AddDEF("visiblenames", true);
- AddDEF("speech", static_cast<int>(Being::TEXT_OVERHEAD));
+ AddDEF("speech", static_cast<int>(Being::NO_NAME_IN_BUBBLE));
AddDEF("showgender", true);
AddDEF("showlevel", false);
AddDEF("showMonstersTakedDamage", true);
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
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 0dafe8e24..014e4cf58 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -889,6 +889,13 @@ std::string BrowserBox::getTextAtPos(const int x, const int y) const
return str;
}
+void BrowserBox::setForegroundColorAll(const gcn::Color &color1,
+ const gcn::Color &color2)
+{
+ mForegroundColor = color1;
+ mForegroundColor2 = color2;
+}
+
LinePart::~LinePart()
{
if (mImage)
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index e06ca3f48..fd037506b 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -231,6 +231,9 @@ class BrowserBox final : public gcn::Widget,
int getPadding() const A_WARN_UNUSED
{ return mPadding; }
+ void setForegroundColorAll(const gcn::Color &color1,
+ const gcn::Color &color2);
+
private:
int calcHeight() A_WARN_UNUSED;