diff --git a/data/gui/window/custom_tod.cfg b/data/gui/window/custom_tod.cfg index 32c99b52441a..32512b336fe8 100644 --- a/data/gui/window/custom_tod.cfg +++ b/data/gui/window/custom_tod.cfg @@ -3,6 +3,110 @@ ### Definition of the custom tod window in the editor. ### +#define _GUI_DATA_PATH_ENTRY ID_STEM LABEL + [row] + grow_factor = 0 + + [column] + grow_factor = 0 + + border = "all" + border_size = 5 + horizontal_alignment = "left" + + [label] + definition = "default" + + label = {LABEL} + linked_group = "labels" + [/label] + + [/column] + + [column] + grow_factor = 1 + + border = "all" + border_size = 5 + horizontal_grow = true + + [text_box] + id = "path_" + {ID_STEM} + definition = "default" + [/text_box] + + [/column] + + [column] + grow_factor = 0 + + border = "all" + border_size = 5 + horizontal_grow = true + + [button] + id = "copy_" + {ID_STEM} + definition = "action_copy" + label = _ "filesystem^Copy" + tooltip = _ "Copy this path to clipboard" + [/button] + + [/column] + + [column] + grow_factor = 0 + + border = "all" + border_size = 5 + horizontal_grow = true + + [button] + id = "browse_" + {ID_STEM} + definition = "action_browse" + label = _ "filesystem^Browse" + tooltip = _ "Browse this location using a file manager" + [/button] + + [/column] + + [/row] +#enddef + +#define _GUI_COLOR_SLIDER _ID _LABEL + [row] + grow_factor = 0 + + [column] + grow_factor = 1 + border = "all" + border_size = 5 + horizontal_alignment = "left" + + [label] + definition = "default" + label = {_LABEL} + [/label] + [/column] + + [column] + grow_factor = 1 + border = "all" + border_size = 5 + horizontal_grow = true + + [slider] + id = {_ID} + definition = "default" + best_slider_length = 512 + minimum_value = -255 + maximum_value = 255 + step_size = 1 + [/slider] + [/column] + + [/row] +#enddef + [window] id = "custom_tod" description = "Custom ToD schedules dialog." @@ -27,177 +131,188 @@ fixed_width = true [/linked_group] - [linked_group] - id = "tod_index" - fixed_width = true - [/linked_group] - [grid] + [row] grow_factor = 0 + [column] grow_factor = 1 border = "all" border_size = 5 horizontal_alignment = "left" + [label] definition = "title" - label = _ "Custom Time Schedule" + label = _ "Edit Time Schedule" [/label] [/column] + [/row] [row] grow_factor = 0 + [column] horizontal_grow = true + [grid] - [row] - [column] - border = "all" - border_size = 5 - horizontal_alignment = "left" - [label] - definition = "default" - linked_group = "labels" - label = _ "Name:" - [/label] - [/column] - [column] - grow_factor = 1 - border = "all" - border_size = 5 - horizontal_alignment = "left" - [text_box] - id = "tod_name" - definition = "default" - [/text_box] - [/column] + [row] [column] - border = "all" - border_size = 5 - horizontal_alignment = "right" - [image] - id = "current_tod_image" - definition = "default" - [/image] - [/column] - [/row] + horizontal_grow = true - [row] - [column] - border = "all" - border_size = 5 - horizontal_alignment = "left" - [label] - definition = "default" - linked_group = "labels" - label = _ "ID:" - [/label] - [/column] + [grid] - [column] - grow_factor = 1 - border = "all" - border_size = 5 - horizontal_alignment = "left" - [text_box] - id = "tod_id" - definition = "default" - [/text_box] - [/column] + [row] - [column] - border = "all" - border_size = 5 - horizontal_alignment = "right" - [image] - id = "current_tod_mask" - definition = "default" - [/image] - [/column] - [/row] + [column] + border = "all" + border_size = 5 + horizontal_alignment = "left" - [row] - [column] - border = "all" - border_size = 5 - horizontal_alignment = "left" - [label] - definition = "default" - linked_group = "labels" - label = _ "Metadata:" - [/label] - [/column] + [label] + definition = "default" + label = _ "Name:" + linked_group = "labels" + [/label] + [/column] - [column] - horizontal_alignment = "left" - [grid] - [row] [column] + grow_factor = 1 border = "all" border_size = 5 horizontal_alignment = "left" - [button] - id = "image_button" + + [text_box] + id = "tod_name" definition = "default" - label = _ "Image" - [/button] + [/text_box] [/column] + [/row] + + [row] [column] border = "all" border_size = 5 horizontal_alignment = "left" - [button] - id = "mask_button" + + [label] definition = "default" - label = _ "Mask" - [/button] + label = _ "ID:" + linked_group = "labels" + [/label] [/column] [column] + grow_factor = 1 border = "all" border_size = 5 horizontal_alignment = "left" - [button] - id = "sound_button" + + [text_box] + id = "tod_id" definition = "default" - label = _ "Sound" - [/button] + [/text_box] [/column] + [/row] + [/grid] + [/column] [column] - border = "all" - border_size = 5 - horizontal_alignment = "right" - [label] - id = "current_sound" - definition = "default" - [/label] + horizontal_grow = true + vertical_grow = true + + [grid] + + [row] + + [column] + border = "all" + border_size = 5 + horizontal_alignment = "right" + + [image] + id = "current_tod_image" + definition = "default" + [/image] + [/column] + + [/row] + + [row] + + [column] + border = "all" + border_size = 5 + horizontal_alignment = "right" + + [image] + id = "current_tod_mask" + definition = "default" + [/image] + [/column] + + [/row] + + [/grid] + [/column] + [/row] + + [/grid] + + [/column] + + [/row] + + {GUI_FILLER_ROW HEIGHT=20} + + [row] + grow_factor = 1 + + [column] + horizontal_grow = true + + [grid] + + {_GUI_DATA_PATH_ENTRY "image" ( _ "Image:")} + {_GUI_DATA_PATH_ENTRY "mask" ( _ "Mask:")} + {_GUI_DATA_PATH_ENTRY "sound" ( _ "Sound:")} + [/grid] + [/column] + [/row] + + {GUI_FILLER_ROW HEIGHT=20} + [row] + grow_factor = 1 + [column] + horizontal_grow = true + [grid] + [row] grow_factor = 0 + [column] grow_factor = 1 border = "all" border_size = 5 horizontal_alignment = "left" + [label] definition = "default" - linked_group = "labels" label = _ "Lawful Bonus:" [/label] [/column] @@ -207,6 +322,7 @@ border = "all" border_size = 5 horizontal_alignment = "left" + [slider] id = "lawful_bonus" definition = "default" @@ -215,116 +331,41 @@ maximum_value = 100 step_size = 5 [/slider] - [/column] - [/row] - [row] - [column] - grow_factor = 0 - border = "all" - border_size = 5 - horizontal_alignment = "left" - [label] - definition = "default" - linked_group = "labels" - label = _ "Red:" - [/label] [/column] - [column] - grow_factor = 1 - border = "all" - border_size = 5 - horizontal_alignment = "left" - [slider] - id = "tod_red" - definition = "default" - best_slider_length = 512 - minimum_value = -255 - maximum_value = 255 - step_size = 1 - [/slider] - [/column] [/row] - [row] - [column] - grow_factor = 0 - border = "all" - border_size = 5 - horizontal_alignment = "left" - [label] - definition = "default" - linked_group = "labels" - label = _ "Green:" - [/label] - [/column] - - [column] - grow_factor = 1 - border = "all" - border_size = 5 - horizontal_alignment = "left" - [slider] - id = "tod_green" - definition = "default" - best_slider_length = 512 - minimum_value = -255 - maximum_value = 255 - step_size = 1 - [/slider] - [/column] - [/row] - - [row] - [column] - grow_factor = 0 - border = "all" - border_size = 5 - horizontal_alignment = "left" - [label] - definition = "default" - linked_group = "labels" - label = _ "Blue:" - [/label] - [/column] + {_GUI_COLOR_SLIDER "tod_red" ( _ "Red:")} + {_GUI_COLOR_SLIDER "tod_green" ( _ "Green:")} + {_GUI_COLOR_SLIDER "tod_blue" ( _ "Blue:")} - [column] - grow_factor = 1 - border = "all" - border_size = 5 - horizontal_alignment = "left" - [slider] - id = "tod_blue" - definition = "default" - best_slider_length = 512 - minimum_value = -255 - maximum_value = 255 - step_size = 1 - [/slider] - [/column] - [/row] [/grid] + [/column] + [/row] [row] - grow_factor = 1 + grow_factor = 0 + [column] horizontal_grow = true + [grid] + [row] grow_factor = 1 + [column] grow_factor = 0 border = "all" border_size = 5 horizontal_alignment = "left" + [button] id = "previous_tod" definition = "left_arrow" - linked_group = "tod_index" - label = _ "Previous" [/button] [/column] @@ -333,10 +374,10 @@ border = "all" border_size = 5 horizontal_alignment = "left" + [label] id = "tod_number" definition = "default" - linked_group = "tod_index" [/label] [/column] @@ -345,11 +386,10 @@ border = "all" border_size = 5 horizontal_alignment = "left" + [button] id = "next_tod" definition = "right_arrow" - linked_group = "tod_index" - label = _ "Next" [/button] [/column] @@ -358,6 +398,7 @@ border = "all" border_size = 5 horizontal_alignment = "left" + [button] id = "new" definition = "add" @@ -370,6 +411,7 @@ border = "all" border_size = 5 horizontal_alignment = "left" + [button] id = "delete" definition = "delete" @@ -382,6 +424,7 @@ border = "all" border_size = 5 horizontal_alignment = "right" + [button] id = "ok" definition = "default" @@ -394,16 +437,27 @@ border = "all" border_size = 5 horizontal_alignment = "right" + [button] id = "cancel" definition = "default" label = _ "Cancel" [/button] [/column] + [/row] + [/grid] + [/column] + [/row] + [/grid] + [/resolution] + [/window] + +#undef _GUI_COLOR_SLIDER +#undef _GUI_DATA_PATH_ENTRY diff --git a/src/gui/dialogs/editor/custom_tod.cpp b/src/gui/dialogs/editor/custom_tod.cpp index b36a37229260..a7253e24d5b1 100644 --- a/src/gui/dialogs/editor/custom_tod.cpp +++ b/src/gui/dialogs/editor/custom_tod.cpp @@ -16,20 +16,20 @@ #include "gui/dialogs/editor/custom_tod.hpp" +#include "desktop/clipboard.hpp" +#include "display.hpp" #include "filesystem.hpp" -#include "editor/editor_preferences.hpp" -#include "editor/editor_display.hpp" +#include "formatter.hpp" +#include "gettext.hpp" #include "gui/auxiliary/field.hpp" #include "gui/dialogs/file_dialog.hpp" #include "gui/dialogs/helper.hpp" #include "gui/widgets/button.hpp" +#include "gui/widgets/image.hpp" #include "gui/widgets/label.hpp" -#include "gui/widgets/slider.hpp" #include "gui/widgets/settings.hpp" -#include "gui/widgets/toggle_button.hpp" -#include "gui/widgets/image.hpp" +#include "gui/widgets/slider.hpp" #include "gui/widgets/text_box.hpp" -#include "gettext.hpp" #include "image.hpp" #include "utils/functional.hpp" @@ -85,32 +85,111 @@ namespace dialogs * @end{table} */ +static custom_tod::string_pair tod_getter_image(const time_of_day& tod) +{ + static std::string type = "image"; + return {type, tod.image}; +} + +static custom_tod::string_pair tod_getter_mask(const time_of_day& tod) +{ + static std::string type = "mask"; + return {type, tod.image_mask}; +} + +static custom_tod::string_pair tod_getter_sound(const time_of_day& tod) +{ + static std::string type = "sound"; + return {type, tod.sounds}; +} + REGISTER_DIALOG(custom_tod) -custom_tod::custom_tod(display& display, - const std::vector& tods) - : tods_(tods) - , current_tod_(0) - , current_tod_name_(nullptr) - , current_tod_id_(nullptr) - , current_tod_image_(nullptr) - , current_tod_mask_(nullptr) - , current_tod_sound_(nullptr) - , current_tod_number_(nullptr) - , lawful_bonus_field_(register_integer("lawful_bonus", true)) - , tod_red_field_(nullptr) - , tod_green_field_(nullptr) - , tod_blue_field_(nullptr) - , display_(display) +custom_tod::custom_tod(const std::vector& times, int current_time) + : times_(times) + , current_tod_(current_time) + , color_field_r_(register_integer("tod_red", true)) + , color_field_g_(register_integer("tod_green", true)) + , color_field_b_(register_integer("tod_blue", true)) { + assert(!times_.empty()); +} + +void custom_tod::pre_show(window& window) +{ + static std::map metadata_stuff { + {"image", tod_getter_image}, + {"mask", tod_getter_mask }, + {"sound", tod_getter_sound} + }; + + for(const auto& data : metadata_stuff) { + find_widget(&window, "path_" + data.first, false).set_active(false); + + button& copy_w = find_widget