Merged 'group' ->'origin'
This commit is contained in:
commit
2cd50d86ce
1 changed files with 220 additions and 32 deletions
|
@ -360,6 +360,17 @@ local SETTINGS_LIST_HEADER_WIDGET_SIZE = {1194, 80}
|
||||||
local SETTINGS_LIST_REGULAR_WIDGET_SIZE = {1194, 50}
|
local SETTINGS_LIST_REGULAR_WIDGET_SIZE = {1194, 50}
|
||||||
|
|
||||||
|
|
||||||
|
local function create_show_widget_condition(widget_definition)
|
||||||
|
local show_widget_condition = nil
|
||||||
|
if widget_definition.show_widget_condition then
|
||||||
|
show_widget_condition = {}
|
||||||
|
for _, i in ipairs(widget_definition.show_widget_condition) do
|
||||||
|
show_widget_condition[i] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return show_widget_condition
|
||||||
|
end
|
||||||
|
|
||||||
-- ██╗ ██╗███████╗ █████╗ ██████╗ ███████╗██████╗
|
-- ██╗ ██╗███████╗ █████╗ ██████╗ ███████╗██████╗
|
||||||
-- ██║ ██║██╔════╝██╔══██╗██╔══██╗██╔════╝██╔══██╗
|
-- ██║ ██║██╔════╝██╔══██╗██╔══██╗██╔════╝██╔══██╗
|
||||||
-- ███████║█████╗ ███████║██║ ██║█████╗ ██████╔╝
|
-- ███████║█████╗ ███████║██║ ██║█████╗ ██████╔╝
|
||||||
|
@ -772,13 +783,7 @@ local function create_checkbox_widget(widget_definition, scenegraph_id)
|
||||||
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
||||||
local offset_y = -widget_size[2]
|
local offset_y = -widget_size[2]
|
||||||
|
|
||||||
local show_widget_condition = nil
|
local show_widget_condition = create_show_widget_condition(widget_definition)
|
||||||
if widget_definition.show_widget_condition then
|
|
||||||
show_widget_condition = {}
|
|
||||||
for _, i in ipairs(widget_definition.show_widget_condition) do
|
|
||||||
show_widget_condition[i] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local definition = {
|
local definition = {
|
||||||
element = {
|
element = {
|
||||||
|
@ -1030,6 +1035,185 @@ local function create_checkbox_widget(widget_definition, scenegraph_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function create_group_widget(widget_definition, scenegraph_id)
|
||||||
|
|
||||||
|
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
||||||
|
local offset_y = -widget_size[2]
|
||||||
|
|
||||||
|
local show_widget_condition = create_show_widget_condition(widget_definition)
|
||||||
|
|
||||||
|
local definition = {
|
||||||
|
element = {
|
||||||
|
passes = {
|
||||||
|
-- VISUALS
|
||||||
|
{
|
||||||
|
pass_type = "texture",
|
||||||
|
|
||||||
|
style_id = "background",
|
||||||
|
texture_id = "background_texture",
|
||||||
|
|
||||||
|
content_check_function = function (content)
|
||||||
|
return content.is_widget_collapsed
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass_type = "texture",
|
||||||
|
|
||||||
|
style_id = "highlight_texture",
|
||||||
|
texture_id = "highlight_texture",
|
||||||
|
content_check_function = function (content)
|
||||||
|
return content.highlight_hotspot.is_hover and content.callback_is_cursor_inside_settings_list()
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass_type = "text",
|
||||||
|
|
||||||
|
style_id = "text",
|
||||||
|
text_id = "text"
|
||||||
|
},
|
||||||
|
-- HOTSPOTS
|
||||||
|
{
|
||||||
|
pass_type = "hotspot",
|
||||||
|
|
||||||
|
content_id = "highlight_hotspot"
|
||||||
|
},
|
||||||
|
-- PROCESSING
|
||||||
|
{
|
||||||
|
pass_type = "local_offset",
|
||||||
|
|
||||||
|
offset_function = function (ui_scenegraph, style, content, ui_renderer)
|
||||||
|
|
||||||
|
local is_interactable = content.highlight_hotspot.is_hover and content.callback_is_cursor_inside_settings_list()
|
||||||
|
|
||||||
|
if is_interactable then
|
||||||
|
|
||||||
|
if content.tooltip_text then
|
||||||
|
style.tooltip_text.cursor_offset = content.callback_fit_tooltip_to_the_screen(content, style.tooltip_text, ui_renderer)
|
||||||
|
end
|
||||||
|
|
||||||
|
if content.highlight_hotspot.on_release then
|
||||||
|
content.callback_hide_sub_widgets(content)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
},
|
||||||
|
-- TOOLTIP
|
||||||
|
{
|
||||||
|
pass_type = "tooltip_text",
|
||||||
|
|
||||||
|
text_id = "tooltip_text",
|
||||||
|
style_id = "tooltip_text",
|
||||||
|
content_check_function = function (content)
|
||||||
|
return content.tooltip_text and content.highlight_hotspot.is_hover and content.callback_is_cursor_inside_settings_list()
|
||||||
|
end
|
||||||
|
},
|
||||||
|
-- DEBUG
|
||||||
|
{
|
||||||
|
pass_type = "rect",
|
||||||
|
|
||||||
|
content_check_function = function (content)
|
||||||
|
return DEBUG_WIDGETS
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass_type = "border",
|
||||||
|
|
||||||
|
content_check_function = function (content, style)
|
||||||
|
if DEBUG_WIDGETS then
|
||||||
|
style.thickness = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
return DEBUG_WIDGETS
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass_type = "rect",
|
||||||
|
|
||||||
|
style_id = "debug_middle_line",
|
||||||
|
content_check_function = function (content)
|
||||||
|
return DEBUG_WIDGETS
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
content = {
|
||||||
|
is_widget_visible = true,
|
||||||
|
is_widget_collapsed = widget_definition.is_widget_collapsed,
|
||||||
|
|
||||||
|
highlight_texture = "playerlist_hover",
|
||||||
|
background_texture = "common_widgets_background_lit",
|
||||||
|
|
||||||
|
highlight_hotspot = {},
|
||||||
|
|
||||||
|
text = widget_definition.text,
|
||||||
|
tooltip_text = widget_definition.tooltip,
|
||||||
|
|
||||||
|
mod_name = widget_definition.mod_name,
|
||||||
|
widget_type = widget_definition.widget_type,
|
||||||
|
parent_widget_number = widget_definition.parent_widget_number,
|
||||||
|
show_widget_condition = show_widget_condition
|
||||||
|
},
|
||||||
|
style = {
|
||||||
|
|
||||||
|
-- VISUALS
|
||||||
|
background = {
|
||||||
|
size = {widget_size[1], widget_size[2] - 3},
|
||||||
|
offset = {0, offset_y + 1, 0}
|
||||||
|
},
|
||||||
|
|
||||||
|
highlight_texture = {
|
||||||
|
size = {widget_size[1], widget_size[2] - 3},
|
||||||
|
offset = {0, offset_y + 1, 1},
|
||||||
|
masked = true
|
||||||
|
},
|
||||||
|
|
||||||
|
text = {
|
||||||
|
offset = {60 + widget_definition.widget_level * 40, offset_y + 5, 2},
|
||||||
|
font_size = 28,
|
||||||
|
font_type = "hell_shark_masked",
|
||||||
|
dynamic_font = true,
|
||||||
|
text_color = Colors.get_color_table_with_alpha("white", 255)
|
||||||
|
},
|
||||||
|
|
||||||
|
-- HOTSPOTS
|
||||||
|
|
||||||
|
-- TOOLTIP
|
||||||
|
|
||||||
|
tooltip_text = {
|
||||||
|
font_type = "hell_shark",
|
||||||
|
font_size = 18,
|
||||||
|
horizontal_alignment = "left",
|
||||||
|
vertical_alignment = "top",
|
||||||
|
cursor_side = "right",
|
||||||
|
max_width = 600,
|
||||||
|
cursor_offset = {27, 27},
|
||||||
|
cursor_offset_bottom = {27, 27},
|
||||||
|
cursor_offset_top = {27, -27},
|
||||||
|
line_colors = {
|
||||||
|
Colors.get_color_table_with_alpha("cheeseburger", 255),
|
||||||
|
Colors.get_color_table_with_alpha("white", 255)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- DEBUG
|
||||||
|
|
||||||
|
debug_middle_line = {
|
||||||
|
size = {widget_size[1], 2},
|
||||||
|
offset = {0, (offset_y + widget_size[2]/2) - 1, 10},
|
||||||
|
color = {200, 0, 255, 0}
|
||||||
|
},
|
||||||
|
|
||||||
|
offset = {0, offset_y, 0},
|
||||||
|
size = {widget_size[1], widget_size[2]},
|
||||||
|
color = {50, 255, 255, 255}
|
||||||
|
},
|
||||||
|
scenegraph_id = scenegraph_id,
|
||||||
|
offset = {0, 0, 0}
|
||||||
|
}
|
||||||
|
|
||||||
|
return UIWidget.init(definition)
|
||||||
|
end
|
||||||
|
|
||||||
-- ██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗███╗ ██╗
|
-- ██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗███╗ ██╗
|
||||||
-- ██╔══██╗██╔══██╗██╔═══██╗██╔══██╗██╔══██╗██╔═══██╗██║ ██║████╗ ██║
|
-- ██╔══██╗██╔══██╗██╔═══██╗██╔══██╗██╔══██╗██╔═══██╗██║ ██║████╗ ██║
|
||||||
-- ██║ ██║██████╔╝██║ ██║██████╔╝██║ ██║██║ ██║██║ █╗ ██║██╔██╗ ██║
|
-- ██║ ██║██████╔╝██║ ██║██████╔╝██║ ██║██║ ██║██║ █╗ ██║██╔██╗ ██║
|
||||||
|
@ -1139,13 +1323,7 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra
|
||||||
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
||||||
local offset_y = -widget_size[2]
|
local offset_y = -widget_size[2]
|
||||||
|
|
||||||
local show_widget_condition = nil
|
local show_widget_condition = create_show_widget_condition(widget_definition)
|
||||||
if widget_definition.show_widget_condition then
|
|
||||||
show_widget_condition = {}
|
|
||||||
for _, i in ipairs(widget_definition.show_widget_condition) do
|
|
||||||
show_widget_condition[i] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local options_texts = {}
|
local options_texts = {}
|
||||||
local options_values = {}
|
local options_values = {}
|
||||||
|
@ -1628,13 +1806,7 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap
|
||||||
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
||||||
local offset_y = -widget_size[2]
|
local offset_y = -widget_size[2]
|
||||||
|
|
||||||
local show_widget_condition = nil
|
local show_widget_condition = create_show_widget_condition(widget_definition)
|
||||||
if widget_definition.show_widget_condition then
|
|
||||||
show_widget_condition = {}
|
|
||||||
for _, i in ipairs(widget_definition.show_widget_condition) do
|
|
||||||
show_widget_condition[i] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local definition = {
|
local definition = {
|
||||||
element = {
|
element = {
|
||||||
|
@ -1927,13 +2099,7 @@ local function create_keybind_widget(widget_definition, scenegraph_id)
|
||||||
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
||||||
local offset_y = -widget_size[2]
|
local offset_y = -widget_size[2]
|
||||||
|
|
||||||
local show_widget_condition = nil
|
local show_widget_condition = create_show_widget_condition(widget_definition)
|
||||||
if widget_definition.show_widget_condition then
|
|
||||||
show_widget_condition = {}
|
|
||||||
for _, i in ipairs(widget_definition.show_widget_condition) do
|
|
||||||
show_widget_condition[i] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local definition = {
|
local definition = {
|
||||||
element = {
|
element = {
|
||||||
|
@ -2297,6 +2463,8 @@ VMFOptionsView.initialize_settings_list_widgets = function (self)
|
||||||
widget = self:initialize_keybind_widget(definition, scenegraph_id_start)
|
widget = self:initialize_keybind_widget(definition, scenegraph_id_start)
|
||||||
elseif widget_type == "header" then
|
elseif widget_type == "header" then
|
||||||
widget = self:initialize_header_widget(definition, scenegraph_id_start)
|
widget = self:initialize_header_widget(definition, scenegraph_id_start)
|
||||||
|
elseif widget_type == "group" then
|
||||||
|
widget = self:initialize_group_widget(definition, scenegraph_id_start)
|
||||||
end
|
end
|
||||||
|
|
||||||
if widget then
|
if widget then
|
||||||
|
@ -2396,6 +2564,18 @@ VMFOptionsView.initialize_checkbox_widget = function (self, definition, scenegra
|
||||||
return widget
|
return widget
|
||||||
end
|
end
|
||||||
|
|
||||||
|
VMFOptionsView.initialize_group_widget = function (self, definition, scenegraph_id)
|
||||||
|
|
||||||
|
local widget = create_group_widget(definition, scenegraph_id)
|
||||||
|
local content = widget.content
|
||||||
|
|
||||||
|
--content.callback_setting_changed = callback(self, "callback_setting_changed")
|
||||||
|
content.callback_hide_sub_widgets = callback(self, "callback_hide_sub_widgets")
|
||||||
|
content.callback_fit_tooltip_to_the_screen = callback(self, "callback_fit_tooltip_to_the_screen")
|
||||||
|
content.callback_is_cursor_inside_settings_list = callback(self, "callback_is_cursor_inside_settings_list")
|
||||||
|
|
||||||
|
return widget
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
VMFOptionsView.initialize_dropdown_widget = function (self, definition, scenegraph_id, scenegraph_2nd_layer_id)
|
VMFOptionsView.initialize_dropdown_widget = function (self, definition, scenegraph_id, scenegraph_2nd_layer_id)
|
||||||
|
@ -3324,19 +3504,23 @@ VMFOptionsView.update_settings_list_widgets_visibility = function (self, mod_nam
|
||||||
|
|
||||||
if widget.content.parent_widget_number then
|
if widget.content.parent_widget_number then
|
||||||
local parent_widget = mod_widgets[widget.content.parent_widget_number]
|
local parent_widget = mod_widgets[widget.content.parent_widget_number]
|
||||||
|
local widget_type = parent_widget.content.widget_type
|
||||||
|
|
||||||
-- if 'header' or 'checkbox'
|
-- if 'header' or 'checkbox'
|
||||||
if parent_widget.style.checkbox or parent_widget.style.checkbox_border then --@TODO:
|
if widget_type == "header" or widget_type == "checkbox" then
|
||||||
|
|
||||||
widget.content.is_widget_visible = parent_widget.content.is_checkbox_checked and parent_widget.content.is_widget_visible and not parent_widget.content.is_widget_collapsed
|
widget.content.is_widget_visible = parent_widget.content.is_checkbox_checked and parent_widget.content.is_widget_visible and not parent_widget.content.is_widget_collapsed
|
||||||
|
|
||||||
-- if 'dropdown'
|
-- if 'dropdown'
|
||||||
else
|
elseif widget_type == "dropdown" then
|
||||||
if widget.content.show_widget_condition then
|
if widget.content.show_widget_condition then
|
||||||
widget.content.is_widget_visible = widget.content.show_widget_condition[parent_widget.content.current_option_number] and parent_widget.content.is_widget_visible and not parent_widget.content.is_widget_collapsed
|
widget.content.is_widget_visible = widget.content.show_widget_condition[parent_widget.content.current_option_number] and parent_widget.content.is_widget_visible and not parent_widget.content.is_widget_collapsed
|
||||||
else
|
else
|
||||||
get_mod(widget.content.mod_name):echo("ERROR: the dropdown widget in the options menu has sub_widgets, but some of its sub_widgets doesn't have 'show_widget_condition' (" .. widget.content.setting_name .. ")" , true)
|
get_mod(widget.content.mod_name):echo("ERROR: the dropdown widget in the options menu has sub_widgets, but some of its sub_widgets doesn't have 'show_widget_condition' (" .. widget.content.setting_name .. ")" , true)
|
||||||
end
|
end
|
||||||
|
-- if 'group'
|
||||||
|
else
|
||||||
|
widget.content.is_widget_visible = parent_widget.content.is_widget_visible and not parent_widget.content.is_widget_collapsed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3825,8 +4009,12 @@ VMFMod.create_options = function (self, widgets_definition, is_mod_toggable, rea
|
||||||
table.insert(mod_settings_list_widgets_definitions, new_widget_definition)
|
table.insert(mod_settings_list_widgets_definitions, new_widget_definition)
|
||||||
end
|
end
|
||||||
|
|
||||||
if current_widget and (current_widget.widget_type == "header" or current_widget.widget_type == "checkbox"
|
if current_widget and (
|
||||||
or current_widget.widget_type == "dropdown") and current_widget.sub_widgets then
|
current_widget.widget_type == "header" or
|
||||||
|
current_widget.widget_type == "group" or
|
||||||
|
current_widget.widget_type == "checkbox" or
|
||||||
|
current_widget.widget_type == "dropdown"
|
||||||
|
) and current_widget.sub_widgets then
|
||||||
|
|
||||||
-- going down to the first subwidget
|
-- going down to the first subwidget
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue