From fa4ce6cc00f1d3029ccfe7fd02cca29d4147bfb3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 2 Mar 2014 13:40:42 +0300 Subject: Dehardcode Fx keys in chat window. --- src/gui/windows/chatwindow.cpp | 56 ++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'src/gui/windows/chatwindow.cpp') diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index d769c4397..51d7d6db7 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -781,14 +781,16 @@ void ChatWindow::mouseDragged(MouseEvent &event) } } -#define caseKey(key, str) case key:\ - temp = str; \ - break +#define ifKey(key, str) \ + else if (actionId == static_cast(key)) \ + { \ + temp = str; \ + } void ChatWindow::keyPressed(KeyEvent &event) { - const int key = event.getKey().getValue(); const int actionId = event.getActionId(); + std::string temp; if (actionId == static_cast(Input::KEY_GUI_DOWN)) { if (mCurHist != mHistory.end()) @@ -910,38 +912,34 @@ void ChatWindow::keyPressed(KeyEvent &event) mChatInput->getText().length())); } } - - std::string temp; - switch (key) + else if (actionId == static_cast(Input::KEY_GUI_F1)) { - case Key::F1: - if (emoteWindow) - { - if (emoteWindow->isVisible()) - emoteWindow->hide(); - else - emoteWindow->show(); - } - break; - caseKey(Key::F2, "\u2318"); - caseKey(Key::F3, "\u263A"); - caseKey(Key::F4, "\u2665"); - caseKey(Key::F5, "\u266A"); - caseKey(Key::F6, "\u266B"); - caseKey(Key::F7, "\u26A0"); - caseKey(Key::F8, "\u2622"); - caseKey(Key::F9, "\u262E"); - caseKey(Key::F10, "\u2605"); - caseKey(Key::F11, "\u2618"); - caseKey(Key::F12, "\u2592"); - default: - break; + if (emoteWindow) + { + if (emoteWindow->isVisible()) + emoteWindow->hide(); + else + emoteWindow->show(); + } } + ifKey(Input::KEY_GUI_F2, "\u2318") + ifKey(Input::KEY_GUI_F3, "\u263A") + ifKey(Input::KEY_GUI_F4, "\u2665") + ifKey(Input::KEY_GUI_F5, "\u266A") + ifKey(Input::KEY_GUI_F6, "\u266B") + ifKey(Input::KEY_GUI_F7, "\u26A0") + ifKey(Input::KEY_GUI_F8, "\u2622") + ifKey(Input::KEY_GUI_F9, "\u262E") + ifKey(Input::KEY_GUI_F10, "\u2605") + ifKey(Input::KEY_GUI_F11, "\u2618") + ifKey(Input::KEY_GUI_F12, "\u2592") if (!temp.empty()) addInputText(temp, false); } +#undef ifKey + void ChatWindow::processEvent(const Channels channel, const DepricatedEvent &event) { -- cgit v1.2.3-70-g09d2