widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #08329
Re: [Merge] lp:~widelands-dev/widelands/bug-1616661_messagebox_hotkeys into lp:widelands
Review: Needs Fixing
Diff comments:
>
> === modified file 'src/wui/game_message_menu.cc'
> --- src/wui/game_message_menu.cc 2016-08-04 15:49:05 +0000
> +++ src/wui/game_message_menu.cc 2016-09-14 07:40:02 +0000
> @@ -357,23 +358,66 @@
> center_view();
> return true;
> case SDLK_0:
> - filter_messages(Widelands::Message::Type::kAllMessages);
> - return true;
> + if (code.mod & KMOD_ALT) {
> + filter_messages(Widelands::Message::Type::kAllMessages);
> + last_keyboard_action_ = 0;
> + return true;
> + }
> + return false;
> case SDLK_1:
> - filter_messages(Widelands::Message::Type::kGeologists);
> - return true;
> + if (code.mod & KMOD_ALT) {
Actually doing this in the input loop would be less lines of codes and probably saver. I vote for that for b19.
> + // Workaround for duplicate triggering of the Alt key in Ubuntu:
> + // Don't accept the same key twice for the same gametime.
> + // TODO(GunChleoc): This means that when the game is paused,
> + // the button won't toggle on and off by pressing ALT + 1 repeatedly.
> + const uint32_t gametime = iplayer().game().get_gametime();
> + if (last_keyboard_action_ != gametime) {
> + filter_messages(Widelands::Message::Type::kGeologists);
> + last_keyboard_action_ = gametime;
> + return true;
> + }
> + }
> + return false;
> case SDLK_2:
> - filter_messages(Widelands::Message::Type::kEconomy);
> - return true;
> + if (code.mod & KMOD_ALT) {
> + const uint32_t gametime = iplayer().game().get_gametime();
> + if (last_keyboard_action_ != gametime) {
> + filter_messages(Widelands::Message::Type::kEconomy);
> + last_keyboard_action_ = gametime;
> + return true;
> + }
> + }
> + return false;
> case SDLK_3:
> - filter_messages(Widelands::Message::Type::kSeafaring);
> - return true;
> + if (code.mod & KMOD_ALT) {
> + const uint32_t gametime = iplayer().game().get_gametime();
> + if (last_keyboard_action_ != gametime) {
> + filter_messages(Widelands::Message::Type::kSeafaring);
> + last_keyboard_action_ = gametime;
> + return true;
> + }
> + }
> + return false;
> case SDLK_4:
> - filter_messages(Widelands::Message::Type::kWarfare);
> - return true;
> + if (code.mod & KMOD_ALT) {
> + const uint32_t gametime = iplayer().game().get_gametime();
> + if (last_keyboard_action_ != gametime) {
> + filter_messages(Widelands::Message::Type::kWarfare);
> + last_keyboard_action_ = gametime;
> + return true;
> + }
> + }
> + return false;
> case SDLK_5:
> - filter_messages(Widelands::Message::Type::kScenario);
> - return true;
> + if (code.mod & KMOD_ALT) {
> + const uint32_t gametime = iplayer().game().get_gametime();
> + if (last_keyboard_action_ != gametime) {
> + filter_messages(Widelands::Message::Type::kScenario);
> + last_keyboard_action_ = gametime;
> + return true;
> + }
> + }
> + return false;
> case SDLK_DELETE:
> archive_or_restore();
> return true;
--
https://code.launchpad.net/~widelands-dev/widelands/bug-1616661_messagebox_hotkeys/+merge/305381
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-1616661_messagebox_hotkeys.
References