Пример #1
0
editor_action* editor_action_unit_replace::perform(map_context& mc) const
{
	std::auto_ptr<editor_action> undo(new editor_action_unit_replace(new_loc_, loc_));

	perform_without_undo(mc);
	return undo.release();
}
Пример #2
0
editor_action_paste* editor_action_shuffle_area::perform(map_context& mc) const
{
	map_fragment mf(mc.get_map(), area_);
	std::unique_ptr<editor_action_paste> undo(new editor_action_paste(mf));
	perform_without_undo(mc);
	return undo.release();
}
Пример #3
0
editor_action_paste* editor_action_paste::perform(map_context& mc) const
{
	map_fragment mf(mc.map(), paste_.get_offset_area(offset_));
	std::unique_ptr<editor_action_paste> undo(new editor_action_paste(mf));

	perform_without_undo(mc);
	return undo.release();
}
Пример #4
0
editor_action* editor_action_select::perform(map_context& mc) const
{
	std::set<map_location> undo_locs;
	for (const map_location& loc : area_) {
		undo_locs.insert(loc);
		mc.add_changed_location(loc);
	}
	perform_without_undo(mc);
	return new editor_action_select(undo_locs);
}
Пример #5
0
editor_action* editor_action_unit_delete::perform(map_context& mc) const
{
	unit_map& units = mc.get_units();
	unit_map::const_unit_iterator unit_it = units.find(loc_);

	std::auto_ptr<editor_action> undo;
	if (unit_it != units.end()) {
		undo.reset(new editor_action_unit(loc_, *unit_it));
		perform_without_undo(mc);
		return undo.release();
	}
	return NULL;
}
Пример #6
0
editor_action* editor_action_label_delete::perform(map_context& mc) const
{
	std::auto_ptr<editor_action> undo;

	const terrain_label* deleted = mc.get_labels().get_label(loc_);

	if (!deleted) return NULL;

	undo.reset(new editor_action_label(loc_, deleted->text(), deleted->team_name()
			, deleted->color(), deleted->visible_in_fog(), deleted->visible_in_shroud(), deleted->immutable()));

	perform_without_undo(mc);
	return undo.release();
}
Пример #7
0
editor_action* editor_action_village_delete::perform(map_context& mc) const
{
	std::unique_ptr<editor_action> undo;

	const std::vector<team>& teams = mc.get_teams();
	for(std::vector<team>::const_iterator i = teams.begin(); i != teams.end(); ++i) {
		if (i->owns_village(loc_)) {
			perform_without_undo(mc);
			undo.reset(new editor_action_village(loc_, i->side() -1));
		}
	}

	return undo.release();
}
Пример #8
0
editor_action* editor_action_label::perform(map_context& mc) const
{
	std::auto_ptr<editor_action> undo;

	const terrain_label *old_label = mc.get_labels().get_label(loc_);
	if (old_label) {
		undo.reset(new editor_action_label(loc_, old_label->text(), old_label->team_name(), old_label->color()
				, old_label->visible_in_fog(), old_label->visible_in_shroud(), old_label->immutable()) );
	} else {
		undo.reset(new editor_action_label_delete(loc_));
	}

	perform_without_undo(mc);
	return undo.release();
}
Пример #9
0
editor_action* editor_action_village::perform(map_context& mc) const
{
	std::unique_ptr<editor_action> undo;

	if(!mc.get_map().is_village(loc_)) return nullptr;
	std::vector<team>& teams = mc.get_teams();
	team *t = unsigned(side_number_) < teams.size() ? &teams[side_number_] : nullptr;
	if (t && t->owns_village(loc_))	return nullptr;

	undo.reset(new editor_action_village_delete(loc_));

	for(std::vector<team>::iterator i = teams.begin(); i != teams.end(); ++i) {
		if (i->owns_village(loc_))
			undo.reset(new editor_action_village(loc_, i->side() -1));
	}

	perform_without_undo(mc);
	return undo.release();
}
Пример #10
0
editor_action_select_inverse* editor_action_select_inverse::perform(map_context& mc) const
{
	perform_without_undo(mc);
	return new editor_action_select_inverse();
}
Пример #11
0
editor_action* editor_action_unit_facing::perform(map_context& mc) const
{
	std::auto_ptr<editor_action> undo(new editor_action_unit_facing(loc_, old_direction_, new_direction_));
	perform_without_undo(mc);
	return undo.release();
}
Пример #12
0
editor_action* editor_action_unit::perform(map_context& mc) const
{
	std::unique_ptr<editor_action> undo(new editor_action_unit_delete(loc_));
	perform_without_undo(mc);
	return undo.release();
}
Пример #13
0
editor_action* editor_action::perform(map_context& mc) const
{
	std::unique_ptr<editor_action> undo(new editor_action_whole_map(mc.get_map()));
	perform_without_undo(mc);
	return undo.release();
}