diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-08-25 13:39:28 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-08-25 13:39:28 +0300 |
commit | 0ae262d137e24c44064f59102ff6b72b19c60b71 (patch) | |
tree | bc03b97a2c0fd007f6076daf18ce6e56c5630a49 /src | |
parent | a7c2351c708c38bf020e8e1250b6a78cb2b6f89e (diff) | |
download | mv-0ae262d137e24c44064f59102ff6b72b19c60b71.tar.gz mv-0ae262d137e24c44064f59102ff6b72b19c60b71.tar.bz2 mv-0ae262d137e24c44064f59102ff6b72b19c60b71.tar.xz mv-0ae262d137e24c44064f59102ff6b72b19c60b71.zip |
Move chat command /toggle into actions.
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/chat.cpp | 46 | ||||
-rw-r--r-- | src/actions/chat.h | 1 | ||||
-rw-r--r-- | src/commands.cpp | 42 | ||||
-rw-r--r-- | src/commands.h | 5 | ||||
-rw-r--r-- | src/input/inputaction.h | 1 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 11 |
6 files changed, 59 insertions, 47 deletions
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp index 4396d438a..8f991dd5f 100644 --- a/src/actions/chat.cpp +++ b/src/actions/chat.cpp @@ -86,6 +86,10 @@ extern std::string tradePartnerName; extern QuitDialog *quitDialog; extern unsigned int tmwServerVersion; +// TRANSLATORS: chat option changed message +#define BOOLEAN_OPTIONS _("Options to /%s are \"yes\", \"no\", \"true\", "\ +"\"false\", \"1\", \"0\".") + namespace Actions { @@ -351,4 +355,46 @@ impHandler(me) return true; } +impHandler(toggle) +{ + if (event.args.empty()) + { + if (chatWindow && event.tab) + { + // TRANSLATORS: message from toggle chat command + event.tab->chatLog(chatWindow->getReturnTogglesChat() ? + _("Return toggles chat.") : _("Message closes chat.")); + } + return true; + } + + switch (parseBoolean(event.args)) + { + case 1: + if (event.tab) + { + // TRANSLATORS: message from toggle chat command + event.tab->chatLog(_("Return now toggles chat.")); + } + if (chatWindow) + chatWindow->setReturnTogglesChat(true); + return true; + case 0: + if (event.tab) + { + // TRANSLATORS: message from toggle chat command + event.tab->chatLog(_("Message now closes chat.")); + } + if (chatWindow) + chatWindow->setReturnTogglesChat(false); + return true; + case -1: + if (event.tab) + event.tab->chatLog(strprintf(BOOLEAN_OPTIONS, "toggle")); + return true; + default: + return true; + } +} + } // namespace Actions diff --git a/src/actions/chat.h b/src/actions/chat.h index 78a3743e6..5bf689ac9 100644 --- a/src/actions/chat.h +++ b/src/actions/chat.h @@ -42,6 +42,7 @@ namespace Actions decHandler(createGuild); decHandler(party); decHandler(me); + decHandler(toggle); } // namespace Actions #undef decHandler diff --git a/src/commands.cpp b/src/commands.cpp index 41c828840..b2e1e6eee 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -251,48 +251,6 @@ static void outStringNormal(ChatTab *const tab, } } -impHandler(toggle) -{ - if (event.args.empty()) - { - if (chatWindow && event.tab) - { - // TRANSLATORS: message from toggle chat command - event.tab->chatLog(chatWindow->getReturnTogglesChat() ? - _("Return toggles chat.") : _("Message closes chat.")); - } - return true; - } - - switch (parseBoolean(event.args)) - { - case 1: - if (event.tab) - { - // TRANSLATORS: message from toggle chat command - event.tab->chatLog(_("Return now toggles chat.")); - } - if (chatWindow) - chatWindow->setReturnTogglesChat(true); - return true; - case 0: - if (event.tab) - { - // TRANSLATORS: message from toggle chat command - event.tab->chatLog(_("Message now closes chat.")); - } - if (chatWindow) - chatWindow->setReturnTogglesChat(false); - return true; - case -1: - if (event.tab) - event.tab->chatLog(strprintf(BOOLEAN_OPTIONS, "toggle")); - return true; - default: - return true; - } -} - impHandler0(present) { if (chatWindow) diff --git a/src/commands.h b/src/commands.h index 89f3f52fe..91b55ccca 100644 --- a/src/commands.h +++ b/src/commands.h @@ -51,7 +51,6 @@ struct CommandInfo final namespace Commands { - decHandler(toggle); decHandler(present); decHandler(quit); decHandler(showAll); @@ -120,8 +119,7 @@ namespace Commands enum { - COMMAND_TOGGLE = 0, - COMMAND_PRESENT, + COMMAND_PRESENT = 0, COMMAND_QUIT, COMMAND_ALL, COMMAND_MOVE, @@ -189,7 +187,6 @@ enum static const CommandInfo commands[] = { - {"toggle", &Commands::toggle, -1, false}, {"present", &Commands::present, -1, false}, {"quit", &Commands::quit, -1, false}, {"all", &Commands::showAll, -1, false}, diff --git a/src/input/inputaction.h b/src/input/inputaction.h index 2eb05dac6..dacd2a2da 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -364,6 +364,7 @@ namespace InputAction CREATE_GUILD, PARTY, ME, + TOGGLE, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 368518afc..289490723 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -3045,7 +3045,16 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputAction::NO_VALUE, 50, InputCondition::INGAME, "me", - true} + true}, + {"keyToggle", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::toggle, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "toggle", + false} }; #endif // INPUT_INPUTACTIONMAP_H |