mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-29 14:33:18 +00:00
Whiteboard: tentatively hide units on mouseover...
...when you can plan a move to their current position because they have a planned move.
This commit is contained in:
parent
1afad9d26e
commit
c41e31d15d
@ -238,7 +238,10 @@ void mouse_handler::mouse_motion(int x, int y, const bool browse, bool update)
|
||||
|
||||
current_route_ = get_route(selected_unit, dest, waypoints_, viewing_team());
|
||||
|
||||
resources::whiteboard->create_temp_move();
|
||||
{ // start enforced real unit map scope
|
||||
wb::scoped_real_unit_map real_unit_map;
|
||||
resources::whiteboard->create_temp_move();
|
||||
} // end enforced real unit map scope
|
||||
|
||||
if(!browse) {
|
||||
gui().set_route(¤t_route_);
|
||||
|
@ -51,7 +51,8 @@ manager::manager():
|
||||
route_(),
|
||||
move_arrow_(),
|
||||
fake_unit_(),
|
||||
key_poller_(new CKey)
|
||||
key_poller_(new CKey),
|
||||
hidden_unit_hex_()
|
||||
{
|
||||
LOG_WB << "Manager initialized.\n";
|
||||
}
|
||||
@ -310,10 +311,19 @@ void manager::draw_hex(const map_location& hex)
|
||||
|
||||
void manager::on_mouseover_change(const map_location& hex)
|
||||
{
|
||||
if (hidden_unit_hex_.valid())
|
||||
{
|
||||
if (unit* unit = get_visible_unit(hidden_unit_hex_,
|
||||
resources::teams->at(viewer_side() - 1), false))
|
||||
{
|
||||
unit->set_hidden(false);
|
||||
}
|
||||
hidden_unit_hex_ = map_location();
|
||||
}
|
||||
|
||||
//FIXME: Detect if a WML event is executing, and if so, avoid modifying the unit map during that time.
|
||||
// Acting otherwise causes a crash.
|
||||
if (!resources::screen->selected_hex().valid() && highlighter_)
|
||||
|
||||
{
|
||||
highlighter_->set_mouseover_hex(hex);
|
||||
highlighter_->highlight();
|
||||
@ -381,7 +391,7 @@ void manager::create_temp_move()
|
||||
// Create temp arrow
|
||||
move_arrow_.reset(new arrow());
|
||||
move_arrow_->set_color(team::get_side_color_index(
|
||||
resources::screen->viewing_side()));
|
||||
viewer_side()));
|
||||
move_arrow_->set_alpha(move::ALPHA_HIGHLIGHT);
|
||||
resources::screen->add_arrow(*move_arrow_);
|
||||
|
||||
@ -401,6 +411,15 @@ void manager::create_temp_move()
|
||||
false); //get facing right
|
||||
fake_unit_->set_location(route_->steps.back());
|
||||
fake_unit_->set_ghosted(false);
|
||||
|
||||
//if destination is over another unit, temporarily hide it
|
||||
unit* mouseover_unit = get_visible_unit(resources::screen->mouseover_hex(),
|
||||
resources::teams->at(viewer_side() - 1), false);
|
||||
if (mouseover_unit && mouseover_unit->side() == viewer_side())
|
||||
{
|
||||
mouseover_unit->set_hidden(true);
|
||||
hidden_unit_hex_ = resources::screen->mouseover_hex();
|
||||
}
|
||||
}
|
||||
|
||||
void manager::erase_temp_move()
|
||||
|
@ -162,8 +162,9 @@ private:
|
||||
arrow_ptr move_arrow_;
|
||||
fake_unit_ptr fake_unit_;
|
||||
|
||||
|
||||
boost::scoped_ptr<CKey> key_poller_;
|
||||
|
||||
map_location hidden_unit_hex_;
|
||||
};
|
||||
|
||||
/** Applies the planned unit map for the duration of the struct's life.
|
||||
|
Loading…
x
Reference in New Issue
Block a user