From b3f08b33aff591346efb4a94c4cfccdd7b120e9f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 Aug 2014 15:29:50 +0300 Subject: Move chat command /dontremovename into actions. --- src/actions/commands.cpp | 12 ++++++++++++ src/actions/commands.h | 1 + src/commands.cpp | 12 ------------ src/commands.h | 5 +---- src/gui/popups/popupmenu.cpp | 4 ++-- src/input/inputaction.h | 1 + src/input/inputactionmap.h | 9 +++++++++ 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 9c34b9a5a..27d80bf00 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -598,4 +598,16 @@ impHandler(disableHighlight) return false; } +impHandler(dontRemoveName) +{ + if (event.tab) + { + event.tab->setRemoveNames(false); + if (chatWindow) + chatWindow->saveState(); + return true; + } + return false; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index e06663660..a00c844a0 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -61,6 +61,7 @@ namespace Actions decHandler(execute); decHandler(enableHighlight); decHandler(disableHighlight); + decHandler(dontRemoveName); } // namespace Actions #undef decHandler diff --git a/src/commands.cpp b/src/commands.cpp index de2d03475..e7a6a2682 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -106,18 +106,6 @@ impHandler(hack) return true; } -impHandler(dontRemoveName) -{ - if (event.tab) - { - event.tab->setRemoveNames(false); - if (chatWindow) - chatWindow->saveState(); - return true; - } - return false; -} - impHandler(removeName) { if (event.tab) diff --git a/src/commands.h b/src/commands.h index c94d802f3..3fc566412 100644 --- a/src/commands.h +++ b/src/commands.h @@ -52,7 +52,6 @@ struct CommandInfo final namespace Commands { decHandler(hack); - decHandler(dontRemoveName); decHandler(removeName); decHandler(disableAway); decHandler(enableAway); @@ -71,8 +70,7 @@ namespace Commands enum { - COMMAND_DONTREMOVENAME = 0, - COMMAND_REMOVENAME, + COMMAND_REMOVENAME = 0, COMMAND_DISABLEAWAY, COMMAND_ENABLEAWAY, COMMAND_TEST_PARTICLE, @@ -90,7 +88,6 @@ enum static const CommandInfo commands[] = { - {"", &Commands::dontRemoveName, -1, false}, {"", &Commands::removeName, -1, false}, {"disableaway", &Commands::disableAway, -1, false}, {"enableaway", &Commands::enableAway, -1, false}, diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 501b1e0ff..7a8285cc0 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -1465,8 +1465,8 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "dont remove name" && mTab) { - if (commandHandler) - commandHandler->invokeCommand(COMMAND_DONTREMOVENAME, mTab); + inputManager.executeChatCommand(InputAction::DONT_REMOVE_NAME, + std::string(), mTab); } else if (link == "remove name" && mTab) { diff --git a/src/input/inputaction.h b/src/input/inputaction.h index 510e42793..cdfe410fa 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -410,6 +410,7 @@ namespace InputAction TEST_SDL_FONT, ENABLE_HIGHLIGHT, DISABLE_HIGHLIGHT, + DONT_REMOVE_NAME, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index d395d83b0..dad0f0cc1 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -3467,6 +3467,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputAction::NO_VALUE, 50, InputCondition::INGAME, "disablehighlight", + false}, + {"keyDontRemoveName", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::dontRemoveName, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "dontremovename", false} }; -- cgit v1.2.3-70-g09d2