Change scroll speed to scroll amount and 1.0.45 options view changes (#29)

* Change scroll speed to scroll amount

* Include 1.0.45 options view changes
This commit is contained in:
Aussiemon 2023-04-04 13:57:48 -06:00 committed by GitHub
parent b13ef309af
commit 1a5b806f90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 19 deletions

View file

@ -16,7 +16,7 @@ dmf_mod_data.options = {
setting_id = "dmf_options_scrolling_speed", setting_id = "dmf_options_scrolling_speed",
type = "numeric", type = "numeric",
default_value = 100, default_value = 100,
range = {1, 1000}, range = {50, 500},
unit_text = "percent" unit_text = "percent"
}, },
{ {

View file

@ -7,13 +7,13 @@ local _widgets_by_name
-- #################################################################################################################### -- ####################################################################################################################
local function load_scrolling_speed_setting() local function load_scrolling_speed_setting()
local dmf_scroll_speed = dmf:get("dmf_options_scrolling_speed") if _widgets_by_name then
if dmf_scroll_speed and _widgets_by_name then local dmf_scroll_speed = math.clamp((dmf:get("dmf_options_scrolling_speed") or 100) / 1000, 0.05, 0.5)
if _widgets_by_name["scrollbar"] then if _widgets_by_name["scrollbar"] then
_widgets_by_name["scrollbar"].content.scroll_speed = dmf_scroll_speed / 10 _widgets_by_name["scrollbar"].content.scroll_amount = dmf_scroll_speed
end end
if _widgets_by_name["settings_scrollbar"] then if _widgets_by_name["settings_scrollbar"] then
_widgets_by_name["settings_scrollbar"].content.scroll_speed = dmf_scroll_speed / 10 _widgets_by_name["settings_scrollbar"].content.scroll_amount = dmf_scroll_speed
end end
end end
end end
@ -844,19 +844,24 @@ end
DMFOptionsView._set_tooltip_data = function (self, widget) DMFOptionsView._set_tooltip_data = function (self, widget)
local current_widget = self._tooltip_data and self._tooltip_data.widget local current_widget = self._tooltip_data and self._tooltip_data.widget
local display_text = nil local localized_text = nil
local tooltip_text = widget.content.entry.tooltip_text local tooltip_text = widget.content.entry.tooltip_text
local disabled_by_list = widget.content.entry.disabled_by local disabled_by_list = widget.content.entry.disabled_by
if tooltip_text then if tooltip_text then
display_text = tooltip_text if type(tooltip_text) == "function" then
localized_text = tooltip_text()
else
-- Should already be localized in mod option generation
localized_text = tooltip_text
end
end end
if disabled_by_list then if disabled_by_list then
display_text = display_text and string.format("%s\n", display_text) localized_text = localized_text and string.format("%s\n", localized_text)
for _, text in pairs(disabled_by_list) do for _, text in pairs(disabled_by_list) do
display_text = display_text and string.format("%s\n%s", display_text, text) or text localized_text = localized_text and string.format("%s\n%s", localized_text, text) or text
end end
end end
@ -868,14 +873,14 @@ DMFOptionsView._set_tooltip_data = function (self, widget)
if current_widget ~= widget or current_widget == widget and new_y ~= current_y then if current_widget ~= widget or current_widget == widget and new_y ~= current_y then
self._tooltip_data = { self._tooltip_data = {
widget = widget, widget = widget,
text = display_text text = localized_text
} }
self._widgets_by_name.tooltip.content.text = display_text self._widgets_by_name.tooltip.content.text = localized_text
local text_style = self._widgets_by_name.tooltip.style.text local text_style = self._widgets_by_name.tooltip.style.text
local x_pos = starting_point[1] + widget.offset[1] local x_pos = starting_point[1] + widget.offset[1]
local width = widget.content.size[1] * 0.5 local width = widget.content.size[1] * 0.5
local text_options = UIFonts.get_font_options_by_style(text_style) local text_options = UIFonts.get_font_options_by_style(text_style)
local _, text_height = self:_text_size(display_text, text_style.font_type, text_style.font_size, { local _, text_height = self:_text_size(localized_text, text_style.font_type, text_style.font_size, {
width, width,
0 0
}, text_options) }, text_options)

View file

@ -628,6 +628,7 @@ blueprints.dropdown = {
local scroll_area_height = parent:settings_grid_length() local scroll_area_height = parent:settings_grid_length()
local dropdown_length = size[2] * (num_visible_options + 1) local dropdown_length = size[2] * (num_visible_options + 1)
local grow_downwards = true local grow_downwards = true
local always_keep_order = true
if scroll_area_height <= offset[2] - scroll_amount + dropdown_length then if scroll_area_height <= offset[2] - scroll_amount + dropdown_length then
grow_downwards = false grow_downwards = false
@ -652,13 +653,13 @@ blueprints.dropdown = {
if selected_index and focused then if selected_index and focused then
if input_service:get("navigate_up_continuous") then if input_service:get("navigate_up_continuous") then
if grow_downwards then if grow_downwards or not grow_downwards and always_keep_order then
new_selection_index = math.max(selected_index - 1, 1) new_selection_index = math.max(selected_index - 1, 1)
else else
new_selection_index = math.min(selected_index + 1, num_options) new_selection_index = math.min(selected_index + 1, num_options)
end end
elseif input_service:get("navigate_down_continuous") then elseif input_service:get("navigate_down_continuous") then
if grow_downwards then if grow_downwards or not grow_downwards and always_keep_order then
new_selection_index = math.min(selected_index + 1, num_options) new_selection_index = math.min(selected_index + 1, num_options)
else else
new_selection_index = math.max(selected_index - 1, 1) new_selection_index = math.max(selected_index - 1, 1)
@ -695,10 +696,10 @@ blueprints.dropdown = {
local using_scrollbar = num_visible_options < num_options local using_scrollbar = num_visible_options < num_options
for i = start_index, end_index do for i = start_index, end_index do
local actual_i = end_index - i + start_index local actual_i = i
if grow_downwards then if not grow_downwards and always_keep_order then
actual_i = i actual_i = end_index - i + start_index
end end
local option_text_id = "option_text_" .. option_index local option_text_id = "option_text_" .. option_index

View file

@ -25,6 +25,7 @@ local settings_mask_size = {
} }
local settings_grid_height = grid_height + mask_offset_y local settings_grid_height = grid_height + mask_offset_y
local settings_grid_scroll_amount = math.clamp((dmf:get("dmf_options_scrolling_speed") or 100) / 1000, 0.05, 0.5)
local tooltip_text_style = table.clone(UIFontSettings.body) local tooltip_text_style = table.clone(UIFontSettings.body)
tooltip_text_style.text_horizontal_alignment = "left" tooltip_text_style.text_horizontal_alignment = "left"
@ -387,7 +388,8 @@ local widget_definitions = {
visible = false visible = false
}), }),
scrollbar = UIWidget.create_definition(ScrollbarPassTemplates.default_scrollbar, "scrollbar", { scrollbar = UIWidget.create_definition(ScrollbarPassTemplates.default_scrollbar, "scrollbar", {
scroll_speed = (dmf:get("dmf_options_scrolling_speed") / 10) or 10 scroll_speed = 10,
scroll_amount = settings_grid_scroll_amount,
}), }),
grid_mask = UIWidget.create_definition({ grid_mask = UIWidget.create_definition({
{ {
@ -410,7 +412,8 @@ local widget_definitions = {
} }
}, "grid_interaction"), }, "grid_interaction"),
settings_scrollbar = UIWidget.create_definition(ScrollbarPassTemplates.default_scrollbar, "settings_scrollbar", { settings_scrollbar = UIWidget.create_definition(ScrollbarPassTemplates.default_scrollbar, "settings_scrollbar", {
scroll_speed = (dmf:get("dmf_options_scrolling_speed") / 10) or 10 scroll_speed = 10,
scroll_amount = settings_grid_scroll_amount,
}), }),
settings_grid_mask = UIWidget.create_definition({ settings_grid_mask = UIWidget.create_definition({
{ {