15 #define GETTEXT_DOMAIN "wesnoth-editor" 40 static std::string
type =
"image";
46 static std::string
type =
"mask";
52 static std::string
type =
"sound";
60 , current_tod_(current_time)
61 , color_field_r_(register_integer("tod_red", true))
62 , color_field_g_(register_integer("tod_green", true))
63 , color_field_b_(register_integer("tod_blue", true))
73 static std::map<std::string, tod_attribute_getter> metadata_stuff {
79 window.
add_to_tab_order(find_widget<text_box>(&window,
"tod_name",
false,
true));
80 window.
add_to_tab_order(find_widget<text_box>(&window,
"tod_id",
false,
true));
82 for(
const auto& data : metadata_stuff) {
83 find_widget<text_box>(&window,
"path_" + data.first,
false).set_active(
false);
85 button& copy_w = find_widget<button>(&window,
"copy_" + data.first,
false);
92 copy_w.
set_tooltip(
_(
"Clipboard support not found, contact your packager"));
97 find_widget<button>(&window,
"browse_image",
false),
98 std::bind(&custom_tod::select_file<tod_getter_image>,
this,
"data/core/images/misc"));
101 find_widget<button>(&window,
"browse_mask",
false),
102 std::bind(&custom_tod::select_file<tod_getter_mask>,
this,
"data/core/images"));
105 find_widget<button>(&window,
"browse_sound",
false),
106 std::bind(&custom_tod::select_file<tod_getter_sound>,
this,
"data/core/sounds/ambient"));
109 find_widget<button>(&window,
"next_tod",
false),
113 find_widget<button>(&window,
"previous_tod",
false),
117 find_widget<button>(&window,
"new",
false),
121 find_widget<button>(&window,
"delete",
false),
125 find_widget<slider>(&window,
"lawful_bonus",
false),
143 template<custom_tod::
string_pair(*fptr)(const time_of_day&)>
164 if(data.first ==
"image") {
166 }
else if(data.first ==
"mask") {
168 }
else if(data.first ==
"sound") {
215 }
catch(
const std::out_of_range&) {
216 throw std::string(
"Attempted to fetch a non-existant ToD!");
234 assert(disp &&
"Display pointer is null!");
271 find_widget<text_box>(
get_window(),
"tod_name",
false).set_value(current_tod.
name);
272 find_widget<text_box>(
get_window(),
"tod_id",
false).set_value(current_tod.
id);
274 find_widget<text_box>(
get_window(),
"path_image",
false).set_value(current_tod.
image);
276 find_widget<text_box>(
get_window(),
"path_sound",
false).set_value(current_tod.
sounds);
278 find_widget<image>(
get_window(),
"current_tod_image",
false).set_image(current_tod.
image);
288 find_widget<label>(
get_window(),
"tod_number",
false).set_label(new_index_str);
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
std::pair< std::string, std::string > string_pair
The execute function.
static display * get_singleton()
Returns the display object if a display object exists.
std::string image_mask
The image that is to be laid over all images while this time of day lasts.
int current_tod_
Current ToD index.
std::vector< time_of_day > times_
Available time_of_days.
tod_color color
The color modifications that should be made to the game board to reflect the time of day...
bool available()
Whether wesnoth was compiled with support for a clipboard.
file_dialog & set_path(const std::string &value)
Sets the initial file selection.
file_dialog & set_ok_label(const std::string &value)
Sets the OK button label.
std::string sounds
List of "ambient" sounds associated with this time_of_day, Played at the beginning of turn...
int lawful_bonus
The % bonus lawful units receive.
std::string image
The image to be displayed in the game status.
window * get_window() const
Returns a pointer to the dialog's window.
static custom_tod::string_pair tod_getter_mask(const time_of_day &tod)
virtual void draw()
Draws invalidated items.
T get_widget_value(window &window)
Gets the value of the field.
Implements some helper classes to ease adding fields to a dialog and hide the synchronization needed...
static std::string _(const char *str)
void update_lawful_bonus()
bool show(const unsigned auto_close_time=0)
Shows the window.
static custom_tod::string_pair tod_getter_sound(const time_of_day &tod)
std::string path() const
Gets the current file selection.
std::string default_dir()
Object which defines a time of day with associated bonuses, image, sounds etc.
file_dialog & set_read_only(bool value)
Whether to provide user interface elements for manipulating existing objects.
void set_widget_value(window &window, CT value)
Sets the value of the field.
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification_function &signal)
Connects a signal handler for getting a notification upon modification.
void update_tod_display()
std::function< string_pair(const time_of_day &)> tod_attribute_getter
const time_of_day & get_selected_tod() const
This file contains the settings handling of the widget library.
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal_function &signal)
Connects a signal handler for a left mouse button click.
void update_tod(const time_of_day *tod_override=nullptr)
Applies r,g,b coloring to the map.
field_integer * color_field_g_
field_integer * color_field_b_
void update_selected_tod_info()
map_display and display: classes which take care of displaying the map and game-data on the screen...
static custom_tod::string_pair tod_getter_image(const time_of_day &tod)
void invalidate_all()
Function to invalidate all tiles.
styled_widget * get_widget()
field_integer * color_field_r_
void select_file(const std::string &default_dir)
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Declarations for File-IO.
void do_next_tod()
Callback for the next tod button.
This shows the dialog to modify tod schedules.
std::string base_name(const std::string &file, const bool remove_extension)
Returns the base filename of a file, with directory name stripped.
int get_retval() const
Returns the cached window exit code.
void undraw()
Undraws the window.
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
void copy_to_clipboard_callback(tod_attribute_getter getter)
Dialog was closed with the OK button.
void add_to_tab_order(widget *widget, int at=-1)
Add the widget to the tabbing order.
base class of top level items, the only item which needs to store the final canvases to draw on...
std::string directory_name(const std::string &file)
Returns the directory name of a file, with filename stripped.
void color_slider_callback()
file_dialog & set_title(const std::string &value)
Sets the current dialog title text.