Skip to content

Commit

Permalink
Keep context menu open after selecting "more" or "earlier items"
Browse files Browse the repository at this point in the history
We remember the last location of the context menu, and in this
case rebuild the menu and relaunch in the same place.
  • Loading branch information
cbeck88 committed Jun 29, 2014
1 parent d684826 commit c11ba80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/play_controller.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1091,6 +1093,12 @@ void play_controller::expand_wml_commands(std::vector<std::string>& items)

void play_controller::show_menu(const std::vector<std::string>& 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<std::string> items = items_arg;
const hotkey::hotkey_command* cmd;
std::vector<std::string>::iterator i = items.begin();
Expand Down
2 changes: 2 additions & 0 deletions src/play_controller.hpp
Expand Up @@ -281,6 +281,8 @@ class play_controller : public controller_base, public events::observer, public
void expand_wml_commands(std::vector<std::string>& items);
std::vector<const_item_ptr> wml_commands_;
boost::scoped_ptr<wmi_pager> wml_command_pager_;
int last_context_menu_x_;
int last_context_menu_y_;

bool victory_when_enemies_defeated_;
bool remove_from_carryover_on_defeat_;
Expand Down

0 comments on commit c11ba80

Please sign in to comment.