Added New Mods and Profiles Folders

This is a complete rebuild of the modpack, with all new mods and updates for 1.5.3 of Anomaly.
This commit is contained in:
2025-01-14 05:07:53 -05:00
parent 85c665b107
commit 376b4b9689
21217 changed files with 546254 additions and 0 deletions
@@ -0,0 +1,69 @@
ini_icons = nil
x_offset, y_offset, seperator = 0
function on_game_start()
rax_icon_layers.register("dyneq_armortype", dyneq_armortype)
rax_icon_layers.register("dyneq_armorfaction", dyneq_armorfaction)
ini_icons = ini_file("plugins\\eq_icons_settings.ltx")
x_offset = ini_icons:r_float("positioning", "x_offset")
y_offset = ini_icons:r_float("positioning", "y_offset")
seperator = ini_icons:r_float("positioning", "seperator")
end
armor_kinds = {
["o_light"] = true,
["o_medium"] = true,
["o_heavy"] = true,
["o_sci"] = true,
}
function dyneq_armortype(cell, obj, sec)
if not z_item_icon_info.settings.armor_info.show_helmet_type and SYS_GetParam(0, sec, "kind", "") == "o_helmet" then return end
if not z_item_icon_info.settings.armor_info.show_armor_type and armor_kinds[SYS_GetParam(0, sec, "kind", "")] then return end
local texture_table = get_repair_to_texture_table(sec)
if not texture_table then return end
local texture_width = texture_table[2]
local texture_height = texture_table[3]
local axis = utils_xml.get_item_axis(sec)
return {texture = texture_table[1], x = (axis.w - texture_width + x_offset), y = (axis.h - texture_height + y_offset), w = texture_width, h = texture_height}
end
function dyneq_armorfaction(cell, obj, sec)
if not z_item_icon_info.settings.armor_info.show_patch then return end
local texture_table = get_comm_to_texture(sec)
if not texture_table then return end
repair_type_h = 0
if z_item_icon_info.settings.armor_info.show_armor_type then
local repair_table = get_repair_to_texture_table(sec)
if repair_table then
repair_type_h = repair_table[3] + seperator
end
end
local texture_width = texture_table[2]
local texture_height = texture_table[3]
local axis = utils_xml.get_item_axis(sec)
return {texture = texture_table[1], x = (axis.w - texture_width + x_offset), y = (axis.h - texture_height + y_offset - repair_type_h), w = texture_width, h = texture_height}
end
function get_repair_to_texture_table(sec)
local repair_type = SYS_GetParam(0, sec, "repair_type")
local tx_table = repair_type and ini_icons:r_string_ex("repair_to_texture", repair_type) or ini_icons:r_string_ex("section_to_texture", sec)
if not tx_table then return end
tx_table = str_explode(tx_table, ",")
return tx_table
end
function get_comm_to_texture(sec)
local comm = SYS_GetParam(0, sec, "community")
local tx_table = comm and ini_icons:r_string_ex("comm_to_texture", comm)
if not tx_table then return end
tx_table = str_explode(tx_table, ",")
return tx_table
end
@@ -0,0 +1,87 @@
op = { id= "item_icon_info" ,gr={
{ id = "cond_text", sh=true, gr={
{ id= "title", type= "slide", link= "ui_options_slider_player", text="ui_mcm_item_icon_info_cond_text_title", size= {512,50}, spacing= 20 },
{id = "enable", type = "check", val = 1, def=true},
{id = "enable_equipped", type = "check", val = 1, def=true},
--[[ {id = "show_attach", type = "check", val = 1, def=true}, ]]
{id = "hide_bar", type = "check", val = 1, def=true},
{id = "hide_bg", type = "check", val = 1, def=false},
{id = "alt_artefact_pos", type = "list", val = 2, content={ {0,"alt_art_pos_lower_left"} , {1,"alt_art_pos_lower_right"}, {2,"alt_art_pos_top_right"}}, def=2},
{id = "padding", type = "track", val = 2, min=0, max=3, step=0.25, def = 1},
}},
{ id = "part_dots", sh=true, gr={
{ id= "title", type= "slide", link= "ui_options_slider_player", text="ui_mcm_item_icon_info_part_dots_title", size= {512,50}, spacing= 20 },
{id = "enable", type = "check", val = 1, def=true},
{id = "show_on_equipped", type = "check", val = 1, def=true},
{id = "show_on_wpn", type = "check", val = 1, def=true},
{id = "show_on_armor", type = "check", val = 1, def=true},
{id = "size_mult", type = "track", val = 2, min=0.5, max=3, step=0.1, def = 1},
{id = "separator_width", type = "track", val = 2, min=0.5, max=3, step=0.1, def = 1},
{id = "position", type = "list", val = 2, content={ {0,"part_dot_right"} , {1,"part_dot_top"}, {2,"part_dot_top_pistol"}}, def=2},
{id = "wpo_mode", type = "check", val = 1, def=true},
{id = "wpo_green", type = "track", val = 2, min=0, max=100, step=1, def = 85},
{id = "wpo_yellow", type = "track", val = 2, min=0, max=100, step=1, def = 60},
{id = "wpo_orange", type = "track", val = 2, min=0, max=100, step=1, def = 20},
}},
{ id = "ammo_name", sh=true, gr={
{ id= "title", type= "slide", link= "ui_options_slider_player", text="ui_mcm_item_icon_info_ammo_name_title", size= {512,50}, spacing= 20 },
{id = "enable", type = "check", val = 1, def=true},
{id = "bad_color", type = "check", val = 1, def=false},
{id = "show_expl", type = "check", val = 1, def=true},
{id = "expl_bad_color", type = "check", val = 1, def=false},
{id = "padding", type = "track", val = 2, min=0, max=3, step=0.25, def = 1},
}},
{ id = "recipe_text", sh=true, gr={
{ id= "title", type= "slide", link= "ui_options_slider_player", text="ui_mcm_item_icon_info_recipe_text_title", size= {512,50}, spacing= 20 },
{id = "enable", type = "check", val = 1, def=true},
{id = "show_on_pda", type = "check", val = 1, def=false},
{id = "padding", type = "track", val = 2, min=0, max=3, step=0.25, def = 1},
}},
{ id = "mag_info", sh=true, gr={
{ id= "title", type= "slide", link= "ui_options_slider_player", text="ui_mcm_item_icon_info_mag_info_title", size= {512,50}, spacing= 20 },
{id = "enable", type = "check", val = 1, def=true},
{id = "show_ammo_name", type = "check", val = 1, def=true},
{id = "show_ammo_count", type = "check", val = 1, def=true},
{id = "hide_bar", type = "check", val = 1, def=true},
{id = "padding", type = "track", val = 2, min=0, max=3, step=0.25, def = 1},
}},
{ id = "money_text", sh=true, gr={
{ id= "title", type= "slide", link= "ui_options_slider_player", text="ui_mcm_item_icon_info_money_text_title", size= {512,50}, spacing= 20 },
{id = "enable", type = "check", val = 1, def=true},
{id = "hide_bg", type = "check", val = 1, def=false},
{id = "padding", type = "track", val = 2, min=0, max=3, step=0.25, def = 1},
}},
{ id = "armor_info", sh=true, gr={
{ id= "title", type= "slide", link= "ui_options_slider_player", text="ui_mcm_item_icon_info_armor_info_title", size= {512,50}, spacing= 20 },
{id = "show_patch", type = "check", val = 1, def=true},
{id = "show_armor_type", type = "check", val = 1, def=true},
{id = "show_helmet_type", type = "check", val = 1, def=true},
}},
{ id = "wpn_info", sh=true, gr={
{ id= "title", type= "slide", link= "ui_options_slider_player", text="ui_mcm_item_icon_info_wpn_info_title", size= {512,50}, spacing= 20 },
{id = "show_gun_repair_type", type = "check", val = 1, def=true},
{id = "show_wpn_name", type = "check", val = 1, def=true},
{id = "main_slots_only", type = "check", val = 1, def=true},
{id = "show_grenade_name", type = "check", val = 1, def=true},
{id = "show_melee", type = "check", val = 1, def=false},
}},
{ id = "wpn_scaling", precondition = {function() return z_scale_equipped_guns end}, output ="ui_mcm_item_icon_info_wpn_scaling_not_installed", sh=true, gr={
{ id= "title", type= "slide", link= "ui_options_slider_player", text="ui_mcm_item_icon_info_wpn_scaling_title", size= {512,50}, spacing= 20 },
{id = "enable_equip_vert_scale", type = "check", val = 1, def = true},
{id = "enable_equip_hor_scale", type = "check", val = 1, def = true},
{id = "equip_vert_padding", type = "track", val = 2, min=-16, max=32, step=1, def = 6},
{id = "equip_hor_padding", type = "track", val = 2, min=-16, max=32, step=1, def = 0},
{id = "enable_inv_scaling", type = "check", val = 1, def = true},
--{id = "sort_on_sil", type = "check", val = 1, def = true},
}},
}
}
function on_mcm_load()
return op
end
@@ -0,0 +1,191 @@
--[[
Dynamic Icon Layers for anomaly inventory. Used by SortingPlus and other mods by RavenAscendant.
4JUL2021
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
Author: RavenAscendant
--]]
function pr(txt, ...)
-- printf("RAXPH: "..txt, ...)
end
local iconor = aaa_rax_icon_override_mcm and true or false
local icon_override = iconor and aaa_rax_icon_override_mcm.icon_override
local ratio = utils_xml.screen_ratio()
local icon_layers = {}
--functor will be passed cell, obj and section
--functor should return table with the same info as an item section icon layer. {icon_layer = "tch_upgr_ico", icon_layer_x = 0, icon_layer_y = 1, icon_layer_scale = 0.75}
--functor can alternitivly return texture name/file, cords and dimesions {texture = "xxy.dds", x = 0, y = 0, w = 10, h = 10}
function register(name, functor)
if not name then return end -- need all three params and field really needs to be a string
if not icon_layers[name] then
icon_layers[name] = {}
end
table.insert(icon_layers[name], functor)
end
function refresh(mode) --safer way to refresh inventory, mode == 1 refreshes sorting.
local inventory = GetActorMenu()
inventory:UnHighlight_All()
if mode == 1 then
local sort = nil
for i=1,#inventory.sort_btn do
if inventory.sort_btn[i]:GetCheck() then
sort = i
end
end
inventory:On_Sort(sort or 1,false)
else
inventory:UpdateItems()
end
end
--add layers to what gets updated
local base_update = utils_ui.UICellItem.Update
function utils_ui.UICellItem:Update(obj)
obj = obj or (self.ID and level.object_by_id(self.ID))
if (self.showcase == 0) and (not obj) then
self:ResetToChild()
return false
end
local sec = self.section
local xml = self:GetXML()
if obj then
local clsid = obj:clsid()
self:Add_Layers(xml, obj, sec, clsid)
end
return base_update(self, obj)
end
local base_layers = utils_ui.UICellItem.Add_Layers
function utils_ui.UICellItem:Add_Layers(xml, obj, sec, clsid)
base_layers(self, xml, obj, sec, clsid)
local ii = 1
while ((iconor and icon_override:section_exist(sec) and icon_override:r_string_ex(sec,(ii).."icon_layer")) or SYS_GetParam(0, sec, (ii).."icon_layer") ~= nil) do --get ii up to next avail layer.
ii = ii + 1
end
if (not self.layer) then
self.layer = {}
end
for key, name in pairs(icon_layers) do
for _, functor in pairs(name) do
if (not self.layer[ii]) then
if (not xml) then
xml = self:GetXML()
end
self.layer[ii] = xml:InitStatic(self.path .. ":" .. self.cx .. ":pic", self.ico)
end
local tbl = functor and functor(self, obj, sec)
if tbl then
if tbl.icon_layer then
add_icon_layer(self, self.layer[ii], self.ico, sec, tbl)
ii = ii + 1
end
if tbl.texture then
add_texture_layer(self,self.layer[ii], self.ico, sec, tbl)
ii = ii + 1
end
end
end
end
end
function add_icon_layer(self,ele, base, sec_m, tbl)
local sec_l = tbl.icon_layer
local grid_size = self.grid_size
local x = tbl.icon_layer_x or 0
local y = tbl.icon_layer_y or 0
local axis = utils_xml.get_item_axis(sec_l, grid_size)
local w = axis.w
local h = axis.h
local scale = tbl.icon_layer_scale or 1
local scale_pos = scale * (grid_size/50)
local rot = ele:GetHeading() > 0
local x_s = x * ratio * scale_pos
local y_s = y * scale_pos
local w_s = w * ratio * scale
local h_s = h * scale
local w_off = (w_s/2)
local h_off = (h_s/2)
if rot then
-- despite rotation, movement for x and y stays normal!
-- Move start pos to match the one for rotated base icon
local w_b, h_b = base:GetWidth(), base:GetHeight()
local x_st = (w_b/2) - (h_b/2)
local y_st = h_b + x_st
-- On 90 rotation, x and y are inverted, y axis goes negative simulate normal x movement
x_s = x_st + (y * ratio * scale_pos)
y_s = y_st - (x * scale_pos)
w_s = w * scale
h_s = h * scale
w_off = (h_s - h_s *ratio/2)
h_off = -w_s/2
end
ele:InitTexture( utils_xml.get_icons_texture(sec_l) )
ele:SetTextureRect(Frect():set( utils_xml.get_item_axis(sec_l, nil, true) ))
ele:SetStretchTexture(true)
ele:SetWndPos(vector2():set( x_s + w_off , y_s + h_off ))
ele:SetWndSize(vector2():set( w_s , h_s ))
ele:Show(true)
end
function add_texture_layer(self,ele, base, sec_m, tbl)
local grid_size = self.grid_size
local x = tbl.x or 0
local y = tbl.y or 0
local w = tbl.w
local h = tbl.h
local scale = 1
local scale_pos = scale * (grid_size/50)
local rot = ele:GetHeading() > 0
local x_s = x * ratio * scale_pos
local y_s = y * scale_pos
local w_s = w * ratio * scale
local h_s = h * scale
local w_off = (w_s/2)
local h_off = (h_s/2)
if rot then
-- despite rotation, movement for x and y stays normal!
-- Move start pos to match the one for rotated base icon
local w_b, h_b = base:GetWidth(), base:GetHeight()
local x_st = (w_b/2) - (h_b/2)
local y_st = h_b + x_st
-- On 90 rotation, x and y are inverted, y axis goes negative simulate normal x movement
x_s = x_st + (y * ratio * scale_pos)
y_s = y_st - (x * scale_pos)
w_s = w * scale
h_s = h * scale
w_off = (h_s - h_s *ratio/2)
h_off = -w_s/2
end
ele:InitTexture( tbl.texture )
ele:SetStretchTexture(true)
ele:SetWndPos(vector2():set( x_s + w_off , y_s + h_off ))
ele:SetWndSize(vector2():set( w_s , h_s ))
ele:Show(true)
end
@@ -0,0 +1,932 @@
bar_list = {
["condition_progess_bar"] = { min= {255,196,18,18,0}, mid= {255,255,255,118,0.5}, max= {255,107,207,119,1}, background= true},
["power_progess_bar"] = { def= GetARGB(255,86,196,209), background= true },
["uses_progess_bar"] = { def= GetARGB(255,255,255,255), background= false },
}
local lerp_color = utils_xml.lerp_color
local gc = game.translate_string
local string_find = string.find
utjan_xml = nil
base_init = utils_ui.UICellItem.InitControls
function utils_ui.UICellItem:InitControls(path, st)
self.disable_bar_og = self.disable_bar -- save original game setting for disabling bar in case user toggles bar visibility
base_init(self, path, st)
end
base_pbar = utils_ui.UICellItem.Add_ProgressBar
function utils_ui.UICellItem:Add_ProgressBar(xml, obj, sec, clsid)
local hide_non_equipped = settings.cond_text.hide_bar and not (self.path == "equipment:cont_equ")
local hide_on_magazine = settings.mag_info.hide_bar and magazine_binder and magazine_binder.is_magazine(sec)
if not IsItem("multiuse", sec) and (hide_non_equipped or hide_on_magazine) then
self.disable_bar = true
else
self.disable_bar = self.disable_bar_og
end
base_pbar(self, xml, obj, sec, clsid)
Add_Parts_Bars(self, xml, obj, sec, clsid)
Add_Mag_Icon_Text(self, xml, obj, sec, clsid)
Add_Condition_Text(self, xml, obj, sec, clsid)
end
base_counter = utils_ui.UICellItem.Add_Counter
function utils_ui.UICellItem:Add_Counter(xml, obj, sec)
base_counter(self, xml, obj, sec)
Add_Ammo_Short_Name_Text(self, xml, obj, sec)
Add_Money_Text(self, xml, obj, sec)
Add_Recipe_Icon_Text(self, xml, obj, sec)
Add_Weapon_Name(self, xml, obj, sec)
Add_Repair_Icon(self, xml, obj, sec)
end
base_reset = utils_ui.UICellItem.Reset
function utils_ui.UICellItem:Reset()
base_reset(self)
if (self.manual) then
if self.parts_indicators then
for k,v in pairs(self.parts_indicators) do
self.parts_indicators[k]:Show(false)
end
end
if self.cond_text then
self.cond_text:Show(false)
end
if self.cond_text_bg then
self.cond_text_bg:Show(false)
end
if self.wpn_name then
self.wpn_name:Show(false)
end
if self.gun_repair_icon then
self.gun_repair_icon:Show(false)
end
end
end
valid_wpn_kinds = {
["w_rifle"] = true,
["w_smg"] = true,
["w_pistol"] = true,
["w_shotgun"] = true,
["w_sniper"] = true,
["w_explosive"] = true,
["w_melee"] = true,
}
grenade_classes = {
["G_F1"] = true,
["G_F1_S"] = true,
["G_RGD5_S"] = true,
}
main_slot_indexes = {
[2] = true,
[3] = true,
}
-- AlphaLion wpn name
function Add_Weapon_Name(self, xml, obj, sec)
if self.wpn_name then
self.wpn_name:Show(false)
end
if not settings.wpn_info.show_wpn_name then return end
local class = SYS_GetParam(0, sec, "class")
if not settings.wpn_info.show_grenade_name and grenade_classes[class] then return end
local kind = SYS_GetParam(0, sec, "kind")
if not valid_wpn_kinds[kind] then return end
if not settings.wpn_info.show_melee and kind == "w_melee" then return end
local wpn_name_short = SYS_GetParam(0, sec, "inv_name_short")
if not wpn_name_short then return end
local is_equipped = self.path == "equipment:cont_equ"
if settings.wpn_info.main_slots_only and is_equipped and not main_slot_indexes[self.indx] then return end
self.wpn_name = self.wpn_name or utjan_xml:InitTextWnd("counter_text", self.cell)
self.wpn_name:SetEllipsis(true)
local name = game.translate_string(wpn_name_short)
self.wpn_name:SetText(name)
self.wpn_name:AdjustHeightToText()
self.wpn_name:AdjustWidthToText()
local x_offset = self.bar and self.bar:IsShown() and self.bar:GetWndPos().x + self.bar:GetWidth() or 0
if self.parts_indicators then
for k,v in pairs(self.parts_indicators) do
local part_x_edge = self.parts_indicators[k]:IsShown() and self.parts_indicators[k]:GetWndPos().x + self.parts_indicators[k]:GetWidth() or 0
if part_x_edge > x_offset then
x_offset = part_x_edge
end
end
end
if self.cond_text and self.cond_text:IsShown() then
local cond_text_x_edge = self.cond_text:GetWndPos().x + self.cond_text:GetWidth()
if cond_text_x_edge > x_offset then
x_offset = cond_text_x_edge
end
end
local cell_h = self.cell:GetHeight()
local cell_w = self.cell:GetWidth()
if not is_equipped then
self.wpn_name:SetTextAlignment(1)
self.wpn_name:SetWndRect(Frect():set(0, 0, cell_w - (x_offset + 2),self.wpn_name:GetHeight() + 2))
self.wpn_name:SetWndPos(vector2():set(x_offset, cell_h - self.wpn_name:GetHeight()))
else
self.wpn_name:SetTextAlignment(2)
self.wpn_name:SetWndRect(Frect():set(0, 0, cell_w, self.wpn_name:GetHeight() + 2))
self.wpn_name:SetWndPos(vector2():set(0, 3))
end
self.wpn_name:Show(true)
end
function set_text_rect(ele, padding_w, padding_h, text)
if text then
ele:SetText(text)
end
ele:AdjustHeightToText()
ele:AdjustWidthToText()
local width = ele:GetWidth()
local height = ele:GetHeight()
ele:SetWndRect(Frect():set(0, 0, width + padding_w, height + padding_h))
end
-- MONEY TEXT
function Add_Money_Text(self, xml, obj, sec)
if self.money_text then
self.money_text:Show(false)
end
if self.money_text_bg then
self.money_text_bg:Show(false)
end
if not settings.money_text.enable then return end
local money_amount = IsItem("money", sec) or parse_list(ini_sys, sec, "money_value") -- money_value is used for Lootboxes cash stacks
if not (money_amount and money_amount[1]) then return end
local show_bg = not settings.money_text.hide_bg
if show_bg then
self.money_text_bg = self.money_text_bg or utjan_xml:InitStatic("background", self.cell)
end
self.money_text = self.money_text or utjan_xml:InitTextWnd("counter_text", self.cell)
local text
if money_amount[2] then
text = gc("ui_utjan_ruble") .. ((money_amount[1] + money_amount[2]) / 2) .. "~"
else
text = gc("ui_utjan_ruble") .. money_amount[1]
end
local text_padding_w = settings.money_text.padding + 1
local text_padding_h = settings.money_text.padding
set_text_rect(self.money_text, text_padding_w, text_padding_h, text)
local text_height = self.money_text:GetHeight()
local cell_h = self.cell:GetHeight()
self.money_text:SetWndPos( vector2():set( 0 , cell_h - text_height) )
if show_bg then
self.money_text_bg:SetWndRect(Frect():set(0, 0, self.money_text:GetWidth(), self.money_text:GetHeight()))
self.money_text_bg:SetWndPos( self.money_text:GetWndPos() )
self.money_text_bg:Show(true)
end
self.money_text:Show(true)
end
-- MONEY TEXT END
-- ADD CONDITION TEXT
arty_table = {
["i_arty_junk"] = true,
["i_arty"] = true,
["i_arty_cont"] = true,
}
function Add_Condition_Text(self, xml, obj, sec, clsid)
if self.cond_text then
self.cond_text:Show(false)
end
if self.cond_text_bg then
self.cond_text_bg:Show(false)
end
if not settings.cond_text.enable then return end
if self.disable_bar_og then return end -- dont show condition when the vanilla scripts hide the condition bar
local is_equipped = self.path == "equipment:cont_equ"
if not settings.cond_text.enable_equipped and is_equipped then return end
if IsItem("multiuse",sec) then return end
local has_cond = utils_item.is_degradable(obj, sec) or IsWeapon(nil,clsid) or IsOutfit(nil,clsid) or IsHeadgear(nil,clsid)
if (not has_cond) then return end
if magazine_binder and magazine_binder.is_magazine(sec) then return end
local show_bg = not settings.cond_text.hide_bg
if show_bg and not is_equipped then
self.cond_text_bg = self.cond_text_bg or utjan_xml:InitStatic("background", self.cell)
end
self.cond_text = self.cond_text or utjan_xml:InitTextWnd("counter_text", self.cell)
local cond = obj:condition()
local str = SYS_GetParam(0,sec, "condition_bar","condition_progess_bar")
local props = bar_list[str]
local color = props.def or lerp_color( cond , props.min , props.mid , props.max )
if color then
self.cond_text:SetTextColor( color )
end
local text = math.ceil(cond * 100) .. "%"
local text_padding_w = is_equipped and 0 or settings.cond_text.padding + 1
local text_padding_h = is_equipped and 0 or settings.cond_text.padding
set_text_rect(self.cond_text, text_padding_w, text_padding_h, text)
local text_height = self.cond_text:GetHeight()
local kind = SYS_GetParam(0, sec, "kind", "na")
if arty_table[kind] then
local alt_artefact_pos = settings.cond_text.alt_artefact_pos
if alt_artefact_pos == 0 then
self.cond_text:SetWndPos( vector2():set( 0 , self.cell:GetHeight() - text_height) )
elseif alt_artefact_pos == 1 then
self.cond_text:SetWndPos( vector2():set( self.cell:GetWidth() - self.cond_text:GetWidth() , self.cell:GetHeight() - text_height) )
elseif alt_artefact_pos == 2 then
self.cond_text:SetWndPos( vector2():set( self.cell:GetWidth() - self.cond_text:GetWidth() , 0) )
end
elseif is_equipped and settings.cond_text.enable_equipped then
local pos_adjusted = false
local bar_pos = self.bar and self.bar:IsShown() and self.bar:GetWndPos()
if self.parts_indicators then -- Adjust position if part dots are shown
for k,v in pairs(self.parts_indicators) do
if self.parts_indicators[k]:IsShown() then
self.cond_text:SetWndPos( vector2():set( bar_pos.x , self.parts_indicators[k]:GetWndPos().y - text_height) )
pos_adjusted = true
break
end
end
end
if not pos_adjusted then
self.cond_text:SetWndPos( vector2():set( bar_pos.x , bar_pos.y - text_height) )
end
elseif settings.part_dots.enable and (settings.part_dots.position == 1 or (settings.part_dots.position == 2 and is_short_gun(obj, clsid, sec))) then
local part_y = self.cell:GetHeight()
if self.parts_indicators then
for k,v in pairs(self.parts_indicators) do
if self.parts_indicators[k]:IsShown() then
part_y = self.parts_indicators[k]:GetWndPos().y
break
end
end
end
self.cond_text:SetWndPos( vector2():set( 0 , part_y - text_height) )
else
local bar_h = self.bar and self.bar:IsShown() and self.bar:GetHeight() or 0
self.cond_text:SetWndPos( vector2():set( 0 , self.cell:GetHeight() - bar_h - text_height) )
end
if show_bg and not is_equipped then
self.cond_text_bg:SetWndRect(Frect():set(0, 0, self.cond_text:GetWidth(), self.cond_text:GetHeight()))
self.cond_text_bg:SetWndPos( self.cond_text:GetWndPos() )
self.cond_text_bg:Show(true)
end
self.cond_text:Show(true)
end
-- END ADD CONDITION TEXT
-- ADD PART CONDITION BARS
function is_short_gun(obj, clsid, sec)
if IsWeapon(obj, clsid) and SYS_GetParam(2, sec, "inv_grid_width") == 2 then
return true
end
end
-- WPO colors
clr_r = GetARGB(255,196,18,18)
clr_o = utils_xml.get_color("d_orange", true)
clr_y = GetARGB(255,255,255,118)
clr_g = GetARGB(255,107,207,119)
clr_missing = GetARGB(255,70,60,60) -- Missing part color
local ini_parts = itms_manager.ini_parts
function has_parts(obj)
if not obj then return end
local sec = SYS_GetParam(0, obj:section(), "parent_section") or obj:section()
local parts = ini_parts:r_string_ex("con_parts_list", sec)
return parts ~= nil
end
function Add_Parts_Bars(self, xml, obj, sec, clsid)
if self.parts_indicators then
for k,v in pairs(self.parts_indicators) do
self.parts_indicators[k]:Show(false)
end
end
if not settings.part_dots.enable then return end
if not has_parts(obj) then return end
local is_equipped = self.path == "equipment:cont_equ"
if not settings.part_dots.show_on_equipped and is_equipped then return end
if not settings.part_dots.show_on_wpn and IsWeapon(nil, clsid) then return end
if not settings.part_dots.show_on_armor and (IsHeadgear(nil, clsid) or IsOutfit(nil, clsid)) then return end
local se_parts = item_parts.get_parts_con(obj, nil, true)
if is_empty(se_parts) then return end
local parts = dup_table(se_parts)
self.parts_indicators = self.parts_indicators or {}
for part, v in pairs(parts) do
if SYS_GetParam(1, part, "cond_part") then
self.parts_indicators[part] = self.parts_indicators[part] or utjan_xml:InitStatic("cond_dot", self.cell)
else
parts[part] = nil
end
end
local bar_shown = self.bar and self.bar:IsShown()
local bar_h = bar_shown and self.bar:GetHeight() or 0
local bar_w = bar_shown and self.bar:GetWidth() or 0
local props = bar_list.condition_progess_bar
local i = 0
for part, condition in spairs(parts, parts_sort) do
local bar_pos = bar_shown and self.bar:GetWndPos()
local cond_dot_h = 4 --self.parts_indicators[part]:GetHeight()
local cond_dot_w = cond_dot_h * 0.75
cond_dot_h = cond_dot_h * settings.part_dots.size_mult
cond_dot_w = cond_dot_w * settings.part_dots.size_mult
local cond_text_w = self.cond_text and self.cond_text:GetWidth() or 0
local separator_width = settings.part_dots.separator_width
self.parts_indicators[part]:SetWndRect( Frect():set(0, 0, cond_dot_w, cond_dot_h) )
if is_equipped then
self.parts_indicators[part]:SetWndPos( vector2():set( bar_pos.x + (cond_dot_w + separator_width) * i, bar_pos.y - cond_dot_h * 1.5))
else
if settings.part_dots.position == 1 or (settings.part_dots.position == 2 and is_short_gun(obj, clsid, sec)) then
if bar_shown then
self.parts_indicators[part]:SetWndPos( vector2():set( (cond_dot_w + separator_width) * i, self.cell:GetHeight() - bar_h - cond_dot_h * 1.5))
else
self.parts_indicators[part]:SetWndPos( vector2():set( 1 + (cond_dot_w + separator_width) * i, self.cell:GetHeight() - cond_dot_h * 1.5))
end
else
if bar_shown then
self.parts_indicators[part]:SetWndPos( vector2():set( bar_w + 1 + (cond_dot_w + separator_width) * i, self.cell:GetHeight() - cond_dot_h * 1.5))
else
self.parts_indicators[part]:SetWndPos( vector2():set( cond_text_w + 1 + (cond_dot_w + separator_width) * i, self.cell:GetHeight() - cond_dot_h * 1.5))
end
end
end
local color
if settings.part_dots.wpo_mode and IsWeapon(nil, clsid) then -- Weapon Parts Overhaul Colors
color = clr_missing
if condition >= settings.part_dots.wpo_green then color = clr_g
elseif condition >= settings.part_dots.wpo_yellow then color = clr_y
elseif condition >= settings.part_dots.wpo_orange then color = clr_o
elseif condition > -1 then color = clr_r end
else
if condition >= 0 then
local cond = clamp(condition / 99, 0, 1)
color = props.def or lerp_color( cond , props.min , props.mid , props.max )
else
color = clr_missing
end
end
if color then
self.parts_indicators[part]:SetTextureColor( color )
end
self.parts_indicators[part]:Show(true)
i = i + 1
end
end
unique_mapping = {
["prt_w_gas_tube_9"] = "extractor",
["prt_w_gas_tube_10"] = "extractor",
["prt_w_gas_tube_8"] = "ejector",
["prt_w_gas_tube_2"] = "pump",
["prt_w_bolt_11"] = "hammers",
["prt_w_bolt_12"] = "hammers",
["prt_w_bolt_carrier_8"] = "chock",
["prt_w_bolt_carrier_9"] = "chock",
}
name_mapping = {
["barrel"] = 1,
["trigger"] = 2,
["bolt"] = 3,
["bolt_carrier"] = 4,
["chock"] = 5,
["ejector"] = 6,
["extractor"] = 7,
["gas_tube"] = 8,
["hammers"] = 9,
["pump"] = 10,
["spring"] = 11,
}
function parts_sort(t, a, b)
if not (a and b) then return false end
local a_map
if unique_mapping[a] then
a_map = name_mapping[unique_mapping[a]]
else
for k,v in pairs(name_mapping) do
if string_find(a, k) then
a_map = v
break
end
end
end
local b_map
if unique_mapping[b] then
b_map = name_mapping[unique_mapping[b]]
else
for k,v in pairs(name_mapping) do
if string_find(b, k) then
b_map = v
break
end
end
end
if not (a_map and b_map) then return false end
return a_map < b_map
end
-- ADD PART CONDITION BARS END
-- ADD AMMO ITEM SHORT NAME TEXT
valid_ammo_class = {
["AMMO"] = true,
["AMMO_S"] = true,
}
valid_exlosive_ammo = {
["S_M209"] = true,
["S_VOG25"] = true,
["S_OG7B"] = true,
}
function Add_Ammo_Short_Name_Text(self, xml, obj, sec)
if self.ammo_name_bg then
for k,v in pairs(self.ammo_name_bg)do
self.ammo_name_bg[k]:Show(false)
end
end
if self.ammo_name then
for k,v in pairs(self.ammo_name)do
self.ammo_name[k]:Show(false)
end
end
local class = SYS_GetParam(0, sec, "class")
if not (valid_ammo_class[class] or valid_exlosive_ammo[class]) then return end
if not settings.ammo_name.enable and valid_ammo_class[class] then return end
if not settings.ammo_name.show_expl and valid_exlosive_ammo[class] then return end
local is_component = SYS_GetParam(1, sec, "is_component")
if is_component then return end -- Ammo maker compat
local ammo_name_short = SYS_GetParam(0, sec, "inv_name_short")
if not ammo_name_short then return end
self.ammo_name = {}
self.ammo_name_bg = {}
local gc_name = gc(ammo_name_short)
local i = 1
local name_cutoff = ""
while i > 0 do
self.ammo_name_bg[i] = self.ammo_name_bg[i] or utjan_xml:InitStatic("background", self.cell)
self.ammo_name[i] = self.ammo_name[i] or utjan_xml:InitTextWnd("counter_text", self.cell)
local text_padding = settings.ammo_name.padding
set_text_rect(self.ammo_name[i], text_padding, text_padding, gc_name)
local incr_i = false
while (self.ammo_name[i]:GetWidth() > self.cell:GetWidth()) do
local str_table = str_explode(gc_name, " ")
if #str_table == 1 then
break
end
if name_cutoff == "" then
name_cutoff = str_table[1]
else
name_cutoff = name_cutoff .. " " .. str_table[1]
end
gc_name = ""
for i = 2, #str_table do
gc_name = gc_name .. str_table[i]
if #str_table > i then
gc_name = gc_name .. " "
end
end
set_text_rect(self.ammo_name[i], text_padding, text_padding, gc_name)
incr_i = true
end
local name_h = self.ammo_name[i]:GetHeight()
local name_w = self.ammo_name[i]:GetWidth()
self.ammo_name[i]:SetWndPos( vector2():set( 0 , self.H - (name_h * i)) )
local bg_padding = name_w * 0.08
self.ammo_name_bg[i]:SetWndRect(Frect():set(0, 0, name_w + (bg_padding * 2), name_h))
local name_pos = self.ammo_name[i]:GetWndPos()
self.ammo_name_bg[i]:SetWndPos( vector2():set(name_pos.x - bg_padding , name_pos.y ) )
if valid_ammo_class[class] and settings.ammo_name.bad_color or
valid_exlosive_ammo[class] and settings.ammo_name.expl_bad_color then
if string.find(sec, "_verybad") then
self.ammo_name[i]:SetTextColor( clr_r )
elseif string.find(sec, "_bad") then
self.ammo_name[i]:SetTextColor( clr_o )
else
self.ammo_name[i]:SetTextColor( clr_g )
end
end
-- Check if ammo icon is dimmed in crafting list
local craft_gui = ui_workshop.GUI and ui_workshop.GUI:IsShown() and ui_workshop.GUI.dlg_craft
if craft_gui then
local menu = craft_gui.list_menu:GetSelectedItem()
local last_type = menu and menu.idx
local r = last_type and craft_gui.recipes[last_type] or {}
local rsp_sec
for k,v in pairs(r) do
if r[k].sec == sec then
rsp_sec = r[k].rsp
break
end
end
if rsp_sec and not craft_gui.recipes_items[rsp_sec] then
local txt_clr = self.ammo_name[i]:GetTextColor()
self.ammo_name[i]:SetTextColor( change_alpha(txt_clr, 140) )
local bg_clr = self.ammo_name_bg[i]:GetTextureColor()
self.ammo_name_bg[i]:SetTextureColor( change_alpha(bg_clr, 140) )
end
end
self.ammo_name_bg[i]:Show(true)
self.ammo_name[i]:Show(true)
if incr_i then
i = i + 1
gc_name = name_cutoff
name_cutoff = ""
else
i = 0
end
end
end
function change_alpha(clr, a)
if not clr and a ~= nil then return end
local b = bit.band(clr, 255)
local g = bit.band(bit.rshift(clr, 8), 255)
local r = bit.band(bit.rshift(clr, 16), 255)
return GetARGB(a, r, g, b)
end
-- ADD AMMO ITEM SHORT NAME TEXT END
-- ADD RECIPE READ/UNREAD TEXT
one_use_recipes = {
recipe_cooking_1 = true,
}
workshop_autoinject_known_recipes = {}
functor_table_readable = {
["item_recipe.func_recipe"] = true,
["item_recipe.func_letter"] = true,
}
function Add_Recipe_Icon_Text(self, xml, obj, sec)
if self.recipe_text then
self.recipe_text:Show(false)
end
if self.recipe_text_bg then
self.recipe_text_bg:Show(false)
end
if not settings.recipe_text.enable then return end
if not sec then return end
local use_map = SYS_GetParam(0, sec, "use_map")
local functor = SYS_GetParam(0, sec, "use1_action_functor", "na")
local has_encyclopedia = functor_table_readable[functor]
local is_pda = functor == "ui_pda_npc_tab.use_view"
if not (has_encyclopedia or is_pda or use_map or one_use_recipes[sec]) then return end
if not settings.recipe_text.show_on_pda and is_pda then return end
local has_stash
if is_pda and obj then
local pda_info = se_load_var(obj:id(), obj:name(), "info")
if pda_info and pda_info.msg then
for k,v in pairs(pda_info.msg) do
if pda_info.msg[k].stash and not pda_info.msg[k].stash_read then
has_stash = true
break
end
end
end
end
if is_pda and not has_stash then return end
local recipe_is_known
if use_map then
local maps = game_statistics.actor_anomaly_maps or {}
recipe_is_known = maps[use_map] or false
else
workshop_autoinject_known_recipes = workshop_autoinject and workshop_autoinject.known_recipe or workshop_autoinject_known_recipes
recipe_is_known = workshop_autoinject_known_recipes[sec] or ui_pda_encyclopedia_tab.is_unlocked_note("encyclopedia__notes_" .. sec)
end
self.recipe_text_bg = self.recipe_text_bg or utjan_xml:InitStatic("background", self.cell)
self.recipe_text = self.recipe_text or utjan_xml:InitTextWnd("counter_text", self.cell)
local text
if recipe_is_known then
text = gc("ui_utjan_recipe_read")
self.recipe_text:SetTextColor( GetARGB(255, 185, 162, 138))
elseif has_stash then
text = "(???)"
self.recipe_text:SetTextColor( GetARGB(255, 255, 232, 208))
else
text = gc("ui_utjan_recipe_unread")
self.recipe_text:SetTextColor( GetARGB(255, 255, 232, 208))
end
local text_padding = settings.recipe_text.padding
set_text_rect(self.recipe_text, text_padding + 1, text_padding, text)
local name_h = self.recipe_text:GetHeight()
local name_w = self.recipe_text:GetWidth()
if has_stash then
local bar_h = self.bar and self.bar:IsShown() and self.bar:GetHeight() or 0
local cond_text_h = self.cond_text and self.cond_text:IsShown() and self.cond_text:GetHeight() or 0
self.recipe_text:SetWndPos( vector2():set( 0 , self.H - bar_h - cond_text_h - name_h) )
else
self.recipe_text:SetWndPos( vector2():set( 0 , self.H - name_h) )
end
local bg_padding = name_w * 0.08
self.recipe_text_bg:SetWndRect(Frect():set(0, 0, name_w + (bg_padding * 2), name_h))
local name_pos = self.recipe_text:GetWndPos()
self.recipe_text_bg:SetWndPos( vector2():set(name_pos.x - bg_padding , name_pos.y ) )
self.recipe_text_bg:Show(true)
self.recipe_text:Show(true)
end
if workshop_autoinject and not workshop_autoinject.known_recipe then
base_wai_load = workshop_autoinject.load_state
function workshop_autoinject.load_state(mdata)
base_wai_load(mdata)
workshop_autoinject_known_recipes = mdata.known_recipe or {}
end
end
-- ADD RECIPE READ/UNREAD TEXT END
-- ADD MAGS REDUX ITEM TEXT
function Add_Mag_Icon_Text(self, xml, obj, sec, clsid)
if not magazine_binder then return end
if self.mag_ammo_count then
self.mag_ammo_count:Show(false)
end
if self.mag_ammo_count_bg then
self.mag_ammo_count_bg:Show(false)
end
if self.mag_ammo_name_bg then
for k,v in pairs(self.mag_ammo_name_bg)do
self.mag_ammo_name_bg[k]:Show(false)
end
end
if self.mag_ammo_name then
for k,v in pairs(self.mag_ammo_name)do
self.mag_ammo_name[k]:Show(false)
end
end
if not settings.mag_info.enable then return end
if not magazine_binder.is_magazine(sec) then return end
if (not self.ID) or self.manual then return end
local mag_data = magazine_binder.get_data(self.ID)
if not mag_data then return end
if self.cond_text then
self.cond_text:Show(false)
end
if self.cond_text_bg then
self.cond_text_bg:Show(false)
end
local count_h
local bar_h = self.bar and self.bar:IsShown() and self.bar:GetHeight() or 0
if settings.mag_info.show_ammo_count then
self.mag_ammo_count_bg = self.mag_ammo_count_bg or utjan_xml:InitStatic("background", self.cell)
self.mag_ammo_count = self.mag_ammo_count or utjan_xml:InitTextWnd("condition_text", self.cell)
local mag_capacity = SYS_GetParam(2, sec, "max_mag_size")
local text = #mag_data.loaded .. "/" .. mag_capacity
local text_padding = settings.mag_info.padding
set_text_rect(self.mag_ammo_count, text_padding + 1, text_padding, text)
count_h = self.mag_ammo_count:GetHeight() + bar_h
local count_w = self.mag_ammo_count:GetWidth()
self.mag_ammo_count:SetWndPos( vector2():set( 0 , self.H - count_h) )
self.mag_ammo_count_bg:SetWndRect(Frect():set(0, 0, count_w, count_h))
self.mag_ammo_count_bg:SetWndPos( self.mag_ammo_count:GetWndPos() )
local props = bar_list["condition_progess_bar"]
local cond = #mag_data.loaded / mag_capacity
local color = props.def or lerp_color( cond , props.min , props.mid , props.max )
if color then
self.mag_ammo_count:SetTextColor( color )
end
self.mag_ammo_count_bg:Show(true)
self.mag_ammo_count:Show(true)
else
count_h = 0
end
if not settings.mag_info.show_ammo_name then return end
if not (#mag_data.loaded > 0) then return end
self.mag_ammo_name = {}
self.mag_ammo_name_bg = {}
local last_bullet_sec
for k,v in pairs(mag_data.loaded) do
last_bullet_sec = v
end
local inv_short_name = SYS_GetParam(0, last_bullet_sec, "inv_name_short", "Bullet?")
local gc_name = gc(inv_short_name)
local i = 1
local name_cutoff = ""
while i > 0 do
self.mag_ammo_name_bg[i] = self.mag_ammo_name_bg[i] or utjan_xml:InitStatic("background", self.cell)
self.mag_ammo_name[i] = self.mag_ammo_name[i] or utjan_xml:InitTextWnd("counter_text", self.cell)
local text_padding = settings.mag_info.padding
set_text_rect(self.mag_ammo_name[i], text_padding, text_padding, gc_name)
local incr_i = false
while (self.mag_ammo_name[i]:GetWidth() > self.cell:GetWidth()) do
local str_table = str_explode(gc_name, " ")
if #str_table == 1 then
break
end
if name_cutoff == "" then
name_cutoff = str_table[1]
else
name_cutoff = name_cutoff .. " " .. str_table[1]
end
gc_name = ""
for i = 2, #str_table do
gc_name = gc_name .. str_table[i]
if #str_table > i then
gc_name = gc_name .. " "
end
end
set_text_rect(self.mag_ammo_name[i], text_padding, text_padding, gc_name)
incr_i = true
end
local name_h = self.mag_ammo_name[i]:GetHeight()
local name_w = self.mag_ammo_name[i]:GetWidth()
self.mag_ammo_name[i]:SetWndPos( vector2():set( 0 , self.H - count_h - (name_h * i)) )
local bg_padding = name_w * 0.08
self.mag_ammo_name_bg[i]:SetWndRect(Frect():set(0, 0, name_w + (bg_padding * 2), name_h))
local name_pos = self.mag_ammo_name[i]:GetWndPos()
self.mag_ammo_name_bg[i]:SetWndPos( vector2():set(name_pos.x - bg_padding , name_pos.y ) )
self.mag_ammo_name_bg[i]:Show(true)
self.mag_ammo_name[i]:Show(true)
if incr_i then
i = i + 1
gc_name = name_cutoff
name_cutoff = ""
else
i = 0
end
end
end
-- ADD MAGS REDUX ITEM TEXT END
function Add_Repair_Icon(self, xml, obj, sec)
if self.gun_repair_icon then
self.gun_repair_icon:Show(false)
end
if not settings.wpn_info.show_gun_repair_type then return end
local repair_type = SYS_GetParam(0, sec, "repair_type")
if not repair_type then return end
local icon_texture = repair_type_texture_tbl[repair_type]
if not icon_texture then return end
local is_equipped = self.path == "equipment:cont_equ"
self.gun_repair_icon = self.gun_repair_icon or utjan_xml:InitStatic("gun_repair_icon", self.cell)
self.gun_repair_icon:InitTexture(icon_texture)
local y_offset = (not is_equipped) and self.wpn_name and self.wpn_name:IsShown() and self.wpn_name:GetHeight() or 2
local x_offset = is_equipped and -4 or -1
self.gun_repair_icon:SetWndPos(vector2():set(self.cell:GetWidth() - self.gun_repair_icon:GetWidth() + x_offset, self.cell:GetHeight() - self.gun_repair_icon:GetHeight() - y_offset))
self.gun_repair_icon:Show(true)
end
repair_type_texture_tbl = {
pistol = "ui_dyn_eq_repair_blue",
shotgun = "ui_dyn_eq_repair_green",
rifle_5 = "ui_dyn_eq_repair_red",
rifle_7 = "ui_dyn_eq_repair_yellow",
}
-- MCM
function load_defaults()
local t = {}
local op = item_icon_info_mcm.op
for i, v in ipairs(op.gr) do
if v.gr then
t[v.id] = {}
for ii, vv in ipairs(v.gr) do
if vv.def ~= nil then
t[v.id][vv.id] = vv.def
end
end
elseif v.def ~= nil then
t[v.id] = v.def
end
end
return t
end
settings = load_defaults()
function load_settings()
settings = load_defaults()
if ui_mcm then
for k, v in pairs(settings) do
if type(settings[k]) == "table" then
for kk, vv in pairs(settings[k]) do
settings[k][kk] = ui_mcm.get("item_icon_info/" .. k .. "/" .. kk)
end
else
settings[k] = ui_mcm.get("item_icon_info/" .. k)
end
end
end
return settings
end
function on_game_start()
RegisterScriptCallback("actor_on_first_update", load_settings)
RegisterScriptCallback("on_option_change", load_settings)
utjan_xml = CScriptXmlInit()
utjan_xml:ParseFile("ui_utjan_icon_info.xml")
end
@@ -0,0 +1,160 @@
local ratio = utils_xml.screen_ratio()
ini_scaling = ini_file("plugins\\utjan_gun_scaling.ltx")
_Set = utils_ui.UICellItem.Set
function utils_ui.UICellItem:Set(obj, area)
self.grid_size = self.container and self.container.grid_size or 41
if not (obj and obj.clsid and IsWeapon(obj, nil)) then return _Set(self, obj, area) end
local has_silencer = utils_item.has_attached_silencer(obj)
local is_equipped = self.path == "equipment:cont_equ"
if not (has_silencer or is_equipped) then return _Set(self, obj, area) end
if not z_item_icon_info.settings.wpn_scaling.enable_inv_scaling and (has_silencer and not is_equipped) then return _Set(self, obj, area) end
if not z_item_icon_info.settings.wpn_scaling.enable_equip_hor_scale and is_equipped and not rot then return _Set(self, obj, area) end
if not z_item_icon_info.settings.wpn_scaling.enable_equip_vert_scale and is_equipped and rot then return _Set(self, obj, area) end
local rot = self.ico:GetHeading() > 0
local wpn_sec = obj:section()
local scale = 1
local sil_end = 0
if has_silencer then
local sil_sec = utils_item.get_attached_silencer(obj)
if sil_sec then
local sil_x = SYS_GetParam(2, wpn_sec, "silencer_x", 0) * (self.grid_size/50)
local sil_offset = ini_scaling:r_float_ex("silencer_cutoffs", sil_sec, 0) * (self.grid_size/50)
local sil_width = (SYS_GetParam(2, sil_sec, "inv_grid_width") * self.grid_size) - sil_offset
sil_end = (sil_x + sil_width) * (rot and 1 or ratio)
end
end
local width_diff = 0 -- delta between original icon width and icon+silencer width
local icon_width = SYS_GetParam(2, wpn_sec, "inv_grid_width") * self.grid_size * (rot and 1 or ratio)
local icon_height = SYS_GetParam(2, wpn_sec, "inv_grid_height") * self.grid_size * (rot and ratio or 1)
local total_width = icon_width
if sil_end > total_width then
width_diff = sil_end - total_width
total_width = sil_end
end
if rot then -- add padding from mcm
total_width = total_width + z_item_icon_info.settings.wpn_scaling.equip_vert_padding
else
total_width = total_width + z_item_icon_info.settings.wpn_scaling.equip_hor_padding
end
local cell_width = is_equipped and self.cell:GetWidth() or icon_width
local cell_height = is_equipped and self.cell:GetHeight() or icon_height
if not rot and (icon_height > cell_height) then
scale = cell_height / icon_height
end
if rot and (total_width > cell_height) then
local h_scale = cell_height / total_width
if h_scale < scale then
scale = h_scale
total_width = total_width
end
end
if not rot and (total_width > cell_width) then
local w_scale = cell_width / total_width
if w_scale < scale then
scale = w_scale
end
end
if scale ~= 1 then
self.grid_size = self.grid_size * scale
end
_align_to_center = utils_xml.align_to_center
function new_align(element, base, offset_x, offset_y)
if has_silencer then
if not is_equipped and self.area then -- unscale the cell of inv items cause messing with their grid size doesnt work as well as equipped items
local grid_size = self.container and self.container.grid_size or 41
local area_x = ((self.area.x * grid_size) - grid_size) * ratio
local area_y = (self.area.y * grid_size) - grid_size
local area_xl = self.grid_line * self.area.x
local area_yl = self.grid_line * self.area.y
base:SetWndPos(vector2():set( area_x + area_xl , area_y + area_yl ))
base:SetWndSize(vector2():set(icon_width, icon_height))
utils_xml.sync_element(self.hl, self.cell)
end
local x_diff = rot and 0 or ((width_diff / 2) * scale)
local y_diff = rot and ((width_diff / 2) * scale) or 0
element:SetWndPos( vector2():set( (base:GetWidth() / 2) - x_diff, (base:GetHeight() / 2) + y_diff))
else
_align_to_center(element, base, offset_x, offset_y)
end
end
utils_xml.align_to_center = new_align
local res = _Set(self, obj, area)
utils_xml.align_to_center = _align_to_center
return res
end
_Action_Attach = ui_inventory.UIInventory.Action_Attach
function ui_inventory.UIInventory:Action_Attach(obj, bag, temp, slot, wpn)
if not z_item_icon_info.settings.wpn_scaling.enable_inv_scaling then _Action_Attach(self, obj, bag, temp, slot, wpn) return end
obj = self:CheckItem(obj,"Action_Attach")
if not (wpn and obj and IsItem("sil",obj:section())) then _Action_Attach(self, obj, bag, temp, slot, wpn) return end
local wpn_bag
local wpn_cell_id
for bag, cc in pairs(self.CC) do
local cell_id = self.CC[bag].indx_id[wpn:id()]
if cell_id then
wpn_bag = bag
wpn_cell_id = cell_id
break
end
end
if not (wpn_bag and wpn_cell_id and wpn_bag ~= "actor_equ") then _Action_Attach(self, obj, bag, temp, slot, wpn) return end
_Action_Attach(self, obj, bag, temp, slot, wpn)
CreateTimeEvent("scale_guns", "attach_update", 0, function()
local cell_item = self.CC[wpn_bag].cell[wpn_cell_id]
if not cell_item then return true end
cell_item:Set(wpn, cell_item.area)
return true
end)
end
_Action_Detach_Silencer = ui_inventory.UIInventory.Action_Detach_Silencer
function ui_inventory.UIInventory:Action_Detach_Silencer(obj, bag)
if not z_item_icon_info.settings.wpn_scaling.enable_inv_scaling then _Action_Detach_Silencer(self, obj, bag) return end
if not self then
self = ui_inventory.GUI
end
obj = self:CheckItem(obj,"Action_Detach_Silencer")
if not obj then _Action_Detach_Silencer(self, obj, bag) return end
if not bag then
if self.mode == "inventory" then
if self.CC["actor_bag"].indx_id[obj:id()] then
bag = "actor_bag"
end
elseif self.mode == "loot" then
if self.CC["npc_bag"].indx_id[obj:id()] then
bag = "npc_bag"
end
end
if not bag then _Action_Detach_Silencer(self, obj, bag) return end
end
_Action_Detach_Silencer(self, obj, bag)
CreateTimeEvent("scale_guns", "detach_update_" .. obj:id(), 0, function()
local sil_indx = self.CC[bag].indx_id[obj:id()]
local cell_item = self.CC[bag].cell[sil_indx]
cell_item:Set(obj, cell_item.area)
return true
end)
end