예제 #1
0
editor_action* mouse_action_select::key_event(
		editor_display& disp, const SDL_Event& event)
{
	editor_action* ret = mouse_action::key_event(disp, event);
	update_brush_highlights(disp, previous_move_hex_);
	return ret;
}
예제 #2
0
void mouse_action::move(editor_display& disp, const map_location& hex)
{
	if (hex != previous_move_hex_) {
		update_brush_highlights(disp, hex);
		previous_move_hex_ = hex;
	}
}
예제 #3
0
editor_action* mouse_action_starting_position::up_left(editor_display& disp, int x, int y)
{
	if (!click_) return NULL;
	click_ = false;
	map_location hex = disp.hex_clicked_on(x, y);
	if (!disp.map().on_board(hex)) {
		return NULL;
	}
	int player_starting_at_hex = disp.map().is_starting_position(hex) + 1;
	std::vector<std::string> players;
	players.push_back(_("(Player)^None"));
	for (int i = 1; i <= gamemap::MAX_PLAYERS; i++) {
		std::stringstream str;
		str << _("Player") << " " << i;
		players.push_back(str.str());
	}
	gui::dialog pmenu = gui::dialog(disp,
				       _("Choose player"),
				       _("Which player should start here? You can use alt and a number key to set the starting position for a player, and del to clear the starting position under the cursor. Pressing a number key by itself will scroll to that player's starting position."),
				       gui::OK_CANCEL);
	pmenu.set_menu(players);
	int res = pmenu.show();
	editor_action* a = NULL;
	if (res == 0 && player_starting_at_hex != -1) {
		a = new editor_action_starting_position(map_location(), player_starting_at_hex);
	} else if (res > 0 && res != player_starting_at_hex) {
		a = new editor_action_starting_position(hex, res);
	}
	update_brush_highlights(disp, hex);
	return a;
}
예제 #4
0
editor_action* mouse_action_map_label::up_left(editor_display& disp, int x, int y)
{
	if (!click_) return NULL;
	click_ = false;

	const map_location hex = disp.hex_clicked_on(x, y);
	if (!disp.get_map().on_board(hex)) {
		return NULL;
	}

	const terrain_label* old_label = editor::get_current_labels()->get_label(hex);
	std::string label     = old_label ? old_label->text()              : "";
	std::string team_name = old_label ? old_label->team_name()         : "";
	std::string category  = old_label ? old_label->category()          : "";
	bool visible_shroud   = old_label ? old_label->visible_in_shroud() : false;
	bool visible_fog      = old_label ? old_label->visible_in_fog()    : true;
	bool immutable        = old_label ? old_label->immutable()         : true;
	SDL_Color color       = old_label ? old_label->color()             : font::NORMAL_COLOR;

	gui2::teditor_edit_label d(label, immutable, visible_fog, visible_shroud, color, category);

	editor_action* a = NULL;
	if(d.show(disp.video())) {
		a = new editor_action_label(hex, label, team_name, color
				, visible_fog, visible_shroud, immutable, category);
		update_brush_highlights(disp, hex);
	}
	return a;
}
예제 #5
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;
}
void mouse_action_unit::move(editor_display& disp, const map_location& hex)
{
	if (hex != previous_move_hex_) {

		update_brush_highlights(disp, hex);

		std::set<map_location> adjacent_set;
		map_location adjacent[6];
		get_adjacent_tiles(previous_move_hex_, adjacent);

		for (int i = 0; i < 6; i++)
			adjacent_set.insert(adjacent[i]);

		disp.invalidate(adjacent_set);
		previous_move_hex_ = hex;

		const unit_map& units = disp.get_units();
		const unit_map::const_unit_iterator unit_it = units.find(hex);
		if (unit_it != units.end()) {

			disp.set_mouseover_hex_overlay(NULL);

			SDL_Rect rect;
			rect.x = disp.get_location_x(hex);
			rect.y = disp.get_location_y(hex);
			rect.h = disp.hex_size();
			rect.w = disp.hex_size();
			std::stringstream str;
			str << N_("Identifier: ") << unit_it->id()     << "\n"
				<< N_("Name: ")    << unit_it->name()      << "\n"
				<< N_("Type: ")    << unit_it->type_name() << "\n"
				<< N_("Level: ")   << unit_it->level()     << "\n"
				<< N_("Cost: ")    << unit_it->cost()      << "\n"
				<< N_("Recruit: ") << utils::join(unit_it->recruits()) << "\n";
			tooltips::clear_tooltips();
			tooltips::add_tooltip(rect, str.str());
		}
		else {
			set_mouse_overlay(disp);
		}
	}
}
예제 #7
0
void mouse_action_item::move(editor_display& disp, const map_location& hex)
{
	if (hex != previous_move_hex_) {

		update_brush_highlights(disp, hex);

		std::set<map_location> adjacent_set;
		map_location adjacent[6];
		get_adjacent_tiles(previous_move_hex_, adjacent);

		for (int i = 0; i < 6; i++)
			adjacent_set.insert(adjacent[i]);

		disp.invalidate(adjacent_set);
		previous_move_hex_ = hex;

	//	const item_map& items = disp.get_items();
	//	const item_map::const_item_iterator item_it = items.find(hex);
//		if (item_it != items.end()) {
//
//			disp.set_mouseover_hex_overlay(nullptr);
//
//			SDL_Rect rect;
//			rect.x = disp.get_location_x(hex);
//			rect.y = disp.get_location_y(hex);
//			rect.h = disp.hex_size();
//			rect.w = disp.hex_size();
//			std::stringstream str;
//			str << N_("ID: ")   << item_it->id()   << "\n"
//				<< N_("Name: ") << item_it->name() << "\n"
//				<< N_("Type: ") << item_it->type_name();
//			tooltips::clear_tooltips();
//			tooltips::add_tooltip(rect, str.str());
//		}
//		else {
//			set_mouse_overlay(disp);
//		}
	}
}
예제 #8
0
editor_action* mouse_action_starting_position::up_left(editor_display& disp, int x, int y)
{
	if (!click_) return NULL;
	click_ = false;
	map_location hex = disp.hex_clicked_on(x, y);
	if (!disp.map().on_board(hex)) {
		return NULL;
	}

	const unsigned player_starting_at_hex =
		static_cast<unsigned>(disp.map().is_starting_position(hex) + 1); // 1st player = 1

	std::vector<map_location> starting_positions;

	for(int i = 1; i <= gamemap::MAX_PLAYERS; ++i) {
		starting_positions.push_back(disp.map().starting_position(i));
	}

	gui2::teditor_set_starting_position dlg(
		player_starting_at_hex, gamemap::MAX_PLAYERS, starting_positions);
	dlg.show(disp.video());

	unsigned new_player_at_hex = dlg.result(); // 1st player = 1
	editor_action* a = NULL;

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

	update_brush_highlights(disp, hex);

	return a;
}