16 #define GETTEXT_DOMAIN "wesnoth-editor"
41 static std::string
type =
"image";
47 static std::string
type =
"mask";
53 static std::string
type =
"sound";
62 , current_tod_(current_time)
63 , color_field_r_(register_integer("tod_red", true))
64 , color_field_g_(register_integer("tod_green", true))
65 , color_field_b_(register_integer("tod_blue", true))
75 static std::map<std::string, tod_attribute_getter> metadata_stuff {
84 for(
const auto&
data : metadata_stuff) {
85 find_widget<text_box>(&
window,
"path_" +
data.first,
false).set_active(
false);
94 copy_w.
set_tooltip(
_(
"Clipboard support not found, contact your packager"));
99 find_widget<button>(&
window,
"browse_image",
false),
100 std::bind(&custom_tod::select_file<tod_getter_image>,
this,
"data/core/images/misc"));
103 find_widget<button>(&
window,
"browse_mask",
false),
104 std::bind(&custom_tod::select_file<tod_getter_mask>,
this,
"data/core/images"));
107 find_widget<button>(&
window,
"browse_sound",
false),
108 std::bind(&custom_tod::select_file<tod_getter_sound>,
this,
"data/core/sounds/ambient"));
111 find_widget<button>(&
window,
"next_tod",
false),
115 find_widget<button>(&
window,
"previous_tod",
false),
119 find_widget<button>(&
window,
"new",
false),
123 find_widget<button>(&
window,
"delete",
false),
127 find_widget<slider>(&
window,
"lawful_bonus",
false),
145 template<custom_tod::
string_pair(*fptr)(const time_of_day&)>
166 if(
data.first ==
"image") {
168 }
else if(
data.first ==
"mask") {
170 }
else if(
data.first ==
"sound") {
217 }
catch(
const std::out_of_range&) {
218 throw std::string(
"Attempted to fetch a non-existant ToD!");
236 assert(disp &&
"Display pointer is null!");
254 find_widget<text_box>(
get_window(),
"tod_name",
false).set_value(current_tod.
name);
255 find_widget<text_box>(
get_window(),
"tod_id",
false).set_value(current_tod.
id);
257 find_widget<text_box>(
get_window(),
"path_image",
false).set_value(current_tod.
image);
259 find_widget<text_box>(
get_window(),
"path_sound",
false).set_value(current_tod.
sounds);
261 find_widget<image>(
get_window(),
"current_tod_image",
false).set_image(current_tod.
image);
271 find_widget<label>(
get_window(),
"tod_number",
false).set_label(new_index_str);
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
void update_tod(const time_of_day *tod_override=nullptr)
Applies r,g,b coloring to the map.
static display * get_singleton()
Returns the display object if a display object exists.
This shows the dialog to modify tod schedules.
std::pair< std::string, std::string > string_pair
The execute function.
field_integer * color_field_g_
std::function< string_pair(const time_of_day &)> tod_attribute_getter
void select_file(const std::string &default_dir)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
void update_lawful_bonus()
std::vector< time_of_day > times_
Available time_of_days.
void copy_to_clipboard_callback(tod_attribute_getter getter)
const time_of_day & get_selected_tod() const
void update_selected_tod_info()
void do_next_tod()
Callback for the next tod button.
field_integer * color_field_b_
field_integer * color_field_r_
int current_tod_
Current ToD index.
void color_slider_callback()
void update_tod_display()
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
file_dialog & set_ok_label(const std::string &value)
Sets the OK button label.
file_dialog & set_path(const std::string &value)
Sets the initial file selection.
file_dialog & set_title(const std::string &value)
Sets the current dialog title text.
file_dialog & set_read_only(bool value)
Whether to provide user interface elements for manipulating existing objects.
std::string path() const
Gets the current file selection.
Abstract base class for all modal dialogs.
bool show(const unsigned auto_close_time=0)
Shows the window.
int get_retval() const
Returns the cached window exit code.
window * get_window()
Returns a pointer to the dialog's window.
styled_widget * get_widget()
void set_widget_value(CT value)
Sets the value of the field.
T get_widget_value()
Gets the value of the field.
base class of top level items, the only item which needs to store the final canvases to draw on.
void add_to_tab_order(widget *widget, int at=-1)
Add the widget to the tabbing order.
Implements some helper classes to ease adding fields to a dialog and hide the synchronization needed.
Declarations for File-IO.
static std::string _(const char *str)
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
bool available()
Whether wesnoth was compiled with support for a clipboard.
std::string base_name(const std::string &file, const bool remove_extension)
Returns the base filename of a file, with directory name stripped.
std::string directory_name(const std::string &file)
Returns the directory name of a file, with filename stripped.
static custom_tod::string_pair tod_getter_mask(const time_of_day &tod)
static custom_tod::string_pair tod_getter_image(const time_of_day &tod)
static custom_tod::string_pair tod_getter_sound(const time_of_day &tod)
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
@ OK
Dialog was closed with the OK button.
std::string default_dir()
This file contains the settings handling of the widget library.
Object which defines a time of day with associated bonuses, image, sounds etc.
tod_color color
The color modifications that should be made to the game board to reflect the time of day.
int lawful_bonus
The % bonus lawful units receive.
std::string image
The image to be displayed in the game status.
std::string sounds
List of "ambient" sounds associated with this time_of_day, Played at the beginning of turn.
std::string image_mask
The image that is to be laid over all images while this time of day lasts.