From 4000deb88f60002b105b0c7b8d81913e1968e613 Mon Sep 17 00:00:00 2001 From: Azumgi Date: Tue, 13 Feb 2018 21:37:37 +0300 Subject: [PATCH] Added new dump_to_file method. A lot of small code changes. --- vmf_source/resource_packages/vmf.package | 1 + .../scripts/mods/vmf/functions/table.lua | 58 +- vmf_source/scripts/mods/vmf/modules/debug.lua | 336 ++++ vmf_source/scripts/mods/vmf/modules/gui.lua | 2 +- vmf_source/scripts/mods/vmf/modules/hooks.lua | 4 +- .../scripts/mods/vmf/modules/keybindings.lua | 2 +- .../mods/vmf/modules/testing_stuff_here.lua | 18 +- .../mods/vmf/modules/vmf_options_view.lua | 226 ++- .../vmf/modules/vmf_options_view_temp.lua | 1454 ----------------- vmf_source/scripts/mods/vmf/vmf_loader.lua | 1 + 10 files changed, 520 insertions(+), 1582 deletions(-) create mode 100644 vmf_source/scripts/mods/vmf/modules/debug.lua delete mode 100644 vmf_source/scripts/mods/vmf/modules/vmf_options_view_temp.lua diff --git a/vmf_source/resource_packages/vmf.package b/vmf_source/resource_packages/vmf.package index 2c7f349..68f24e9 100644 --- a/vmf_source/resource_packages/vmf.package +++ b/vmf_source/resource_packages/vmf.package @@ -22,6 +22,7 @@ lua = [ "scripts/mods/vmf/vmf_loader" "scripts/mods/vmf/modules/dev_console" "scripts/mods/vmf/modules/mods" + "scripts/mods/vmf/modules/debug" "scripts/mods/vmf/modules/hooks" "scripts/mods/vmf/modules/chat" "scripts/mods/vmf/modules/settings" diff --git a/vmf_source/scripts/mods/vmf/functions/table.lua b/vmf_source/scripts/mods/vmf/functions/table.lua index 58b4c96..f4464b2 100644 --- a/vmf_source/scripts/mods/vmf/functions/table.lua +++ b/vmf_source/scripts/mods/vmf/functions/table.lua @@ -4,11 +4,11 @@ end table.combine = function(a, b) local r = {unpack(a)} - + for i = 1, #b do r[#a + i] = b[i] end - + return r; end @@ -45,51 +45,51 @@ end table.adress = function(tbl) local str = tostring(tbl) - + return string.sub(str, 8, str:len()) end --- Serialization and deserialization +-- Serialization and deserialization local serialization = function(key, value) local str = "" - + if type(value) == "string" then str = str .. tostring(key) .. "=\"" .. value .. "\"," elseif type(value) == "number" then str = str .. tostring(key) .. "=" .. tostring(value) .. "," elseif type(value) == "boolean" then str = str .. tostring(key) .. "=" - + if value then str = str .. "true" else str = str .. "false" end - + str = str .. "," - + elseif type(value) == "table" then str = str .. tostring(key) .. "=" .. table.serialization(value) .. "," end - + return str end local deserialization = function(str) for i = 1, string.len(str) do local value = string.sub(str, i, i) - + if value == "=" then local key = string.sub(str, 1, i - 1) local value = string.sub(str, i + 1, string.len(str)) - + -- Check key if string.sub(key, 1, 1) == "[" then key = string.sub(key, 3, string.len(key) - 2) else key = tonumber(key) end - + -- Check value if value == "true" then value = true @@ -102,17 +102,17 @@ local deserialization = function(str) else value = tonumber(value) end - - return key, value + + return key, value end end - + return nil, nil end table.serialization = function(tbl) local str = "{" - + for key, value in ipairs(tbl) do str = str .. serialization(key, value) end @@ -121,35 +121,35 @@ table.serialization = function(tbl) str = str .. serialization("[\"" .. key .. "\"]", value) end end - + str = str .. "}" - + return str end - + table.deserialization = function(str) local tbl = {} - + -- Collected data local data = "" - + -- Checks local c_list = 0 local c_str = false - + for i = 2, string.len(str) do local before_value = string.sub(str, i - 1, i - 1) local value = string.sub(str, i, i) - + -- If not inside a list or string if value == "," and c_list == 0 then -- Save propety local key, val = deserialization(data) - + if key then tbl[key] = val end - + -- Search for new propety data = "" else @@ -157,7 +157,7 @@ table.deserialization = function(str) if value == "\"" and not before_value ~= "\\" then c_str = not c_str end - + -- Detect list type if not c_str then if value == "{" then @@ -166,11 +166,11 @@ table.deserialization = function(str) c_list = c_list - 1 end end - + -- save value data = data .. value end end - + return tbl -end +end \ No newline at end of file diff --git a/vmf_source/scripts/mods/vmf/modules/debug.lua b/vmf_source/scripts/mods/vmf/modules/debug.lua new file mode 100644 index 0000000..de45a81 --- /dev/null +++ b/vmf_source/scripts/mods/vmf/modules/debug.lua @@ -0,0 +1,336 @@ +local vmf = get_mod("VMF") + + +local function table_dump(key, value, depth, max_depth) + if max_depth < depth then + return + end + + local prefix = string.rep(" ", depth) .. ((key == nil and "") or "[" .. tostring(key) .. "]") + local value_type = type(value) + + if value_type == "table" then + prefix = prefix .. ((key == nil and "") or " = ") + + print(prefix .. "table") + + for key_, value_ in pairs(value) do + table_dump(key_, value_, depth + 1, max_depth) + end + + local meta = getmetatable(value) + + if meta then + if type(meta) == "boolean" then + print(prefix .. "protected metatable") + else + print(prefix .. "metatable") + for key_, value_ in pairs(meta) do + if key_ ~= "__index" and key_ ~= "super" then + table_dump(key_, value_, depth + 1, max_depth) + end + end + end + end + elseif value_type == "function" or value_type == "thread" or value_type == "userdata" or value == nil then + print(prefix .. " = " .. tostring(value)) + else + print(prefix .. " = " .. tostring(value) .. " (" .. value_type .. ")") + end +end + +VMFMod.dump = function (self, t, tag, max_depth) + + if tag then + print(string.format("<%s>", tag)) + end + + if not max_depth then + self:echo("ERROR(dump): maximum depth is not specified", true) + return + end + + local success, error_message = pcall(function() + for key, value in pairs(t) do + table_dump(key, value, 0, max_depth) + end + end) + + if not success then + self:echo("ERROR(dump): " .. tostring(error_message), true) + end + + if tag then + print(string.format("", tag)) + end +end + + + + + + + +local function table_dump_to_file(dumped_table, dumped_table_name, max_depth) + + -- ##################### + -- ## Parsing ## + -- ##################### + + -- All tables which needs to be parsed will be put in here (their references). + local parsing_queue = {} + + -- Special entry is created for every table added to 'parsing_queue'. It will contain parsed contents + -- of the table in the text form and other 'reached_tables' entries (plus some extra info) + local reached_tables = {} + + -- This variable will contain the reference to the top 'reached_tables' entry + local parsed_tree + + + parsing_queue[1] = {} + table.insert(parsing_queue[1], dumped_table) + + + local system_table_name = tostring(dumped_table) + local new_table_entry = { + false, -- 'true' if parser will come across this table again + system_table_name:sub(8), -- table identifier, will be shown in json if previous value is 'true' + {}, -- all things which are stored inside the parsed table will be put in here + nil -- if table has metatable, {} will be created and it will be parsed as well + } + reached_tables[system_table_name] = new_table_entry + parsed_tree = new_table_entry + + + -- some temporary variables for speeding things up + local current_entry + local value_type + local reached_table + local parsed_metatable + + + -- parsing + for i = 1, max_depth do + + -- the parser is not reached the max_level but there's nothing more to parse + if #parsing_queue[i] == 0 then + break + end + + local allow_pushing_new_entries = i < max_depth + if allow_pushing_new_entries then + parsing_queue[i + 1] = {} + end + + local function parse_table(table_entry, parsed_table) + + for key, value in pairs(parsed_table) do + + if key ~= "__index" then + + -- key can be the table and the userdata. Unfortunately JSON does not support table keys + key = tostring(key):gsub('\\','\\\\'):gsub('\"','\\\"'):gsub('\t','\\t'):gsub('\n','\\n') + + value_type = type(value) + + if value_type == "table" then + + if allow_pushing_new_entries then + + system_table_name = tostring(value) + + reached_table = reached_tables[system_table_name] + if reached_table then + + reached_table[1] = true + table_entry[key] = "(table)(" .. system_table_name:sub(8) .. ")" + else + + new_table_entry = { + false, + system_table_name:sub(8), + {}, + nil + } + + reached_tables[system_table_name] = new_table_entry + + table_entry[key] = new_table_entry + + table.insert(parsing_queue[i + 1], value) + end + + else + table_entry[key] = "(table)" + end + + elseif value_type == "function" or value_type == "thread" then + + table_entry[key] = "[" .. value_type .. "]" + else + + table_entry[key] = tostring(value):gsub('\\','\\\\'):gsub('\"','\\\"'):gsub('\t','\\t'):gsub('\n','\\n') .. " (" .. value_type .. ")" + end + end + end + end + + -- parsing all the tables in 'parsing_queue' for the current depth level + for _, parsed_table in pairs(parsing_queue[i]) do + + current_entry = reached_tables[tostring(parsed_table)] + + -- table + + parse_table(current_entry[3], parsed_table) + + -- metatable + + parsed_metatable = getmetatable(parsed_table) + + if parsed_metatable and type(parsed_metatable) == "table" then + + current_entry[4] = {} + + parse_table(current_entry[4], parsed_metatable) + end + end + end + + -- #################### + -- ## Saving to file ## + -- #################### + + local file = assert(io.open(dumped_table_name .. ".json", "w+")) + + local function dump_to_file(table_entry, table_name, depth) + + local print_string = nil + + local prefix = string.rep(' ', depth) + + -- if table was reached more than once, add its system identifier to its name + if table_entry[1] then + file:write(prefix .. '"' .. table_name .. ' (' .. table_entry[2] .. ')": {\n') + else + file:write(prefix .. '"' .. table_name .. '": {\n') + end + + -- if table has metatable + if table_entry[4] then + + local prefix2 = prefix .. ' ' + local prefix3 = prefix2 .. ' "' + + -- TABLE + + file:write(prefix2 .. '"table": {\n') + + for key, value in pairs(table_entry[3]) do + + if print_string then + file:write(print_string .. ',\n') + end + + if type(value) == "table" then + dump_to_file(value, key, depth + 2) + print_string = prefix2 .. ' }' + else + print_string = prefix3 .. key .. '": "' .. value .. '"' + end + end + + if print_string then + file:write(print_string .. '\n') + print_string = nil + end + + file:write(prefix2 .. '},\n') + + -- METATABLE + + file:write(prefix2 .. '"metatable": {\n') + + for key, value in pairs(table_entry[4]) do + + if print_string then + file:write(print_string .. ',\n') + end + + if type(value) == "table" then + dump_to_file(value, key, depth + 2) + print_string = prefix2 .. ' }' + else + print_string = prefix3 .. key .. '": "' .. value .. '"' + end + end + + if print_string then + file:write(print_string .. '\n') + end + + file:write(prefix2 .. '}\n') + + else + + local prefix2 = prefix .. ' "' + + for key, value in pairs(table_entry[3]) do + + if print_string then + file:write(print_string .. ',\n') + end + + if type(value) == "table" then + dump_to_file(value, key, depth + 1) + print_string = prefix .. ' }' + else + print_string = prefix2 .. key .. '": "' .. value .. '"' + end + end + + if print_string then + file:write(print_string .. '\n') + end + end + end + + -- dumping parsed info to the file + file:write('{\n') + dump_to_file (parsed_tree, dumped_table_name, 1) + file:write(' }\n') + file:write('}\n') + file:close() +end + + +VMFMod.dump_to_file = function (self, dumped_object, object_name, max_depth) + + if not dumped_object or not object_name or not max_depth then + self:echo("ERROR(dump_to_file): not all arguments are specified.", true) + return + end + + local object_type = type(dumped_object) + + if object_type ~= "table" then + local error_message = "ERROR(dump_to_file): \"object_name\" is not a table. It's " .. object_type + + if object_type ~= "nil" then + error_message = error_message .. " (" .. tostring(dumped_object) .. ")" + end + + self:echo(error_message, true) + return + end + + local success, error_message = pcall(function() table_dump_to_file(dumped_object, object_name, max_depth) end) + if not success then + self:echo("ERROR(dump_to_file): " .. tostring(error_message), true) + end +end + +VMFMod.dtf = VMFMod.dump_to_file + +-- Managers.curl._requests crashes the game \ No newline at end of file diff --git a/vmf_source/scripts/mods/vmf/modules/gui.lua b/vmf_source/scripts/mods/vmf/modules/gui.lua index fc26180..8014908 100644 --- a/vmf_source/scripts/mods/vmf/modules/gui.lua +++ b/vmf_source/scripts/mods/vmf/modules/gui.lua @@ -206,7 +206,7 @@ vmf:hook("IngameUI.destroy", function(func, self) end) -vmf.check_custom_menus_close_keybinds = function(dt) +vmf.check_custom_menus_close_keybinds = function() if ingame_ui then if views_settings[ingame_ui.current_view] then local opened_view_settings = views_settings[ingame_ui.current_view] diff --git a/vmf_source/scripts/mods/vmf/modules/hooks.lua b/vmf_source/scripts/mods/vmf/modules/hooks.lua index a74f736..ad86dca 100644 --- a/vmf_source/scripts/mods/vmf/modules/hooks.lua +++ b/vmf_source/scripts/mods/vmf/modules/hooks.lua @@ -1,7 +1,6 @@ ---@TODO: maybe update_function_hook_chain() pass entry instead of name local vmf = get_mod("VMF") -HOOKED_FUNCTIONS = HOOKED_FUNCTIONS or {} -- global, because 'loadstring' doesn't see local variables @TODO: or just HOOKED_FUNCTIONS = {} +HOOKED_FUNCTIONS = {} -- global, because 'loadstring' doesn't see local variables -- #################################################################################################################### -- ##### Private functions ############################################################################################ @@ -112,7 +111,6 @@ local function update_function_hook_chain(hooked_function_name) end assert(loadstring(hooked_function_name .. " = HOOKED_FUNCTIONS[" .. hooked_function_entry_index .. "].exec_function"))() - --table.dump(HOOKED_FUNCTIONS, "HOOKED_FUNCTIONS", 3) end diff --git a/vmf_source/scripts/mods/vmf/modules/keybindings.lua b/vmf_source/scripts/mods/vmf/modules/keybindings.lua index b2f41b4..bb3052c 100644 --- a/vmf_source/scripts/mods/vmf/modules/keybindings.lua +++ b/vmf_source/scripts/mods/vmf/modules/keybindings.lua @@ -203,7 +203,7 @@ local function apply_keybinds() optimized_keybinds = {} for mod_name, mod_keybinds in pairs(raw_keybinds) do - for setting_name, keybind in pairs(mod_keybinds) do + for _, keybind in pairs(mod_keybinds) do local action_name = keybind[1] local primary_key = keybind[2][1] 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 16b072b..7f5561c 100644 --- a/vmf_source/scripts/mods/vmf/modules/testing_stuff_here.lua +++ b/vmf_source/scripts/mods/vmf/modules/testing_stuff_here.lua @@ -78,14 +78,14 @@ local options_widgets = { ["tooltip"] = "Warn joining players about game mode", ["default_value"] = true, ["sub_widgets"] = { - { - ["setting_name"] = "whatever", - ["widget_type"] = "checkbox", - ["text"] = "Whatever", - ["tooltip"] = "Whatever," .. "\n" .. - "whatever", - ["default_value"] = true - } + { + ["setting_name"] = "whatever", + ["widget_type"] = "checkbox", + ["text"] = "Whatever", + ["tooltip"] = "Whatever," .. "\n" .. + "whatever", + ["default_value"] = true + } } } } @@ -147,7 +147,7 @@ local options_widgets = { mod:create_options(options_widgets, true, "Test", "Mod description") -- chat_broadcast -mod.whatever = function(message) +mod.whatever = function() mod:echo("whatever") end 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 8816a16..8e71f7f 100644 --- a/vmf_source/scripts/mods/vmf/modules/vmf_options_view.lua +++ b/vmf_source/scripts/mods/vmf/modules/vmf_options_view.lua @@ -31,12 +31,12 @@ inject_material("materials/search_bar_icon", "search_bar_icon", "ingame_ui") -- #################################################################################################################### ---███████╗ ██████╗███████╗███╗ ██╗███████╗ ██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗ ---██╔════╝██╔════╝██╔════╝████╗ ██║██╔════╝██╔════╝ ██╔══██╗██╔══██╗██╔══██╗██║ ██║██╔════╝ ---███████╗██║ █████╗ ██╔██╗ ██║█████╗ ██║ ███╗██████╔╝███████║██████╔╝███████║███████╗ ---╚════██║██║ ██╔══╝ ██║╚██╗██║██╔══╝ ██║ ██║██╔══██╗██╔══██║██╔═══╝ ██╔══██║╚════██║ ---███████║╚██████╗███████╗██║ ╚████║███████╗╚██████╔╝██║ ██║██║ ██║██║ ██║ ██║███████║ ---╚══════╝ ╚═════╝╚══════╝╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚══════╝ +-- ███████╗ ██████╗███████╗███╗ ██╗███████╗ ██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗ +-- ██╔════╝██╔════╝██╔════╝████╗ ██║██╔════╝██╔════╝ ██╔══██╗██╔══██╗██╔══██╗██║ ██║██╔════╝ +-- ███████╗██║ █████╗ ██╔██╗ ██║█████╗ ██║ ███╗██████╔╝███████║██████╔╝███████║███████╗ +-- ╚════██║██║ ██╔══╝ ██║╚██╗██║██╔══╝ ██║ ██║██╔══██╗██╔══██║██╔═══╝ ██╔══██║╚════██║ +-- ███████║╚██████╗███████╗██║ ╚████║███████╗╚██████╔╝██║ ██║██║ ██║██║ ██║ ██║███████║ +-- ╚══════╝ ╚═════╝╚══════╝╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚══════╝ local scenegraph_definition = { @@ -283,9 +283,7 @@ local menu_widgets_definition = { { pass_type = "scroll", -- the function is called only during scrolls - scroll_function = function (ui_scenegraph, style, content, input_service, scroll_axis) - local scroll_step = content.scroll_step - local current_scroll_value = content.internal_scroll_value + scroll_function = function (ui_scenegraph_, style_, content, input_service_, scroll_axis) content.internal_scroll_value = content.internal_scroll_value - scroll_axis.y end @@ -530,7 +528,7 @@ local function create_header_widget(widget_definition, scenegraph_id) { pass_type = "local_offset", - offset_function = function (ui_scenegraph, style, content, ui_renderer) + 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() @@ -605,7 +603,7 @@ local function create_header_widget(widget_definition, scenegraph_id) { pass_type = "border", - content_check_function = function (content, style) + content_check_function = function (content_, style) if DEBUG_WIDGETS then style.thickness = 1 end @@ -617,7 +615,7 @@ local function create_header_widget(widget_definition, scenegraph_id) pass_type = "rect", style_id = "debug_middle_line", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end } @@ -848,7 +846,7 @@ local function create_checkbox_widget(widget_definition, scenegraph_id) { pass_type = "local_offset", - offset_function = function (ui_scenegraph, style, content, ui_renderer) + 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() @@ -901,14 +899,14 @@ local function create_checkbox_widget(widget_definition, scenegraph_id) { pass_type = "rect", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end }, { pass_type = "border", - content_check_function = function (content, style) + content_check_function = function (content_, style) if DEBUG_WIDGETS then style.thickness = 1 end @@ -920,7 +918,7 @@ local function create_checkbox_widget(widget_definition, scenegraph_id) pass_type = "rect", style_id = "debug_middle_line", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end } @@ -933,8 +931,6 @@ local function create_checkbox_widget(widget_definition, scenegraph_id) rect_masked_texture = "rect_masked", highlight_texture = "playerlist_hover", - --background_texture = "common_widgets_background_lit", - rect_masked_texture = "rect_masked", checkbox_hotspot = {}, highlight_hotspot = {}, @@ -1035,6 +1031,14 @@ local function create_checkbox_widget(widget_definition, scenegraph_id) end +-- ██████╗ ██████╗ ██████╗ ██╗ ██╗██████╗ +-- ██╔════╝ ██╔══██╗██╔═══██╗██║ ██║██╔══██╗ +-- ██║ ███╗██████╔╝██║ ██║██║ ██║██████╔╝ +-- ██║ ██║██╔══██╗██║ ██║██║ ██║██╔═══╝ +-- ╚██████╔╝██║ ██║╚██████╔╝╚██████╔╝██║ +-- ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ + + local function create_group_widget(widget_definition, scenegraph_id) local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE @@ -1050,7 +1054,7 @@ local function create_group_widget(widget_definition, scenegraph_id) pass_type = "texture", style_id = "background", - texture_id = "background_texture", + texture_id = "rect_masked_texture", content_check_function = function (content) return content.is_widget_collapsed @@ -1059,7 +1063,7 @@ local function create_group_widget(widget_definition, scenegraph_id) { pass_type = "texture", - style_id = "highlight_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() @@ -1069,7 +1073,7 @@ local function create_group_widget(widget_definition, scenegraph_id) pass_type = "text", style_id = "text", - text_id = "text" + text_id = "text" }, -- HOTSPOTS { @@ -1081,7 +1085,7 @@ local function create_group_widget(widget_definition, scenegraph_id) { pass_type = "local_offset", - offset_function = function (ui_scenegraph, style, content, ui_renderer) + 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() @@ -1111,14 +1115,14 @@ local function create_group_widget(widget_definition, scenegraph_id) { pass_type = "rect", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end }, { pass_type = "border", - content_check_function = function (content, style) + content_check_function = function (content_, style) if DEBUG_WIDGETS then style.thickness = 1 end @@ -1130,7 +1134,7 @@ local function create_group_widget(widget_definition, scenegraph_id) pass_type = "rect", style_id = "debug_middle_line", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end } @@ -1141,7 +1145,7 @@ local function create_group_widget(widget_definition, scenegraph_id) is_widget_collapsed = widget_definition.is_widget_collapsed, highlight_texture = "playerlist_hover", - background_texture = "common_widgets_background_lit", + rect_masked_texture = "rect_masked", highlight_hotspot = {}, @@ -1158,7 +1162,8 @@ local function create_group_widget(widget_definition, scenegraph_id) -- VISUALS background = { size = {widget_size[1], widget_size[2] - 3}, - offset = {0, offset_y + 1, 0} + offset = {0, offset_y + 1, 0}, + color = {255, 30, 23, 15} }, highlight_texture = { @@ -1175,8 +1180,6 @@ local function create_group_widget(widget_definition, scenegraph_id) text_color = Colors.get_color_table_with_alpha("white", 255) }, - -- HOTSPOTS - -- TOOLTIP tooltip_text = { @@ -1409,7 +1412,7 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra { pass_type = "local_offset", - offset_function = function (ui_scenegraph, style, content, ui_renderer) + 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() @@ -1420,7 +1423,7 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra end if content.dropdown_hotspot.on_release then - content.callback_change_dropdown_menu_visibility(content, style) + content.callback_change_dropdown_menu_visibility(content) end if content.highlight_hotspot.on_release and not content.dropdown_hotspot.on_release then @@ -1432,7 +1435,7 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra local old_value = content.options_values[content.current_option_number] - if content.callback_draw_dropdown_menu(content, style) then + if content.callback_draw_dropdown_menu(content) then if content.is_widget_collapsed then content.callback_hide_sub_widgets(content) @@ -1461,7 +1464,7 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra text_id = "tooltip_text", style_id = "tooltip_text", - content_check_function = function (content, style) + content_check_function = function (content) return content.tooltip_text and content.highlight_hotspot.is_hover and content.callback_is_cursor_inside_settings_list() end }, @@ -1469,14 +1472,14 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra { pass_type = "rect", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end }, { pass_type = "border", - content_check_function = function (content, style) + content_check_function = function (content_, style) if DEBUG_WIDGETS then style.thickness = 1 end @@ -1488,7 +1491,7 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra pass_type = "rect", style_id = "debug_middle_line", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end } @@ -1707,12 +1710,12 @@ local function create_numeric_menu_widget(dropdown_definition, scenegraph_2nd_la local cursor = UIInverseScaleVectorToResolution(input_service.get(input_service, "cursor")) local scenegraph_id = ui_content.scenegraph_id local world_position = UISceneGraph.get_world_position(ui_scenegraph, scenegraph_id) - local size_x = ui_style.size[1] + local size_x_ = ui_style.size[1] local cursor_x = cursor[1] local pos_start = world_position[1] + ui_style.offset[1] local old_value = ui_content.internal_value local cursor_x_norm = cursor_x - pos_start - local value = math.clamp(cursor_x_norm/size_x, 0, 1) + local value = math.clamp(cursor_x_norm/size_x_, 0, 1) ui_content.internal_value = value if old_value ~= value then @@ -1871,7 +1874,7 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap { pass_type = "local_offset", - offset_function = function (ui_scenegraph, style, content, ui_renderer) + 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() @@ -1883,7 +1886,7 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap if content.dropdown_hotspot.on_release then - content.callback_change_numeric_menu_visibility(content, style) + content.callback_change_numeric_menu_visibility(content) end end @@ -1891,7 +1894,7 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap local old_value = content.current_value - if content.callback_draw_numeric_menu(content, style) then + if content.callback_draw_numeric_menu(content) then local mod_name = content.mod_name local setting_name = content.setting_name @@ -1912,7 +1915,7 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap text_id = "tooltip_text", style_id = "tooltip_text", - content_check_function = function (content, style) + content_check_function = function (content) return content.tooltip_text and content.highlight_hotspot.is_hover and content.callback_is_cursor_inside_settings_list() end }, @@ -1920,14 +1923,14 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap { pass_type = "rect", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end }, { pass_type = "border", - content_check_function = function (content, style) + content_check_function = function (content_, style) if DEBUG_WIDGETS then style.thickness = 1 end @@ -1939,7 +1942,7 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap pass_type = "rect", style_id = "debug_middle_line", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end } @@ -2158,7 +2161,7 @@ local function create_keybind_widget(widget_definition, scenegraph_id) { pass_type = "local_offset", - offset_function = function (ui_scenegraph, style, content, ui_renderer) + 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() @@ -2177,13 +2180,13 @@ local function create_keybind_widget(widget_definition, scenegraph_id) end if content.keybind_text_hotspot.on_release then - content.callback_change_setting_keybind_state(content, style) + content.callback_change_setting_keybind_state(content) return end end if content.is_setting_keybind then - if content.callback_setting_keybind(content, style) then + if content.callback_setting_keybind(content) then content.callback_setting_changed(content.mod_name, content.setting_name, nil, content.keys) return end @@ -2199,7 +2202,7 @@ local function create_keybind_widget(widget_definition, scenegraph_id) text_id = "tooltip_text", style_id = "tooltip_text", - content_check_function = function (content, style) + content_check_function = function (content) return content.tooltip_text and content.highlight_hotspot.is_hover and content.callback_is_cursor_inside_settings_list() end }, @@ -2207,14 +2210,14 @@ local function create_keybind_widget(widget_definition, scenegraph_id) { pass_type = "rect", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end }, { pass_type = "border", - content_check_function = function (content, style) + content_check_function = function (content_, style) if DEBUG_WIDGETS then style.thickness = 1 end @@ -2226,7 +2229,7 @@ local function create_keybind_widget(widget_definition, scenegraph_id) pass_type = "rect", style_id = "debug_middle_line", - content_check_function = function (content) + content_check_function = function () return DEBUG_WIDGETS end } @@ -2450,7 +2453,6 @@ VMFOptionsView.initialize_settings_list_widgets = function (self) for _, definition in ipairs(mod_settings_list_definitions) do local widget = nil - local size_y = 0 local widget_type = definition.widget_type if widget_type == "checkbox" then @@ -2874,7 +2876,7 @@ VMFOptionsView.callback_hide_sub_widgets = function (self, widget_content) end -VMFOptionsView.callback_change_setting_keybind_state = function (self, widget_content, widget_style) +VMFOptionsView.callback_change_setting_keybind_state = function (self, widget_content) if not widget_content.is_setting_keybind then self.input_manager:device_unblock_all_services("keyboard", 1) @@ -2903,7 +2905,7 @@ VMFOptionsView.callback_change_setting_keybind_state = function (self, widget_co end -VMFOptionsView.callback_setting_keybind = function (self, widget_content, widget_style) +VMFOptionsView.callback_setting_keybind = function (self, widget_content) if not widget_content.first_pressed_button and (Keyboard.any_pressed() or Mouse.any_pressed()) then @@ -2972,7 +2974,7 @@ VMFOptionsView.callback_setting_keybind = function (self, widget_content, widget get_mod(widget_content.mod_name):keybind(widget_content.setting_name, widget_content.action, widget_content.keys) end - self:callback_change_setting_keybind_state(widget_content, widget_style) + self:callback_change_setting_keybind_state(widget_content) return true end @@ -2987,7 +2989,7 @@ VMFOptionsView.callback_setting_keybind = function (self, widget_content, widget get_mod(widget_content.mod_name):keybind(widget_content.setting_name, widget_content.action, widget_content.keys) end - self:callback_change_setting_keybind_state(widget_content, widget_style) + self:callback_change_setting_keybind_state(widget_content) return true end @@ -2995,7 +2997,7 @@ VMFOptionsView.callback_setting_keybind = function (self, widget_content, widget end -VMFOptionsView.callback_change_dropdown_menu_visibility = function (self, widget_content, widget_style) +VMFOptionsView.callback_change_dropdown_menu_visibility = function (self, widget_content) if not widget_content.is_dropdown_menu_opened then self.input_manager:device_unblock_all_services("keyboard", 1) @@ -3027,7 +3029,7 @@ VMFOptionsView.callback_change_dropdown_menu_visibility = function (self, widget end -VMFOptionsView.callback_draw_dropdown_menu = function (self, widget_content, widget_style) +VMFOptionsView.callback_draw_dropdown_menu = function (self, widget_content) local ui_renderer = self.ui_renderer local scenegraph = self.ui_scenegraph_2nd_layer local parent_scenegraph_id = self.settings_list_scenegraph_id_start @@ -3045,7 +3047,7 @@ VMFOptionsView.callback_draw_dropdown_menu = function (self, widget_content, wid for _, hotspot_content in pairs(widget_content.popup_menu_widget.content) do if type(hotspot_content) == "table" and hotspot_content.on_release then - self:callback_change_dropdown_menu_visibility(widget_content, widget_style) + self:callback_change_dropdown_menu_visibility(widget_content) widget_content.current_option_number = hotspot_content.num widget_content.current_option_text = widget_content.options_texts[widget_content.current_option_number] @@ -3056,14 +3058,14 @@ VMFOptionsView.callback_draw_dropdown_menu = function (self, widget_content, wid --if Left Mouse Button or Esc pressed if Mouse.released(0) and not widget_content.wrong_mouse_on_release or Keyboard.released(27) then - self:callback_change_dropdown_menu_visibility(widget_content, widget_style) + self:callback_change_dropdown_menu_visibility(widget_content) end widget_content.wrong_mouse_on_release = nil end -VMFOptionsView.callback_change_numeric_menu_visibility = function (self, widget_content, widget_style) +VMFOptionsView.callback_change_numeric_menu_visibility = function (self, widget_content) if not widget_content.is_numeric_menu_opened then self.input_manager:device_unblock_all_services("keyboard", 1) @@ -3103,14 +3105,14 @@ VMFOptionsView.callback_change_numeric_menu_visibility = function (self, widget_ if not min_text_has_dot then min_text = min_text .. "." - for i = 1, decimals_number do + for _ = 1, decimals_number do min_text = min_text .. "0" end end if not max_text_has_dot then max_text = max_text .. "." - for i = 1, decimals_number do + for _ = 1, decimals_number do max_text = max_text .. "0" end end @@ -3135,7 +3137,7 @@ VMFOptionsView.callback_change_numeric_menu_visibility = function (self, widget_ end -VMFOptionsView.callback_draw_numeric_menu = function (self, widget_content, widget_style) +VMFOptionsView.callback_draw_numeric_menu = function (self, widget_content) local numeric_menu_content = widget_content.popup_menu_widget.content local numeric_menu_text_style = widget_content.popup_menu_widget.style.new_value_text @@ -3291,9 +3293,7 @@ VMFOptionsView.callback_draw_numeric_menu = function (self, widget_content, widg -- Left Mouse Button or Enter pressed ---------------- if Mouse.released(0) and not widget_content.wrong_mouse_on_release and not numeric_menu_content.slider_is_held or Keyboard.released(13) then - self:callback_change_numeric_menu_visibility(widget_content, widget_style) - - table.dump(numeric_menu_content.slider_hotspot, "WHATEVER", 1) + self:callback_change_numeric_menu_visibility(widget_content) if new_value_number and new_value_number >= widget_content.range[1] and new_value_number <= widget_content.range[2] then widget_content.current_value = new_value_number @@ -3310,7 +3310,7 @@ VMFOptionsView.callback_draw_numeric_menu = function (self, widget_content, widg -- Esc pressed --------------------------------------- if Keyboard.released(27) then - self:callback_change_numeric_menu_visibility(widget_content, widget_style) + self:callback_change_numeric_menu_visibility(widget_content) end -- Fix for closing menu when releasing LMB outside the hotspot @@ -3411,9 +3411,9 @@ VMFOptionsView.update_picked_option_for_settings_list_widgets = function (self) if type(loaded_setting_value) == "boolean" then widget_content.is_checkbox_checked = loaded_setting_value else - if type(loaded_setting_value) ~= "nil" then + --if type(loaded_setting_value) ~= "nil" then -- @TODO: warning: variable of wrong type in config - end + --end widget_content.is_checkbox_checked = widget_content.default_value get_mod(widget_content.mod_name):set(widget_content.setting_name, widget_content.default_value) @@ -3436,9 +3436,9 @@ VMFOptionsView.update_picked_option_for_settings_list_widgets = function (self) end if setting_not_found then - if type(loaded_setting_value) ~= "nil" then + --if type(loaded_setting_value) ~= "nil" then -- @TODO: warning: variable which is not in the dropdown options list in config - end + --end for i, option_value in ipairs(widget_content.options_values) do @@ -3793,16 +3793,13 @@ VMFOptionsView.update_settings_list = function (self, settings_list_widgets, ui_ for _, widget in ipairs(mod_widgets) do if widget.content.is_widget_visible then local style = widget.style - local widget_name = widget.name local size = style.size local offset = style.offset temp_pos_table.x = list_position[1] + offset[1] temp_pos_table.y = list_position[2] + offset[2] + widget.offset[2] local lower_visible = math.point_is_inside_2d_box(temp_pos_table, mask_pos, mask_size) - temp_pos_table.y = temp_pos_table.y + size[2]/2 - local middle_visible = math.point_is_inside_2d_box(temp_pos_table, mask_pos, mask_size) - temp_pos_table.y = temp_pos_table.y + size[2]/2 + temp_pos_table.y = temp_pos_table.y + size[2] local top_visible = math.point_is_inside_2d_box(temp_pos_table, mask_pos, mask_size) local visible = lower_visible or top_visible @@ -3901,10 +3898,6 @@ end -- ##### VMFMod ####################################################################################################### -- #################################################################################################################### -local function check_widget_definition(mod, widget) - -end - VMFMod.create_options = function (self, widgets_definition, is_mod_toggable, readable_mod_name, mod_description) @@ -3992,8 +3985,6 @@ VMFMod.create_options = function (self, widgets_definition, is_mod_toggable, rea 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 self:set(current_widget.setting_name, current_widget.default_value) end @@ -4010,8 +4001,8 @@ VMFMod.create_options = function (self, widgets_definition, is_mod_toggable, rea end if current_widget and ( - current_widget.widget_type == "header" or - current_widget.widget_type == "group" or + 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 @@ -4223,10 +4214,75 @@ vmf:register_new_view(view_data) + + + + + + + + + + + + + + + +vmf:hook("IngameView.setup_button_layout", function (func, self, layout_data) + + local mods_options_button = { + display_name = "Mods Options", + transition = "vmf_options_view", + fade = false + } + + for i, button_info in ipairs(layout_data) do + + if button_info.transition == "options_menu" then + + table.insert(layout_data, i + 1, mods_options_button) + break + end + end + + func(self, layout_data) + + for _, button_info in ipairs(self.active_button_data) do + + if button_info.transition == "vmf_options_view" then + + button_info.widget.style.text.localize = false + button_info.widget.style.text_disabled.localize = false + button_info.widget.style.text_click.localize = false + button_info.widget.style.text_hover.localize = false + button_info.widget.style.text_selected.localize = false + end + end +end) + + + + + + + + + + + + + local ingame_ui_exists, ingame_ui = pcall(function () return Managers.player.network_manager.matchmaking_manager.matchmaking_ui.ingame_ui end) if ingame_ui_exists then ingame_ui.handle_transition(ingame_ui, "leave_group") +vmf:pcall(function() + + print("AYYYYY" .. tostring(ingame_ui)) + --vmf:dump(ingame_ui.views, "whatever", 1) + +end) --------------------------------------------------- diff --git a/vmf_source/scripts/mods/vmf/modules/vmf_options_view_temp.lua b/vmf_source/scripts/mods/vmf/modules/vmf_options_view_temp.lua deleted file mode 100644 index 061318b..0000000 --- a/vmf_source/scripts/mods/vmf/modules/vmf_options_view_temp.lua +++ /dev/null @@ -1,1454 +0,0 @@ -local mod = new_mod("vmf_options_view") -- @TODO: replace it with VMF later - - ---███████╗ ██████╗███████╗███╗ ██╗███████╗ ██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗ ---██╔════╝██╔════╝██╔════╝████╗ ██║██╔════╝██╔════╝ ██╔══██╗██╔══██╗██╔══██╗██║ ██║██╔════╝ ---███████╗██║ █████╗ ██╔██╗ ██║█████╗ ██║ ███╗██████╔╝███████║██████╔╝███████║███████╗ ---╚════██║██║ ██╔══╝ ██║╚██╗██║██╔══╝ ██║ ██║██╔══██╗██╔══██║██╔═══╝ ██╔══██║╚════██║ ---███████║╚██████╗███████╗██║ ╚████║███████╗╚██████╔╝██║ ██║██║ ██║██║ ██║ ██║███████║ ---╚══════╝ ╚═════╝╚══════╝╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚══════╝ - -local scenegraph_definition = { - - sg_root = { - size = {1920, 1080}, - position = {0, 0, UILayer.default + 10}, - is_root = true - }, - - sg_background_border = { - size = {1206, 1056}, - position = {357, 12, 0}, - - parent = "sg_root" - }, - - sg_background_settings_list = { - size = {1200, 1000}, - position = {360, 65, 1}, - - parent = "sg_root" - }, - - sg_mousewheel_scroll_area = { - size = {1200, 1000}, - position = {0, 0, 0}, - - parent = "sg_background_settings_list" - }, - - sg_settings_list_mask = { - size = {1200, 1000}, - position = {0, 0, 2}, - - parent = "sg_background_settings_list" - }, - - sg_settings_list_mask_edge_fade_top = { - size = {1200, 15}, - position = {0, 985, 3}, - - parent = "sg_background_settings_list" - }, - - sg_settings_list_mask_edge_fade_bottom = { - size = {1200, 15}, - position = {0, 0, 3}, - - parent = "sg_background_settings_list" - }, - - sg_background_search_bar = { - size = {1200, 47}, - position = {360, 15, 1}, - - parent = "sg_root" - }, - - sg_scrollbar = { - size = {360, 1050}, - position = {1560, 40, 0}, - - parent = "sg_root" - }, - - sg_dead_space_filler = { - size = {1920, 1080}, - position = {0, 0, 0}, - scale = "fit" -- WHY? - } -} - - ---███╗ ███╗███████╗███╗ ██╗██╗ ██╗ ██╗ ██╗██╗██████╗ ██████╗ ███████╗████████╗███████╗ ---████╗ ████║██╔════╝████╗ ██║██║ ██║ ██║ ██║██║██╔══██╗██╔════╝ ██╔════╝╚══██╔══╝██╔════╝ ---██╔████╔██║█████╗ ██╔██╗ ██║██║ ██║ ██║ █╗ ██║██║██║ ██║██║ ███╗█████╗ ██║ ███████╗ ---██║╚██╔╝██║██╔══╝ ██║╚██╗██║██║ ██║ ██║███╗██║██║██║ ██║██║ ██║██╔══╝ ██║ ╚════██║ ---██║ ╚═╝ ██║███████╗██║ ╚████║╚██████╔╝ ╚███╔███╔╝██║██████╔╝╚██████╔╝███████╗ ██║ ███████║ ---╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚══╝╚══╝ ╚═╝╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚══════╝ - -local menu_widgets_definition = { - - - static_menu_elements = { - scenegraph_id = "sg_root", - element = { - passes = { - { - pass_type = "rect", - - style_id = "background_border" - }, - { - pass_type = "rect", - - style_id = "background_search_bar" - }, - { - pass_type = "rect", - - style_id = "background_settings_list" - }, - { - pass_type = "texture", - - style_id = "settings_list_mask", - texture_id = "settings_list_mask_texture_id" - }, - { - pass_type = "texture_uv", - - style_id = "settings_list_mask_edge_fade_top", - content_id = "settings_list_mask_edge_fade_top" - }, - { - pass_type = "texture_uv", - - style_id = "settings_list_mask_edge_fade_bottom", - content_id = "settings_list_mask_edge_fade_bottom" - }, - { - pass_type = "rect", - - style_id = "dead_space_filler" - } - } - }, - content = { - settings_list_mask_texture_id = "mask_rect", - - settings_list_mask_edge_fade_top = { - texture_id = "mask_rect_edge_fade", - uvs = {{0, 0}, {1, 1}} - }, - - settings_list_mask_edge_fade_bottom = { - texture_id = "mask_rect_edge_fade", - uvs = {{0, 1}, {1, 0}} - } - }, - style = { - - background_border = { - scenegraph_id = "sg_background_border", - color = {255, 140, 100, 50} - }, - - background_search_bar = { - scenegraph_id = "sg_background_search_bar", - color = {255, 0, 0, 0} - }, - - background_settings_list = { - scenegraph_id = "sg_background_settings_list", - color = {255, 0, 0, 0} - }, - - settings_list_mask = { - scenegraph_id = "sg_settings_list_mask", - color = {255, 255, 255, 255} - }, - - settings_list_mask_edge_fade_top = { - scenegraph_id = "sg_settings_list_mask_edge_fade_top", - color = {255, 255, 255, 255} - }, - - settings_list_mask_edge_fade_bottom = { - scenegraph_id = "sg_settings_list_mask_edge_fade_bottom", - color = {255, 255, 255, 255} - }, - - dead_space_filler = { - scenegraph_id = "sg_dead_space_filler", - color = {150, 0, 0, 0} - } - } - }, - - mousewheel_scroll_area = { - scenegraph_id = "sg_mousewheel_scroll_area", - element = { - passes = { - { - pass_type = "scroll", - -- the function is being called only during scrolls - scroll_function = function (ui_scenegraph, ui_style, ui_content, input_service, scroll_axis) - local scroll_step = ui_content.scroll_step - local current_scroll_value = ui_content.internal_scroll_value - - --current_scroll_value = current_scroll_value + scroll_step*-scroll_axis.y - --ui_content.internal_scroll_value = math.clamp(current_scroll_value, 0, 1) - - ui_content.internal_scroll_value = ui_content.internal_scroll_value - scroll_axis.y - end - } - } - }, - content = { - internal_scroll_value = 0, - scroll_step = 0.01 - }, - style = { - } - }, - - scrollbar = UIWidgets.create_scrollbar(scenegraph_definition.sg_scrollbar.size[2], "sg_scrollbar") -} - - --- @TODO: make scrollbar full windowed o_O - -menu_widgets_definition.scrollbar.content.scroll_bar_info.bar_height_percentage = 0.5 -menu_widgets_definition.scrollbar.content.scroll_bar_info.old_value = 0 -menu_widgets_definition.scrollbar.content.disable_frame = true -menu_widgets_definition.scrollbar.style.scroll_bar_box.size[1] = 360 -- don't change visual scrollbox size - -menu_widgets_definition.scrollbar.content.button_up_hotspot.disable_button = true -menu_widgets_definition.scrollbar.content.button_down_hotspot.disable_button = true - --- removing up and down buttons -table.remove(menu_widgets_definition.scrollbar.element.passes, 7) -table.remove(menu_widgets_definition.scrollbar.element.passes, 7) -table.remove(menu_widgets_definition.scrollbar.element.passes, 8) -table.remove(menu_widgets_definition.scrollbar.element.passes, 8) ---table.remove(menu_widgets_definition.scrollbar.element.passes, 7) - - - - - - ---████████╗███████╗███╗ ███╗██████╗ ---╚══██╔══╝██╔════╝████╗ ████║██╔══██╗ --- ██║ █████╗ ██╔████╔██║██████╔╝ --- ██║ ██╔══╝ ██║╚██╔╝██║██╔═══╝ --- ██║ ███████╗██║ ╚═╝ ██║██║ --- ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ - - -script_data.ui_debug_hover = false - -local DEBUG_WIDGETS = false - -local SETTINGS_LIST_BIG_WIDGET_SIZE = {1194, 70} -local SETTINGS_LIST_REGULAR_WIDGET_SIZE = {1194, 50} - - ---[[alright, this is it]] - -local function create_header_widget(text, scenegraph_id, offset_y) - - base_offset[2] = base_offset[2] - SETTINGS_LIST_BIG_WIDGET_SIZE[2] - - local definition = { - element = { - passes = { - { - style_id = "checkbox", - pass_type = "hotspot", - content_id = "hotspot" - }, - { - pass_type = "hotspot", - content_id = "highlight_hotspot" - }, - { - pass_type = "texture", - style_id = "highlight_texture", - texture_id = "highlight_texture", - content_check_function = function (content) - return content.is_highlighted - end - }, - { - pass_type = "local_offset", - offset_function = function (ui_scenegraph, ui_style, ui_content, ui_renderer) - if ui_content.hotspot.on_release then - ui_content.flag = not ui_content.flag - end - - local flag = ui_content.flag - - if flag then - ui_content.checkbox = "checkbox_checked" - else - ui_content.checkbox = "checkbox_unchecked" - end - - return - end - }, - { - pass_type = "texture", - style_id = "checkbox", - texture_id = "checkbox" - }, - { - style_id = "text", - pass_type = "text", - text_id = "text" - }, - { - 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 - }, - { - style_id = "debug_middle_line", - pass_type = "rect", - content_check_function = function (content) - return DEBUG_WIDGETS - end - } - } - }, - content = { - flag = false, - checkbox = "checkbox_unchecked", --just a texture name - highlight_texture = "playerlist_hover", - hotspot = {}, - highlight_hotspot = {}, - text = text, - hotspot_content_ids = { - "hotspot" - } - }, - style = { - highlight_texture = { - masked = true, - offset = { - base_offset[1], - base_offset[2], - base_offset[3] - }, - color = Colors.get_table("white"), - size = { - SETTINGS_LIST_BIG_WIDGET_SIZE[1], - SETTINGS_LIST_BIG_WIDGET_SIZE[2] - } - }, - checkbox = { - masked = true, - offset = { - base_offset[1] + 642, - base_offset[2] + 17, - base_offset[3] - }, - size = { - 16, - 16 - } - }, - text = { - font_type = "hell_shark_masked", - dynamic_font = true, - localize = true, - font_size = 28, - offset = { - base_offset[1] + 2, - base_offset[2] + 5, - base_offset[3] - }, - text_color = Colors.get_color_table_with_alpha("white", 255) - }, - offset = { - base_offset[1], - base_offset[2], - base_offset[3] - }, - size = table.clone(SETTINGS_LIST_BIG_WIDGET_SIZE), - color = { - 50, - 255, - 255, - 255 - }, - debug_middle_line = { - offset = { - base_offset[1], - (base_offset[2] + SETTINGS_LIST_BIG_WIDGET_SIZE[2]/2) - 1, - base_offset[3] + 10 - }, - size = { - SETTINGS_LIST_BIG_WIDGET_SIZE[1], - 2 - }, - color = { - 200, - 0, - 255, - 0 - } - } - }, - scenegraph_id = scenegraph_id - } - - return UIWidget.init(definition) -end - - -local function build_header_widget (element, scenegraph_id, base_offset) - --local callback_name = element.callback - --local callback_func = self.make_callback(self, callback_name) - --local saved_value_cb_name = element.saved_value - --local saved_value_cb = callback(self, saved_value_cb_name) - --local setup_name = element.setup - --local flag, text, default_value = self[setup_name](self) - - --fassert(type(flag) == "boolean", "Flag type is wrong, need boolean, got %q", type(flag)) - - local text = "Whatever" - - local widget = create_header_widget(text, scenegraph_id, base_offset) - local content = widget.content - content.flag = true - --content.callback = callback_func - --content.saved_value_cb = saved_value_cb - --content.default_value = default_value - content.callback = function () - return - end - content.saved_value_cb = function () - return - end - - return widget -end - - - - - - - - - - - ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- ------------------------------------------------------------- - -local CHECKBOX_WIDGET_SIZE = { - 795, - 50 -} - -local function create_checkbox_widget(text, scenegraph_id, base_offset) - base_offset[2] = base_offset[2] - CHECKBOX_WIDGET_SIZE[2] - local definition = { - element = { - passes = { - { - style_id = "checkbox", - pass_type = "hotspot", - content_id = "hotspot" - }, - { - pass_type = "hotspot", - content_id = "highlight_hotspot" - }, - { - pass_type = "texture", - style_id = "highlight_texture", - texture_id = "highlight_texture", - content_check_function = function (content) - return content.is_highlighted - end - }, - { - pass_type = "local_offset", - offset_function = function (ui_scenegraph, ui_style, ui_content, ui_renderer) - if ui_content.hotspot.on_release then - ui_content.flag = not ui_content.flag - end - - local flag = ui_content.flag - - if flag then - ui_content.checkbox = "checkbox_checked" - else - ui_content.checkbox = "checkbox_unchecked" - end - - return - end - }, - { - pass_type = "texture", - style_id = "checkbox", - texture_id = "checkbox" - }, - { - style_id = "text", - pass_type = "text", - text_id = "text" - }, - { - 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 - }, - { - style_id = "debug_middle_line", - pass_type = "rect", - content_check_function = function (content) - return DEBUG_WIDGETS - end - } - } - }, - content = { - flag = false, - checkbox = "checkbox_unchecked", --just a texture name - highlight_texture = "playerlist_hover", - hotspot = {}, - highlight_hotspot = {}, - text = text, - hotspot_content_ids = { - "hotspot" - } - }, - style = { - highlight_texture = { - masked = true, - offset = { - base_offset[1], - base_offset[2], - base_offset[3] - }, - color = Colors.get_table("white"), - size = { - CHECKBOX_WIDGET_SIZE[1], - CHECKBOX_WIDGET_SIZE[2] - } - }, - checkbox = { - masked = true, - offset = { - base_offset[1] + 642, - base_offset[2] + 17, - base_offset[3] - }, - size = { - 16, - 16 - } - }, - text = { - font_type = "hell_shark_masked", - dynamic_font = true, - localize = true, - font_size = 28, - offset = { - base_offset[1] + 2, - base_offset[2] + 5, - base_offset[3] - }, - text_color = Colors.get_color_table_with_alpha("white", 255) - }, - offset = { - base_offset[1], - base_offset[2], - base_offset[3] - }, - size = table.clone(CHECKBOX_WIDGET_SIZE), - color = { - 50, - 255, - 255, - 255 - }, - debug_middle_line = { - offset = { - base_offset[1], - (base_offset[2] + CHECKBOX_WIDGET_SIZE[2]/2) - 1, - base_offset[3] + 10 - }, - size = { - CHECKBOX_WIDGET_SIZE[1], - 2 - }, - color = { - 200, - 0, - 255, - 0 - } - } - }, - scenegraph_id = scenegraph_id - } - - return UIWidget.init(definition) -end - - -local function build_checkbox_widget (element, scenegraph_id, base_offset) - --local callback_name = element.callback - --local callback_func = self.make_callback(self, callback_name) - --local saved_value_cb_name = element.saved_value - --local saved_value_cb = callback(self, saved_value_cb_name) - --local setup_name = element.setup - --local flag, text, default_value = self[setup_name](self) - - --fassert(type(flag) == "boolean", "Flag type is wrong, need boolean, got %q", type(flag)) - - local text = "Whatever" - - local widget = create_checkbox_widget(text, scenegraph_id, base_offset) - local content = widget.content - content.flag = true - --content.callback = callback_func - --content.saved_value_cb = saved_value_cb - --content.default_value = default_value - content.callback = function () - return - end - content.saved_value_cb = function () - return - end - - return widget -end - - -local function create_simple_texture_widget(texture, texture_size, scenegraph_id, base_offset) - base_offset[2] = base_offset[2] - texture_size[2] - local definition = { - element = { - passes = { - { - texture_id = "texture_id", - style_id = "texture_id", - pass_type = "texture" - } - } - }, - content = { - texture_id = texture - }, - style = { - size = { - texture_size[1], - texture_size[2] - }, - offset = { - base_offset[1], - base_offset[2], - base_offset[3] - }, - texture_id = { - masked = true, -- GOD DAMN IT THIS IS THE FUCKING REASON! - color = { - 255, - 255, - 255, - 255 - }, - offset = { - base_offset[1], - base_offset[2], - base_offset[3] - }, - size = { - texture_size[1], - texture_size[2] - } - } - }, - scenegraph_id = scenegraph_id - } - - return UIWidget.init(definition) -end - -local function build_image(element, scenegraph_id, base_offset) - local widget = create_simple_texture_widget(element.image, element.image_size, scenegraph_id, base_offset) - local content = widget.content - content.callback = function () - return - end - content.saved_value_cb = function () - return - end - content.disabled = true - - return widget -end - -local settings_list_definition = { - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "checkbox" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "header" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "header" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - }, - { - image = "stance_bar_blue", - image_size = {1194, 60}, - callback = "cb_mouse_look_invert_y", - widget_type = "image" - } -} - - - --- ██████╗██╗ █████╗ ███████╗███████╗ ---██╔════╝██║ ██╔══██╗██╔════╝██╔════╝ ---██║ ██║ ███████║███████╗███████╗ ---██║ ██║ ██╔══██║╚════██║╚════██║ ---╚██████╗███████╗██║ ██║███████║███████║ --- ╚═════╝╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝ - - - - -VMFOptionsView = class(VMFOptionsView) -VMFOptionsView.init = function (self, ingame_ui_context) - - self.current_setting_list_offset_y = 0 -- [int] - self.max_setting_list_offset_y = nil -- [int] - self.setting_list_mask_size_y = nil -- [int] - self.scroll_step = 10 -- [int] - - self.menu_widgets = nil -- [table] - self.settings_list_widgets = nil -- [table] - - -- get necessary things for rendering - self.ui_renderer = ingame_ui_context.ui_renderer - self.render_settings = {snap_pixel_positions = true} - self.ingame_ui = ingame_ui_context.ingame_ui - - -- create input service - local input_manager = ingame_ui_context.input_manager - input_manager:create_input_service("vmf_options_menu", "IngameMenuKeymaps", "IngameMenuFilters") - input_manager:map_device_to_service("vmf_options_menu", "keyboard") - input_manager:map_device_to_service("vmf_options_menu", "mouse") - input_manager:map_device_to_service("vmf_options_menu", "gamepad") - self.input_manager = input_manager - - -- wwise_world is used for making sounds (for opening menu, closing menu etc) - local world = ingame_ui_context.world_manager:world("music_world") - self.wwise_world = Managers.world:wwise_world(world) - - self:create_ui_elements() -end - - -VMFOptionsView.create_ui_elements = function (self) - - self.menu_widgets = {} - - for name, definition in pairs(menu_widgets_definition) do - self.menu_widgets[name] = UIWidget.init(definition) - end - - self.settings_list_widgets = self:build_settings_list(settings_list_definition) - - self.ui_scenegraph = UISceneGraph.init_scenegraph(scenegraph_definition) - - self.setting_list_mask_size_y = self.ui_scenegraph.sg_settings_list_mask.size[2] - - self:calculate_scrollbar_size() -end - - -VMFOptionsView.build_settings_list = function (self, setting_list_widgets_definition) - - --local scenegraph_definition = definitions.scenegraph_definition - local scenegraph_id = "sg_settings_list" - local scenegraph_id_start = "sg_settings_list_start" - local list_size_y = 0 - local widgets = {} - - for i, definition in ipairs(setting_list_widgets_definition) do - - local element = definition - local base_offset = {0, -list_size_y, 0} - local widget = nil - local size_y = 0 - local widget_type = element.widget_type - - --if widget_type == "drop_down" then - -- widget = self.build_drop_down_widget(self, element, scenegraph_id_start, base_offset) - --elseif widget_type == "slider" then - -- widget = self.build_slider_widget(self, element, scenegraph_id_start, base_offset) - if widget_type == "checkbox" then - widget = build_checkbox_widget(element, scenegraph_id_start, base_offset) - --elseif widget_type == "stepper" then - -- widget = self.build_stepper_widget(self, element, scenegraph_id_start, base_offset) - --elseif widget_type == "keybind" then - -- widget = self.build_keybind_widget(self, element, scenegraph_id_start, base_offset) - elseif widget_type == "image" then - widget = build_image(element, scenegraph_id_start, base_offset) - elseif widget_type == "header" then - widget = build_header_widget(element, scenegraph_id_start, base_offset) - --elseif widget_type == "gamepad_layout" then - -- widget = self.build_gamepad_layout(self, element, scenegraph_id_start, base_offset) - -- self.gamepad_layout_widget = widget - -- local using_left_handed_option = assigned(self.changed_user_settings.gamepad_left_handed, Application.user_setting("gamepad_left_handed")) - - -- self.update_gamepad_layout_widget(self, DefaultGamepadLayoutKeymaps, using_left_handed_option) - --elseif widget_type == "empty" then - -- size_y = element.size_y - --else - -- error("[OptionsView] Unsupported widget type") - end - - if widget then - local name = element.callback - size_y = widget.style.size[2] - widget.type = widget_type - widget.name = name - end - - list_size_y = list_size_y + size_y - - if widget then - if element.name then - widget.name = element.name - end - - table.insert(widgets, widget) - end - end - - local mask_size = scenegraph_definition.sg_settings_list_mask.size - local size_x = mask_size[1] - - scenegraph_definition[scenegraph_id] = { - size = {size_x, list_size_y}, - position = {0, 0, -1}, -- changed -1 to 100. nothing changed. seems like it doesn't matter - offset = {0, 0, 0}, - - vertical_alignment = "top", - horizontal_alignment = "center", - - parent = "sg_settings_list_mask" - } - - scenegraph_definition[scenegraph_id_start] = { - size = {1, 1}, - position = {3, 0, 10}, - - vertical_alignment = "top", - horizontal_alignment = "left", - - parent = scenegraph_id - } - - local scrollbar = false - local max_offset_y = 0 - - if mask_size[2] < list_size_y then - scrollbar = true - max_offset_y = list_size_y - mask_size[2] - end - - self.max_setting_list_offset_y = max_offset_y - self.settings_list_size_y = list_size_y - - local widget_list = { - scenegraph_id = scenegraph_id, - scenegraph_id_start = scenegraph_id_start, - scrollbar = scrollbar, - max_offset_y = max_offset_y, - widgets = widgets - } - - return widget_list -end - - -local temp_pos_table = { - x = 0, - y = 0 -} -VMFOptionsView.update_settings_list = function (self, settings_list, ui_renderer, ui_scenegraph, input_service, dt) - - --self.update_scrollbar(self, settings_list, ui_scenegraph) - - - -- instead of self.update_scrollbar: - local scenegraph = ui_scenegraph[settings_list.scenegraph_id] - scenegraph.offset[2] = self.current_setting_list_offset_y - ------------------------------------ - - local scenegraph_id_start = settings_list.scenegraph_id_start - local list_position = UISceneGraph.get_world_position(ui_scenegraph, scenegraph_id_start) - local mask_pos = Vector3.deprecated_copy(UISceneGraph.get_world_position(ui_scenegraph, "sg_settings_list_mask")) - local mask_size = UISceneGraph.get_size(ui_scenegraph, "sg_settings_list_mask") - --local selected_widget = self.selected_widget - - for i, widget in ipairs(settings_list.widgets) do - - local style = widget.style - local widget_name = widget.name - local size = style.size - local offset = style.offset - temp_pos_table.x = list_position[1] + offset[1] - temp_pos_table.y = list_position[2] + offset[2] - local lower_visible = math.point_is_inside_2d_box(temp_pos_table, mask_pos, mask_size) - temp_pos_table.y = temp_pos_table.y + size[2]/2 - local middle_visible = math.point_is_inside_2d_box(temp_pos_table, mask_pos, mask_size) - temp_pos_table.y = temp_pos_table.y + size[2]/2 - local top_visible = math.point_is_inside_2d_box(temp_pos_table, mask_pos, mask_size) - local visible = lower_visible or top_visible - widget.content.visible = visible - - UIRenderer.draw_widget(ui_renderer, widget) - end -end - ---@TODO: refactor --- 'ignore_mousewheel_scroll' - 'true' if user is changing the scrollbar in the meantime -VMFOptionsView.update_mouse_scroll_input = function (self, ignore_mousewheel_scroll) - local widget_content = self.menu_widgets["mousewheel_scroll_area"].content - - local mouse_scroll_value = widget_content.internal_scroll_value - - if mouse_scroll_value ~= 0 then - - local new_offset = self.current_setting_list_offset_y + mouse_scroll_value * self.scroll_step - - self.current_setting_list_offset_y = math.clamp(new_offset, 0, self.max_setting_list_offset_y) - - widget_content.internal_scroll_value = 0 - - self:set_scrollbar_value() - end -end - --- @TODO: refactor -VMFOptionsView.set_scrollbar_value = function (self) - - local widget_content = self.menu_widgets["scrollbar"].content - - local percentage = self.current_setting_list_offset_y / self.max_setting_list_offset_y - - widget_content.scroll_bar_info.value = percentage - widget_content.scroll_bar_info.old_value = percentage -end - --- @TODO: refactor - -VMFOptionsView.calculate_scrollbar_size = function (self) - - local widget_content = self.menu_widgets["scrollbar"].content - - local percentage = self.setting_list_mask_size_y / self.settings_list_size_y - - widget_content.scroll_bar_info.bar_height_percentage = percentage -end - --- if scrollbar was moved, change offset_y -VMFOptionsView.update_scrollbar = function (self) - local scrollbar_info = self.menu_widgets["scrollbar"].content.scroll_bar_info - local value = scrollbar_info.value - local old_value = scrollbar_info.old_value - - if value ~= old_value then - self.current_setting_list_offset_y = self.max_setting_list_offset_y * value - scrollbar_info.old_value = value - end - - return -end - - -VMFOptionsView.update = function (self, dt) - if self.suspended then - return - end - - self:update_scrollbar() - - self:update_mouse_scroll_input(false) - - self.draw_widgets(self, dt) - - - - local input_manager = self.input_manager - local input_service = input_manager:get_service("vmf_options_menu") - if input_service.get(input_service, "toggle_menu") then - --self.ingame_ui:transition_with_fade("ingame_menu") - self.ingame_ui:handle_transition("exit_menu") - end - - return -end - -VMFOptionsView.draw_widgets = function (self, dt) - local ui_renderer = self.ui_renderer - local ui_scenegraph = self.ui_scenegraph - local input_manager = self.input_manager - local input_service = input_manager.get_service(input_manager, "vmf_options_menu") - - UIRenderer.begin_pass(ui_renderer, ui_scenegraph, input_service, dt, nil, self.render_settings) - - local menu_widgets = self.menu_widgets - - for _, widget in pairs(menu_widgets) do - UIRenderer.draw_widget(ui_renderer, widget) - end - - self:update_settings_list(self.settings_list_widgets, ui_renderer, ui_scenegraph, input_service, dt) - - - - UIRenderer.end_pass(ui_renderer) - - return -end - -VMFOptionsView.input_service = function (self) - return self.input_manager:get_service("vmf_options_menu") -end - -VMFOptionsView.on_enter = function (self) - - local input_manager = self.input_manager - - input_manager.block_device_except_service(input_manager, "vmf_options_menu", "keyboard", 1) - input_manager.block_device_except_service(input_manager, "vmf_options_menu", "mouse", 1) - input_manager.block_device_except_service(input_manager, "vmf_options_menu", "gamepad", 1) - - - - WwiseWorld.trigger_event(self.wwise_world, "Play_hud_map_open") - - self.menu_active = true - return -end - -VMFOptionsView.on_exit = function (self) - - WwiseWorld.trigger_event(self.wwise_world, "Play_hud_map_close") - - self.exiting = nil - self.menu_active = nil - - return -end - -VMFOptionsView.exit = function (self, return_to_game) - - local exit_transition = (return_to_game and "exit_menu") or "ingame_menu" - - self.ingame_ui:transition_with_fade(exit_transition) - - self.exiting = true - - return -end - - --- i'm not really sure if suspend and unsuspend are needed: --- --- StateInGameRunning.gm_event_end_conditions_met -> --- IngameUI.suspend_active_view -> --- XXXXXXX.suspend -VMFOptionsView.suspend = function (self) - self.suspended = true - - self.input_manager:device_unblock_all_services("keyboard", 1) - self.input_manager:device_unblock_all_services("mouse", 1) - self.input_manager:device_unblock_all_services("gamepad", 1) - - return -end -VMFOptionsView.unsuspend = function (self) - self.suspended = nil - - self.input_manager:block_device_except_service("vmf_options_menu", "keyboard", 1) - self.input_manager:block_device_except_service("vmf_options_menu", "mouse", 1) - self.input_manager:block_device_except_service("vmf_options_menu", "gamepad", 1) - - return -end - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -mod:hook("IngameUI.update", function(func, self, dt, t, disable_ingame_ui, end_of_level_ui) - func(self, dt, t, disable_ingame_ui, end_of_level_ui) - - local end_screen_active = self.end_screen_active(self) - local gdc_build = Development.parameter("gdc") - local input_service = self.input_manager:get_service("ingame_menu") - - if not self.pending_transition(self) and not end_screen_active and not self.menu_active and not self.leave_game and not self.return_to_title_screen and not gdc_build and not self.popup_join_lobby_handler.visible and input_service.get(input_service, "open_vmf_options", true) then - self.handle_transition(self, "vmf_options_view_force") - --mod:echo("F10") - --MOOD_BLACKBOARD.menu = true - end ---mod:echo("F10") -end) ---mod:echo("F10") - -IngameMenuKeymaps.win32.open_vmf_options = { - "keyboard", - "f4", - "pressed" - } - - -local view_data = { - view_name = "vmf_options_view", - view_settings = { - init_view_function = function (ingame_ui_context) - return VMFOptionsView:new(ingame_ui_context) - end, - active = { - inn = true, - ingame = false - }, - blocked_transitions = { - inn = {}, - ingame = { - vmf_options_view = true, - vmf_options_view_force = true - } - }, - hotkey_mapping = { --@TODO: find out what the hell is this -> 'IngameUI.handle_menu_hotkeys' (only in inn -> useless) - --view = "inventory_view", - --error_message = "matchmaking_ready_interaction_message_inventory", - --in_transition = "inventory_view_force", --opening from hotkey - --in_transition_menu = "inventory_view" -- opening from esc menu - }, - hotkey_name = "open_vmf_options", - hotkey = { - "keyboard", - "f9", - "pressed" - }, - transition_fade = false - }, - view_transitions = { - - vmf_options_view = function (self) - self.current_view = "vmf_options_view" - - return - end, - - vmf_options_view_force = function (self) - ShowCursorStack.push() - - self.current_view = "vmf_options_view" - - self.views[self.current_view].exit_to_game = true -- why? - return - end - } -} - -mod:register_new_view(view_data) - - -local ingame_ui_exists, ingame_ui = pcall(function () return Managers.player.network_manager.matchmaking_manager.matchmaking_ui.ingame_ui end) -if ingame_ui_exists then - ingame_ui.handle_transition(ingame_ui, "leave_group") -end - - ---[[ -mod:hook("OptionsView.update", function(func, self, dt) - func(self, dt) - --self.scroll_field_widget.style.edge_fade_bottom_id.color = {0,0,0,0} - self.scroll_field_widget.style.edge_fade_bottom_id.color = {0,0,0,0} - self.ui_scenegraph["list_mask"].size[2] = 850 -end) - - -mod:hook("InputManager.change_keybinding", function(func, self, keybinding_table_name, keybinding_table_key, keymap_name, new_button_index, new_device_type, new_state_type) - mod:echo("keybinding_table_name: " .. keybinding_table_name) - mod:echo("keybinding_table_key: " .. keybinding_table_key) - mod:echo("keymap_name: " .. keymap_name) - mod:echo("new_button_index: " .. new_button_index) - mod:echo("new_device_type: " .. new_device_type) - mod:echo("new_state_type: " .. new_state_type) - - local keymaps_data = self.keymaps_data(self, keybinding_table_name) - - --table.dump(keymaps_data, "keymaps_data", 2) - - func(self, keybinding_table_name, keybinding_table_key, keymap_name, new_button_index, new_device_type, new_state_type) -end)]] \ No newline at end of file diff --git a/vmf_source/scripts/mods/vmf/vmf_loader.lua b/vmf_source/scripts/mods/vmf/vmf_loader.lua index 1a15b63..33e7724 100644 --- a/vmf_source/scripts/mods/vmf/vmf_loader.lua +++ b/vmf_source/scripts/mods/vmf/vmf_loader.lua @@ -5,6 +5,7 @@ return { dofile("scripts/mods/vmf/modules/dev_console") dofile("scripts/mods/vmf/modules/mods") + dofile("scripts/mods/vmf/modules/debug") dofile("scripts/mods/vmf/modules/hooks") dofile("scripts/mods/vmf/modules/chat") dofile("scripts/mods/vmf/modules/settings")