From c11ba80a53ca07e1798a1b0ea52436b2b7c16eb3 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Sat, 28 Jun 2014 21:37:05 -0400 Subject: [PATCH] Keep context menu open after selecting "more" or "earlier items" We remember the last location of the context menu, and in this case rebuild the menu and relaunch in the same place. --- src/play_controller.cpp | 8 ++++++++ src/play_controller.hpp | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/play_controller.cpp b/src/play_controller.cpp index f16f071061d2..7e7860aca29f 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -728,6 +728,8 @@ bool play_controller::execute_command(const hotkey::hotkey_command& cmd, int ind } else if ( i < wml_commands_.size() && wml_commands_[i] ) { if (!wml_command_pager_->capture(*wml_commands_[i])) { wml_commands_[i]->fire_event(mouse_handler_.get_last_hex()); + } else { //relaunch the menu + show_menu(get_display().get_theme().context_menu()->items(),last_context_menu_x_,last_context_menu_y_,true, get_display()); } return true; } @@ -1091,6 +1093,12 @@ void play_controller::expand_wml_commands(std::vector& items) void play_controller::show_menu(const std::vector& items_arg, int xloc, int yloc, bool context_menu, display& disp) { + if (context_menu) + { + last_context_menu_x_ = xloc; + last_context_menu_y_ = yloc; + } + std::vector items = items_arg; const hotkey::hotkey_command* cmd; std::vector::iterator i = items.begin(); diff --git a/src/play_controller.hpp b/src/play_controller.hpp index f7a632e78856..4af404bd3510 100644 --- a/src/play_controller.hpp +++ b/src/play_controller.hpp @@ -281,6 +281,8 @@ class play_controller : public controller_base, public events::observer, public void expand_wml_commands(std::vector& items); std::vector wml_commands_; boost::scoped_ptr wml_command_pager_; + int last_context_menu_x_; + int last_context_menu_y_; bool victory_when_enemies_defeated_; bool remove_from_carryover_on_defeat_;