From f7cfc27b2f2ddd10205507416fa642edc27539d2 Mon Sep 17 00:00:00 2001 From: Azumgi Date: Thu, 25 Jan 2018 00:12:27 +0300 Subject: [PATCH] added collapsing widgets feature to the options menu --- FEATURES_LIST.MD | 3 +- .../gui/common_widgets_background_lit.dds | Bin 0 -> 1152 bytes .../gui/common_widgets_background_lit.texture | 18 ++ vmf_source/gui/header_background_lit.dds | Bin 0 -> 1152 bytes vmf_source/gui/header_background_lit.png | Bin 18161 -> 0 bytes vmf_source/gui/header_background_lit.texture | 1 + .../common_widgets_background_lit.material | 14 ++ .../materials/header_background_lit.material | 2 +- vmf_source/resource_packages/vmf.package | 1 + .../mods/vmf/modules/testing_stuff_here.lua | 12 +- .../mods/vmf/modules/vmf_options_view.lua | 183 ++++++++++++++++-- 11 files changed, 215 insertions(+), 19 deletions(-) create mode 100644 vmf_source/gui/common_widgets_background_lit.dds create mode 100644 vmf_source/gui/common_widgets_background_lit.texture create mode 100644 vmf_source/gui/header_background_lit.dds delete mode 100644 vmf_source/gui/header_background_lit.png create mode 100644 vmf_source/materials/common_widgets_background_lit.material diff --git a/FEATURES_LIST.MD b/FEATURES_LIST.MD index 6b2f3d8..1d91584 100644 --- a/FEATURES_LIST.MD +++ b/FEATURES_LIST.MD @@ -136,12 +136,11 @@ With this event you won't need to repeatedly check if some option is changed. By -Localization Gui (WIP) Options menu (WIP) Keybindings (Will do) Network (Will do) Actions -Chat +Localization Game modes Debug modules \ No newline at end of file diff --git a/vmf_source/gui/common_widgets_background_lit.dds b/vmf_source/gui/common_widgets_background_lit.dds new file mode 100644 index 0000000000000000000000000000000000000000..59e16ea87775936da9f9f841c9547eef966c3191 GIT binary patch literal 1152 zcmZ>930A0KU|?Vu;9w8{(jd&h0wPEU3P3H6P;DSK1H*q9f^fiwgC*buzqs80Q9K$3 KqiJAdrU3xn*-2Lb literal 0 HcmV?d00001 diff --git a/vmf_source/gui/common_widgets_background_lit.texture b/vmf_source/gui/common_widgets_background_lit.texture new file mode 100644 index 0000000..7235865 --- /dev/null +++ b/vmf_source/gui/common_widgets_background_lit.texture @@ -0,0 +1,18 @@ +common = { + input = { + filename = "gui/common_widgets_background_lit" + } + output = { + apply_processing = true + correct_gamma = true + cut_alpha_threshold = 0.5 + enable_cut_alpha_threshold = false + format = "A8R8G8B8" + mipmap_filter = "kaiser" + mipmap_filter_wrap_mode = "mirror" + mipmap_keep_original = false + mipmap_num_largest_steps_to_discard = 0 + mipmap_num_smallest_steps_to_discard = 0 + srgb = true + } +} \ No newline at end of file diff --git a/vmf_source/gui/header_background_lit.dds b/vmf_source/gui/header_background_lit.dds new file mode 100644 index 0000000000000000000000000000000000000000..bcf1e0e2bfa597630e8f31c44f12f961edd2cf29 GIT binary patch literal 1152 zcmZ>930A0KU|?Vu;9w8{(jd&h0wPEU3P3H6P;DSK1H*q9f^fiwgC*dEx?kS^Q9K$3 KqiJAdrU3w0is)AW literal 0 HcmV?d00001 diff --git a/vmf_source/gui/header_background_lit.png b/vmf_source/gui/header_background_lit.png deleted file mode 100644 index ba1d59b3553072bedcf724ecaa4017eff34a92e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18161 zcmeI33piBkzsHxfk$XidX^%@KnVY#V(-@a=4GANpi@B^B6J~~)a%m@$=(3YkL~PYA zcNL|CLZT9)-3?_IlG=23YHL?G3x!rSXFvb*KhJs2d1gHiGr#xuet++JKkx7Tt+nQP z)~;16?Nt=#D*^zZ;^<)G4t=VR{wc^o|9>19VL%@g-$wAc&)imp5w zZPhA&fmk5&7YGrKG#Ww}BH-`>K>!GAP50o^J$mPu4?ccl?Gzt%&`IE~seo{|-V>#f zxY$T{hWd(l-D3|m-Ku8V+D_NLo*6H@Z(r12O*doZ-HH$7yL6B5i#ZX$`{suyTTTSr zD<6E;Fns<#wI_cdy|_ufQbGB!1I~>QrJQ5EaOUqZbv3n5x=@zUiUvaHyo=eoq9J`5 z;9VqzvP`d1{xTpFc1KA8sB}rI#4Ly#QF~#1WUWlp4w*`E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X{k8!NMAVy;1M d02mpO1)eROHtolsPi!2u9c@?I6k7Xj|4*-x$c+F1 diff --git a/vmf_source/gui/header_background_lit.texture b/vmf_source/gui/header_background_lit.texture index 2c9d5ba..2e18e40 100644 --- a/vmf_source/gui/header_background_lit.texture +++ b/vmf_source/gui/header_background_lit.texture @@ -13,5 +13,6 @@ common = { mipmap_keep_original = false mipmap_num_largest_steps_to_discard = 0 mipmap_num_smallest_steps_to_discard = 0 + srgb = true } } \ No newline at end of file diff --git a/vmf_source/materials/common_widgets_background_lit.material b/vmf_source/materials/common_widgets_background_lit.material new file mode 100644 index 0000000..de8a460 --- /dev/null +++ b/vmf_source/materials/common_widgets_background_lit.material @@ -0,0 +1,14 @@ +common_widgets_background_lit = { + material_contexts = { + surface_material = "" + } + + shader = "gui_gradient:DIFFUSE_MAP:MASKED" + + textures = { + diffuse_map = "gui/common_widgets_background_lit" + } + + variables = { + } +} diff --git a/vmf_source/materials/header_background_lit.material b/vmf_source/materials/header_background_lit.material index 4526cec..1ac89b9 100644 --- a/vmf_source/materials/header_background_lit.material +++ b/vmf_source/materials/header_background_lit.material @@ -3,7 +3,7 @@ header_background_lit = { surface_material = "" } - shader = "gui:DIFFUSE_MAP" + shader = "gui_gradient:DIFFUSE_MAP:MASKED" textures = { diffuse_map = "gui/header_background_lit" diff --git a/vmf_source/resource_packages/vmf.package b/vmf_source/resource_packages/vmf.package index 1ef73fa..d31e78b 100644 --- a/vmf_source/resource_packages/vmf.package +++ b/vmf_source/resource_packages/vmf.package @@ -9,6 +9,7 @@ package = [ material = [ "materials/header_background" "materials/header_background_lit" + "materials/common_widgets_background_lit" ] lua = [ diff --git a/vmf_source/scripts/mods/vmf/modules/testing_stuff_here.lua b/vmf_source/scripts/mods/vmf/modules/testing_stuff_here.lua index 9c93abf..94f7911 100644 --- a/vmf_source/scripts/mods/vmf/modules/testing_stuff_here.lua +++ b/vmf_source/scripts/mods/vmf/modules/testing_stuff_here.lua @@ -65,7 +65,17 @@ local options_widgets = { ["text"] = "Warn joining players about game mode", ["tooltip"] = "You don't want others to ruin your game," .. "\n" .. "do you?", - ["default_value"] = true -- Default first option is enabled. In this case Below + ["default_value"] = true, -- Default first option is enabled. In this case Below + ["sub_widgets"] = { + { + ["setting_name"] = "whatever", + ["widget_type"] = "checkbox", + ["text"] = "Whatever", + ["tooltip"] = "Whatever," .. "\n" .. + "whatever", + ["default_value"] = true -- Default first option is enabled. In this case Below + } + } } } }, diff --git a/vmf_source/scripts/mods/vmf/modules/vmf_options_view.lua b/vmf_source/scripts/mods/vmf/modules/vmf_options_view.lua index 0ae5e2e..ec72d03 100644 --- a/vmf_source/scripts/mods/vmf/modules/vmf_options_view.lua +++ b/vmf_source/scripts/mods/vmf/modules/vmf_options_view.lua @@ -1,15 +1,17 @@ --[[ Don't set settings to the values which aren't defined in options + Glitch I won't fix soon: widget is collapsed, setting were changed not from .. whatever VMFOptionsView.update_picked_option_for_settings_list_widgets ]] -local vmf = get_mod("VMF") -- @TODO: replace it with VMF later +local vmf = get_mod("VMF") inject_material("materials/header_background", "header_background", "ingame_ui") inject_material("materials/header_background_lit", "header_background_lit", "ingame_ui") +inject_material("materials/common_widgets_background_lit", "common_widgets_background_lit", "ingame_ui") --███████╗ ██████╗███████╗███╗ ██╗███████╗ ██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗ --██╔════╝██╔════╝██╔════╝████╗ ██║██╔════╝██╔════╝ ██╔══██╗██╔══██╗██╔══██╗██║ ██║██╔════╝ @@ -329,8 +331,16 @@ local function create_header_widget(widget_definition, scenegraph_id, offset_y) offset_function = function (ui_scenegraph, ui_style, ui_content, ui_renderer) + if ui_content.highlight_hotspot.on_release and not ui_content.checkbox_hotspot.on_release then + ui_content.callback_hide_sub_widgets(ui_content) + end + if ui_content.checkbox_hotspot.on_release then + if ui_content.is_widget_collapsed then + ui_content.callback_hide_sub_widgets(ui_content) + end + local mod_name = ui_content.mod_name local is_mod_suspended = ui_content.is_checkbox_checked @@ -339,6 +349,7 @@ local function create_header_widget(widget_definition, scenegraph_id, offset_y) ui_content.callback_mod_suspend_state_changed(mod_name, is_mod_suspended) end + ui_content.background_texture = ui_content.is_widget_collapsed and "header_background_lit" or "header_background" ui_content.checkbox_texture = ui_content.is_checkbox_checked and "checkbox_checked" or "checkbox_unchecked" end }, @@ -368,6 +379,7 @@ local function create_header_widget(widget_definition, scenegraph_id, offset_y) is_checkbox_checked = true, is_checkbox_visible = false, is_widget_visible = true, -- for header it will always be 'true', but I need this variable anyways + is_widget_collapsed = widget_definition.is_widget_collapsed, checkbox_texture = "checkbox_unchecked", highlight_texture = "playerlist_hover", @@ -379,7 +391,6 @@ local function create_header_widget(widget_definition, scenegraph_id, offset_y) text = widget_definition.readable_mod_name, mod_name = widget_definition.mod_name, - setting_name = widget_definition.setting_name, widget_type = widget_definition.widget_type, }, style = { @@ -388,19 +399,18 @@ local function create_header_widget(widget_definition, scenegraph_id, offset_y) background = { size = {widget_size[1], widget_size[2] - 3}, - offset = {0, offset_y + 1, 1}, - masked = true + offset = {0, offset_y + 1, 1} }, highlight_texture = { size = {widget_size[1], widget_size[2] - 3}, - offset = {0, offset_y + 1, 1}, + offset = {0, offset_y + 1, 2}, color = {255, 255, 255, 255}, masked = true }, text = { - offset = {60, offset_y + 18, 2}, + offset = {60, offset_y + 18, 3}, font_size = 28, font_type = "hell_shark_masked", dynamic_font = true, @@ -409,7 +419,7 @@ local function create_header_widget(widget_definition, scenegraph_id, offset_y) checkbox = { size = {30, 30}, - offset = {widget_size[1] - 180, offset_y + 25, 2}, + offset = {widget_size[1] - 180, offset_y + 25, 3}, masked = true }, @@ -466,6 +476,16 @@ local function create_checkbox_widget(widget_definition, scenegraph_id, offset_y { 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) @@ -502,7 +522,16 @@ local function create_checkbox_widget(widget_definition, scenegraph_id, offset_y offset_function = function (ui_scenegraph, ui_style, ui_content, ui_renderer) + if ui_content.highlight_hotspot.on_release and not ui_content.checkbox_hotspot.on_release then + ui_content.callback_hide_sub_widgets(ui_content) + end + if ui_content.checkbox_hotspot.on_release then + + if ui_content.is_widget_collapsed then + ui_content.callback_hide_sub_widgets(ui_content) + end + local mod_name = ui_content.mod_name local setting_name = ui_content.setting_name local old_value = ui_content.is_checkbox_checked @@ -548,9 +577,11 @@ local function create_checkbox_widget(widget_definition, scenegraph_id, offset_y content = { is_checkbox_checked = false, is_widget_visible = true, + is_widget_collapsed = widget_definition.is_widget_collapsed, - checkbox_texture = "checkbox_unchecked", -- texture name - highlight_texture = "playerlist_hover", -- texture name + checkbox_texture = "checkbox_unchecked", + highlight_texture = "playerlist_hover", + background_texture = "common_widgets_background_lit", checkbox_hotspot = {}, highlight_hotspot = {}, @@ -567,15 +598,19 @@ local function create_checkbox_widget(widget_definition, scenegraph_id, offset_y 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, 0}, + offset = {0, offset_y + 1, 1}, masked = true }, text = { - offset = {60 + widget_definition.widget_level * 40, offset_y + 5, 0}, + offset = {60 + widget_definition.widget_level * 40, offset_y + 5, 2}, font_size = 28, font_type = "hell_shark_masked", dynamic_font = true, @@ -663,6 +698,16 @@ local function create_stepper_widget(widget_definition, scenegraph_id, offset_y, { 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) @@ -716,10 +761,17 @@ local function create_stepper_widget(widget_definition, scenegraph_id, offset_y, pass_type = "local_offset", offset_function = function (ui_scenegraph, ui_style, ui_content, ui_renderer) - ui_content.left_arrow_texture = ui_content.left_arrow_hotspot.is_hover and "settings_arrow_clicked" or "settings_arrow_normal" - ui_content.right_arrow_texture = ui_content.right_arrow_hotspot.is_hover and "settings_arrow_clicked" or "settings_arrow_normal" + + if ui_content.highlight_hotspot.on_release and not ui_content.left_arrow_hotspot.on_release and not ui_content.right_arrow_hotspot.on_release then + ui_content.callback_hide_sub_widgets(ui_content) + end if ui_content.left_arrow_hotspot.on_release or ui_content.right_arrow_hotspot.on_release then + + if ui_content.is_widget_collapsed then + ui_content.callback_hide_sub_widgets(ui_content) + end + local mod_name = ui_content.mod_name local setting_name = ui_content.setting_name local old_value = ui_content.options_values[ui_content.current_option_number] @@ -737,6 +789,9 @@ local function create_stepper_widget(widget_definition, scenegraph_id, offset_y, local new_value = ui_content.options_values[new_option_number] ui_content.callback_setting_changed(mod_name, setting_name, old_value, new_value) end + + ui_content.left_arrow_texture = ui_content.left_arrow_hotspot.is_hover and "settings_arrow_clicked" or "settings_arrow_normal" + ui_content.right_arrow_texture = ui_content.right_arrow_hotspot.is_hover and "settings_arrow_clicked" or "settings_arrow_normal" end }, -- DEBUG @@ -770,10 +825,12 @@ local function create_stepper_widget(widget_definition, scenegraph_id, offset_y, }, content = { is_widget_visible = true, + is_widget_collapsed = widget_definition.is_widget_collapsed, highlight_texture = "playerlist_hover", -- texture name left_arrow_texture = "settings_arrow_normal", right_arrow_texture = "settings_arrow_normal", + background_texture = "common_widgets_background_lit", highlight_hotspot = {}, left_arrow_hotspot = {}, @@ -798,6 +855,11 @@ local function create_stepper_widget(widget_definition, scenegraph_id, offset_y, -- 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, 0}, @@ -1061,6 +1123,7 @@ VMFOptionsView.build_header_widget = function (self, definition, scenegraph_id, content.is_checkbox_visible = definition.is_mod_toggable content.callback_mod_suspend_state_changed = callback(self, "callback_mod_suspend_state_changed") + content.callback_hide_sub_widgets = callback(self, "callback_hide_sub_widgets") return widget end @@ -1071,6 +1134,7 @@ VMFOptionsView.build_stepper_widget = function (self, 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") return widget end @@ -1081,6 +1145,7 @@ VMFOptionsView.build_checkbox_widget = function (self, 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") return widget end @@ -1125,6 +1190,78 @@ VMFOptionsView.rearrange_settings_list = function (self) end +VMFOptionsView.callback_hide_sub_widgets = function (self, widget_content) + + local mod_name = widget_content.mod_name + local setting_name = widget_content.setting_name + local is_widget_collapsed = widget_content.is_widget_collapsed + + local widget_number = not setting_name and 1 -- if (setting_name == nil) -> it's header -> #1 + + local are_there_visible_sub_widgets = false + + if not is_widget_collapsed then + + for _, mod_widgets in ipairs(self.settings_list_widgets) do + + if mod_widgets[1].content.mod_name == mod_name then + + for i, widget in ipairs(mod_widgets) do + + if widget_number then + if widget.content.parent_widget_number == widget_number then + --vmf:echo(tostring(i)) + are_there_visible_sub_widgets = are_there_visible_sub_widgets or widget.content.is_widget_visible + end + else + if widget.content.setting_name == setting_name then + widget_number = i + end + end + end + end + end + end + + widget_content.is_widget_collapsed = not is_widget_collapsed and are_there_visible_sub_widgets + + + setting_name = setting_name or mod_name -- header + + local all_collapsed_widgets = vmf:get("options_menu_collapsed_widgets") + all_collapsed_widgets = all_collapsed_widgets or {} + + local mod_collapsed_widgets = all_collapsed_widgets[mod_name] + + if widget_content.is_widget_collapsed then + + mod_collapsed_widgets = mod_collapsed_widgets or {} + mod_collapsed_widgets[setting_name] = true + + all_collapsed_widgets[mod_name] = mod_collapsed_widgets + else + if mod_collapsed_widgets then + mod_collapsed_widgets[setting_name] = nil + + local is_collapsed_widgets_list_empty = true + + for _, _ in pairs(mod_collapsed_widgets) do + is_collapsed_widgets_list_empty = false + end + + if is_collapsed_widgets_list_empty then + all_collapsed_widgets[mod_name] = nil + end + end + end + + vmf:set("options_menu_collapsed_widgets", all_collapsed_widgets) + + --vmf:echo(tostring(are_there_visible_sub_widgets)) + + self:update_settings_list_widgets_visibility(mod_name) + self:rearrange_settings_list() +end VMFOptionsView.callback_setting_changed = function (self, mod_name, setting_name, old_value, new_value) --vmf:echo("CHANGED: " .. mod_name .. " " .. setting_name .. " " .. tostring(old_value) .. " " .. tostring(new_value)) @@ -1235,6 +1372,7 @@ VMFOptionsView.update_picked_option_for_settings_list_widgets = function (self) end end + VMFOptionsView.update_settings_list_widgets_visibility = function (self, mod_name) --table.dump(self.settings_list_widgets, "WIDGETSSSSSSSS", 3) @@ -1251,12 +1389,12 @@ VMFOptionsView.update_settings_list_widgets_visibility = function (self, mod_nam -- if 'header' or 'checkbox' if parent_widget.style.checkbox then - widget.content.is_widget_visible = parent_widget.content.is_checkbox_checked and parent_widget.content.is_widget_visible + 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 'stepper' else 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 + 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 get_mod(widget.content.mod_name):echo("ERROR: the stepper widget in the options menu has sub_widgets, but some of its sub_widgets doesn't have 'show_widget_condition'", true) end @@ -1516,6 +1654,12 @@ VMFMod.create_options = function (self, widgets_definition, is_mod_toggable, rea local new_widget_definition = nil local new_widget_index = nil + local options_menu_collapsed_widgets = vmf:get("options_menu_collapsed_widgets") + local mod_collapsed_widgets = nil + if options_menu_collapsed_widgets then + mod_collapsed_widgets = options_menu_collapsed_widgets[self._name] + end + -- defining header widget new_widget_index = 1 @@ -1530,6 +1674,11 @@ VMFMod.create_options = function (self, widgets_definition, is_mod_toggable, rea new_widget_definition.default = true new_widget_definition.is_mod_toggable = is_mod_toggable + if mod_collapsed_widgets then + new_widget_definition.is_widget_collapsed = mod_collapsed_widgets[self._name] + end + + -- @TODO: wtf? local mod_suspend_state_list = vmf:get("mod_suspend_state_list") mod_suspend_state_list = (type(mod_suspend_state_list) == "table") and mod_suspend_state_list or {} if type(mod_suspend_state_list[self._name]) == "nil" then @@ -1572,6 +1721,10 @@ VMFMod.create_options = function (self, widgets_definition, is_mod_toggable, rea new_widget_definition.show_widget_condition = current_widget.show_widget_condition new_widget_definition.parent_widget_number = parent_number + if mod_collapsed_widgets then + new_widget_definition.is_widget_collapsed = mod_collapsed_widgets[current_widget.setting_name] + end + check_widget_definition(self, new_widget_definition) if type(self:get(current_widget.setting_name)) == "nil" then