From 8d8872c61cfdc86ee91d8016dbf3d9903228aa63 Mon Sep 17 00:00:00 2001 From: Dan Reeves Date: Wed, 11 Jan 2023 00:57:15 +0000 Subject: [PATCH 1/2] editor config and add description to mod menu --- .editorconfig | 7 ++++ dmf/scripts/mods/dmf/modules/core/options.lua | 2 +- .../dmf/modules/ui/options/mod_options.lua | 41 +++++++++++++++++-- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1b922a7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*.lua] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 diff --git a/dmf/scripts/mods/dmf/modules/core/options.lua b/dmf/scripts/mods/dmf/modules/core/options.lua index 7ab3081..84369ea 100644 --- a/dmf/scripts/mods/dmf/modules/core/options.lua +++ b/dmf/scripts/mods/dmf/modules/core/options.lua @@ -518,7 +518,7 @@ local function initialize_mod_options_widgets_data(mod, widgets_data, localize) -- Before starting widgets data initialization, clear this table. It's used to detect if 2 widgets -- defined the same setting_id. _defined_mod_settings = {} - + -- Initialize widgets' data. for _, widget_data in ipairs(_unfolded_raw_widgets_data) do local initialized_widget_data = initialize_widget_data(mod, widget_data, localize, collapsed_widgets) diff --git a/dmf/scripts/mods/dmf/modules/ui/options/mod_options.lua b/dmf/scripts/mods/dmf/modules/ui/options/mod_options.lua index 887a932..917cb51 100644 --- a/dmf/scripts/mods/dmf/modules/ui/options/mod_options.lua +++ b/dmf/scripts/mods/dmf/modules/ui/options/mod_options.lua @@ -35,6 +35,23 @@ local create_header_template = function (self, params) end _type_template_map["header"] = create_header_template +-- ########################## +-- ###### Description ####### +-- ########################## + +-- Create description template +local create_description_template = function (self, params) + + local template = { + category = params.category, + group_name = params.mod_name, + display_name = params.description, + widget_type = "description", + after = params.after + } + return template +end +_type_template_map["description"] = create_description_template -- ########################### -- ###### Percent Slider ##### @@ -328,7 +345,7 @@ local function create_option_template(self, widget_data, category_name, index_of template.custom = true template.category = category_name template.after = template.after and template.after + index_offset or nil - + return template end end @@ -351,13 +368,31 @@ dmf.create_mod_options_settings = function (self, options_templates) local category = create_mod_category(self, categories, mod_data[1]) local index_offset = 0 - + -- Create the category header local template = create_option_template(self, mod_data[1], category.display_name, index_offset) if template then settings[#settings + 1] = template end + -- Create the mod description + if mod_data[1].tooltip then + local desc_widget_data = { + mod_name = mod_data[1].mod_name, + description = mod_data[1].tooltip, + category = category.display_name, + display_name = category.display_name, + after = #settings, + type = "description" + } + local desc_template = create_option_template(self, desc_widget_data, category.display_name, index_offset) + + if desc_template then + settings[#settings + 1] = desc_template + index_offset = index_offset + 1 + end + end + -- Create a top-level toggle option if the mod is togglable if mod_data[1].is_togglable then local toggle_widget_data = { @@ -383,7 +418,7 @@ dmf.create_mod_options_settings = function (self, options_templates) template.custom = true template.category = category.display_name template.after = template.after + index_offset - + settings[#settings + 1] = template end end From 5e0ea6fa158b7b0e8c8545af2c79d6acce2a96ce Mon Sep 17 00:00:00 2001 From: Dan Reeves Date: Wed, 11 Jan 2023 01:02:27 +0000 Subject: [PATCH 2/2] rename header tooltip to description --- dmf/scripts/mods/dmf/modules/core/options.lua | 2 +- dmf/scripts/mods/dmf/modules/ui/options/mod_options.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dmf/scripts/mods/dmf/modules/core/options.lua b/dmf/scripts/mods/dmf/modules/core/options.lua index 84369ea..58cc515 100644 --- a/dmf/scripts/mods/dmf/modules/core/options.lua +++ b/dmf/scripts/mods/dmf/modules/core/options.lua @@ -46,7 +46,7 @@ local function initialize_header_data(mod, data) new_data.index = data.index new_data.mod_name = mod:get_name() new_data.readable_mod_name = mod:get_readable_name() - new_data.tooltip = mod:get_description() + new_data.description = mod:get_description() new_data.is_togglable = mod:get_internal_data("is_togglable") and not mod:get_internal_data("is_mutator") new_data.is_collapsed = dmf:get("options_menu_collapsed_mods")[mod:get_name()] diff --git a/dmf/scripts/mods/dmf/modules/ui/options/mod_options.lua b/dmf/scripts/mods/dmf/modules/ui/options/mod_options.lua index 917cb51..9511fa0 100644 --- a/dmf/scripts/mods/dmf/modules/ui/options/mod_options.lua +++ b/dmf/scripts/mods/dmf/modules/ui/options/mod_options.lua @@ -376,10 +376,10 @@ dmf.create_mod_options_settings = function (self, options_templates) end -- Create the mod description - if mod_data[1].tooltip then + if mod_data[1].description then local desc_widget_data = { mod_name = mod_data[1].mod_name, - description = mod_data[1].tooltip, + description = mod_data[1].description, category = category.display_name, display_name = category.display_name, after = #settings,