Пример #1
0
void custom_tod::update_selected_tod_info(window& window)
{
	const time_of_day& current_tod = get_selected_tod();

	find_widget<text_box>(&window, "tod_name", false).set_value(current_tod.name);
	find_widget<text_box>(&window, "tod_id", false).set_value(current_tod.id);

	find_widget<text_box>(&window, "path_image", false).set_value(current_tod.image);
	find_widget<text_box>(&window, "path_mask", false).set_value(current_tod.image_mask);
	find_widget<text_box>(&window, "path_sound", false).set_value(current_tod.sounds);

	find_widget<image>(&window, "current_tod_image", false).set_image(current_tod.image);
	find_widget<image>(&window, "current_tod_mask", false).set_image(current_tod.image_mask);

	find_widget<slider>(&window, "lawful_bonus", false).set_value(current_tod.lawful_bonus);

	color_field_r_->set_widget_value(window, current_tod.color.r);
	color_field_g_->set_widget_value(window, current_tod.color.g);
	color_field_b_->set_widget_value(window, current_tod.color.b);

	const std::string new_index_str = formatter() << (current_tod_ + 1) << "/" << times_.size();
	find_widget<label>(&window, "tod_number", false).set_label(new_index_str);

	update_tod_display(window);
}
Пример #2
0
void custom_tod::update_tod_display(window& window)
{
	display* disp = display::get_singleton();
	assert(disp && "Display pointer is null!");

	// Prevent a floating slice of window appearing alone over the
	// theme UI sidebar after redrawing tiles and before we have a
	// chance to redraw the rest of this window.
	window.undraw();

	// NOTE: We only really want to re-render the gamemap tiles here.
	// Redrawing everything is a significantly more expensive task.
	// At this time, tiles are the only elements on which ToD tint is
	// meant to have a visible effect. This is very strongly tied to
	// the image caching mechanism.
	//
	// If this ceases to be the case in the future, you'll need to call
	// redraw_everything() instead.

	disp->update_tod(&get_selected_tod());

	// invalidate all tiles so they are redrawn with the new ToD tint next
	disp->invalidate_all();

	// redraw tiles
	disp->draw(false);

	// NOTE: revert to invalidate_layout if necessary to display the ToD mask image.
	window.set_is_dirty(true);
}
Пример #3
0
void custom_tod::select_file(window& window, const std::string& default_dir)
{
	const string_pair& data = (*fptr)(get_selected_tod());

	std::string fn = filesystem::base_name(data.second);
	std::string dn = filesystem::directory_name(fn);
	if(dn.empty()) {
		dn = default_dir;
	}

	gui2::dialogs::file_dialog dlg;

	dlg.set_title(_("Choose File"))
	   .set_ok_label(_("Select"))
	   .set_path(dn)
	   .set_read_only(true);

	if(dlg.show()) {
		dn = dlg.path();

		if(data.first == "image") {
			times_[current_tod_].image = dn;
		} else if(data.first == "mask") {
			times_[current_tod_].image_mask = dn;
		} else if(data.first == "sound") {
			times_[current_tod_].sounds = dn;
		}
	}

	update_selected_tod_info(window);
}
void teditor_settings::update_selected_tod_info(twindow& window)
{
	bool custom = custom_tod_toggle_->get_value();
	if (custom) {
		current_tod_label_->set_label(_("Custom setting"));
	} else {
		std::stringstream ss;
		ss << (current_tod_ + 1);
		ss << "/" << tods_.size();
		ss << ": " << get_selected_tod().name;
		current_tod_label_->set_label(ss.str());
		/**
		 * @todo Implement the showing of the ToD icon.
		 *
		 * Note at the moment the icon is a label widget, should become an
		 * image widget.
		 */
		//current_tod_image_->set_icon_name(get_selected_tod().image);
		custom_tod_red_->set_value(get_selected_tod().red);
		custom_tod_green_->set_value(get_selected_tod().green);
		custom_tod_blue_->set_value(get_selected_tod().blue);
		custom_tod_red_field_->set_cache_value(get_selected_tod().red);
		custom_tod_green_field_->set_cache_value(get_selected_tod().green);
		custom_tod_blue_field_->set_cache_value(get_selected_tod().blue);
	}
	custom_tod_red_->set_active(custom);
	custom_tod_green_->set_active(custom);
	custom_tod_blue_->set_active(custom);
	current_tod_label_->set_active(!custom);
	update_tod_display(window);
	window.invalidate_layout();
}
Пример #5
0
void custom_tod::update_selected_tod_info(window& window)
{
	current_tod_name_->set_value(get_selected_tod().name);
	current_tod_id_->set_value(get_selected_tod().id);
	current_tod_image_->set_image(get_selected_tod().image);
	current_tod_mask_->set_image(get_selected_tod().image_mask);
	current_tod_sound_->set_label(get_selected_tod().sounds);

	std::stringstream ss;
	ss << (current_tod_ + 1) << "/" << tods_.size();
	current_tod_number_->set_label(ss.str());

	lawful_bonus_field_->set_widget_value(window,
										  get_selected_tod().lawful_bonus);
	tod_red_field_->set_value(get_selected_tod().color.r);
	tod_green_field_->set_value(get_selected_tod().color.g);
	tod_blue_field_->set_value(get_selected_tod().color.b);

	update_tod_display(window);
}
Пример #6
0
void custom_tod::pre_show(window& window)
{
	assert(!tods_.empty());

	tod_red_field_
			= find_widget<slider>(&window, "tod_red", false, true);

	tod_green_field_
			= find_widget<slider>(&window, "tod_green", false, true);

	tod_blue_field_
			= find_widget<slider>(&window, "tod_blue", false, true);

	current_tod_name_
			= find_widget<text_box>(&window, "tod_name", false, true);

	current_tod_id_ = find_widget<text_box>(&window, "tod_id", false, true);

	current_tod_image_
			= find_widget<image>(&window, "current_tod_image", false, true);

	current_tod_mask_
			= find_widget<image>(&window, "current_tod_mask", false, true);

	current_tod_sound_
			= find_widget<label>(&window, "current_sound", false, true);

	current_tod_number_
			= find_widget<label>(&window, "tod_number", false, true);

	connect_signal_mouse_left_click(find_widget<button>(&window, "image_button", false),
			std::bind(&custom_tod::select_file,
					this,
					get_selected_tod().image,
					"data/core/images/misc",
					"image",
					std::ref(window)));

	connect_signal_mouse_left_click(find_widget<button>(&window, "mask_button", false),
			std::bind(&custom_tod::select_file,
					this,
					get_selected_tod().image_mask,
					"data/core/images",
					"mask",
					std::ref(window)));

	connect_signal_mouse_left_click(find_widget<button>(&window, "sound_button", false),
			std::bind(&custom_tod::select_file,
					this,
					get_selected_tod().sounds,
					"data/core/sounds/ambient",
					"sound",
					std::ref(window)));

	connect_signal_mouse_left_click(
			find_widget<button>(&window, "next_tod", false),
			std::bind(&custom_tod::do_next_tod, this, std::ref(window)));

	connect_signal_mouse_left_click(
			find_widget<button>(&window, "previous_tod", false),
			std::bind(&custom_tod::do_prev_tod, this, std::ref(window)));

	connect_signal_mouse_left_click(
			find_widget<button>(&window, "new", false),
			std::bind(&custom_tod::do_new_tod, this, std::ref(window)));

	connect_signal_mouse_left_click(
			find_widget<button>(&window, "delete", false),
			std::bind(&custom_tod::do_delete_tod, this, std::ref(window)));

	connect_signal_notify_modified(
			*(lawful_bonus_field_->get_widget()),
			std::bind(&custom_tod::update_lawful_bonus,
					this,
					std::ref(window)));

	connect_signal_notify_modified(
			*tod_red_field_,
			std::bind(&custom_tod::update_tod_display,
					this,
					std::ref(window)));

	connect_signal_notify_modified(
			*tod_green_field_,
			std::bind(&custom_tod::update_tod_display,
					this,
					std::ref(window)));

	connect_signal_notify_modified(
			*tod_blue_field_,
			std::bind(&custom_tod::update_tod_display,
					this,
					std::ref(window)));

	for(size_t i = 0; i < tods_.size(); ++i) {
		time_of_day& tod = tods_[i];
		const int r = tod_red_field_->get_value();
		const int g = tod_green_field_->get_value();
		const int b = tod_blue_field_->get_value();
		if(tod.color.r == r && tod.color.g == g && tod.color.b == b) {
			current_tod_ = i;
			update_selected_tod_info(window);
			return;
		}
	}

	update_selected_tod_info(window);
}
Пример #7
0
void custom_tod::copy_to_clipboard_callback(tod_attribute_getter getter)
{
	desktop::clipboard::copy_to_clipboard(getter(get_selected_tod()).second, false);
}