mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-17 11:28:16 +00:00
Changed how the whiteboard clear_undo() works.
This commit is contained in:
parent
d19a24c5b8
commit
4ed2082c2a
@ -2651,7 +2651,8 @@ size_t move_unit(move_unit_spectator *move_spectator,
|
||||
}
|
||||
|
||||
if(undo_stack != NULL) {
|
||||
if(event_mutated || should_clear_stack || maybe_ui == units.end()) {
|
||||
if(event_mutated || should_clear_stack || maybe_ui == units.end()
|
||||
|| resources::whiteboard->active_and_should_clear_undo()) {
|
||||
apply_shroud_changes(*undo_stack, team_num + 1);
|
||||
undo_stack->clear();
|
||||
} else {
|
||||
@ -2661,7 +2662,6 @@ size_t move_unit(move_unit_spectator *move_spectator,
|
||||
starting_waypoints, starting_moves,
|
||||
action_time_bonus, orig_village_owner, orig_dir));
|
||||
}
|
||||
resources::whiteboard->possibly_clear_undo();
|
||||
}
|
||||
|
||||
bool redraw = false;
|
||||
|
@ -132,7 +132,8 @@ void manager::set_active(bool active)
|
||||
|
||||
if (active_)
|
||||
{
|
||||
possibly_clear_undo();
|
||||
if(should_clear_undo())
|
||||
clear_undo();
|
||||
validate_viewer_actions();
|
||||
LOG_WB << "Whiteboard activated! " << *viewer_actions() << "\n";
|
||||
create_temp_move();
|
||||
@ -815,13 +816,11 @@ void manager::validate_actions_if_needed()
|
||||
}
|
||||
}
|
||||
|
||||
void manager::possibly_clear_undo()
|
||||
void manager::clear_undo()
|
||||
{
|
||||
if(is_active())
|
||||
{
|
||||
resources::undo_stack->clear();
|
||||
resources::redo_stack->clear();
|
||||
}
|
||||
apply_shroud_changes(*resources::undo_stack, viewer_side());
|
||||
resources::undo_stack->clear();
|
||||
resources::redo_stack->clear();
|
||||
}
|
||||
|
||||
scoped_planned_unit_map::scoped_planned_unit_map():
|
||||
|
@ -150,12 +150,12 @@ public:
|
||||
/// Is referenced by the top bar gold display
|
||||
int get_spent_gold_for(int side);
|
||||
|
||||
/**
|
||||
* Clears the undo_stack and redo_stack if the whiteboard is on.
|
||||
* @todo Add other conditions where it won't get cleared, such as preferences option
|
||||
* and when player has no network allies.
|
||||
*/
|
||||
void possibly_clear_undo();
|
||||
/// Determines whether or not the undo_stack should be cleared.
|
||||
///@todo Only when there are networked allies and we have set a preferences option
|
||||
bool should_clear_undo() const {return true;}
|
||||
bool active_and_should_clear_undo() const {return manager::active_ && should_clear_undo();}
|
||||
/// Updates shroud and clears the undo_stack and redo_stack.
|
||||
void clear_undo();
|
||||
|
||||
private:
|
||||
void validate_actions_if_needed();
|
||||
|
@ -176,7 +176,8 @@ bool side_actions::execute(side_actions::iterator position)
|
||||
throw;
|
||||
}
|
||||
|
||||
resources::whiteboard->possibly_clear_undo();
|
||||
if(resources::whiteboard->should_clear_undo())
|
||||
resources::whiteboard->clear_undo();
|
||||
|
||||
if(exec_result!=action::FAIL)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user