Esempio n. 1
0
editor_action* mouse_action_starting_position::up_left(editor_display& disp, int x, int y)
{
	if (!click_) return nullptr;
	click_ = false;
	map_location hex = disp.hex_clicked_on(x, y);
	if (!disp.map().on_board(hex)) {
		return nullptr;
	}
	auto player_starting_at_hex = disp.map().is_starting_position(hex);
	 
	if (has_ctrl_modifier()) {
		if (player_starting_at_hex) {
			location_palette_.add_item(*player_starting_at_hex);
		}
		return nullptr;
	}

	std::string new_player_at_hex = location_palette_.selected_item();
	editor_action* a = nullptr;

	if(!player_starting_at_hex || new_player_at_hex != *player_starting_at_hex) {
		// Set a starting position
		a = new editor_action_starting_position(hex, new_player_at_hex);
	}
	else {
		// Erase current starting position
		a = new editor_action_starting_position(map_location(), *player_starting_at_hex);
	}

	update_brush_highlights(disp, hex);

	return a;
}
Esempio n. 2
0
editor_action* mouse_action_paint::click_perform_right(
		editor_display& /*disp*/, const std::set<map_location>& hexes)
{
	if (has_ctrl_modifier()) return nullptr;
	return new editor_action_chain(new editor_action_paint_area(
			hexes, terrain_palette_.selected_bg_item(), has_shift_modifier()));
}
Esempio n. 3
0
editor_action* mouse_action_select::click_perform_left(
		editor_display& /*disp*/, const std::set<map_location>& hexes)
{
	if (has_ctrl_modifier())
		return new editor_action_chain(new editor_action_deselect(hexes));
	else
		return new editor_action_chain(new editor_action_select(hexes));
}
editor_action* mouse_action_paint::click_right(editor_display& disp, int x, int y)
{
	if (has_ctrl_modifier()) {
		map_location hex = disp.hex_clicked_on(x, y);
		terrain_right_ = disp.map().get_terrain(hex);
		return NULL;
	} else {
		return brush_drag_mouse_action::click_right(disp, x, y);
	}
}
Esempio n. 5
0
editor_action* mouse_action_paint::click_right(editor_display& disp, int x, int y)
{
	if (has_ctrl_modifier()) {
		map_location hex = disp.hex_clicked_on(x, y);
		terrain_palette_.select_bg_item(disp.map().get_terrain(hex));
		return nullptr;
	} else {
		return brush_drag_mouse_action::click_right(disp, x, y);
	}
}
editor_action* mouse_action_fill::click_left(editor_display& disp, int x, int y)
{
	map_location hex = disp.hex_clicked_on(x, y);
	if (has_ctrl_modifier()) {
		terrain_left_ = disp.map().get_terrain(hex);
		return NULL;
	} else {
		//TODO only take the base terrain into account when searching for contigious terrain when painting base only
		//or use a different key modifier for that
		editor_action_fill* a = new editor_action_fill(hex, terrain_left_, has_shift_modifier());
		return a;
	}
}
Esempio n. 7
0
editor_action* mouse_action_fill::click_right(editor_display& disp, int x, int y)
{
	map_location hex = disp.hex_clicked_on(x, y);
	if (has_ctrl_modifier()) {
		terrain_palette_.select_bg_item(disp.map().get_terrain(hex));
		return nullptr;
	} else {
		/** @todo only take the base terrain into account when searching for contiguous terrain when painting base only */
		//or use a different key modifier for that
		editor_action_fill* a = new editor_action_fill(hex, terrain_palette_.selected_bg_item(),
				has_shift_modifier());
		return a;
	}
}
editor_action* mouse_action_paint::click_perform_right(
		editor_display& /*disp*/, const std::set<map_location>& hexes)
{
	if (has_ctrl_modifier()) return NULL;
	return new editor_action_chain(new editor_action_paint_area(hexes, terrain_right_, has_shift_modifier()));
}