From 8de44a41862b3a0ff714e68169b6443a2a06b3aa Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 11 Jan 2015 15:33:28 +0300 Subject: Add chat command for select general tab. New chat command: /generaltab Aloases: /general /generalchattab --- src/actions/chat.cpp | 7 +++++++ src/actions/chat.h | 1 + src/gui/windows/chatwindow.cpp | 18 ++++++++++++++++++ src/gui/windows/chatwindow.h | 2 ++ src/input/inputaction.h | 1 + src/input/inputactionmap.h | 5 +++++ 6 files changed, 34 insertions(+) diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp index 670e81356..d5b3d9475 100644 --- a/src/actions/chat.cpp +++ b/src/actions/chat.cpp @@ -464,4 +464,11 @@ impHandler0(clearChat) return true; } +impHandler0(chatGeneralTab) +{ + if (chatWindow) + chatWindow->selectGeneralTab(); + return true; +} + } // namespace Actions diff --git a/src/actions/chat.h b/src/actions/chat.h index 5fe828555..ccad18739 100644 --- a/src/actions/chat.h +++ b/src/actions/chat.h @@ -49,6 +49,7 @@ namespace Actions decHandler(kickParty); decHandler(addText); decHandler(clearChat); + decHandler(chatGeneralTab); } // namespace Actions #undef decHandler diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 49ef73907..c3b78f066 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -374,6 +374,24 @@ void ChatWindow::nextTab() mChatTabs->setSelectedTabByIndex(tab); } +void ChatWindow::selectGeneralTab() +{ + if (!mChatTabs) + return; + + int sz = mChatTabs->getNumberOfTabs(); + for (int f = 0; f < sz; f ++) + { + ChatTab *const tab = dynamic_cast( + mChatTabs->getTabByIndex(f)); + if (tab && tab->getType() == ChatTabType::INPUT) + { + mChatTabs->setSelectedTab(tab); + break; + } + } +} + void ChatWindow::closeTab() const { if (!mChatTabs) diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 7287410d9..d4dfa602d 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -285,6 +285,8 @@ class ChatWindow final : public Window, bool isTabPresent(const ChatTab *const tab) const A_WARN_UNUSED; + void selectGeneralTab(); + void attributeChanged(const int id, const int oldVal, const int newVal) override final; diff --git a/src/input/inputaction.h b/src/input/inputaction.h index f94af67c8..9a93863e7 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -526,6 +526,7 @@ namespace InputAction PET_DIRECT_RIGHT, PET_AI_START, PET_AI_STOP, + CHAT_GENERAL_TAB, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 103bede52..bb0a27e61 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -3924,6 +3924,11 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputCondition::INGAME, "petaistop|stoppetai|disablepetai|petaidisable", false}, + {"keyGeneralTab", + defaultAction(&Actions::chatGeneralTab), + InputCondition::INGAME, + "generaltab|generalchattab|general", + false}, }; #undef defaultAction -- cgit v1.2.3-70-g09d2