Moved custom gui textures information to mod_data
This commit is contained in:
parent
1fbe207930
commit
accbf12f2d
3 changed files with 45 additions and 22 deletions
|
@ -46,38 +46,38 @@ end
|
||||||
-- ##### VMFMod #######################################################################################################
|
-- ##### VMFMod #######################################################################################################
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
|
|
||||||
VMFMod.custom_textures = function (self, ...)
|
vmf.custom_textures = function (mod, ...)
|
||||||
|
|
||||||
for i, texture_name in ipairs({...}) do
|
for i, texture_name in ipairs({...}) do
|
||||||
if type(texture_name) == "string" then
|
if type(texture_name) == "string" then
|
||||||
if check_texture_availability(self, texture_name) then
|
if check_texture_availability(mod, texture_name) then
|
||||||
_CUSTOM_NONE_ATLAS_TEXTURES[texture_name] = self:get_name()
|
_CUSTOM_NONE_ATLAS_TEXTURES[texture_name] = mod:get_name()
|
||||||
end
|
end
|
||||||
else
|
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
|
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)
|
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
|
if vmf.check_wrong_argument_type(mod, "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(mod, "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(mod, "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(mod, "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(mod, "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
|
vmf.check_wrong_argument_type(mod, "custom_atlas", "saturated_material_name", saturated_material_name, "string", "nil") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local material_settings = self:dofile(material_settings_file)
|
local material_settings = mod:dofile(material_settings_file)
|
||||||
if material_settings then
|
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
|
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.mod_name = mod_name
|
||||||
|
|
||||||
texture_settings.material_name = material_name
|
texture_settings.material_name = material_name
|
||||||
|
@ -91,19 +91,19 @@ VMFMod.custom_atlas = function (self, material_settings_file, material_name, mas
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
self:error("(custom_atlas): can't load 'material_settings'")
|
mod:error("(custom_atlas): can't load 'material_settings'")
|
||||||
end
|
end
|
||||||
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local injected_materials_list = _INJECTED_MATERIALS[ui_renderer_creator] or {}
|
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
|
for i, new_injected_material in ipairs({...}) do
|
||||||
if type(new_injected_material) == "string" then
|
if type(new_injected_material) == "string" then
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ VMFMod.inject_materials = function (self, ui_renderer_creator, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,6 @@ function VMFMod:pcall(...)
|
||||||
return vmf.xpcall(self, "(pcall)", ...)
|
return vmf.xpcall(self, "(pcall)", ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function VMFMod:dofile(file_path)
|
function VMFMod:dofile(file_path)
|
||||||
local _, return_values = pack_pcall(vmf.xpcall_dofile(self, "(dofile)", file_path))
|
local _, return_values = pack_pcall(vmf.xpcall_dofile(self, "(dofile)", file_path))
|
||||||
return unpack(return_values, 1, return_values.n)
|
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
|
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)
|
vmf.create_options(mod, mod_data.options_widgets)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
-- VARIABLES
|
-- VARIABLES
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
local vmf = get_mod("VMF")
|
local vmf = get_mod("VMF")
|
||||||
|
|
||||||
--vmf:custom_textures("header_fav_icon", "header_fav_icon_lit", "header_fav_arrow", "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.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 #####################################################################################
|
-- ##### MENU WIDGETS DEFINITIONS #####################################################################################
|
||||||
|
|
Loading…
Add table
Reference in a new issue