summaryrefslogtreecommitdiff
path: root/src/gui/windows/chatwindow.cpp
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 /src/gui/windows/chatwindow.cpp
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.
Diffstat (limited to 'src/gui/windows/chatwindow.cpp')
-rw-r--r--src/gui/windows/chatwindow.cpp39
1 files changed, 36 insertions, 3 deletions
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)