summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/chatwindow.cpp39
-rw-r--r--src/gui/windows/chatwindow.h2
2 files changed, 38 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)
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;