From a0de9bc8c0bec21d3a793e958b7a8a98ec482cf6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 20 Oct 2013 20:11:32 +0300 Subject: Add emotes button in chat input line. Enabled by default. --- src/gui/windows/chatwindow.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'src/gui/windows/chatwindow.cpp') 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) -- cgit v1.2.3-60-g2f50