Fixed context menu showing when deselecting unit with right click (fixes #1908)
Do note the mouse_handler::unselected_reach_ flag is only used for this one bugfix, and I haven't tested whether it needs to be set any time game_display::unhighlight_reach is called.
This commit is contained in:
parent
fd2d44f783
commit
8e388c1b35
4 changed files with 17 additions and 8 deletions
|
@ -576,14 +576,17 @@ void game_display::highlight_another_reach(const pathfind::paths &paths_list)
|
|||
reach_map_changed_ = true;
|
||||
}
|
||||
|
||||
void game_display::unhighlight_reach()
|
||||
bool game_display::unhighlight_reach()
|
||||
{
|
||||
reach_map_ = reach_map();
|
||||
reach_map_changed_ = true;
|
||||
reach_map_changed_ = !reach_map_.empty();
|
||||
|
||||
if(reach_map_changed_) {
|
||||
reach_map_.clear();
|
||||
}
|
||||
|
||||
return reach_map_changed_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void game_display::invalidate_route()
|
||||
{
|
||||
for(std::vector<map_location>::const_iterator i = route_.steps.begin();
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
void highlight_another_reach(const pathfind::paths &paths_list);
|
||||
|
||||
/** Reset highlighting of paths. */
|
||||
void unhighlight_reach();
|
||||
bool unhighlight_reach();
|
||||
|
||||
/**
|
||||
* Sets the route along which footsteps are drawn to show movement of a
|
||||
|
|
|
@ -485,7 +485,12 @@ void mouse_handler::mouse_press(const SDL_MouseButtonEvent& event, const bool br
|
|||
|
||||
bool mouse_handler::right_click_show_menu(int x, int y, const bool /*browse*/)
|
||||
{
|
||||
return (selected_hex_.valid() ? false : sdl::point_in_rect(x, y, gui().map_area()));
|
||||
if(selected_hex_.valid() || unselected_reach_) {
|
||||
unselected_reach_ = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return sdl::point_in_rect(x, y, gui().map_area());
|
||||
}
|
||||
|
||||
void mouse_handler::select_or_action(bool browse)
|
||||
|
@ -784,7 +789,7 @@ void mouse_handler::select_hex(const map_location& hex, const bool browse, const
|
|||
gui_->highlight_another_reach(reaching_unit_locations);
|
||||
} else {
|
||||
if(!pc_.gamestate().board_.units_.find(last_hex_)) {
|
||||
gui_->unhighlight_reach();
|
||||
unselected_reach_ = gui_->unhighlight_reach();
|
||||
}
|
||||
|
||||
current_paths_ = pathfind::paths();
|
||||
|
|
|
@ -137,6 +137,7 @@ private:
|
|||
pathfind::marked_route current_route_;
|
||||
pathfind::paths current_paths_;
|
||||
bool unselected_paths_;
|
||||
bool unselected_reach_;
|
||||
int path_turns_;
|
||||
int side_num_;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue