Swithing from lots of textures to single atlas

This commit is contained in:
Unknown 2018-03-26 18:56:47 +03:00
parent 6886e74fc9
commit 92005e0340
30 changed files with 116 additions and 231 deletions

View file

@ -1 +0,0 @@
*.psd

Binary file not shown.

View file

@ -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
}
}

Binary file not shown.

Binary file not shown.

View file

@ -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
}
}

Binary file not shown.

View file

@ -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
}
}

Binary file not shown.

View file

@ -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
}
}

Binary file not shown.

View file

@ -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
}
}

BIN
vmf/gui/vmf/vmf_atlas.dds Normal file

Binary file not shown.

View file

@ -1,6 +1,6 @@
common = { common = {
input = { input = {
filename = "gui/vmf/header_fav_icon" filename = "gui/vmf/vmf_atlas"
} }
output = { output = {
apply_processing = true apply_processing = true

View file

@ -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 = {
}
}

View file

@ -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 = {
}
}

View file

@ -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 = {
}
}

View file

@ -1,14 +0,0 @@
mutator_button = {
material_contexts = {
surface_material = ""
}
shader = "gui_gradient:DIFFUSE_MAP"
textures = {
diffuse_map = "gui/vmf/mutator_button"
}
variables = {
}
}

View file

@ -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 = {
}
}

View file

@ -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 = {
}
}

View file

@ -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, },
},
}

View file

@ -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 = {
}
}

View file

@ -22,4 +22,6 @@ lua = [
"scripts/mods/vmf/modules/ui/options/*" "scripts/mods/vmf/modules/ui/options/*"
"scripts/mods/vmf/modules/ui/chat/*" "scripts/mods/vmf/modules/ui/chat/*"
"scripts/mods/vmf/modules/ui/mutators/*" "scripts/mods/vmf/modules/ui/mutators/*"
"materials/vmf/vmf_atlas"
] ]

View file

@ -7,31 +7,8 @@ local vmf = get_mod("VMF")
not sure about UI scaling not sure about UI scaling
]] ]]
-- @TODO: move 'vmf.check_wrong_argument_type' to somewhere else
local _COMMANDS = {} 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 ####################################################################################################### -- ##### VMFMod #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
@ -45,6 +22,12 @@ VMFMod.command = function (self, command_name, command_description, command_func
return return
end 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() command_name = command_name:lower()
if _COMMANDS[command_name] and _COMMANDS[command_name].mod ~= self then if _COMMANDS[command_name] and _COMMANDS[command_name].mod ~= self then

View file

@ -175,6 +175,22 @@ end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### 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 vmf.unsent_chat_messages = _UNSENT_CHAT_MESSAGES

View file

@ -171,13 +171,8 @@ VMFMod.network_register = function (self, rpc_name, rpc_function)
return return
end end
if type(rpc_name) ~= "string" then if vmf.check_wrong_argument_type(self, "network_register", "rpc_name", rpc_name, "string") or
self:error("(network_register): rpc_name should be the string, not %s", type(rpc_name)) vmf.check_wrong_argument_type(self, "network_register", "rpc_function", rpc_function, "function") then
return
end
if type(rpc_function) ~= "function" then
self:error("(network_register): rpc_function should be the function, not %s", type(rpc_name))
return return
end end

View file

@ -62,14 +62,12 @@ end
VMFMod.custom_atlas = function (self, material_settings_file, material_name, masked_material_name, point_sample_material_name, 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) masked_point_sample_material_name, saturated_material_name)
-- @TODO: this check is legit... is it? if vmf.check_wrong_argument_type(self, "custom_atlas", "material_settings_file", material_settings_file, "string") or
if type(material_settings_file) ~= "string" or vmf.check_wrong_argument_type(self, "custom_atlas", "material_name", material_name, "string", "nil") or
type(material_name) ~= "string" or vmf.check_wrong_argument_type(self, "custom_atlas", "masked_material_name", masked_material_name, "string", "nil") or
type(masked_material_name) ~= "string" or vmf.check_wrong_argument_type(self, "custom_atlas", "point_sample_material_name", point_sample_material_name, "string", "nil") or
type(point_sample_material_name) ~= "string" or vmf.check_wrong_argument_type(self, "custom_atlas", "masked_point_sample_material_name", masked_point_sample_material_name, "string", "nil") or
type(masked_point_sample_material_name) ~= "string" or vmf.check_wrong_argument_type(self, "custom_atlas", "saturated_material_name", saturated_material_name, "string", "nil") then
type(saturated_material_name) ~= "string" then
self:error("(custom_atlas): all the arguments have to have the string type")
return return
end end
@ -99,8 +97,7 @@ end
VMFMod.inject_materials = function (self, ui_renderer_creator, ...) VMFMod.inject_materials = function (self, ui_renderer_creator, ...)
if type(ui_renderer_creator) ~= "string" then if vmf.check_wrong_argument_type(self, "inject_materials", "ui_renderer_creator", ui_renderer_creator, "string") then
self:error("(inject_materials): argument 'ui_renderer_creator' should have the string type, not %s", type(ui_renderer_creator))
return return
end end
@ -160,7 +157,6 @@ end
-- ##### Hooks ######################################################################################################## -- ##### Hooks ########################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
local ui_renderer_creating = false
vmf:hook("UIRenderer.create", function(func, world, ...) vmf:hook("UIRenderer.create", function(func, world, ...)
-- FINDING OUT WHO CREATED UI_RENDERER -- FINDING OUT WHO CREATED UI_RENDERER

View file

@ -25,6 +25,10 @@ local _CHAT_HISTORY_SAVE_COMMANDS_ONLY = false
-- ##### Local functions ############################################################################################## -- ##### 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() local function clean_chat_history()
_CHAT_HISTORY = {} _CHAT_HISTORY = {}
_CHAT_HISTORY_INDEX = 0 _CHAT_HISTORY_INDEX = 0
@ -38,7 +42,7 @@ vmf:hook("WorldManager.create_world", function(func, self, name, ...)
local world = func(self, name, ...) local world = func(self, name, ...)
if name == "top_ingame_view" then if name == "top_ingame_view" then
_COMMANDS_LIST_GUI_DRAW = dofile("scripts/mods/vmf/modules/ui/chat/commands_list_gui") initialize_drawing_function()
end end
return world return world
@ -271,6 +275,5 @@ if _CHAT_HISTORY_SAVE then
end end
if Managers.world:has_world("top_ingame_view") then if Managers.world:has_world("top_ingame_view") then
-- @TODO: move this to local function? initialize_drawing_function()
_COMMANDS_LIST_GUI_DRAW = dofile("scripts/mods/vmf/modules/ui/chat/commands_list_gui")
end end

View file

@ -3,8 +3,8 @@
local manager = get_mod("vmf_mutator_manager") local manager = get_mod("vmf_mutator_manager")
local mutators = manager.mutators local mutators = manager.mutators
manager:custom_textures("mutator_button", "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") --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") local definitions = manager:dofile("scripts/mods/vmf/modules/ui/mutators/mutator_gui_definitions")

View file

@ -16,9 +16,10 @@
]] ]]
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:inject_materials("ingame_ui", "materials/vmf/header_fav_icon", "materials/vmf/header_fav_icon_lit", vmf:custom_atlas("materials/vmf/vmf_atlas", "vmf_atlas", "vmf_atlas_masked")
"materials/vmf/header_fav_arrow", "materials/vmf/search_bar_icon")
vmf:inject_materials("ingame_ui", "materials/vmf/vmf_atlas")
-- #################################################################################################################### -- ####################################################################################################################
-- ##### MENU WIDGETS DEFINITIONS ##################################################################################### -- ##### MENU WIDGETS DEFINITIONS #####################################################################################
@ -660,13 +661,15 @@ local function create_header_widget(widget_definition, scenegraph_id)
fav_icon = { fav_icon = {
size = {30, 30}, size = {30, 30},
offset = {15, offset_y + 25, 3} offset = {15, offset_y + 25, 3},
masked = true
}, },
fav_arrow_up = { fav_arrow_up = {
size = {20, 20}, size = {20, 20},
offset = {20, offset_y + 57, 3}, offset = {20, offset_y + 57, 3},
color = {90, 255, 255, 255} color = {90, 255, 255, 255},
masked = true
}, },
fav_arrow_down = { fav_arrow_down = {
@ -674,7 +677,8 @@ local function create_header_widget(widget_definition, scenegraph_id)
offset = {20, offset_y + 3, 3}, offset = {20, offset_y + 3, 3},
angle = math.pi, angle = math.pi,
pivot = {10, 10}, pivot = {10, 10},
color = {90, 255, 255, 255} color = {90, 255, 255, 255},
masked = true
}, },
text = { text = {