diff --git a/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua b/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua index b0c46ce..73d99a3 100644 --- a/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua +++ b/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua @@ -46,38 +46,38 @@ end -- ##### VMFMod ####################################################################################################### -- #################################################################################################################### -VMFMod.custom_textures = function (self, ...) +vmf.custom_textures = function (mod, ...) for i, texture_name in ipairs({...}) do if type(texture_name) == "string" then - if check_texture_availability(self, texture_name) then - _CUSTOM_NONE_ATLAS_TEXTURES[texture_name] = self:get_name() + if check_texture_availability(mod, texture_name) then + _CUSTOM_NONE_ATLAS_TEXTURES[texture_name] = mod:get_name() end else - self:error("(custom_textures): all arguments should have the string type, but the argument #%s is %s", i, type(texture_name)) + mod:error("(custom_textures): all arguments should have the string type, but the argument #%s is %s", i, type(texture_name)) end end end -VMFMod.custom_atlas = function (self, material_settings_file, material_name, masked_material_name, point_sample_material_name, +vmf.custom_atlas = function (mod, material_settings_file, material_name, masked_material_name, point_sample_material_name, masked_point_sample_material_name, saturated_material_name) - 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 + if vmf.check_wrong_argument_type(mod, "custom_atlas", "material_settings_file", material_settings_file, "string") or + vmf.check_wrong_argument_type(mod, "custom_atlas", "material_name", material_name, "string", "nil") or + vmf.check_wrong_argument_type(mod, "custom_atlas", "masked_material_name", masked_material_name, "string", "nil") or + vmf.check_wrong_argument_type(mod, "custom_atlas", "point_sample_material_name", point_sample_material_name, "string", "nil") or + vmf.check_wrong_argument_type(mod, "custom_atlas", "masked_point_sample_material_name", masked_point_sample_material_name, "string", "nil") or + vmf.check_wrong_argument_type(mod, "custom_atlas", "saturated_material_name", saturated_material_name, "string", "nil") then return end - local material_settings = self:dofile(material_settings_file) + local material_settings = mod:dofile(material_settings_file) if material_settings then - local mod_name = self:get_name() + local mod_name = mod:get_name() for texture_name, texture_settings in pairs(material_settings) do - if check_texture_availability(self, texture_name) then + if check_texture_availability(mod, texture_name) then texture_settings.mod_name = mod_name texture_settings.material_name = material_name @@ -91,19 +91,19 @@ VMFMod.custom_atlas = function (self, material_settings_file, material_name, mas end else - self:error("(custom_atlas): can't load 'material_settings'") + mod:error("(custom_atlas): can't load 'material_settings'") end end -VMFMod.inject_materials = function (self, ui_renderer_creator, ...) +vmf.inject_materials = function (mod, ui_renderer_creator, ...) - if vmf.check_wrong_argument_type(self, "inject_materials", "ui_renderer_creator", ui_renderer_creator, "string") then + if vmf.check_wrong_argument_type(mod, "inject_materials", "ui_renderer_creator", ui_renderer_creator, "string") then return end local injected_materials_list = _INJECTED_MATERIALS[ui_renderer_creator] or {} - local can_inject = true + local can_inject for i, new_injected_material in ipairs({...}) do if type(new_injected_material) == "string" then @@ -122,7 +122,7 @@ VMFMod.inject_materials = function (self, ui_renderer_creator, ...) end else - self:error("(inject_materials): all arguments should have the string type, but the argument #%s is %s", i + 1, type(new_injected_material)) + mod:error("(inject_materials): all arguments should have the string type, but the argument #%s is %s", i + 1, type(new_injected_material)) end end diff --git a/vmf/scripts/mods/vmf/modules/mods.lua b/vmf/scripts/mods/vmf/modules/mods.lua index 8407447..4a08ef6 100644 --- a/vmf/scripts/mods/vmf/modules/mods.lua +++ b/vmf/scripts/mods/vmf/modules/mods.lua @@ -163,7 +163,6 @@ function VMFMod:pcall(...) return vmf.xpcall(self, "(pcall)", ...) end - function VMFMod:dofile(file_path) local _, return_values = pack_pcall(vmf.xpcall_dofile(self, "(dofile)", file_path)) return unpack(return_values, 1, return_values.n) @@ -237,6 +236,30 @@ function vmf.initialize_mod_data(mod, mod_data) if mod_data.options_widgets or (mod_data.is_togglable and not mod_data.is_mutator) then vmf.create_options(mod, mod_data.options_widgets) end + + if type(mod_data.custom_gui_textures) == "table" then + local custom_gui_textures = mod_data.custom_gui_textures + + if type(custom_gui_textures.textures) == "table" then + vmf.custom_textures(mod, unpack(custom_gui_textures.textures)) + end + + if type(custom_gui_textures.atlases) == "table" then + for _, atlas_settings in ipairs(custom_gui_textures.atlases) do + if type(atlas_settings) == "table" then + vmf.custom_atlas(mod, unpack(atlas_settings)) + end + end + end + + if type(custom_gui_textures.ui_renderer_injections) == "table" then + for _, injection_settings in ipairs(custom_gui_textures.ui_renderer_injections) do + if type(injection_settings) == "table" then + vmf.inject_materials(mod, unpack(injection_settings)) + end + end + end + end end -- VARIABLES 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 1583af0..c2d48b7 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 @@ -17,9 +17,9 @@ local vmf = get_mod("VMF") --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.custom_atlas(vmf, "materials/vmf/vmf_atlas", "vmf_atlas", "vmf_atlas_masked") -vmf:inject_materials("ingame_ui", "materials/vmf/vmf_atlas") +vmf.inject_materials(vmf, "ingame_ui", "materials/vmf/vmf_atlas") -- #################################################################################################################### -- ##### MENU WIDGETS DEFINITIONS #####################################################################################