diff --git a/vmf/gui/vmf/.gitignore b/vmf/gui/vmf/.gitignore deleted file mode 100644 index fcd3efb..0000000 --- a/vmf/gui/vmf/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.psd diff --git a/vmf/gui/vmf/header_fav_arrow.dds b/vmf/gui/vmf/header_fav_arrow.dds deleted file mode 100644 index 437ac74..0000000 Binary files a/vmf/gui/vmf/header_fav_arrow.dds and /dev/null differ diff --git a/vmf/gui/vmf/header_fav_arrow.texture b/vmf/gui/vmf/header_fav_arrow.texture deleted file mode 100644 index b2d574d..0000000 --- a/vmf/gui/vmf/header_fav_arrow.texture +++ /dev/null @@ -1,18 +0,0 @@ -common = { - input = { - filename = "gui/vmf/header_fav_arrow" - } - output = { - apply_processing = true - correct_gamma = true - cut_alpha_threshold = 0.5 - enable_cut_alpha_threshold = false - format = "A8R8G8B8" - mipmap_filter = "kaiser" - mipmap_filter_wrap_mode = "mirror" - mipmap_keep_original = false - mipmap_num_largest_steps_to_discard = 0 - mipmap_num_smallest_steps_to_discard = 0 - srgb = true - } -} \ No newline at end of file diff --git a/vmf/gui/vmf/header_fav_icon.dds b/vmf/gui/vmf/header_fav_icon.dds deleted file mode 100644 index 88e96e8..0000000 Binary files a/vmf/gui/vmf/header_fav_icon.dds and /dev/null differ diff --git a/vmf/gui/vmf/header_fav_icon_lit.dds b/vmf/gui/vmf/header_fav_icon_lit.dds deleted file mode 100644 index c8efa11..0000000 Binary files a/vmf/gui/vmf/header_fav_icon_lit.dds and /dev/null differ diff --git a/vmf/gui/vmf/header_fav_icon_lit.texture b/vmf/gui/vmf/header_fav_icon_lit.texture deleted file mode 100644 index 0d41c7c..0000000 --- a/vmf/gui/vmf/header_fav_icon_lit.texture +++ /dev/null @@ -1,18 +0,0 @@ -common = { - input = { - filename = "gui/vmf/header_fav_icon_lit" - } - output = { - apply_processing = true - correct_gamma = true - cut_alpha_threshold = 0.5 - enable_cut_alpha_threshold = false - format = "A8R8G8B8" - mipmap_filter = "kaiser" - mipmap_filter_wrap_mode = "mirror" - mipmap_keep_original = false - mipmap_num_largest_steps_to_discard = 0 - mipmap_num_smallest_steps_to_discard = 0 - srgb = true - } -} \ No newline at end of file diff --git a/vmf/gui/vmf/mutator_button.dds b/vmf/gui/vmf/mutator_button.dds deleted file mode 100644 index 311c80e..0000000 Binary files a/vmf/gui/vmf/mutator_button.dds and /dev/null differ diff --git a/vmf/gui/vmf/mutator_button.texture b/vmf/gui/vmf/mutator_button.texture deleted file mode 100644 index d9e804f..0000000 --- a/vmf/gui/vmf/mutator_button.texture +++ /dev/null @@ -1,17 +0,0 @@ -common = { - input = { - filename = "gui/vmf/mutator_button" - } - output = { - apply_processing = true - correct_gamma = true - cut_alpha_threshold = 0.5 - enable_cut_alpha_threshold = false - format = "A8R8G8B8" - mipmap_filter = "kaiser" - mipmap_filter_wrap_mode = "mirror" - mipmap_keep_original = false - mipmap_num_largest_steps_to_discard = 0 - mipmap_num_smallest_steps_to_discard = 0 - } -} \ No newline at end of file diff --git a/vmf/gui/vmf/mutator_button_hover.dds b/vmf/gui/vmf/mutator_button_hover.dds deleted file mode 100644 index 72a600b..0000000 Binary files a/vmf/gui/vmf/mutator_button_hover.dds and /dev/null differ diff --git a/vmf/gui/vmf/mutator_button_hover.texture b/vmf/gui/vmf/mutator_button_hover.texture deleted file mode 100644 index e1e5379..0000000 --- a/vmf/gui/vmf/mutator_button_hover.texture +++ /dev/null @@ -1,17 +0,0 @@ -common = { - input = { - filename = "gui/vmf/mutator_button_hover" - } - output = { - apply_processing = true - correct_gamma = true - cut_alpha_threshold = 0.5 - enable_cut_alpha_threshold = false - format = "A8R8G8B8" - mipmap_filter = "kaiser" - mipmap_filter_wrap_mode = "mirror" - mipmap_keep_original = false - mipmap_num_largest_steps_to_discard = 0 - mipmap_num_smallest_steps_to_discard = 0 - } -} \ No newline at end of file diff --git a/vmf/gui/vmf/search_bar_icon.dds b/vmf/gui/vmf/search_bar_icon.dds deleted file mode 100644 index 5d55033..0000000 Binary files a/vmf/gui/vmf/search_bar_icon.dds and /dev/null differ diff --git a/vmf/gui/vmf/search_bar_icon.texture b/vmf/gui/vmf/search_bar_icon.texture deleted file mode 100644 index 7286b31..0000000 --- a/vmf/gui/vmf/search_bar_icon.texture +++ /dev/null @@ -1,18 +0,0 @@ -common = { - input = { - filename = "gui/vmf/search_bar_icon" - } - output = { - apply_processing = true - correct_gamma = true - cut_alpha_threshold = 0.5 - enable_cut_alpha_threshold = false - format = "A8R8G8B8" - mipmap_filter = "kaiser" - mipmap_filter_wrap_mode = "mirror" - mipmap_keep_original = false - mipmap_num_largest_steps_to_discard = 0 - mipmap_num_smallest_steps_to_discard = 0 - srgb = true - } -} \ No newline at end of file diff --git a/vmf/gui/vmf/vmf_atlas.dds b/vmf/gui/vmf/vmf_atlas.dds new file mode 100644 index 0000000..a085acd Binary files /dev/null and b/vmf/gui/vmf/vmf_atlas.dds differ diff --git a/vmf/gui/vmf/header_fav_icon.texture b/vmf/gui/vmf/vmf_atlas.texture similarity index 90% rename from vmf/gui/vmf/header_fav_icon.texture rename to vmf/gui/vmf/vmf_atlas.texture index 1d40431..05701d6 100644 --- a/vmf/gui/vmf/header_fav_icon.texture +++ b/vmf/gui/vmf/vmf_atlas.texture @@ -1,6 +1,6 @@ common = { input = { - filename = "gui/vmf/header_fav_icon" + filename = "gui/vmf/vmf_atlas" } output = { apply_processing = true diff --git a/vmf/materials/vmf/header_fav_arrow.material b/vmf/materials/vmf/header_fav_arrow.material deleted file mode 100644 index 9f78214..0000000 --- a/vmf/materials/vmf/header_fav_arrow.material +++ /dev/null @@ -1,14 +0,0 @@ -header_fav_arrow = { - material_contexts = { - surface_material = "" - } - - shader = "gui_gradient:DIFFUSE_MAP:MASKED" - - textures = { - diffuse_map = "gui/vmf/header_fav_arrow" - } - - variables = { - } -} diff --git a/vmf/materials/vmf/header_fav_icon.material b/vmf/materials/vmf/header_fav_icon.material deleted file mode 100644 index 548d034..0000000 --- a/vmf/materials/vmf/header_fav_icon.material +++ /dev/null @@ -1,14 +0,0 @@ -header_fav_icon = { - material_contexts = { - surface_material = "" - } - - shader = "gui_gradient:DIFFUSE_MAP:MASKED" - - textures = { - diffuse_map = "gui/vmf/header_fav_icon" - } - - variables = { - } -} diff --git a/vmf/materials/vmf/header_fav_icon_lit.material b/vmf/materials/vmf/header_fav_icon_lit.material deleted file mode 100644 index e193268..0000000 --- a/vmf/materials/vmf/header_fav_icon_lit.material +++ /dev/null @@ -1,14 +0,0 @@ -header_fav_icon_lit = { - material_contexts = { - surface_material = "" - } - - shader = "gui_gradient:DIFFUSE_MAP:MASKED" - - textures = { - diffuse_map = "gui/vmf/header_fav_icon_lit" - } - - variables = { - } -} diff --git a/vmf/materials/vmf/mutator_button.material b/vmf/materials/vmf/mutator_button.material deleted file mode 100644 index 788a6c9..0000000 --- a/vmf/materials/vmf/mutator_button.material +++ /dev/null @@ -1,14 +0,0 @@ -mutator_button = { - material_contexts = { - surface_material = "" - } - - shader = "gui_gradient:DIFFUSE_MAP" - - textures = { - diffuse_map = "gui/vmf/mutator_button" - } - - variables = { - } -} diff --git a/vmf/materials/vmf/mutator_button_hover.material b/vmf/materials/vmf/mutator_button_hover.material deleted file mode 100644 index 5b04ff1..0000000 --- a/vmf/materials/vmf/mutator_button_hover.material +++ /dev/null @@ -1,14 +0,0 @@ -mutator_button_hover = { - material_contexts = { - surface_material = "" - } - - shader = "gui_gradient:DIFFUSE_MAP" - - textures = { - diffuse_map = "gui/vmf/mutator_button_hover" - } - - variables = { - } -} diff --git a/vmf/materials/vmf/search_bar_icon.material b/vmf/materials/vmf/search_bar_icon.material deleted file mode 100644 index 69158d7..0000000 --- a/vmf/materials/vmf/search_bar_icon.material +++ /dev/null @@ -1,14 +0,0 @@ -search_bar_icon = { - material_contexts = { - surface_material = "" - } - - shader = "gui_gradient:DIFFUSE_MAP" - - textures = { - diffuse_map = "gui/vmf/search_bar_icon" - } - - variables = { - } -} diff --git a/vmf/materials/vmf/vmf_atlas.lua b/vmf/materials/vmf/vmf_atlas.lua new file mode 100644 index 0000000..f5eab19 --- /dev/null +++ b/vmf/materials/vmf/vmf_atlas.lua @@ -0,0 +1,33 @@ +-- Image Source: ../test +return { + header_fav_arrow = { + size = { 48, 48, }, + uv00 = { 0.187500, 0.687500, }, + uv11 = { 0.375000, 0.875000, }, + }, + header_fav_icon = { + size = { 48, 48, }, + uv00 = { 0.187500, 0.500000, }, + uv11 = { 0.375000, 0.687500, }, + }, + search_bar_icon = { + size = { 48, 48, }, + uv00 = { 0.000000, 0.687500, }, + uv11 = { 0.187500, 0.875000, }, + }, + header_fav_icon_lit = { + size = { 48, 48, }, + uv00 = { 0.000000, 0.500000, }, + uv11 = { 0.187500, 0.687500, }, + }, + mutator_button = { + size = { 128, 128, }, + uv00 = { 0.500000, 0.000000, }, + uv11 = { 1.000000, 0.500000, }, + }, + mutator_button_hover = { + size = { 128, 128, }, + uv00 = { 0.000000, 0.000000, }, + uv11 = { 0.500000, 0.500000, }, + }, +} diff --git a/vmf/materials/vmf/vmf_atlas.material b/vmf/materials/vmf/vmf_atlas.material new file mode 100644 index 0000000..1339923 --- /dev/null +++ b/vmf/materials/vmf/vmf_atlas.material @@ -0,0 +1,26 @@ +vmf_atlas = { + material_contexts = { + surface_material = "" + } + + shader = "gui:DIFFUSE_MAP" + + textures = { + diffuse_map = "gui/vmf/vmf_atlas" + } + + variables = { + } +} + +vmf_atlas_masked = { + material_contexts = { + surface_material = "" + } + shader = "gui_gradient:DIFFUSE_MAP:MASKED" + textures = { + diffuse_map = "gui/vmf/vmf_atlas" + } + variables = { + } +} diff --git a/vmf/resource_packages/vmf.package b/vmf/resource_packages/vmf.package index a45f905..f963a6e 100644 --- a/vmf/resource_packages/vmf.package +++ b/vmf/resource_packages/vmf.package @@ -22,4 +22,6 @@ lua = [ "scripts/mods/vmf/modules/ui/options/*" "scripts/mods/vmf/modules/ui/chat/*" "scripts/mods/vmf/modules/ui/mutators/*" + + "materials/vmf/vmf_atlas" ] \ No newline at end of file diff --git a/vmf/scripts/mods/vmf/modules/core/commands.lua b/vmf/scripts/mods/vmf/modules/core/commands.lua index 8d38aa1..da6db18 100644 --- a/vmf/scripts/mods/vmf/modules/core/commands.lua +++ b/vmf/scripts/mods/vmf/modules/core/commands.lua @@ -7,31 +7,8 @@ local vmf = get_mod("VMF") not sure about UI scaling ]] - --- @TODO: move 'vmf.check_wrong_argument_type' to somewhere else - local _COMMANDS = {} --- #################################################################################################################### --- ##### Local functions ############################################################################################## --- #################################################################################################################### - -vmf.check_wrong_argument_type = function(mod, vmf_function_name, argument_name, argument, ...) - - local allowed_types = {...} - local argument_type = type(argument) - - for _, allowed_type in ipairs(allowed_types) do - if allowed_type == argument_type then - return false - end - end - - mod:error("(%s): argument '%s' should have the '%s' type, not '%s'", vmf_function_name, argument_name, table.concat(allowed_types, "/"), argument_type) - - return true -end - -- #################################################################################################################### -- ##### VMFMod ####################################################################################################### -- #################################################################################################################### @@ -45,6 +22,12 @@ VMFMod.command = function (self, command_name, command_description, command_func return end + if string.find(command_name, " ") then + + self:error("(command): command name can't contain spaces: [%s]", command_name) + return + end + command_name = command_name:lower() if _COMMANDS[command_name] and _COMMANDS[command_name].mod ~= self then diff --git a/vmf/scripts/mods/vmf/modules/core/core_functions.lua b/vmf/scripts/mods/vmf/modules/core/core_functions.lua index c5b2834..2f047bc 100644 --- a/vmf/scripts/mods/vmf/modules/core/core_functions.lua +++ b/vmf/scripts/mods/vmf/modules/core/core_functions.lua @@ -175,6 +175,22 @@ end -- #################################################################################################################### -- ##### VMF internal functions and variables ######################################################################### -- #################################################################################################################### +-- @TODO: maybe it doesn't belong in here +vmf.check_wrong_argument_type = function(mod, vmf_function_name, argument_name, argument, ...) + + local allowed_types = {...} + local argument_type = type(argument) + + for _, allowed_type in ipairs(allowed_types) do + if allowed_type == argument_type then + return false + end + end + + mod:error("(%s): argument '%s' should have the '%s' type, not '%s'", vmf_function_name, argument_name, table.concat(allowed_types, "/"), argument_type) + + return true +end vmf.unsent_chat_messages = _UNSENT_CHAT_MESSAGES diff --git a/vmf/scripts/mods/vmf/modules/core/network.lua b/vmf/scripts/mods/vmf/modules/core/network.lua index 0a4a73d..ed6c9fb 100644 --- a/vmf/scripts/mods/vmf/modules/core/network.lua +++ b/vmf/scripts/mods/vmf/modules/core/network.lua @@ -171,13 +171,8 @@ VMFMod.network_register = function (self, rpc_name, rpc_function) return end - if type(rpc_name) ~= "string" then - self:error("(network_register): rpc_name should be the string, not %s", type(rpc_name)) - return - end - - if type(rpc_function) ~= "function" then - self:error("(network_register): rpc_function should be the function, not %s", type(rpc_name)) + if vmf.check_wrong_argument_type(self, "network_register", "rpc_name", rpc_name, "string") or + vmf.check_wrong_argument_type(self, "network_register", "rpc_function", rpc_function, "function") then return end diff --git a/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua b/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua index 287d3c8..6159e15 100644 --- a/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua +++ b/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua @@ -62,14 +62,12 @@ end VMFMod.custom_atlas = function (self, material_settings_file, material_name, masked_material_name, point_sample_material_name, masked_point_sample_material_name, saturated_material_name) - -- @TODO: this check is legit... is it? - if type(material_settings_file) ~= "string" or - type(material_name) ~= "string" or - type(masked_material_name) ~= "string" or - type(point_sample_material_name) ~= "string" or - type(masked_point_sample_material_name) ~= "string" or - type(saturated_material_name) ~= "string" then - self:error("(custom_atlas): all the arguments have to have the string type") + if vmf.check_wrong_argument_type(self, "custom_atlas", "material_settings_file", material_settings_file, "string") or + vmf.check_wrong_argument_type(self, "custom_atlas", "material_name", material_name, "string", "nil") or + vmf.check_wrong_argument_type(self, "custom_atlas", "masked_material_name", masked_material_name, "string", "nil") or + vmf.check_wrong_argument_type(self, "custom_atlas", "point_sample_material_name", point_sample_material_name, "string", "nil") or + vmf.check_wrong_argument_type(self, "custom_atlas", "masked_point_sample_material_name", masked_point_sample_material_name, "string", "nil") or + vmf.check_wrong_argument_type(self, "custom_atlas", "saturated_material_name", saturated_material_name, "string", "nil") then return end @@ -99,8 +97,7 @@ end VMFMod.inject_materials = function (self, ui_renderer_creator, ...) - if type(ui_renderer_creator) ~= "string" then - self:error("(inject_materials): argument 'ui_renderer_creator' should have the string type, not %s", type(ui_renderer_creator)) + if vmf.check_wrong_argument_type(self, "inject_materials", "ui_renderer_creator", ui_renderer_creator, "string") then return end @@ -160,7 +157,6 @@ end -- ##### Hooks ######################################################################################################## -- #################################################################################################################### -local ui_renderer_creating = false vmf:hook("UIRenderer.create", function(func, world, ...) -- FINDING OUT WHO CREATED UI_RENDERER diff --git a/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua b/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua index 7603939..b330dfe 100644 --- a/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua +++ b/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua @@ -25,6 +25,10 @@ local _CHAT_HISTORY_SAVE_COMMANDS_ONLY = false -- ##### Local functions ############################################################################################## -- #################################################################################################################### +local function initialize_drawing_function() + _COMMANDS_LIST_GUI_DRAW = dofile("scripts/mods/vmf/modules/ui/chat/commands_list_gui") +end + local function clean_chat_history() _CHAT_HISTORY = {} _CHAT_HISTORY_INDEX = 0 @@ -38,7 +42,7 @@ vmf:hook("WorldManager.create_world", function(func, self, name, ...) local world = func(self, name, ...) if name == "top_ingame_view" then - _COMMANDS_LIST_GUI_DRAW = dofile("scripts/mods/vmf/modules/ui/chat/commands_list_gui") + initialize_drawing_function() end return world @@ -232,11 +236,11 @@ end) vmf.load_chat_history_settings = function(clean_chat_history_) - _CHAT_HISTORY_ENABLED = vmf:get("chat_history_enable") - _CHAT_HISTORY_SAVE = vmf:get("chat_history_save") - _CHAT_HISTORY_MAX = vmf:get("chat_history_buffer_size") - _CHAT_HISTORY_REMOVE_DUPS_LAST = vmf:get("chat_history_remove_dups") - _CHAT_HISTORY_REMOVE_DUPS_ALL = vmf:get("chat_history_remove_dups") and (vmf:get("chat_history_remove_dups_mode") == "all") + _CHAT_HISTORY_ENABLED = vmf:get("chat_history_enable") + _CHAT_HISTORY_SAVE = vmf:get("chat_history_save") + _CHAT_HISTORY_MAX = vmf:get("chat_history_buffer_size") + _CHAT_HISTORY_REMOVE_DUPS_LAST = vmf:get("chat_history_remove_dups") + _CHAT_HISTORY_REMOVE_DUPS_ALL = vmf:get("chat_history_remove_dups") and (vmf:get("chat_history_remove_dups_mode") == "all") _CHAT_HISTORY_SAVE_COMMANDS_ONLY = vmf:get("chat_history_commands_only") if _CHAT_HISTORY_ENABLED then @@ -271,6 +275,5 @@ if _CHAT_HISTORY_SAVE then end if Managers.world:has_world("top_ingame_view") then - -- @TODO: move this to local function? - _COMMANDS_LIST_GUI_DRAW = dofile("scripts/mods/vmf/modules/ui/chat/commands_list_gui") + initialize_drawing_function() end \ No newline at end of file diff --git a/vmf/scripts/mods/vmf/modules/ui/mutators/mutator_gui.lua b/vmf/scripts/mods/vmf/modules/ui/mutators/mutator_gui.lua index 12ab12c..7dd8ad8 100644 --- a/vmf/scripts/mods/vmf/modules/ui/mutators/mutator_gui.lua +++ b/vmf/scripts/mods/vmf/modules/ui/mutators/mutator_gui.lua @@ -3,8 +3,8 @@ local manager = get_mod("vmf_mutator_manager") local mutators = manager.mutators -manager:custom_textures("mutator_button", "mutator_button_hover") -manager:inject_materials("ingame_ui", "materials/vmf/mutator_button", "materials/vmf/mutator_button_hover") +--manager:custom_textures("mutator_button", "mutator_button_hover") +--manager:inject_materials("ingame_ui", "materials/vmf/mutator_button", "materials/vmf/mutator_button_hover") local definitions = manager:dofile("scripts/mods/vmf/modules/ui/mutators/mutator_gui_definitions") diff --git a/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua b/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua index e513374..647bf86 100644 --- a/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua +++ b/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua @@ -16,9 +16,10 @@ ]] local vmf = get_mod("VMF") -vmf:custom_textures("header_fav_icon", "header_fav_icon_lit", "header_fav_arrow", "search_bar_icon") -vmf:inject_materials("ingame_ui", "materials/vmf/header_fav_icon", "materials/vmf/header_fav_icon_lit", - "materials/vmf/header_fav_arrow", "materials/vmf/search_bar_icon") +--vmf:custom_textures("header_fav_icon", "header_fav_icon_lit", "header_fav_arrow", "search_bar_icon") +vmf:custom_atlas("materials/vmf/vmf_atlas", "vmf_atlas", "vmf_atlas_masked") + +vmf:inject_materials("ingame_ui", "materials/vmf/vmf_atlas") -- #################################################################################################################### -- ##### MENU WIDGETS DEFINITIONS ##################################################################################### @@ -660,13 +661,15 @@ local function create_header_widget(widget_definition, scenegraph_id) fav_icon = { size = {30, 30}, - offset = {15, offset_y + 25, 3} + offset = {15, offset_y + 25, 3}, + masked = true }, fav_arrow_up = { size = {20, 20}, offset = {20, offset_y + 57, 3}, - color = {90, 255, 255, 255} + color = {90, 255, 255, 255}, + masked = true }, fav_arrow_down = { @@ -674,7 +677,8 @@ local function create_header_widget(widget_definition, scenegraph_id) offset = {20, offset_y + 3, 3}, angle = math.pi, pivot = {10, 10}, - color = {90, 255, 255, 255} + color = {90, 255, 255, 255}, + masked = true }, text = {