Added new dump_to_file method. A lot of small code changes.
This commit is contained in:
parent
9e8bb97493
commit
4000deb88f
10 changed files with 520 additions and 1582 deletions
|
@ -22,6 +22,7 @@ lua = [
|
||||||
"scripts/mods/vmf/vmf_loader"
|
"scripts/mods/vmf/vmf_loader"
|
||||||
"scripts/mods/vmf/modules/dev_console"
|
"scripts/mods/vmf/modules/dev_console"
|
||||||
"scripts/mods/vmf/modules/mods"
|
"scripts/mods/vmf/modules/mods"
|
||||||
|
"scripts/mods/vmf/modules/debug"
|
||||||
"scripts/mods/vmf/modules/hooks"
|
"scripts/mods/vmf/modules/hooks"
|
||||||
"scripts/mods/vmf/modules/chat"
|
"scripts/mods/vmf/modules/chat"
|
||||||
"scripts/mods/vmf/modules/settings"
|
"scripts/mods/vmf/modules/settings"
|
||||||
|
|
336
vmf_source/scripts/mods/vmf/modules/debug.lua
Normal file
336
vmf_source/scripts/mods/vmf/modules/debug.lua
Normal file
|
@ -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("</%s>", 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
|
|
@ -206,7 +206,7 @@ vmf:hook("IngameUI.destroy", function(func, self)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
vmf.check_custom_menus_close_keybinds = function(dt)
|
vmf.check_custom_menus_close_keybinds = function()
|
||||||
if ingame_ui then
|
if ingame_ui then
|
||||||
if views_settings[ingame_ui.current_view] then
|
if views_settings[ingame_ui.current_view] then
|
||||||
local opened_view_settings = views_settings[ingame_ui.current_view]
|
local opened_view_settings = views_settings[ingame_ui.current_view]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
--@TODO: maybe update_function_hook_chain() pass entry instead of name
|
|
||||||
local vmf = get_mod("VMF")
|
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 ############################################################################################
|
-- ##### Private functions ############################################################################################
|
||||||
|
@ -112,7 +111,6 @@ local function update_function_hook_chain(hooked_function_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert(loadstring(hooked_function_name .. " = HOOKED_FUNCTIONS[" .. hooked_function_entry_index .. "].exec_function"))()
|
assert(loadstring(hooked_function_name .. " = HOOKED_FUNCTIONS[" .. hooked_function_entry_index .. "].exec_function"))()
|
||||||
--table.dump(HOOKED_FUNCTIONS, "HOOKED_FUNCTIONS", 3)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ local function apply_keybinds()
|
||||||
optimized_keybinds = {}
|
optimized_keybinds = {}
|
||||||
|
|
||||||
for mod_name, mod_keybinds in pairs(raw_keybinds) do
|
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 action_name = keybind[1]
|
||||||
local primary_key = keybind[2][1]
|
local primary_key = keybind[2][1]
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ local options_widgets = {
|
||||||
mod:create_options(options_widgets, true, "Test", "Mod description")
|
mod:create_options(options_widgets, true, "Test", "Mod description")
|
||||||
|
|
||||||
-- chat_broadcast
|
-- chat_broadcast
|
||||||
mod.whatever = function(message)
|
mod.whatever = function()
|
||||||
mod:echo("whatever")
|
mod:echo("whatever")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -283,9 +283,7 @@ local menu_widgets_definition = {
|
||||||
{
|
{
|
||||||
pass_type = "scroll",
|
pass_type = "scroll",
|
||||||
-- the function is called only during scrolls
|
-- the function is called only during scrolls
|
||||||
scroll_function = function (ui_scenegraph, style, content, input_service, scroll_axis)
|
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
|
|
||||||
|
|
||||||
content.internal_scroll_value = content.internal_scroll_value - scroll_axis.y
|
content.internal_scroll_value = content.internal_scroll_value - scroll_axis.y
|
||||||
end
|
end
|
||||||
|
@ -530,7 +528,7 @@ local function create_header_widget(widget_definition, scenegraph_id)
|
||||||
{
|
{
|
||||||
pass_type = "local_offset",
|
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()
|
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",
|
pass_type = "border",
|
||||||
|
|
||||||
content_check_function = function (content, style)
|
content_check_function = function (content_, style)
|
||||||
if DEBUG_WIDGETS then
|
if DEBUG_WIDGETS then
|
||||||
style.thickness = 1
|
style.thickness = 1
|
||||||
end
|
end
|
||||||
|
@ -617,7 +615,7 @@ local function create_header_widget(widget_definition, scenegraph_id)
|
||||||
pass_type = "rect",
|
pass_type = "rect",
|
||||||
|
|
||||||
style_id = "debug_middle_line",
|
style_id = "debug_middle_line",
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -848,7 +846,7 @@ local function create_checkbox_widget(widget_definition, scenegraph_id)
|
||||||
{
|
{
|
||||||
pass_type = "local_offset",
|
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()
|
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",
|
pass_type = "rect",
|
||||||
|
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pass_type = "border",
|
pass_type = "border",
|
||||||
|
|
||||||
content_check_function = function (content, style)
|
content_check_function = function (content_, style)
|
||||||
if DEBUG_WIDGETS then
|
if DEBUG_WIDGETS then
|
||||||
style.thickness = 1
|
style.thickness = 1
|
||||||
end
|
end
|
||||||
|
@ -920,7 +918,7 @@ local function create_checkbox_widget(widget_definition, scenegraph_id)
|
||||||
pass_type = "rect",
|
pass_type = "rect",
|
||||||
|
|
||||||
style_id = "debug_middle_line",
|
style_id = "debug_middle_line",
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -933,8 +931,6 @@ local function create_checkbox_widget(widget_definition, scenegraph_id)
|
||||||
|
|
||||||
rect_masked_texture = "rect_masked",
|
rect_masked_texture = "rect_masked",
|
||||||
highlight_texture = "playerlist_hover",
|
highlight_texture = "playerlist_hover",
|
||||||
--background_texture = "common_widgets_background_lit",
|
|
||||||
rect_masked_texture = "rect_masked",
|
|
||||||
|
|
||||||
checkbox_hotspot = {},
|
checkbox_hotspot = {},
|
||||||
highlight_hotspot = {},
|
highlight_hotspot = {},
|
||||||
|
@ -1035,6 +1031,14 @@ local function create_checkbox_widget(widget_definition, scenegraph_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- ██████╗ ██████╗ ██████╗ ██╗ ██╗██████╗
|
||||||
|
-- ██╔════╝ ██╔══██╗██╔═══██╗██║ ██║██╔══██╗
|
||||||
|
-- ██║ ███╗██████╔╝██║ ██║██║ ██║██████╔╝
|
||||||
|
-- ██║ ██║██╔══██╗██║ ██║██║ ██║██╔═══╝
|
||||||
|
-- ╚██████╔╝██║ ██║╚██████╔╝╚██████╔╝██║
|
||||||
|
-- ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝
|
||||||
|
|
||||||
|
|
||||||
local function create_group_widget(widget_definition, scenegraph_id)
|
local function create_group_widget(widget_definition, scenegraph_id)
|
||||||
|
|
||||||
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
local widget_size = SETTINGS_LIST_REGULAR_WIDGET_SIZE
|
||||||
|
@ -1050,7 +1054,7 @@ local function create_group_widget(widget_definition, scenegraph_id)
|
||||||
pass_type = "texture",
|
pass_type = "texture",
|
||||||
|
|
||||||
style_id = "background",
|
style_id = "background",
|
||||||
texture_id = "background_texture",
|
texture_id = "rect_masked_texture",
|
||||||
|
|
||||||
content_check_function = function (content)
|
content_check_function = function (content)
|
||||||
return content.is_widget_collapsed
|
return content.is_widget_collapsed
|
||||||
|
@ -1081,7 +1085,7 @@ local function create_group_widget(widget_definition, scenegraph_id)
|
||||||
{
|
{
|
||||||
pass_type = "local_offset",
|
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()
|
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",
|
pass_type = "rect",
|
||||||
|
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pass_type = "border",
|
pass_type = "border",
|
||||||
|
|
||||||
content_check_function = function (content, style)
|
content_check_function = function (content_, style)
|
||||||
if DEBUG_WIDGETS then
|
if DEBUG_WIDGETS then
|
||||||
style.thickness = 1
|
style.thickness = 1
|
||||||
end
|
end
|
||||||
|
@ -1130,7 +1134,7 @@ local function create_group_widget(widget_definition, scenegraph_id)
|
||||||
pass_type = "rect",
|
pass_type = "rect",
|
||||||
|
|
||||||
style_id = "debug_middle_line",
|
style_id = "debug_middle_line",
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -1141,7 +1145,7 @@ local function create_group_widget(widget_definition, scenegraph_id)
|
||||||
is_widget_collapsed = widget_definition.is_widget_collapsed,
|
is_widget_collapsed = widget_definition.is_widget_collapsed,
|
||||||
|
|
||||||
highlight_texture = "playerlist_hover",
|
highlight_texture = "playerlist_hover",
|
||||||
background_texture = "common_widgets_background_lit",
|
rect_masked_texture = "rect_masked",
|
||||||
|
|
||||||
highlight_hotspot = {},
|
highlight_hotspot = {},
|
||||||
|
|
||||||
|
@ -1158,7 +1162,8 @@ local function create_group_widget(widget_definition, scenegraph_id)
|
||||||
-- VISUALS
|
-- VISUALS
|
||||||
background = {
|
background = {
|
||||||
size = {widget_size[1], widget_size[2] - 3},
|
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 = {
|
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)
|
text_color = Colors.get_color_table_with_alpha("white", 255)
|
||||||
},
|
},
|
||||||
|
|
||||||
-- HOTSPOTS
|
|
||||||
|
|
||||||
-- TOOLTIP
|
-- TOOLTIP
|
||||||
|
|
||||||
tooltip_text = {
|
tooltip_text = {
|
||||||
|
@ -1409,7 +1412,7 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra
|
||||||
{
|
{
|
||||||
pass_type = "local_offset",
|
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()
|
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
|
end
|
||||||
|
|
||||||
if content.dropdown_hotspot.on_release then
|
if content.dropdown_hotspot.on_release then
|
||||||
content.callback_change_dropdown_menu_visibility(content, style)
|
content.callback_change_dropdown_menu_visibility(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
if content.highlight_hotspot.on_release and not content.dropdown_hotspot.on_release then
|
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]
|
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
|
if content.is_widget_collapsed then
|
||||||
content.callback_hide_sub_widgets(content)
|
content.callback_hide_sub_widgets(content)
|
||||||
|
@ -1461,7 +1464,7 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra
|
||||||
|
|
||||||
text_id = "tooltip_text",
|
text_id = "tooltip_text",
|
||||||
style_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()
|
return content.tooltip_text and content.highlight_hotspot.is_hover and content.callback_is_cursor_inside_settings_list()
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
@ -1469,14 +1472,14 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra
|
||||||
{
|
{
|
||||||
pass_type = "rect",
|
pass_type = "rect",
|
||||||
|
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pass_type = "border",
|
pass_type = "border",
|
||||||
|
|
||||||
content_check_function = function (content, style)
|
content_check_function = function (content_, style)
|
||||||
if DEBUG_WIDGETS then
|
if DEBUG_WIDGETS then
|
||||||
style.thickness = 1
|
style.thickness = 1
|
||||||
end
|
end
|
||||||
|
@ -1488,7 +1491,7 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra
|
||||||
pass_type = "rect",
|
pass_type = "rect",
|
||||||
|
|
||||||
style_id = "debug_middle_line",
|
style_id = "debug_middle_line",
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
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 cursor = UIInverseScaleVectorToResolution(input_service.get(input_service, "cursor"))
|
||||||
local scenegraph_id = ui_content.scenegraph_id
|
local scenegraph_id = ui_content.scenegraph_id
|
||||||
local world_position = UISceneGraph.get_world_position(ui_scenegraph, 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 cursor_x = cursor[1]
|
||||||
local pos_start = world_position[1] + ui_style.offset[1]
|
local pos_start = world_position[1] + ui_style.offset[1]
|
||||||
local old_value = ui_content.internal_value
|
local old_value = ui_content.internal_value
|
||||||
local cursor_x_norm = cursor_x - pos_start
|
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
|
ui_content.internal_value = value
|
||||||
|
|
||||||
if old_value ~= value then
|
if old_value ~= value then
|
||||||
|
@ -1871,7 +1874,7 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap
|
||||||
{
|
{
|
||||||
pass_type = "local_offset",
|
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()
|
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
|
if content.dropdown_hotspot.on_release then
|
||||||
|
|
||||||
content.callback_change_numeric_menu_visibility(content, style)
|
content.callback_change_numeric_menu_visibility(content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1891,7 +1894,7 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap
|
||||||
|
|
||||||
local old_value = content.current_value
|
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 mod_name = content.mod_name
|
||||||
local setting_name = content.setting_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",
|
text_id = "tooltip_text",
|
||||||
style_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()
|
return content.tooltip_text and content.highlight_hotspot.is_hover and content.callback_is_cursor_inside_settings_list()
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
@ -1920,14 +1923,14 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap
|
||||||
{
|
{
|
||||||
pass_type = "rect",
|
pass_type = "rect",
|
||||||
|
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pass_type = "border",
|
pass_type = "border",
|
||||||
|
|
||||||
content_check_function = function (content, style)
|
content_check_function = function (content_, style)
|
||||||
if DEBUG_WIDGETS then
|
if DEBUG_WIDGETS then
|
||||||
style.thickness = 1
|
style.thickness = 1
|
||||||
end
|
end
|
||||||
|
@ -1939,7 +1942,7 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap
|
||||||
pass_type = "rect",
|
pass_type = "rect",
|
||||||
|
|
||||||
style_id = "debug_middle_line",
|
style_id = "debug_middle_line",
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -2158,7 +2161,7 @@ local function create_keybind_widget(widget_definition, scenegraph_id)
|
||||||
{
|
{
|
||||||
pass_type = "local_offset",
|
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()
|
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
|
end
|
||||||
|
|
||||||
if content.keybind_text_hotspot.on_release then
|
if content.keybind_text_hotspot.on_release then
|
||||||
content.callback_change_setting_keybind_state(content, style)
|
content.callback_change_setting_keybind_state(content)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if content.is_setting_keybind then
|
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)
|
content.callback_setting_changed(content.mod_name, content.setting_name, nil, content.keys)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -2199,7 +2202,7 @@ local function create_keybind_widget(widget_definition, scenegraph_id)
|
||||||
|
|
||||||
text_id = "tooltip_text",
|
text_id = "tooltip_text",
|
||||||
style_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()
|
return content.tooltip_text and content.highlight_hotspot.is_hover and content.callback_is_cursor_inside_settings_list()
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
@ -2207,14 +2210,14 @@ local function create_keybind_widget(widget_definition, scenegraph_id)
|
||||||
{
|
{
|
||||||
pass_type = "rect",
|
pass_type = "rect",
|
||||||
|
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pass_type = "border",
|
pass_type = "border",
|
||||||
|
|
||||||
content_check_function = function (content, style)
|
content_check_function = function (content_, style)
|
||||||
if DEBUG_WIDGETS then
|
if DEBUG_WIDGETS then
|
||||||
style.thickness = 1
|
style.thickness = 1
|
||||||
end
|
end
|
||||||
|
@ -2226,7 +2229,7 @@ local function create_keybind_widget(widget_definition, scenegraph_id)
|
||||||
pass_type = "rect",
|
pass_type = "rect",
|
||||||
|
|
||||||
style_id = "debug_middle_line",
|
style_id = "debug_middle_line",
|
||||||
content_check_function = function (content)
|
content_check_function = function ()
|
||||||
return DEBUG_WIDGETS
|
return DEBUG_WIDGETS
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -2450,7 +2453,6 @@ VMFOptionsView.initialize_settings_list_widgets = function (self)
|
||||||
for _, definition in ipairs(mod_settings_list_definitions) do
|
for _, definition in ipairs(mod_settings_list_definitions) do
|
||||||
|
|
||||||
local widget = nil
|
local widget = nil
|
||||||
local size_y = 0
|
|
||||||
local widget_type = definition.widget_type
|
local widget_type = definition.widget_type
|
||||||
|
|
||||||
if widget_type == "checkbox" then
|
if widget_type == "checkbox" then
|
||||||
|
@ -2874,7 +2876,7 @@ VMFOptionsView.callback_hide_sub_widgets = function (self, widget_content)
|
||||||
end
|
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
|
if not widget_content.is_setting_keybind then
|
||||||
self.input_manager:device_unblock_all_services("keyboard", 1)
|
self.input_manager:device_unblock_all_services("keyboard", 1)
|
||||||
|
@ -2903,7 +2905,7 @@ VMFOptionsView.callback_change_setting_keybind_state = function (self, widget_co
|
||||||
end
|
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
|
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)
|
get_mod(widget_content.mod_name):keybind(widget_content.setting_name, widget_content.action, widget_content.keys)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:callback_change_setting_keybind_state(widget_content, widget_style)
|
self:callback_change_setting_keybind_state(widget_content)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
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)
|
get_mod(widget_content.mod_name):keybind(widget_content.setting_name, widget_content.action, widget_content.keys)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:callback_change_setting_keybind_state(widget_content, widget_style)
|
self:callback_change_setting_keybind_state(widget_content)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -2995,7 +2997,7 @@ VMFOptionsView.callback_setting_keybind = function (self, widget_content, widget
|
||||||
end
|
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
|
if not widget_content.is_dropdown_menu_opened then
|
||||||
self.input_manager:device_unblock_all_services("keyboard", 1)
|
self.input_manager:device_unblock_all_services("keyboard", 1)
|
||||||
|
@ -3027,7 +3029,7 @@ VMFOptionsView.callback_change_dropdown_menu_visibility = function (self, widget
|
||||||
end
|
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 ui_renderer = self.ui_renderer
|
||||||
local scenegraph = self.ui_scenegraph_2nd_layer
|
local scenegraph = self.ui_scenegraph_2nd_layer
|
||||||
local parent_scenegraph_id = self.settings_list_scenegraph_id_start
|
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
|
for _, hotspot_content in pairs(widget_content.popup_menu_widget.content) do
|
||||||
if type(hotspot_content) == "table" and hotspot_content.on_release then
|
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_number = hotspot_content.num
|
||||||
widget_content.current_option_text = widget_content.options_texts[widget_content.current_option_number]
|
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 Left Mouse Button or Esc pressed
|
||||||
if Mouse.released(0) and not widget_content.wrong_mouse_on_release or Keyboard.released(27) then
|
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
|
end
|
||||||
|
|
||||||
widget_content.wrong_mouse_on_release = nil
|
widget_content.wrong_mouse_on_release = nil
|
||||||
end
|
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
|
if not widget_content.is_numeric_menu_opened then
|
||||||
self.input_manager:device_unblock_all_services("keyboard", 1)
|
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
|
if not min_text_has_dot then
|
||||||
min_text = min_text .. "."
|
min_text = min_text .. "."
|
||||||
|
|
||||||
for i = 1, decimals_number do
|
for _ = 1, decimals_number do
|
||||||
min_text = min_text .. "0"
|
min_text = min_text .. "0"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not max_text_has_dot then
|
if not max_text_has_dot then
|
||||||
max_text = max_text .. "."
|
max_text = max_text .. "."
|
||||||
|
|
||||||
for i = 1, decimals_number do
|
for _ = 1, decimals_number do
|
||||||
max_text = max_text .. "0"
|
max_text = max_text .. "0"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3135,7 +3137,7 @@ VMFOptionsView.callback_change_numeric_menu_visibility = function (self, widget_
|
||||||
end
|
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_content = widget_content.popup_menu_widget.content
|
||||||
local numeric_menu_text_style = widget_content.popup_menu_widget.style.new_value_text
|
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 ----------------
|
-- 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
|
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)
|
self:callback_change_numeric_menu_visibility(widget_content)
|
||||||
|
|
||||||
table.dump(numeric_menu_content.slider_hotspot, "WHATEVER", 1)
|
|
||||||
|
|
||||||
if new_value_number and new_value_number >= widget_content.range[1] and new_value_number <= widget_content.range[2] then
|
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
|
widget_content.current_value = new_value_number
|
||||||
|
@ -3310,7 +3310,7 @@ VMFOptionsView.callback_draw_numeric_menu = function (self, widget_content, widg
|
||||||
-- Esc pressed ---------------------------------------
|
-- Esc pressed ---------------------------------------
|
||||||
|
|
||||||
if Keyboard.released(27) then
|
if Keyboard.released(27) then
|
||||||
self:callback_change_numeric_menu_visibility(widget_content, widget_style)
|
self:callback_change_numeric_menu_visibility(widget_content)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Fix for closing menu when releasing LMB outside the hotspot
|
-- 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
|
if type(loaded_setting_value) == "boolean" then
|
||||||
widget_content.is_checkbox_checked = loaded_setting_value
|
widget_content.is_checkbox_checked = loaded_setting_value
|
||||||
else
|
else
|
||||||
if type(loaded_setting_value) ~= "nil" then
|
--if type(loaded_setting_value) ~= "nil" then
|
||||||
-- @TODO: warning: variable of wrong type in config
|
-- @TODO: warning: variable of wrong type in config
|
||||||
end
|
--end
|
||||||
|
|
||||||
widget_content.is_checkbox_checked = widget_content.default_value
|
widget_content.is_checkbox_checked = widget_content.default_value
|
||||||
get_mod(widget_content.mod_name):set(widget_content.setting_name, 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
|
end
|
||||||
|
|
||||||
if setting_not_found then
|
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
|
-- @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
|
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
|
for _, widget in ipairs(mod_widgets) do
|
||||||
if widget.content.is_widget_visible then
|
if widget.content.is_widget_visible then
|
||||||
local style = widget.style
|
local style = widget.style
|
||||||
local widget_name = widget.name
|
|
||||||
local size = style.size
|
local size = style.size
|
||||||
local offset = style.offset
|
local offset = style.offset
|
||||||
|
|
||||||
temp_pos_table.x = list_position[1] + offset[1]
|
temp_pos_table.x = list_position[1] + offset[1]
|
||||||
temp_pos_table.y = list_position[2] + offset[2] + widget.offset[2]
|
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)
|
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
|
temp_pos_table.y = temp_pos_table.y + size[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 top_visible = math.point_is_inside_2d_box(temp_pos_table, mask_pos, mask_size)
|
||||||
|
|
||||||
local visible = lower_visible or top_visible
|
local visible = lower_visible or top_visible
|
||||||
|
@ -3901,10 +3898,6 @@ end
|
||||||
-- ##### VMFMod #######################################################################################################
|
-- ##### VMFMod #######################################################################################################
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
|
|
||||||
local function check_widget_definition(mod, widget)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
VMFMod.create_options = function (self, widgets_definition, is_mod_toggable, readable_mod_name, mod_description)
|
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]
|
new_widget_definition.is_widget_collapsed = mod_collapsed_widgets[current_widget.setting_name]
|
||||||
end
|
end
|
||||||
|
|
||||||
check_widget_definition(self, new_widget_definition)
|
|
||||||
|
|
||||||
if type(self:get(current_widget.setting_name)) == "nil" then
|
if type(self:get(current_widget.setting_name)) == "nil" then
|
||||||
self:set(current_widget.setting_name, current_widget.default_value)
|
self:set(current_widget.setting_name, current_widget.default_value)
|
||||||
end
|
end
|
||||||
|
@ -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)
|
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
|
if ingame_ui_exists then
|
||||||
ingame_ui.handle_transition(ingame_ui, "leave_group")
|
ingame_ui.handle_transition(ingame_ui, "leave_group")
|
||||||
|
|
||||||
|
vmf:pcall(function()
|
||||||
|
|
||||||
|
print("AYYYYY" .. tostring(ingame_ui))
|
||||||
|
--vmf:dump(ingame_ui.views, "whatever", 1)
|
||||||
|
|
||||||
|
end)
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,6 +5,7 @@ return {
|
||||||
|
|
||||||
dofile("scripts/mods/vmf/modules/dev_console")
|
dofile("scripts/mods/vmf/modules/dev_console")
|
||||||
dofile("scripts/mods/vmf/modules/mods")
|
dofile("scripts/mods/vmf/modules/mods")
|
||||||
|
dofile("scripts/mods/vmf/modules/debug")
|
||||||
dofile("scripts/mods/vmf/modules/hooks")
|
dofile("scripts/mods/vmf/modules/hooks")
|
||||||
dofile("scripts/mods/vmf/modules/chat")
|
dofile("scripts/mods/vmf/modules/chat")
|
||||||
dofile("scripts/mods/vmf/modules/settings")
|
dofile("scripts/mods/vmf/modules/settings")
|
||||||
|
|
Loading…
Add table
Reference in a new issue