From df58743a63e28c84719ea5d51116b66377b67de4 Mon Sep 17 00:00:00 2001 From: Azumgi Date: Fri, 26 Jan 2018 00:37:33 +0300 Subject: [PATCH] Added functionality to move favorite mods up and down (options menu) --- vmf_source/gui/header_fav_arrow.dds | Bin 0 -> 9344 bytes vmf_source/gui/header_fav_arrow.texture | 18 +++ .../materials/header_fav_arrow.material | 14 +++ vmf_source/resource_packages/vmf.package | 1 + .../mods/vmf/modules/vmf_options_view.lua | 118 ++++++++++++++++-- 5 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 vmf_source/gui/header_fav_arrow.dds create mode 100644 vmf_source/gui/header_fav_arrow.texture create mode 100644 vmf_source/materials/header_fav_arrow.material diff --git a/vmf_source/gui/header_fav_arrow.dds b/vmf_source/gui/header_fav_arrow.dds new file mode 100644 index 0000000000000000000000000000000000000000..437ac744ec25282dd795724d8ab32e3af12d9f90 GIT binary patch literal 9344 zcmd5>X;f6_8D?ex0g+7*j5VSJMMT_K1X%`AKoC$gdXgSJS!-;X#payESeqD^gzU{R z(V8?pb&H@#6hW4mc@>R`X_GWP`PcsHqHSVbSq7I#pXZzT;4+Rqn5a0%$GP0O_kQp9 zJn#E{@AuwWvlhgz_VMu<6c*q!8Q+A@J^b&+Ke4za&wU$@eSEt0Ki3~&>g28X&xD5t z0I@&`z$yLS$7HVeF+W$Q$A)G5)PyQj{%#3=E2h!OGv>Jg5wt8 z1K{@81nvY4$UQxC z8n6r?_f3N*&XjRmPRQ8zPe??;a;?D@{PsAI4%`VEkUt~$FX8Vh_`M@;-62WZc1n`A zpOUffd?O~m00(}f1{(mz!JVLiH@|NTPRf1I>Lb zxGV+e_q)mcxOFX(QgcSqKRzqdfwbCllC=37u>=MiH5lkP@Z|otu)irRyYaCYkkZlG}Je@><$tCcxvYhIUEb^tG4= z1yO?kkZ)ump!yQt5q*IEIc1qFVPMK+Ilbohbne^V5 zVi_Dt4fX;9p@H^$Blpdb*8AY&C&g;(RGgQ5;*`=)yA*g_aHs?R)FIP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|ZT}y^Ze~pY literal 0 HcmV?d00001 diff --git a/vmf_source/gui/header_fav_arrow.texture b/vmf_source/gui/header_fav_arrow.texture new file mode 100644 index 0000000..8025595 --- /dev/null +++ b/vmf_source/gui/header_fav_arrow.texture @@ -0,0 +1,18 @@ +common = { + input = { + filename = "gui/header_fav_arrow" + } + 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/materials/header_fav_arrow.material b/vmf_source/materials/header_fav_arrow.material new file mode 100644 index 0000000..a9f6528 --- /dev/null +++ b/vmf_source/materials/header_fav_arrow.material @@ -0,0 +1,14 @@ +header_fav_arrow = { + material_contexts = { + surface_material = "" + } + + shader = "gui_gradient:DIFFUSE_MAP:MASKED" + + textures = { + diffuse_map = "gui/header_fav_arrow" + } + + variables = { + } +} diff --git a/vmf_source/resource_packages/vmf.package b/vmf_source/resource_packages/vmf.package index db0ef89..a482c25 100644 --- a/vmf_source/resource_packages/vmf.package +++ b/vmf_source/resource_packages/vmf.package @@ -12,6 +12,7 @@ material = [ "materials/common_widgets_background_lit" "materials/header_fav_icon" "materials/header_fav_icon_lit" + "materials/header_fav_arrow" ] lua = [ 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 66eff9d..26328de 100644 --- a/vmf_source/scripts/mods/vmf/modules/vmf_options_view.lua +++ b/vmf_source/scripts/mods/vmf/modules/vmf_options_view.lua @@ -14,6 +14,7 @@ inject_material("materials/header_background_lit", "header_background_lit", "ing inject_material("materials/common_widgets_background_lit", "common_widgets_background_lit", "ingame_ui") inject_material("materials/header_fav_icon", "header_fav_icon", "ingame_ui") inject_material("materials/header_fav_icon_lit", "header_fav_icon_lit", "ingame_ui") +inject_material("materials/header_fav_arrow", "header_fav_arrow", "ingame_ui") --███████╗ ██████╗███████╗███╗ ██╗███████╗ ██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗ --██╔════╝██╔════╝██╔════╝████╗ ██║██╔════╝██╔════╝ ██╔══██╗██╔══██╗██╔══██╗██║ ██║██╔════╝ @@ -305,6 +306,26 @@ local function create_header_widget(widget_definition, scenegraph_id) return content.is_favorited or content.highlight_hotspot.is_hover end }, + { + pass_type = "texture", + + style_id = "fav_arrow_up", + texture_id = "fav_arrow_texture", + + content_check_function = function (content) + return content.is_favorited and content.highlight_hotspot.is_hover + end + }, + { + pass_type = "rotated_texture", + + style_id = "fav_arrow_down", + texture_id = "fav_arrow_texture", + + content_check_function = function (content) + return content.is_favorited and content.highlight_hotspot.is_hover + end + }, { pass_type = "text", @@ -326,10 +347,26 @@ local function create_header_widget(widget_definition, scenegraph_id) pass_type = "hotspot", style_id = "fav_icon_hotspot", - content_id = "fav_icon_hotspot", + content_id = "fav_icon_hotspot" + }, + { + pass_type = "hotspot", + + style_id = "fav_arrow_up_hotspot", + content_id = "fav_arrow_up_hotspot", content_check_function = function (content) - return content.parent.is_checkbox_visible + return content.parent.is_favorited + end + }, + { + pass_type = "hotspot", + + style_id = "fav_arrow_down_hotspot", + content_id = "fav_arrow_down_hotspot", + + content_check_function = function (content) + return content.parent.is_favorited end }, { @@ -353,7 +390,9 @@ local function create_header_widget(widget_definition, scenegraph_id) 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 and not ui_content.fav_icon_hotspot.on_release then + if ui_content.highlight_hotspot.on_release and not ui_content.checkbox_hotspot.on_release and not ui_content.fav_icon_hotspot.on_release + and not ui_content.fav_arrow_up_hotspot.on_release and not ui_content.fav_arrow_down_hotspot.on_release then + ui_content.callback_hide_sub_widgets(ui_content) end @@ -361,6 +400,15 @@ local function create_header_widget(widget_definition, scenegraph_id) ui_content.callback_favorite(ui_content) end + if ui_content.fav_arrow_up_hotspot.on_release then + ui_content.callback_move_favorite(ui_content, true) + end + + if ui_content.fav_arrow_down_hotspot.on_release then + ui_content.callback_move_favorite(ui_content, false) + end + + if ui_content.checkbox_hotspot.on_release then if ui_content.is_widget_collapsed then @@ -378,6 +426,8 @@ local function create_header_widget(widget_definition, scenegraph_id) ui_content.fav_icon_texture = ui_content.is_favorited and "header_fav_icon_lit" or "header_fav_icon" 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" + ui_style.fav_arrow_up.color[1] = ui_content.fav_arrow_up_hotspot.is_hover and 255 or 90 + ui_style.fav_arrow_down.color[1] = ui_content.fav_arrow_down_hotspot.is_hover and 255 or 90 end }, -- DEBUG @@ -413,10 +463,13 @@ local function create_header_widget(widget_definition, scenegraph_id) checkbox_texture = "checkbox_unchecked", highlight_texture = "playerlist_hover", background_texture = "header_background", + fav_arrow_texture = "header_fav_arrow", - fav_icon_hotspot = {}, - checkbox_hotspot = {}, - highlight_hotspot = {}, + fav_icon_hotspot = {}, + fav_arrow_up_hotspot = {}, + fav_arrow_down_hotspot = {}, + checkbox_hotspot = {}, + highlight_hotspot = {}, text = widget_definition.readable_mod_name, @@ -444,6 +497,20 @@ local function create_header_widget(widget_definition, scenegraph_id) offset = {15, offset_y + 25, 3} }, + fav_arrow_up = { + size = {20, 20}, + offset = {20, offset_y + 57, 3}, + color = {90, 255, 255, 255} + }, + + fav_arrow_down = { + size = {20, 20}, + offset = {20, offset_y + 3, 3}, + angle = math.pi, + pivot = {10, 10}, + color = {90, 255, 255, 255} + }, + text = { offset = {60, offset_y + 18, 3}, font_size = 28, @@ -465,6 +532,16 @@ local function create_header_widget(widget_definition, scenegraph_id) offset = {15, offset_y + 25, 3} }, + fav_arrow_up_hotspot = { + size = {20, 20}, + offset = {20, offset_y + 60, 3} + }, + + fav_arrow_down_hotspot = { + size = {20, 20}, + offset = {20, offset_y, 3} + }, + checkbox_hotspot = { size = {80, 80}, offset = {widget_size[1] - 205, offset_y, 0} @@ -1162,6 +1239,7 @@ VMFOptionsView.build_header_widget = function (self, definition, scenegraph_id) content.is_checkbox_visible = definition.is_mod_toggable content.callback_favorite = callback(self, "callback_favorite") + content.callback_move_favorite = callback(self, "callback_move_favorite") content.callback_mod_suspend_state_changed = callback(self, "callback_mod_suspend_state_changed") content.callback_hide_sub_widgets = callback(self, "callback_hide_sub_widgets") @@ -1304,6 +1382,32 @@ VMFOptionsView.callback_favorite = function (self, widget_content) end +VMFOptionsView.callback_move_favorite = function (self, widget_content, is_moved_up) + + local mod_name = widget_content.mod_name + + local new_index = nil + + local favorite_mods_list = vmf:get("options_menu_favorite_mods") + + for i, current_mod_name in ipairs(favorite_mods_list) do + if current_mod_name == mod_name then + + new_index = is_moved_up and (i - 1) or (i + 1) + new_index = math.min(math.max(new_index, 1), #favorite_mods_list) + + table.insert(favorite_mods_list, new_index, table.remove(favorite_mods_list, i)) + break + end + end + + vmf:set("options_menu_favorite_mods", favorite_mods_list) + + self:sort_settings_list_widgets() + self:rearrange_settings_list() +end + + VMFOptionsView.callback_hide_sub_widgets = function (self, widget_content) local mod_name = widget_content.mod_name @@ -1379,7 +1483,7 @@ 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)) - +vmf:echo("whatever") if self.is_setting_changes_applied_immidiately then get_mod(mod_name):set(setting_name, new_value, true) end