summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-20 20:11:32 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-20 20:11:32 +0300
commita0de9bc8c0bec21d3a793e958b7a8a98ec482cf6 (patch)
tree56a45c6c9e990825e36377c715c281f01fb5c52c
parent1a6beed9f1c58afd0d9eb6999f0ca12e08d0531d (diff)
downloadmanaverse-a0de9bc8c0bec21d3a793e958b7a8a98ec482cf6.tar.gz
manaverse-a0de9bc8c0bec21d3a793e958b7a8a98ec482cf6.tar.bz2
manaverse-a0de9bc8c0bec21d3a793e958b7a8a98ec482cf6.tar.xz
manaverse-a0de9bc8c0bec21d3a793e958b7a8a98ec482cf6.zip
Add emotes button in chat input line.
Enabled by default.
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/widgets/tabs/setup_chat.cpp8
-rw-r--r--src/gui/windows/chatwindow.cpp39
-rw-r--r--src/gui/windows/chatwindow.h2
4 files changed, 45 insertions, 5 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index c1d1d2927..9e6716517 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -132,6 +132,7 @@ DefaultsData* getConfigDefaults()
AddDEF("customcursor", true);
AddDEF("showDidYouKnow", true);
#endif
+ AddDEF("showEmotesButton", true);
AddDEF("screen", false);
AddDEF("hwaccel", false);
AddDEF("sound", false);
diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp
index e5acd10e5..121886830 100644
--- a/src/gui/widgets/tabs/setup_chat.cpp
+++ b/src/gui/widgets/tabs/setup_chat.cpp
@@ -120,6 +120,10 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) :
new SetupItemCheckBox(_("Hide shop messages"), "",
"hideShopMessages", this, "hideShopMessagesEvent");
+ // TRANSLATORS: settings option
+ new SetupItemCheckBox(_("Show MVP messages"), "",
+ "showMVP", this, "showMVPEvent");
+
// TRANSLATORS: settings group
new SetupItemLabel(_("Tabs"), "", this);
@@ -184,8 +188,8 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) :
"globalsFilter", this, "globalsFilterEvent");
// TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show MVP messages"), "",
- "showMVP", this, "showMVPEvent");
+ new SetupItemCheckBox(_("Show emotes button in chat"), "",
+ "showEmotesButton", this, "showEmotesButtonEvent");
setDimension(gcn::Rectangle(0, 0, 550, 350));
}
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 4533d7ee4..09685e88d 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -48,6 +48,7 @@
#include "gui/widgets/tabs/battletab.h"
+#include "gui/widgets/button.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/itemlinkhandler.h"
#include "gui/widgets/scrollarea.h"
@@ -119,10 +120,15 @@ class ChatInput final : public TextField
if (!n)
mFocusGaining = true;
setVisible(n);
- if (config.getBoolValue("hideChatInput"))
+ if (config.getBoolValue("hideChatInput")
+ || config.getBoolValue("showEmotesButton"))
+ {
mWindow->adjustTabSize();
+ }
if (emoteWindow)
+ {
emoteWindow->hide();
+ }
}
void unprotectFocus()
@@ -210,6 +216,7 @@ ChatWindow::ChatWindow():
mTradeFilter(),
mColorListModel(new ColorListModel),
mColorPicker(new DropDown(this, mColorListModel)),
+ mChatButton(new Button(this, ":)", "openemote", this)),
mChatColor(config.getIntValue("chatColor")),
mChatHistoryIndex(0),
mAwayLog(),
@@ -262,6 +269,8 @@ ChatWindow::ChatWindow():
if (emoteWindow)
emoteWindow->addListeners(this);
+ mChatButton->adjustSize();
+
mChatTabs->enableScrollButtons(true);
mChatTabs->setFollowDownScroll(true);
mChatTabs->setResizeHeight(false);
@@ -317,6 +326,7 @@ void ChatWindow::postInit()
add(mChatTabs);
add(mChatInput);
add(mColorPicker);
+ add(mChatButton);
updateVisibility();
}
@@ -361,8 +371,11 @@ void ChatWindow::adjustTabSize()
const int inputHeight = mChatInput->getHeight();
const int frame2 = 2 * frame;
const int awFrame2 = aw - frame2;
- mChatInput->setPosition(frame, ah - inputHeight - frame);
- mChatInput->setWidth(awFrame2);
+ const bool showEmotes = config.getBoolValue("showEmotesButton");
+ const int chatButtonSize = showEmotes ? 20 : 0;
+ const int y = ah - inputHeight - frame;
+ mChatInput->setPosition(frame, y);
+ mChatInput->setWidth(awFrame2 - chatButtonSize);
mChatTabs->setWidth(awFrame2);
const int height = ah - frame2 - (inputHeight + frame2);
if (mChatInput->isVisible() || !config.getBoolValue("hideChatInput"))
@@ -370,6 +383,16 @@ void ChatWindow::adjustTabSize()
else
mChatTabs->setHeight(height + inputHeight);
+ if (showEmotes)
+ {
+ mChatButton->setVisible(mChatInput->isVisible());
+ mChatButton->setPosition(aw - frame - chatButtonSize, y);
+ }
+ else
+ {
+ mChatButton->setVisible(false);
+ }
+
const ChatTab *const tab = getFocused();
if (tab)
{
@@ -510,6 +533,16 @@ void ChatWindow::action(const gcn::ActionEvent &event)
}
}
}
+ else if (eventId == "openemote")
+ {
+ if (emoteWindow)
+ {
+ if (emoteWindow->isVisible())
+ emoteWindow->hide();
+ else
+ emoteWindow->show();
+ }
+ }
else if (eventId == "color")
{
if (emoteWindow)
diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h
index 64d3d66e0..b2001a6ef 100644
--- a/src/gui/windows/chatwindow.h
+++ b/src/gui/windows/chatwindow.h
@@ -36,6 +36,7 @@
#include <map>
#include <set>
+class Button;
class ChatTab;
class ChatInput;
class ColorListModel;
@@ -360,6 +361,7 @@ class ChatWindow final : public Window,
ColorListModel *mColorListModel;
DropDown *mColorPicker;
+ Button *mChatButton;
int mChatColor;
unsigned int mChatHistoryIndex;
std::list<std::string> mAwayLog;