diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-03-02 13:40:42 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-03-02 13:40:42 +0300 |
commit | fa4ce6cc00f1d3029ccfe7fd02cca29d4147bfb3 (patch) | |
tree | 8f3950de53b13b8b9071d3006121f050ea9c23d2 | |
parent | 07518d71fdcb0c16ea8ece1993b6448839346092 (diff) | |
download | manaplus-fa4ce6cc00f1d3029ccfe7fd02cca29d4147bfb3.tar.gz manaplus-fa4ce6cc00f1d3029ccfe7fd02cca29d4147bfb3.tar.bz2 manaplus-fa4ce6cc00f1d3029ccfe7fd02cca29d4147bfb3.tar.xz manaplus-fa4ce6cc00f1d3029ccfe7fd02cca29d4147bfb3.zip |
Dehardcode Fx keys in chat window.
-rw-r--r-- | src/gui/setupactiondata.h | 61 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 56 | ||||
-rw-r--r-- | src/input/keyboarddata.h | 85 | ||||
-rw-r--r-- | src/input/keydata.h | 12 |
4 files changed, 185 insertions, 29 deletions
diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h index 1b767516d..aa07e24c4 100644 --- a/src/gui/setupactiondata.h +++ b/src/gui/setupactiondata.h @@ -1232,6 +1232,67 @@ static SetupActionData setupActionData5[] = "", }, { + // TRANSLATORS: input action name + N_("Show smiles"), + Input::KEY_GUI_F1, + "", + }, + { + "F2", + Input::KEY_GUI_F2, + "", + }, + { + "F3", + Input::KEY_GUI_F3, + "", + }, + { + "F4", + Input::KEY_GUI_F4, + "", + }, + { + "F5", + Input::KEY_GUI_F5, + "", + }, + { + "F6", + Input::KEY_GUI_F6, + "", + }, + { + "F7", + Input::KEY_GUI_F7, + "", + }, + { + "F8", + Input::KEY_GUI_F8, + "", + }, + { + "F9", + Input::KEY_GUI_F9, + "", + }, + { + "F10", + Input::KEY_GUI_F10, + "", + }, + { + "F11", + Input::KEY_GUI_F11, + "", + }, + { + "F12", + Input::KEY_GUI_F12, + "", + }, + { "", Input::KEY_NO_VALUE, "" 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<int>(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<int>(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<int>(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) { diff --git a/src/input/keyboarddata.h b/src/input/keyboarddata.h index e6bafb61b..a3fbbeab5 100644 --- a/src/input/keyboarddata.h +++ b/src/input/keyboarddata.h @@ -2087,6 +2087,91 @@ static const KeyData keyData[Input::KEY_TOTAL] = { &ActionManager::openTrade, Input::KEY_NO_VALUE, 50, COND_GAME | COND_NOTARGET}, + + {"keyGUIF1", + INPUT_KEYBOARD, SDLK_F1, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF2", + INPUT_KEYBOARD, SDLK_F2, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF3", + INPUT_KEYBOARD, SDLK_F3, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF4", + INPUT_KEYBOARD, SDLK_F4, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF5", + INPUT_KEYBOARD, SDLK_F5, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF6", + INPUT_KEYBOARD, SDLK_F6, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF7", + INPUT_KEYBOARD, SDLK_F7, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF8", + INPUT_KEYBOARD, SDLK_F8, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF9", + INPUT_KEYBOARD, SDLK_F9, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF10", + INPUT_KEYBOARD, SDLK_F10, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF11", + INPUT_KEYBOARD, SDLK_F11, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, + {"keyGUIF12", + INPUT_KEYBOARD, SDLK_F12, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_GUICHAN | Input::GRP_CHAT, + nullptr, + Input::KEY_NO_VALUE, 50, + COND_DEFAULT}, }; #endif // INPUT_KEYBOARDDATA_H diff --git a/src/input/keydata.h b/src/input/keydata.h index 62517b64b..e8b44bd64 100644 --- a/src/input/keydata.h +++ b/src/input/keydata.h @@ -358,6 +358,18 @@ namespace Input KEY_PREV_COMMANDS_TAB, KEY_NEXT_COMMANDS_TAB, KEY_OPEN_TRADE, + KEY_GUI_F1, + KEY_GUI_F2, + KEY_GUI_F3, + KEY_GUI_F4, + KEY_GUI_F5, + KEY_GUI_F6, + KEY_GUI_F7, + KEY_GUI_F8, + KEY_GUI_F9, + KEY_GUI_F10, + KEY_GUI_F11, + KEY_GUI_F12, KEY_TOTAL }; } // namespace Input |