editor config and add description to mod menu

This commit is contained in:
Dan Reeves 2023-01-11 00:57:15 +00:00
parent eca671c7f7
commit 8d8872c61c
3 changed files with 46 additions and 4 deletions

7
.editorconfig Normal file
View file

@ -0,0 +1,7 @@
root = true
[*.lua]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2

View file

@ -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 -- Before starting widgets data initialization, clear this table. It's used to detect if 2 widgets
-- defined the same setting_id. -- defined the same setting_id.
_defined_mod_settings = {} _defined_mod_settings = {}
-- Initialize widgets' data. -- Initialize widgets' data.
for _, widget_data in ipairs(_unfolded_raw_widgets_data) do for _, widget_data in ipairs(_unfolded_raw_widgets_data) do
local initialized_widget_data = initialize_widget_data(mod, widget_data, localize, collapsed_widgets) local initialized_widget_data = initialize_widget_data(mod, widget_data, localize, collapsed_widgets)

View file

@ -35,6 +35,23 @@ local create_header_template = function (self, params)
end end
_type_template_map["header"] = create_header_template _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 ##### -- ###### Percent Slider #####
@ -328,7 +345,7 @@ local function create_option_template(self, widget_data, category_name, index_of
template.custom = true template.custom = true
template.category = category_name template.category = category_name
template.after = template.after and template.after + index_offset or nil template.after = template.after and template.after + index_offset or nil
return template return template
end end
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 category = create_mod_category(self, categories, mod_data[1])
local index_offset = 0 local index_offset = 0
-- Create the category header -- Create the category header
local template = create_option_template(self, mod_data[1], category.display_name, index_offset) local template = create_option_template(self, mod_data[1], category.display_name, index_offset)
if template then if template then
settings[#settings + 1] = template settings[#settings + 1] = template
end 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 -- Create a top-level toggle option if the mod is togglable
if mod_data[1].is_togglable then if mod_data[1].is_togglable then
local toggle_widget_data = { local toggle_widget_data = {
@ -383,7 +418,7 @@ dmf.create_mod_options_settings = function (self, options_templates)
template.custom = true template.custom = true
template.category = category.display_name template.category = category.display_name
template.after = template.after + index_offset template.after = template.after + index_offset
settings[#settings + 1] = template settings[#settings + 1] = template
end end
end end