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,49 @@
op = {
id = "better_stats_bars", sh = true, gr = {
{id = "banner", type = "slide", text = "ui_mcm_better_stats_bars_title", size = {512, 50}, spacing = 20},
{id = "positive_color_help", type = "desc", clr = {200, 200, 255, 200}, text = "ui_mcm_better_stats_bars_positive_color_help"},
{id = "positive_color_a", type = "track", val = 2, min = 0, max = 255, step = 1, def = 255},
{id = "positive_color_r", type = "track", val = 2, min = 0, max = 255, step = 1, def = 0},
{id = "positive_color_g", type = "track", val = 2, min = 0, max = 255, step = 1, def = 255},
{id = "positive_color_b", type = "track", val = 2, min = 0, max = 255, step = 1, def = 0},
{id = "divider", type = "line"},
{id = "negative_color_help", type = "desc", clr = {200, 200, 255, 200}, text = "ui_mcm_better_stats_bars_negative_color_help"},
{id = "negative_color_a", type = "track", val = 2, min = 0, max = 255, step = 1, def = 255},
{id = "negative_color_r", type = "track", val = 2, min = 0, max = 255, step = 1, def = 255},
{id = "negative_color_g", type = "track", val = 2, min = 0, max = 255, step = 1, def = 0},
{id = "negative_color_b", type = "track", val = 2, min = 0, max = 255, step = 1, def = 0},
{id = "divider", type = "line"},
{id = "neutral_color_help", type = "desc", clr = {200, 200, 255, 200}, text = "ui_mcm_better_stats_bars_neutral_color_help"},
{id = "neutral_color_a", type = "track", val = 2, min = 0, max = 255, step = 1, def = 255},
{id = "neutral_color_r", type = "track", val = 2, min = 0, max = 255, step = 1, def = 100},
{id = "neutral_color_g", type = "track", val = 2, min = 0, max = 255, step = 1, def = 100},
{id = "neutral_color_b", type = "track", val = 2, min = 0, max = 255, step = 1, def = 100},
{id = "divider", type = "line"},
{id = "position", type="list", val=0, def="bottom", content={
{"bottom", "better_stats_bars_position_bottom"},
{"top", "better_stats_bars_position_top"},
{"justify", "better_stats_bars_position_justify"},
}},
{id = "use_game_values", type="list", val=0, def="max", content={
{"none", "better_stats_bars_use_game_values_none"},
{"max", "better_stats_bars_use_game_values_max"},
{"max_no_mines", "better_stats_bars_use_game_values_max_no_mines"},
-- {"middle", "better_stats_bars_use_game_values_middle"},
-- {"median", "better_stats_bars_use_game_values_median"},
}},
{id = "arx_compatibility", type = "check", val = 1, def = false},
{id = "abf_compatibility", type = "check", val = 1, def = false},
{id = "acid_bar_fix", type = "check", val = 1, def = true},
{id = "divider", type = "line"},
-- Edited by Sota - no longer needed
-- {id = "efp_ui_compatibility", type = "check", val = 1, def = false},
-- {id = "gamma_ui_compatibility", type = "check", val = 1, def = false},
}
}
function on_mcm_load()
return op
end
@@ -0,0 +1,288 @@
--[[
MCM script made for EFP UI
Author: HarukaSai
08/04/2022
]]
--[[
Edit by Sota for UI Rework
24/09/2024
]]
-- check if IWR patch is installed
local is_z_iwr = z_utils_ui_demonized_inventory_weights and true or false
local mcm_id = "efp_ui"
local string_format = string.format
local faction_color_defs = {-- Edited by Sota - stupid fix for incorrect order of adding to settings (add i = _)
["stalker"] = { a= 255 , r= 228 , g= 185 , b= 69 , i= 1 },
["bandit"] = { a= 255 , r= 217 , g= 217 , b= 217 , i= 2 },
["csky"] = { a= 255 , r= 0 , g= 182 , b= 222 , i= 3 },
["dolg"] = { a= 255 , r= 193 , g= 32 , b= 38 , i= 4 },
["freedom"] = { a= 255 , r= 79 , g= 162 , b= 69 , i= 5 },
["killer"] = { a= 255 , r= 3 , g= 94 , b= 168 , i= 6 },
["army"] = { a= 255 , r= 184 , g= 153 , b= 84 , i= 7 },
["ecolog"] = { a= 255 , r= 67 , g= 134 , b= 120 , i= 8 },
["monolith"] = { a= 255 , r= 81 , g= 231 , b= 241 , i= 9 },
["renegade"] = { a= 255 , r= 30 , g= 123 , b= 48 , i= 10 },
["greh"] = { a= 255 , r= 255 , g= 93 , b= 0 , i= 11 },
["isg"] = { a= 255 , r= 145 , g= 5 , b= 0 , i= 12 }
}
local faction_color_text_defs = {
["stalker"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["bandit"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["csky"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["dolg"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["freedom"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["killer"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["army"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["ecolog"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["monolith"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["renegade"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["greh"] = { a= 255 , r= 255 , g= 232 , b= 208 },
["isg"] = { a= 255 , r= 255 , g= 232 , b= 208 }
}
local stat_defs = {-- Edited by Sota - stupid fix for incorrect order of adding to settings (add i = _)
["health"] = { a= 255 , r= 255 , g= 0 , b= 0 , i= 1 },
["radia"] = { a= 255 , r= 253 , g= 208 , b= 23 , i= 2 },
["acid"] = { a= 255 , r= 0 , g= 255 , b= 0 , i= 3 },
["shock"] = { a= 255 , r= 255 , g= 255 , b= 0 , i= 4 },
["fire"] = { a= 255 , r= 255 , g= 0 , b= 128 , i= 5 },
["psi"] = { a= 255 , r= 0 , g= 255 , b= 255 , i= 6 },
["wound"] = { a= 255 , r= 255 , g= 255 , b= 255 , i= 7 },
["fire_wound"] = { a= 255 , r= 255 , g= 128 , b= 0 , i= 8 },
["power"] = { a= 255 , r= 128 , g= 255 , b= 255 , i= 9 },
["hunger"] = { a= 255 , r= 165 , g= 137 , b= 193 , i= 10 },
["thirst"] = { a= 255 , r= 154 , g= 206 , b= 223 , i= 11 },
["sleep"] = { a= 255 , r= 253 , g= 222 , b= 238 , i= 12 }
}
local slot_cell_defs = { -- base slot = {UI slots to fit in}
["belt"] = { string= "belt" , a= 255 , r= 255 , g= 0 , b= 147 },
["quick"] = { string= "quick" , a= 255 , r= 21 , g= 236 , b= 135 },
[1] = { string= "knife" , a= 255 , r= 185 , g= 70 , b= 255 }, -- Knife
[2] = { string= "pistol" , a= 255 , r= 255 , g= 216 , b= 0 }, -- Pistol
[3] = { string= "rifle" , a= 255 , r= 255 , g= 126 , b= 70 }, -- Rifle
[4] = { string= "grenade" , a= 255 , r= 255 , g= 0 , b= 0 }, -- Grenade
[5] = { string= "binoculars" , a= 255 , r= 75 , g= 181 , b= 255 }, -- Binoculars
[6] = { string= "bolt" , a= 255 , r= 234 , g= 70 , b= 150 }, -- Bolt
[7] = { string= "outfit" , a= 255 , r= 70 , g= 103 , b= 234 }, -- Outfit
[8] = { string= "pda" , a= 255 , r= 0 , g= 193 , b= 255 }, -- PDA
[9] = { string= "detector" , a= 255 , r= 0 , g= 108 , b= 255 }, -- Detector
[10] = { string= "torch" , a= 255 , r= 59 , g= 244 , b= 146 }, -- Torch
[12] = { string= "helmet" , a= 255 , r= 122 , g= 0 , b= 244 }, -- Helmet
[13] = { string= "backpack" , a= 255 , r= 236 , g= 197 , b= 32 } -- Backpack
}
local faction_banner_defs = { a= 255, r= 39, g= 39, b= 160 }
local faction_banner_text_defs = { a= 255, r= 255, g= 232, b= 208 }
function get_faction_color_template(faction)
local template = {
id = faction, sh = true, gr = {
{ id= "title" , type= "slide", link= "ui_options_slider_warfare", text= "ui_mcm_menu_" .. mcm_id .. "_title", size= {512,50}, spacing= 20 },
{ id= "desc_faction_color" , type= "desc", text= "ui_mcm_desc_faction_banner_color"},
{ id= "color_red" , hint= mcm_id .. "_red" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_color_defs[faction].r },
{ id= "color_green" , hint= mcm_id .. "_green" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_color_defs[faction].g },
{ id= "color_blue" , hint= mcm_id .. "_blue" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_color_defs[faction].b },
{ id= "color_alpha" , hint= mcm_id .. "_alpha" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_color_defs[faction].a },
{ id= "divider" , type= "line" },
{ id= "desc_faction_text_color" , type= "desc", text= "ui_mcm_desc_faction_text_color" },
{ id= "color_red_text" , hint= mcm_id .. "_red" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_color_text_defs[faction].r },
{ id= "color_green_text" , hint= mcm_id .. "_green" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_color_text_defs[faction].g },
{ id= "color_blue_text" , hint= mcm_id .. "_blue" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_color_text_defs[faction].b },
{ id= "color_alpha_text" , hint= mcm_id .. "_alpha" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_color_text_defs[faction].a }
}
}
return template
end
function get_stats_color_template(stat)
local template = {
{ id= "desc" .. stat, type= "desc", text= "ui_mcm_desc_stat_" .. stat },
{ id= "color_red" .. stat, hint= mcm_id .. "_red" , type= "track", val= 2, min= 0, max= 255, step= 1, def= stat_defs[stat].r },
{ id= "color_green" .. stat, hint= mcm_id .. "_green" , type= "track", val= 2, min= 0, max= 255, step= 1, def= stat_defs[stat].g },
{ id= "color_blue" .. stat, hint= mcm_id .. "_blue" , type= "track", val= 2, min= 0, max= 255, step= 1, def= stat_defs[stat].b },
{ id= "color_alpha" .. stat, hint= mcm_id .. "_alpha" , type= "track", val= 2, min= 0, max= 255, step= 1, def= stat_defs[stat].a },
{ id= "divider", type= "line" }
}
return template
end
module_settings = {}
function add_module_settings(t)
module_settings[#module_settings + 1] = t
end
function get_module_settings(path)
return ui_mcm.get(string_format("%s/modules_settings/%s", mcm_id, path))
end
function get_slot_cell_template(slot)
local template = {
{ id= "desc" .. slot_cell_defs[slot].string, type= "desc", text= "ui_mcm_desc_cell_" .. slot_cell_defs[slot].string },
{ id= "color_red" .. slot, hint= mcm_id .. "_red" , type= "track", val= 2, min= 0, max= 255, step= 1, def= slot_cell_defs[slot].r },
{ id= "color_green" .. slot, hint= mcm_id .. "_green" , type= "track", val= 2, min= 0, max= 255, step= 1, def= slot_cell_defs[slot].g },
{ id= "color_blue" .. slot, hint= mcm_id .. "_blue" , type= "track", val= 2, min= 0, max= 255, step= 1, def= slot_cell_defs[slot].b },
{ id= "color_alpha" .. slot, hint= mcm_id .. "_alpha" , type= "track", val= 2, min= 0, max= 255, step= 1, def= slot_cell_defs[slot].a },
{ id= "divider", type= "line" }
}
return template
end
function on_mcm_load()
local options = { id= mcm_id, gr= {{ id= "faction_settings", gr= {} }} }
options.gr[1] = { id= "main_settings", sh= true, gr= {
{ id= "title", type= "slide", link= "ui_options_slider_warfare", text= "ui_mcm_menu_" .. mcm_id.. "_title", size= {512,50}, spacing= 20 },
-- Edited by Sota - change check to list
-- { id= "use_alt_ranks" , hint= mcm_id .. "_use_alt_ranks" , type= "check" , val= 1, def= false },
{ id= "use_alt_ranks" , hint= mcm_id .. "_use_alt_ranks" , type= "list" , val= 2, content= { { 1, "ranks" }, { 2, "ranks_mui" }, { 3, "ranks_svui" }, { 4, "ranks_svui_alt" } } , def= 1 },
-- Added by Sota - new MCM settings for UI Rework
{ id= "use_alt_factions" , hint= mcm_id .. "_use_alt_factions" , type= "list" , val= 2, content= { { 1, "factions" }, { 2, "factions_alt" }, { 3, "factions_alt2" } } , def= 1 },
{ id= "use_alt_inv" , hint= mcm_id .. "_use_alt_inv" , type= "list" , val= 2, content= { { 1, "inv" }, { 2, "inv_alt" }, { 3, "inv_alt_bg" } } , def= 1 },
{ id= "use_alt_grid" , hint= mcm_id .. "_use_alt_grid" , type= "list" , val= 2, content= { { 1, "no_grid" }, { 2, "grid" }, { 3, "grid_alt" } } , def= 1 },
{ id= "use_alt_blockers" , hint= mcm_id .. "_use_alt_blockers" , type= "list" , val= 2, content= { { 1, "blck_lock" }, { 2, "blck_cross" }, { 3, "blck_dash" } } , def= 1 },
{ id= "use_alt_upgr" , hint= mcm_id .. "_use_alt_upgr" , type= "list" , val= 2, content= { { 1, "upgr" }, { 2, "upgr_gear" }, { 3, "upgr_arrow" }, { 4, "upgr_wrench" } } , def= 1 },
{ id= "use_alt_equ_bars" , hint= mcm_id .. "_use_alt_equ_bars" , type= "list" , val= 2, content= { { 1, "bars" }, { 2, "bars_flat" }, { 3, "bars_fade" } } , def= 1 },
{ id= "use_alt_inv_bars" , hint= mcm_id .. "_use_alt_inv_bars" , type= "list" , val= 2, content= { { 1, "bars" }, { 2, "bars_flat" }, { 3, "bars_fade" } } , def= 1 },
{ id= "use_alt_stats_bars" , hint= mcm_id .. "_use_alt_stats_bars" , type= "list" , val= 2, content= { { 1, "bars" }, { 2, "bars_flat" }, { 3, "bars_fade" } } , def= 1 },
{ id= "divider", type= "line" },
{ id= "use_inv_labels" , hint= mcm_id .. "_use_inv_labels" , type= "check" , val= 1, def= true },
{ id= "use_small_icons" , hint= mcm_id .. "_use_small_icons" , type= "check" , val= 1, def= false },
{ id= "use_inv_vert" , hint= mcm_id .. "_use_inv_vert" , type= "check" , val= 1, def= false },
{ id= "divider", type= "line" },
{ id= "inv_hint_alpha" , hint= mcm_id .. "_inv_hint_alpha" , type= "track" , val= 2, min= 0, max= 255, step= 5, def= 255 },
{ id= "divider", type= "line" },
}}
-- if HTS Bars patch is installed need to create mcm setting
if hts_inventory_bars then
options.gr[1].gr[#options.gr[1].gr + 1] = { id= "use_alt_hts" , hint= mcm_id .. "_use_alt_hts" , type= "list" , val= 2, content= { { 1, "hts" }, { 2, "htsp" }, { 3, "hts_alt" } } , def= 1 }
end
-- if IWR patch is installed need to create mcm setting
if is_z_iwr then
options.gr[1].gr[#options.gr[1].gr + 1] = { id= "use_inv_weights" , hint= mcm_id .. "_use_inv_weights" , type= "check" , val= 1 , def= true }
end
options.gr[2] = { id= "faction_settings", gr= {} }
options.gr[3] = {
id= "base_settings", gr= {
{ id= "slots", sh= true, gr= {
{ id= "title", type= "slide", link= "ui_options_slider_warfare", text= "ui_mcm_menu_" .. mcm_id.. "_title", size= {512,50}, spacing= 20 },
{ id= "use_faction", hint= mcm_id .. "_use_faction", val= 1, type= "check", def= true },
{ id= "divider", type= "line" }
}},
{ id= "stats", sh= true, gr= {
{ id= "title", type= "slide", link= "ui_options_slider_warfare", text= "ui_mcm_menu_" .. mcm_id.. "_title", size= {512,50}, spacing= 20 },
{ id= "use_faction", hint= mcm_id .. "_use_faction", val= 1, type= "check", def= true },
{ id= "divider", type= "line" }
}},
{ id= "faction_banner", sh= true, gr= {
{ id= "title", type= "slide", link= "ui_options_slider_warfare", text= "ui_mcm_menu_" .. mcm_id.. "_title", size= {512,50}, spacing= 20 },
{ id= "desc_faction_color", type= "desc", text= "ui_mcm_desc_faction_banner_color" },
{ id= "use_faction" , hint= mcm_id .. "_use_faction", type= "check", val= 1, def= true },
{ id= "color_red" , hint= mcm_id .. "_red" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_banner_defs.r },
{ id= "color_green" , hint= mcm_id .. "_green" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_banner_defs.g },
{ id= "color_blue" , hint= mcm_id .. "_blue" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_banner_defs.b },
{ id= "color_alpha" , hint= mcm_id .. "_alpha" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_banner_defs.a },
{ id= "divider", type= "line" },
{ id= "desc_faction_text_color", type= "desc", text= "ui_mcm_desc_faction_text_color" },
{ id= "use_faction_text" , hint= mcm_id .. "_use_faction", type= "check", val= 1, def= true },
{ id= "color_red_text" , hint= mcm_id .. "_red" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_banner_text_defs.r },
{ id= "color_green_text" , hint= mcm_id .. "_green" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_banner_text_defs.g },
{ id= "color_blue_text" , hint= mcm_id .. "_blue" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_banner_text_defs.b },
{ id= "color_alpha_text" , hint= mcm_id .. "_alpha" , type= "track", val= 2, min= 0, max= 255, step= 1, def= faction_banner_text_defs.a }
}}
}
}
if not is_empty(module_settings) then -- add modules if there's any
options.gr[4] = { id= "modules_settings", gr= module_settings }
end
-- Edited by Sota - stupid fix for incorrect order of adding to settings
-- for faction, _ in pairs(faction_color_defs) do
for faction, v in pairs(faction_color_defs) do
-- options.gr[2].gr[№options.gr[2].gr + 1] = get_faction_color_template(faction)
options.gr[2].gr[v.i] = get_faction_color_template(faction)
end
for slot, _ in pairs(slot_cell_defs) do
local slot_template = get_slot_cell_template(slot)
for key = 1, #slot_template do
options.gr[3].gr[1].gr[#options.gr[3].gr[1].gr + 1] = slot_template[key]
end
end
-- Edited by Sota - stupid fix for incorrect order of adding to settings
local frst_idx_stat = #options.gr[3].gr[2].gr
-- for stat, _ in pairs(stat_defs) do
for stat, v in pairs(stat_defs) do
local stat_template = get_stats_color_template(stat)
for key = 1, #stat_template do
local idx = frst_idx_stat + v.i + (#stat_template - 1) * (v.i - 1) + key - 1
-- options.gr[3].gr[2].gr[№options.gr[3].gr[2].g] = stat_template[key]
options.gr[3].gr[2].gr[idx] = stat_template[key]
end
end
return options
end
function on_option_change()
if not ui_mcm then return end
for faction, _ in pairs(faction_color_defs) do
ui_inventory.faction_color[faction] = get_colors_for_path(string_format( "%s/faction_settings/%s", mcm_id, faction ), "")
ui_inventory.faction_text_colors[faction] = get_colors_for_path(string_format( "%s/faction_settings/%s", mcm_id, faction ), "_text")
end
for slot, _ in pairs(slot_cell_defs) do
ui_inventory.slot_colors[slot] = get_colors_for_path(string_format( "%s/base_settings/slots", mcm_id ), slot)
end
for stat, _ in pairs(stat_defs) do
ui_inventory.stat_colors[stat] = get_colors_for_path(string_format( "%s/base_settings/stats", mcm_id ), stat)
end
ui_inventory.banner_color = get_colors_for_path(string_format( "%s/base_settings/faction_banner", mcm_id ), "")
ui_inventory.player_faction_color = get_colors_for_path(string_format( "%s/base_settings/faction_banner", mcm_id ), "_text")
ui_inventory.color_settings = {
["stat_colors"] = ui_mcm.get(string_format( "%s/base_settings/stats/use_faction" , mcm_id )),
["banner_color"] = ui_mcm.get(string_format( "%s/base_settings/faction_banner/use_faction" , mcm_id )),
["slot_colors"] = ui_mcm.get(string_format( "%s/base_settings/slots/use_faction" , mcm_id )),
["text_color"] = ui_mcm.get(string_format( "%s/base_settings/faction_banner/use_faction_text" , mcm_id )),
["use_alt_ranks"] = ui_mcm.get(string_format( "%s/main_settings/use_alt_ranks" , mcm_id )),
-- Added by Sota - new MCM settings for UI Rework
["use_alt_factions"] = ui_mcm.get(string_format( "%s/main_settings/use_alt_factions" , mcm_id )),
["use_alt_inv"] = ui_mcm.get(string_format( "%s/main_settings/use_alt_inv" , mcm_id )),
["use_alt_grid"] = ui_mcm.get(string_format( "%s/main_settings/use_alt_grid" , mcm_id )),
["use_alt_blockers"] = ui_mcm.get(string_format( "%s/main_settings/use_alt_blockers" , mcm_id )),
["use_alt_upgr"] = ui_mcm.get(string_format( "%s/main_settings/use_alt_upgr" , mcm_id )),
["use_alt_equ_bars"] = ui_mcm.get(string_format( "%s/main_settings/use_alt_equ_bars" , mcm_id )),
["use_alt_inv_bars"] = ui_mcm.get(string_format( "%s/main_settings/use_alt_inv_bars" , mcm_id )),
["use_alt_stats_bars"] = ui_mcm.get(string_format( "%s/main_settings/use_alt_stats_bars" , mcm_id )),
["use_inv_labels"] = ui_mcm.get(string_format( "%s/main_settings/use_inv_labels" , mcm_id )),
["use_small_icons"] = ui_mcm.get(string_format( "%s/main_settings/use_small_icons" , mcm_id )),
["use_inv_vert"] = ui_mcm.get(string_format( "%s/main_settings/use_inv_vert" , mcm_id )),
["inv_hint_alpha"] = ui_mcm.get(string_format( "%s/main_settings/inv_hint_alpha" , mcm_id )),
}
-- if HTS Bars patch is installed need to get mcm setting
if hts_inventory_bars then
ui_inventory.color_settings["use_alt_hts"] = ui_mcm.get(string_format( "%s/main_settings/use_alt_hts" , mcm_id ))
end
-- if IWR patch is installed need to get mcm setting
if is_z_iwr then
ui_inventory.color_settings["use_inv_weights"] = ui_mcm.get(string_format( "%s/main_settings/use_inv_weights" , mcm_id ))
end
end
function get_colors_for_path(path, str)
return GetARGB(
ui_mcm.get(string_format( "%s/color_alpha%s" , path, str )),
ui_mcm.get(string_format( "%s/color_red%s" , path, str )),
ui_mcm.get(string_format( "%s/color_green%s" , path, str )),
ui_mcm.get(string_format( "%s/color_blue%s" , path, str ))
)
end
function on_game_start()
RegisterScriptCallback("on_option_change", on_option_change)
on_option_change()
end
@@ -0,0 +1,214 @@
--[[
HUD = nil
function activate_hud(gui)
-- open with inventory only
if gui ~= "UIInventory" then
return
end
-- check for inventory gui
if not (ui_inventory and ui_inventory.GUI) then
return
end
-- disable inventory power bar
if ui_inventory.GUI.stat and ui_inventory.GUI.stat["power"] and ui_inventory.GUI.stat["power"].base then
ui_inventory.GUI.stat["power"].base:Show(false)
end
-- show hud
if HUD == nil then
HUD = hts_tooltips()
get_hud():AddDialogToRender(HUD)
HUD:Update_Bars(true)
end
end
function deactivate_hud(gui)
-- if gui ~= "UIInventory" then return end
if HUD ~= nil then
get_hud():RemoveDialogToRender(HUD)
HUD = nil
end
end
class "hts_tooltips" (CUIScriptWnd)
function hts_tooltips:__init() super()
self:InitControls()
end
function hts_tooltips:InitControls()
self:SetWndRect(Frect():set(0,0,1024,768))
self:SetAutoDelete(true)
self.xml = CScriptXmlInit()
local xml = self.xml
xml:ParseFile("ui_new_bars.xml")
self.hts_t = {
[1] = { "satiety", get_satiety_val },
[2] = { "thirst", get_thirst_val },
[3] = { "sleep", get_sleep_val },
}
-- timer
self.tmr = 0
-- build elements
self.elems = self.elems or {}
for i = 1, 3 do
self.elems[i] = self.elems[i] or {}
-- bars
self.elems[i].bar_wnd = xml:InitStatic(self.hts_t[i][1] .. "_wnd", self)
self.elems[i].bar = xml:InitStatic(self.hts_t[i][1] .. "_wnd:bar", self.elems[i].bar_wnd)
-- default bar width, height
self.elems[i].width = self.elems[i].bar:GetWidth()
self.elems[i].height = self.elems[i].bar:GetHeight()
-- default bar texture rect (full bar = x2 - x1)
self.elems[i].rect_x1 = self.elems[i].bar:GetTextureRect().x1
self.elems[i].rect_y1 = self.elems[i].bar:GetTextureRect().y1
self.elems[i].rect_x2 = self.elems[i].bar:GetTextureRect().x2
self.elems[i].rect_y2 = self.elems[i].bar:GetTextureRect().y2
-- tooltip
self.elems[i].tooltip = xml:InitStatic(self.hts_t[i][1] .. "_wnd:tooltip", self.elems[i].bar_wnd)
end
end
function hts_tooltips:Update()
CUIScriptWnd.Update(self)
-- disable bars when in picker window
local picker_enabled = ui_inventory.GUI and ui_inventory.GUI.CC and ui_inventory.GUI.CC["picker"] and ui_inventory.GUI.CC["picker"]:IsShown()
for i = 1, #self.elems do
self.elems[i].bar_wnd:Show( (not picker_enabled) )
end
local tg = time_global()
if (tg < self.tmr) then return end
self.tmr = tg + 50
self:Update_Bars()
end
function hts_tooltips:Update_Bars()
local pos = GetCursorPosition()
for i = 1, #self.elems do
local elem = self.elems[i]
-- update bars
if elem.bar then
-- set new x2 rect
local x1 = elem.rect_x1
local x2 = x1 + ( (elem.rect_x2 - x1) * self.hts_t[i][2]())
self.elems[i].bar:SetTextureRect(Frect():set( x1, elem.rect_y1, x2, elem.rect_y2 ))
-- set new width
local width = elem.width * self.hts_t[i][2]()
self.elems[i].bar:SetWndSize(vector2():set( width, elem.height ))
end
-- update tooltip
self.elems[i].tooltip:Show(false)
if elem.tooltip then
local p, w, h = elem.bar_wnd:GetWndPos(), elem.bar_wnd:GetWidth(), elem.bar_wnd:GetHeight()
local pos_true = pos.x > p.x and pos.y > p.y and pos.x < (p.x + w) and pos.y < (p.y + h)
if pos_true then
self.elems[i].tooltip:Show(true)
self.elems[i].tooltip:TextControl():SetText( math.ceil(self.hts_t[i][2]() * 100) .. " %" )
end
end
end
end
function hts_tooltips:__finalize()
end
--]]
-------------------------- misc --------------------------
function get_red_thirst()
local max_thirst = get_local_val([[gamedata\scripts\actor_status_thirst.script]], "actor_status_thirst", "local start_blur_4") or 5760
return max_thirst
end
function get_red_sleep()
local max_sleep = get_local_val([[gamedata\scripts\actor_status_sleep.script]], "actor_status_sleep", "local start_blur_4") or 8750
return max_sleep
end
function get_local_val(path, script_name, str_to_find)
if _G[script_name] then
if not file_exists(path) then
return
end
for line in io.lines(path) do
if string.find(line, str_to_find) then
_,_, loc_val = string.find(line, "start_blur_4%s*=%s*(%d+)")
if type(tonumber(loc_val)) == "number" then
return loc_val
end
end
end
end
end
function file_exists(name)
local f = io.open(name, "r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
function get_satiety_val()
local conditions = db.actor:cast_Actor():conditions()
local satiety = conditions:GetSatiety()
local red_icon_satiety = conditions:SatietyCritical() * 0.5
satiety = normalize(satiety, red_icon_satiety, 1)
return satiety
end
function get_thirst_val()
local thirst = 1 - actor_status_thirst.get_water_deprivation()
local red_icon_thirst = get_red_thirst()
red_icon_thirst = 1 - normalize(red_icon_thirst, 0, 10000)
thirst = normalize(thirst, red_icon_thirst, 1)
return thirst
end
function get_sleep_val()
local sleep = 1 - actor_status_sleep.get_sleep_deprivation()
local red_icon_sleep = get_red_sleep()
red_icon_sleep = 1 - normalize(red_icon_sleep, 0, 10000)
sleep = normalize(sleep, red_icon_sleep, 1)
return sleep
end
--[[
function on_game_start()
RegisterScriptCallback("GUI_on_show", activate_hud)
RegisterScriptCallback("GUI_on_hide", deactivate_hud)
end
--]]
@@ -0,0 +1,24 @@
function on_xml_read()
RegisterScriptCallback("on_xml_read", function(xml_file_name, xml_obj)
if xml_file_name == [[ui\ui_inventory.xml]]
or xml_file_name == [[ui\ui_inventory_16.xml]]
or xml_file_name == [[ui\ui_inventory_21.xml]]
or xml_file_name == [[ui\actor_menu_equipment.xml]]
or xml_file_name == [[ui\actor_menu_equipment_16.xml]]
or xml_file_name == [[ui\actor_menu_equipment_21.xml]]
then
local opt_bars = ui_mcm and ui_mcm.get("efp_ui/main_settings/use_alt_equ_bars") or ui_inventory.color_settings.use_alt_equ_bars
local str_bars = ui_inventory.ui_rework_support.str_bars_lst[ opt_bars ]
local tex_bar = string.format( "ui_inGame2_inventory_status_bar%s" , str_bars )
for i=1,13 do
local res = xml_obj:query("equipment > cont_equ > cell_"..i.." > bar > progress > texture")
if res[1] then
local el = res[1]
xml_obj:setText(el, tex_bar)
end
end
end
end)
end
@@ -0,0 +1,19 @@
function on_xml_read()
RegisterScriptCallback("on_xml_read", function(xml_file_name, xml_obj)
if xml_file_name == [[ui\ui_hud.xml]]
then
local ratio = utils_xml.screen_ratio()
local res = xml_obj:query("indicators")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=208*ratio, y=728})
end
local res = xml_obj:query("belt")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=1024-156*ratio, y=742})
end
end
end)
end
@@ -0,0 +1,24 @@
function on_xml_read()
RegisterScriptCallback("on_xml_read", function(xml_file_name, xml_obj)
if xml_file_name == [[ui\ui_condition_bars.xml]]
or xml_file_name == [[ui\ui_condition_bars_16.xml]]
or xml_file_name == [[ui\ui_condition_bars_21.xml]]
then
local opt_bars = ui_mcm and ui_mcm.get("efp_ui/main_settings/use_alt_inv_bars") or ui_inventory.color_settings.use_alt_inv_bars
local str_bars = ui_inventory.ui_rework_support.str_bars_lst[ opt_bars ]
local tex_bar = string.format( "ui_svui_cond_bar%s" , str_bars )
local res = xml_obj:query("bar_cond > background > texture")
if res[1] then
local el = res[1]
xml_obj:setText(el, tex_bar)
end
local res = xml_obj:query("bar_cond > progress > texture")
if res[1] then
local el = res[1]
xml_obj:setText(el, tex_bar)
end
end
end)
end
@@ -0,0 +1,62 @@
function on_xml_read()
if not ui_mcm then
return
end
RegisterScriptCallback("on_xml_read", function(xml_file_name, xml_obj)
if xml_file_name == [[ui\ui_mm_main.xml]]
or xml_file_name == [[ui\ui_mm_main_16.xml]]
or xml_file_name == [[ui\ui_mm_main_21.xml]]
then
if is_not_empty(xml_obj:query("menu_main btn[name=btn_mcm]")) then
return
end
local ratio = utils_xml.screen_ratio()
local mcm_logo =
[[
<auto_static x="]] .. 1024-(15+(64+5)*3)*ratio .. [[" y="684" width="]] .. 64*ratio .. [[" height="64" stretch="1">
<texture>LogoAMCM.dds</texture>
</auto_static>
]]
local mcm_menu = [[<btn name="btn_mcm" caption="ui_mm_menu_mcm"/>]]
local res = xml_obj:query("background")
if res[1] then
local el = res[1]
xml_obj:insertFromXMLString(mcm_logo, el, #el.kids)
end
local res = xml_obj:query("menu_main")
if res[1] then
local el = res[1]
xml_obj:insertFromXMLString(mcm_menu, el, #el.kids-1)
end
local res = xml_obj:query("menu_main_logout")
if res[1] then
local el = res[1]
xml_obj:insertFromXMLString(mcm_menu, el, #el.kids)
end
local res = xml_obj:query("menu_main_last_save")
if res[1] then
local el = res[1]
xml_obj:insertFromXMLString(mcm_menu, el, #el.kids)
end
local res = xml_obj:query("menu_main_single")
if res[1] then
local el = res[1]
xml_obj:insertFromXMLString(mcm_menu, el, #el.kids-1)
end
local res = xml_obj:query("menu_main_single_dead")
if res[1] then
local el = res[1]
xml_obj:insertFromXMLString(mcm_menu, el, #el.kids-1)
end
local res = xml_obj:query("menu_main_mm")
if res[1] then
local el = res[1]
xml_obj:insertFromXMLString(mcm_menu, el, #el.kids-1)
end
end
end)
end
@@ -0,0 +1,216 @@
function on_xml_read()
RegisterScriptCallback("on_xml_read", function(xml_file_name, xml_obj)
-- PDA checkboxes
if xml_file_name == [[ui\pda_relations_f9.xml]]
or xml_file_name == [[ui\pda_relations_f9x.xml]]
or xml_file_name == [[ui\pda_relations_f10.xml]]
or xml_file_name == [[ui\pda_relations_f10x.xml]]
or xml_file_name == [[ui\pda_relations_f11.xml]]
or xml_file_name == [[ui\pda_relations_f11x.xml]]
or xml_file_name == [[ui\pda_relations_f12.xml]]
or xml_file_name == [[ui\pda_relations_f12x.xml]]
or xml_file_name == [[ui\pda_relations_f13.xml]]
or xml_file_name == [[ui\pda_relations_f13x.xml]]
or xml_file_name == [[ui\pda_relations_f14.xml]]
or xml_file_name == [[ui\pda_relations_f14x.xml]]
or xml_file_name == [[ui\pda_contacts.xml]]
or xml_file_name == [[ui\pda_contacts_16.xml]]
or xml_file_name == [[ui\pda_encyclopedia.xml]]
or xml_file_name == [[ui\pda_encyclopedia_16.xml]]
or xml_file_name == [[ui\pda_logs.xml]]
or xml_file_name == [[ui\pda_logs_16.xml]]
or xml_file_name == [[ui\pda_relations.xml]]
or xml_file_name == [[ui\pda_relations_16.xml]]
then
-- auto_check
local res = xml_obj:query("auto_check")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("auto_check > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=-20, y=2})
end
-- show_all
local res = xml_obj:query("show_all")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("show_all > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=-20, y=2})
end
-- image_checkbox
local res = xml_obj:query("image_checkbox")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("image_checkbox > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=-20, y=2})
end
-- message_checkbox
local res = xml_obj:query("message_checkbox")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("message_checkbox > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=-20, y=2})
end
-- filter_news
local res = xml_obj:query("filter_news")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("filter_news > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=-20, y=2})
end
-- filter_talk
local res = xml_obj:query("filter_talk")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("filter_talk > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=-20, y=2})
end
end
-- PDA upper buttons bg
if xml_file_name == [[ui\pda.xml]]
or xml_file_name == [[ui\pda_16.xml]]
then
local res = xml_obj:query("background_static > auto_frameline")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=753})
end
if res[2] then
local el = res[2]
xml_obj:setElementAttr(el, {width=0, height=0})
end
end
-- PDA small buttons bg
if xml_file_name == [[ui\pda_tasks.xml]]
or xml_file_name == [[ui\pda_tasks_16.xml]]
then
local res = xml_obj:query("center_background > auto_static")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=0, height=0, stretch=1})
end
if res[2] then
local el = res[2]
xml_obj:setElementAttr(el, {width=0, height=0})
end
local res = xml_obj:query("center_background > auto_frameline")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=0, y=8, width=764, height=19})
end
local res = xml_obj:query("filter_quest_npcs")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=615})
end
end
-- iTheon PDA taskboard buttons
if xml_file_name == [[ui\pda_taskboard.xml]]
or xml_file_name == [[ui\pda_taskboard_16.xml]]
then
local res = xml_obj:query("btn_accept_task")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("btn_accept_task > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=20, y=1, vert_align="c"})
end
local res = xml_obj:query("btn_next_task")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("btn_next_task > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=20, y=1, vert_align="c"})
end
local res = xml_obj:query("btn_refresh_tasks")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("btn_refresh_tasks > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=20, y=1, vert_align="c"})
end
end
if xml_file_name == [[ui\pda_taskboard.xml]]
or xml_file_name == [[ui\pda_taskboard_16.xml]]
then
local res = xml_obj:query("btn_accept_task")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("btn_accept_task > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=20, y=1, vert_align="c"})
end
local res = xml_obj:query("btn_next_task")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("btn_next_task > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=20, y=1, vert_align="c"})
end
local res = xml_obj:query("btn_refresh_tasks")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {width=15})
end
local res = xml_obj:query("btn_refresh_tasks > text")
if res[1] then
local el = res[1]
xml_obj:setElementAttr(el, {x=20, y=1, vert_align="c"})
end
end
end)
end
@@ -0,0 +1,59 @@
function on_xml_read()
RegisterScriptCallback("on_xml_read", function(xml_file_name, xml_obj)
if xml_file_name == [[ui\ui_inventory.xml]]
or xml_file_name == [[ui\ui_inventory_16.xml]]
or xml_file_name == [[ui\ui_inventory_21.xml]]
or xml_file_name == [[ui\actor_menu_state_info_htsp.xml]]
or xml_file_name == [[ui\actor_menu_state_info_htsp_16.xml]]
or xml_file_name == [[ui\actor_menu_state_info_htsp_21.xml]]
or xml_file_name == [[ui\actor_menu_state_info_hts_alt.xml]]
or xml_file_name == [[ui\actor_menu_state_info_hts_alt_16.xml]]
or xml_file_name == [[ui\actor_menu_state_info_hts_alt_21.xml]]
then
local opt_bars = ui_mcm and ui_mcm.get("efp_ui/main_settings/use_alt_stats_bars") or ui_inventory.color_settings.use_alt_stats_bars
local str_bars = ui_inventory.ui_rework_support.str_bars_lst[ opt_bars ]
local bar_type
for name,_ in pairs(ui_inventory.stat_colors) do
if name == "health" then
bar_type = name
elseif name == "hunger"
or name == "thirst"
or name == "sleep"
then
if xml_file_name == [[ui\ui_inventory.xml]]
or xml_file_name == [[ui\ui_inventory_16.xml]]
or xml_file_name == [[ui\ui_inventory_21.xml]]
then
bar_type = "hts"
elseif xml_file_name == [[ui\actor_menu_state_info_htsp.xml]]
or xml_file_name == [[ui\actor_menu_state_info_htsp_16.xml]]
or xml_file_name == [[ui\actor_menu_state_info_htsp_21.xml]]
then
bar_type = "hts_power"
else
bar_type = "progress"
end
else
bar_type = "progress"
end
local tex_bar_bg = string.format( "ui_inGame2_inventory_%s_bar%s_bg" , bar_type , str_bars )
local tex_bar = string.format( "ui_inGame2_inventory_%s_bar%s" , bar_type , str_bars )
local res = xml_obj:query("equipment > actor_state_info > "..name.."_sensor > state_progress > texture")
if res[1] then
local el = res[1]
xml_obj:setText(el, tex_bar_bg)
end
local res = xml_obj:query("equipment > actor_state_info > "..name.."_sensor > state_progress > progress > texture")
if res[1] then
local el = res[1]
xml_obj:setText(el, tex_bar)
end
end
end
end)
end
@@ -0,0 +1,65 @@
local patched = false
function on_game_start()
patch_ress_list()
end
function on_mcm_load()
patch_ress_list()
end
function patch_ress_list()
if patched then return end
if #ui_options.options == 0 then
ui_options.init_opt_base()
end
local id_1, id_2, id_3 = 0, 0, 0
for i=1,#ui_options.options do
if (ui_options.options[i].id == "video") then id_1 = i break end
end
for i=1,#ui_options.options[id_1].gr do
if (ui_options.options[id_1].gr[i].id == "basic") then id_2 = i break end
end
for i=1,#ui_options.options[id_1].gr[id_2].gr do
if (ui_options.options[id_1].gr[id_2].gr[i].id == "resolution") then id_3 = i break end
end
ui_options.options[id_1].gr[id_2].gr[id_3].content = { cont_vid_mode }
patched = true
end
function cont_vid_mode()
local function round_idp(num, idp)
local mult = 10^(idp or 0)
return math.ceil(num * mult + 0.5) / mult
end
local ratio = {
[round_idp(8/9, 1)] = "(8:9)" , -- 0,88 (1280 x 1440)
[round_idp(5/3, 1)] = "(5:3)" , -- 1,66 (1280 x 768)
[round_idp(5/4, 1)] = "(5:4)" , -- 1,25 (1280 x 1024)
[round_idp(4/3, 1)] = "(4:3)" , -- 1,33 (1024 x 768)
[round_idp(16/9, 1)] = "(16:9)" , -- 1,77 (1920 x 1080)
[round_idp(16/10, 1)] = "(16:10)" , -- 1,6 (1920 x 1200)
[round_idp(21/9, 1)] = "(21:9)" , -- 2,33 ()
[round_idp(21.33/9, 1)] = "(21:9)" , -- 2,37 (2560 x 1080)
[round_idp(32/9, 1)] = "(32:9)" , -- 3,55 (3840 x 1080)
}
local ress = game.get_resolutions() -- get all res list from engine in one string
ress = str_explode(ress,",")
local cont = {}
for i=#ress,1,-1 do
local res = str_explode( ress[i] , "x" )
local w = tonumber( res[1] )
local h = tonumber( res[2] )
local rat = ratio[round_idp( w/h , 1 )] or ""
cont[#cont + 1] = { (w.."x"..h) , (w.." x "..h.." "..rat) }
end
return cont
end
@@ -0,0 +1,114 @@
local _InitControls = ui_sleep_dialog.UISleep.InitControls
local _InitCallbacks = ui_sleep_dialog.UISleep.InitCallbacks
local _TestAndShow = ui_sleep_dialog.UISleep.TestAndShow
local _OnButtonSleep = ui_sleep_dialog.UISleep.OnButtonSleep
function ui_sleep_dialog.UISleep.OnButtonSleep(self)
if not soulslike.IsSoulslikeMode() then
_OnButtonSleep(self)
return
end
local bleeding = db.actor.bleeding > 0
local radiation = db.actor.radiation > 0
-- Prevent sleep if bleeding and/or iradiated.
if (bleeding or radiation) then
if (bleeding and radiation) then
actor_menu.set_msg(1, game.translate_string("st_sleep_bleeding_irradiated"),5)
elseif (bleeding) then
actor_menu.set_msg(1, game.translate_string("st_sleep_bleeding"),4)
elseif (radiation) then
actor_menu.set_msg(1, game.translate_string("st_sleep_irradiated"),4)
end
disable_info("sleep_active")
if self:IsShown() then
self:HideDialog()
Unregister_UI("UISleep")
end
return
end
-- Check if actor is inside a safe zone
local actor_hide = GetEvent("current_safe_cover") and true or false
-- Check if actor is inside a tent
if (not actor_hide) then
actor_hide = item_tent.get_nearby_tent(1.5)
end
-- If all is no, dont sleep
if (not actor_hide) then
actor_menu.set_msg(1, game.translate_string("st_cant_sleep_find_shelter_mlr"),4)
disable_info("sleep_active")
if self:IsShown() then
self:HideDialog()
Unregister_UI("UISleep")
end
return
end
_OnButtonSleep(self)
end
function ui_sleep_dialog.UISleep.TestAndShow(self, force)
if not soulslike.IsSoulslikeMode() then
_TestAndShow(self, force)
return
end
if force then
_TestAndShow(self, force)
else
-- Detour and show the UI so we can let the user
-- set their spawn point. Move the sleep check code
-- to the Sleep button click instead
self:Initialize()
self:ShowDialog(true)
Register_UI("UISleep","ui_sleep_dialog")
end
end
function ui_sleep_dialog.UISleep.InitControls(self)
_InitControls(self)
if not soulslike.IsSoulslikeMode() then
return
end
local xml = CScriptXmlInit()
xml:ParseFile("soulslike_ui_sleep_dialog.xml")
local function move(ctrl, deltaX, deltaY)
local pos = ctrl:GetWndPos()
ctrl:SetWndPos(vector2():set( pos.x + deltaX ,pos.y + deltaY ))
end
-- Edited by Sota
-- move(self.btn_sleep, 52, 0)
-- move(self.btn_cancel, 52, 0)
local ratio = utils_xml.screen_ratio()
move(self.btn_sleep, 70.5 * ratio, 0)
move(self.btn_cancel, 70.5 * ratio, 0)
self.btn_set_spawn = xml:Init3tButton("btn_set_spawn", self.back)
self:Register(self.btn_set_spawn, "btn_set_spawn")
-- Edited by Sota
-- if not utils_xml.is_widescreen() then
-- move(self.btn_set_spawn, 40, 0)
-- end
end
function ui_sleep_dialog.UISleep.InitCallbacks(self)
_InitCallbacks(self)
if not soulslike.IsSoulslikeMode() then
return
end
self:AddCallback("btn_set_spawn", ui_events.BUTTON_CLICKED, self.OnButtonSetSpawn, self)
end
function ui_sleep_dialog.UISleep:OnButtonSetSpawn()
soulslike.set_spawn(true);
end
@@ -0,0 +1,142 @@
local _Main_Controls = ui_mm_faction_select.UINewGame.Main_Controls
local _Main_CallBacks = ui_mm_faction_select.UINewGame.Main_CallBacks
local _OnStartGame = ui_mm_faction_select.UINewGame.OnStartGame
local _OnCheckSetAzazel = ui_mm_faction_select.UINewGame.OnCheckSetAzazel
function ui_mm_faction_select.UINewGame.Main_Controls(self, rand)
_Main_Controls(self, rand)
--[[
local function move(ctrl, deltaX, deltaY)
local pos = ctrl:GetWndPos()
ctrl:SetWndPos(vector2():set( pos.x + deltaX ,pos.y + deltaY ))
end
if efp_utils_mcm then
move(self.ck_azazel_mode_cap, 0, -10)
move(self.ck_azazel_mode, 0, -10)
else
move(self.ck_story_cap, 0, -10)
move(self.ck_story, 0, -10)
move(self.ck_azazel_mode_cap, 0, -15)
move(self.ck_azazel_mode, 0, -15)
move(self.ck_survival_cap, 0, -20)
move(self.ck_survival, 0, -20)
end
--]]
local xml = CScriptXmlInit()
xml:ParseFile ("soulslike_ui_mm_gamemode.xml")
self.ck_soulslike_mode_cap = xml:InitStatic("main_dialog:options:cap_check_soulslike_mode",self.templ_options)
self.ck_soulslike_mode = xml:InitCheck("main_dialog:options:check_soulslike_mode", self.templ_options)
self:Register(self.ck_soulslike_mode,"check_soulslike_mode")
--[[
if efp_utils_mcm then
move(self.ck_soulslike_mode_cap, 0, 65)
move(self.ck_soulslike_mode, 0, 65)
end
--]]
self.ck_states["ck_soulslike_mode"] = false
end
function ui_mm_faction_select.UINewGame.Main_CallBacks(self)
_Main_CallBacks(self)
self:AddCallback("check_soulslike_mode", ui_events.BUTTON_CLICKED, self.OnCheckSetSoulslike, self)
self:AddCallback("check_hardcore", ui_events.BUTTON_CLICKED, self.OnCheckHardcore, self)
end
function ui_mm_faction_select.UINewGame.OnStartGame(self)
if (not self.access) then
return
end
local character_name = self.character_name:GetText()
if axr_main and axr_main.config and character_name and character_name ~= "" then
local is_soulslike_mode = self.ck_soulslike_mode and self.ck_soulslike_mode:GetCheck() and true or nil
printf('[Soulslike] OnStartGame:is_soulslike_mode='..tostring(is_soulslike_mode))
axr_main.config:w_value("character_creation", "new_game_soulslike_mode", is_soulslike_mode)
axr_main.config:save()
end
_OnStartGame(self)
end
function ui_mm_faction_select.UINewGame.OnCheckSetAzazel(self)
_OnCheckSetAzazel(self)
if (not self.access) then
return
end
self.ck_soulslike_mode:SetCheck(false)
self.ck_states["ck_soulslike_mode"] = false
end
function ui_mm_faction_select.UINewGame:OnCheckHardcore()
if (not self.access) then
return
end
self.ck_soulslike_mode:SetCheck(false)
self.ck_states["ck_soulslike_mode"] = false
end
function ui_mm_faction_select.UINewGame:OnCheckSetSoulslike()
if (not self.access) then
return
end
self.ck_azazel_mode:SetCheck(false)
self.ck_states["ck_azazel_mode"] = false
self.ck_hardcore:SetCheck(false)
self.ck_states["ck_hardcore"] = false
self:LoadMap()
end
local function on_game_load(binder)
local config = axr_main.config
if not (config) then
printf('[Soulslike] on_game_load:no config')
return
end
local need_save
-- Gameplay Options
if (USE_MARSHAL) then
if (config:r_value("character_creation","new_game_soulslike_mode", 1) == true) then
printf('[Soulslike] on_game_load:enable_soulslike_mode=true')
alife_storage_manager.get_state().enable_soulslike_mode = true
config:w_value("character_creation","new_game_soulslike_mode")
need_save = true
end
end
if (need_save) then
config:save()
end
end
local function actor_on_first_update()
if not soulslike.IsSoulslikeMode() then
return
end
local state = alife_storage_manager.get_state()
if not state.soulslike_mode_initial_spawn_set and level.name() ~= 'fake_start' then
printf('Initial spawn point set to '..level.name())
soulslike.set_spawn(false)
state.soulslike_mode_initial_spawn_set = true
end
end
function on_game_start()
RegisterScriptCallback("on_game_load",on_game_load)
RegisterScriptCallback("actor_on_first_update", actor_on_first_update)
end
@@ -0,0 +1,48 @@
XML_bars = CScriptXmlInit()
XML_bars:ParseFile("ui_condition_bars.xml")
local 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
function on_game_start()
_Add_ProgressBar = utils_ui.UICellItem.Add_ProgressBar
utils_ui.UICellItem.Add_ProgressBar = function(self, xml, obj, sec, clsid)
_Add_ProgressBar(self, xml, obj, sec, clsid)
if (not self.bar) or (self.manual) or (self.alt_bar_set == sec) then return end
-- Hide all bars
self.bar:Show(false)
local multiuse = IsItem("multiuse",sec)
self.bar = XML_bars:InitProgressBar(multiuse and "bar_uses" or "bar_cond", self.cell)
local h_bar = self.bar:GetHeight()
self.bar:SetWndPos(vector2():set( 0 , (self.H - h_bar)))
-- Set progress
local cond = multiuse and (obj:get_remaining_uses()/10) or round_idp(obj:condition(), 1)
self.bar:SetProgressPos( clamp(cond,0,1) )
-- Bar properties
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.bar:SetColor( color )
end
self.bar:ShowBackground(props.background)
self.bar:Show(true)
self.alt_bar_set = sec -- so the bars don't constantly reset
end
end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1 @@
printf("1057 crash fix")
@@ -0,0 +1,245 @@
--[[
EverybodyLies
03 February 2022
RELEASE:
- Fixed bug in UICellItem:Add_Icon/Add_Shadow functions when icon inside rotated cells is displayed incorrectly.
UPD.03/02/2022:
- Added UICellItem:Create_Layer() fix from RavenAscendant icon override script.
- Fixed compatibility issue then player have an icon override script.
- Script renamed to 'utils_ui_icon_rotation_fix_mcm.script' for loading early enough to modify the New Game screens.
UPD.11/02/2022:
- Upgrade icon in rotated cell is now displayed on the top-right corner.
UPD.13/02/2022:
- Added shadows for scopes, silencers and grenade launchers! Compatible with icon_override.
TODO:
+ Add shadows for equipped atachments on weapon.
- Add support for custom attachment icon on weapon, not only attachment item icon itself.
]]--
-- Credits to RavenAscendant for this fix
function utils_ui.UICellItem:Create_Layer(ele, base, sec_m, sec_l, str_x, str_y, str_scale)
local ratio = utils_xml.screen_ratio()
local grid_size = self.grid_size
local x = str_x and SYS_GetParam(2,sec_m, str_x) or 0
local y = str_y and SYS_GetParam(2,sec_m, str_y) or 0
local w = SYS_GetParam(2,sec_l, "inv_grid_width",1) * grid_size
local h = SYS_GetParam(2,sec_l, "inv_grid_height",1) * grid_size
local scale = str_scale and SYS_GetParam(2,sec_m, str_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, the dimensions of the base icon do not change!
-- Move start pos to match the one for rotated base icon
-- Base icon rotates on its center. To calculate where the upper left corner went move to the center of the window then move along the rotated image
local w_b, h_b = base:GetWidth(), base:GetHeight()
local x_st = (w_b/2) - (h_b/2)*ratio --When the engine rotates an image it doesn't get streched. Which means it is efectivly ratio corected and centered, to move out from the center of the window to the top of the gun, we need to ratio corect the old height to get to the new width.
local y_st = (h_b/2) + (w_b/2) --no ratio corection here because movement out from the center is along the veritcal axis where no ratio adjustment is needed
-- printf("w:%s,h:%s, y:%s,x:%s",w_b, h_b, y_st,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 --window size doesn't change despite rotation so these dimensions don't get swapped. Because the icon is getting rotated ratio corection is moot and would just need to be compensated for in h_off
h_s = h * scale
w_off = (h_s/2) * ratio --because this is moving along the x axis it needs ratio corection
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 utils_ui.UICellItem:Add_Attachements(xml, obj, sec, clsid)
-- Hide attachments
if self.ico_scope then self.ico_scope:Show(false) end
if self.shadow_ico_scope then self.shadow_ico_scope:Show(false) end
if self.ico_sil then
self.ico_sil:Show(false)
self.shadow_sil:Show(false)
end
if self.ico_gl then
self.ico_gl:Show(false)
self.shadow_gl:Show(false)
end
-- On full stacking, hide counter
if self.container.stack_all and (self.childs and is_not_empty(self.childs)) then
return
end
-- No attachments on showcase cells
if (self.showcase ~= 0) then
return
end
-- No attachments for non-firearms
local magazined_wpn = IsWeapon(nil,clsid) and (not IsItem("fake_ammo_wpn",sec))
if (not magazined_wpn) then
return
end
-- Scope
local scope = (not utils_item.has_scope(sec)) and utils_item.get_attached_scope(obj)
if scope then
if (not self.ico_scope) then
if (not xml) then
xml = self:GetXML()
end
self.ico_scope = xml:InitStatic(self.path .. ":" .. self.cx .. ":pic", self.ico)
self.shadow_ico_scope = xml:InitStatic(self.path .. ":" .. self.cx .. ":pic", self.shadow)
end
local scopes_sect = utils_item.get_param(sec, obj:id(), "scopes_sect", "string", false)
self:Create_Layer(self.ico_scope, self.ico, scopes_sect, scope, "scope_x", "scope_y")
self:Print(nil, "Show scope")
self:Create_Layer(self.shadow_ico_scope, self.shadow, scopes_sect, scope, "scope_x", "scope_y")
self.shadow_ico_scope:SetTextureColor( GetARGB(200, 20, 20, 20) )
self:Print(nil, "Show scope shadow")
end
-- Silencer
local sil = utils_item.get_attached_silencer(obj)
if sil then
if (not self.ico_sil) then
if (not xml) then
xml = self:GetXML()
end
self.ico_sil = xml:InitStatic(self.path .. ":" .. self.cx .. ":pic", self.ico)
self.shadow_sil = xml:InitStatic(self.path .. ":" .. self.cx .. ":pic", self.shadow)
end
self:Create_Layer(self.ico_sil, self.ico, sec, sil, "silencer_x", "silencer_y")
self:Print(nil, "Show silencer")
self:Create_Layer(self.shadow_sil, self.shadow, sec, sil, "silencer_x", "silencer_y")
self.shadow_sil:SetTextureColor( GetARGB(200, 20, 20, 20) )
self:Print(nil, "Show silencer shadow")
end
-- Grenade Launcher
local gl = utils_item.get_attached_gl(obj)
if gl then
if (not self.ico_gl) then
if (not xml) then
xml = self:GetXML()
end
self.ico_gl = xml:InitStatic(self.path .. ":" .. self.cx .. ":pic", self.ico)
self.shadow_gl = xml:InitStatic(self.path .. ":" .. self.cx .. ":pic", self.shadow)
end
self:Create_Layer(self.ico_gl, self.ico, sec, gl, "grenade_launcher_x", "grenade_launcher_y")
self:Print(nil, "Show grenade launcher")
self:Create_Layer(self.shadow_gl, self.shadow, sec, gl, "grenade_launcher_x", "grenade_launcher_y")
self.shadow_gl:SetTextureColor( GetARGB(200, 20, 20, 20) )
self:Print(nil, "Show grenade launcher shadow")
end
end
function utils_ui.UICellItem:Add_Icon(sec, w, h)
local rot = self.ico:GetHeading() > 0
self.ico:InitTexture( utils_xml.get_icons_texture(sec) )
self.ico:SetTextureRect(Frect():set( utils_xml.get_item_axis(sec, nil, true) ))
self.ico:SetStretchTexture(true)
self.ico:SetWndSize(vector2():set( w * (rot and 1 or utils_xml.screen_ratio()) , h ))
self.ico:Show(true)
utils_xml.align_to_center(self.ico, self.cell)
self:Print(nil, "Show icon")
end
function utils_ui.UICellItem:Add_Shadow(sec, w, h)
local rot = self.shadow:GetHeading() > 0
local shadow_offset_x, shadow_offset_y = 1, 2
self.shadow:InitTexture( utils_xml.get_icons_texture(sec) )
self.shadow:SetTextureRect(Frect():set( utils_xml.get_item_axis(sec, nil, true) ))
self.shadow:SetStretchTexture(true)
self.shadow:SetWndSize(vector2():set( w * (rot and 1 or utils_xml.screen_ratio()) , h ))
self.shadow:Show(true)
utils_xml.align_to_center(self.shadow, self.cell)
local pos = self.ico:GetWndPos()
self.shadow:SetWndPos( vector2():set( pos.x + shadow_offset_x , pos.y + shadow_offset_y ) )
self.shadow:SetTextureColor( GetARGB(200, 20, 20, 20) )
self:Print(nil, "Show shadow")
end
function utils_ui.UICellItem:Add_Upgrade(xml, obj, sec)
-- Hide upgrade indicator
if self.upgr then
self.upgr:Show(false)
end
-- On full stacking, hide upgrade indicator
if self.container.stack_all and (self.childs and is_not_empty(self.childs)) then
return
end
-- Bar is applied only to upgraded items
if (not utils_item.has_upgrades(obj, sec)) then
return
end
-- Init if it doesn't exist
if (not self.upgr) then
if (not xml) then
xml = self:GetXML()
end
self.upgr = xml:InitStatic(self.path .. ":cell:upgrade", self.ico)
end
-- Positioning
local ico = self.ico
local ratio = utils_xml.screen_ratio()
local xx = 1 * ratio
local yy = 1
local w_b, h_b = ico:GetWidth(), ico:GetHeight()
local w_upgr, h_upgr = self.upgr:GetWidth(), self.upgr:GetHeight()
local rot = ico:GetHeading() > 0
if rot then
-- top corners (rot cell)
yy = yy - (w_b/2) + (h_b/2)
if utils_ui_demonized_inventory_weights then
-- top-right corner (rot cell)
xx = -xx + (w_b/2) + (h_b/2) * ratio - w_upgr
else
-- top-left corner (rot cell)
xx = xx + (w_b/2) - (h_b/2) * ratio
end
elseif utils_ui_demonized_inventory_weights then
-- top-right corner (non rot cell)
xx = -xx + w_b - w_upgr
end
self.upgr:SetWndPos(vector2():set( xx , yy ))
self.upgr:Show(true)
self:Print(nil, "Show upgrade indicator")
end
@@ -0,0 +1,99 @@
local icon_override = aaa_rax_icon_override_mcm.icon_override
local sync_element = utils_xml.sync_element
function aaa_rax_icon_override_mcm.utils_ui.UICellItem:Set(obj, area)
local ratio = utils_xml.screen_ratio()
-- Added by Sota - lazy fix for 16:10 ratio (specifically for 1600x1024)
local ratio_1610 = (4/3) / (16/10)
ratio = (ratio > ratio_1610) and (ratio < 1) and ratio_1610 or ratio
local xml = self:GetXML()
local path = self.path
local is_obj = (self.showcase == 0)
local grid_size = self.grid_size
local sec = is_obj and obj:section() or obj
local clsid = is_obj and obj:clsid()
local x = icon_override:section_exist(sec) and icon_override:r_float_ex(sec,"inv_grid_x") or SYS_GetParam(2,sec, "inv_grid_x")
local y = icon_override:section_exist(sec) and icon_override:r_float_ex(sec,"inv_grid_y") or SYS_GetParam(2,sec, "inv_grid_y")
local w = icon_override:section_exist(sec) and icon_override:r_float_ex(sec,"inv_grid_width") or SYS_GetParam(2,sec, "inv_grid_width")
local h = icon_override:section_exist(sec) and icon_override:r_float_ex(sec,"inv_grid_height") or SYS_GetParam(2,sec, "inv_grid_height")
if not x or not y or not w or not h then
return false
end
x = x * grid_size
y = y * grid_size
-- Edited by G_FLAT - inventory cells use grid line thickness, separate dimensions for icons
-- w = w * grid_size
-- h = h * grid_size
local icon_w = w * grid_size
local icon_h = h * grid_size
-- Added by G_FLAT - inventory cells use grid line thickness
local grid_line = self.grid_line
w = w * grid_size + (w-1) * grid_line
h = h * grid_size + (h-1) * grid_line
self.ID = is_obj and obj:id() or nil
self.section = sec
self.area = area
--self.X = x
--self.Y = y
self.W = w
self.H = h
-- Trade mode
--if self:Check_TradeMode(obj, sec) then
--return false
--end
-- Cell pos
if area and (not self.manual) then
local area_x = ((area.x * grid_size) - grid_size) * ratio
local area_y = (area.y * grid_size) - grid_size
-- Edited by Sota - fix the gap between cells for wide screens
-- local area_xl = self.grid_line * area.x
local area_xl = grid_line * area.x * ratio
local area_yl = grid_line * area.y
self.cell:SetWndPos(vector2():set( area_x + area_xl , area_y + area_yl ))
self.cell:SetWndSize(vector2():set(w * ratio , h))
sync_element(self.hl, self.cell)
self:Print(nil, "Set for [%s] in (%s,%s,%s,%s)", sec, area_x, area_y, w, h)
-- Cell pos (free cell)
elseif self.st then
local st_x = ((self.st:GetWidth() /2) - ((w * ratio) /2))
local st_y = ((self.st:GetHeight() /2) - (h /2))
self.cell:SetWndPos(vector2():set( st_x , st_y ))
self.cell:SetWndSize(vector2():set(w * ratio , h))
sync_element(self.hl, self.cell)
self:Print(nil, "Set for [%s] in free cell", sec)
end
-- Icon
-- Edited by G_FLAT - inventory cells use grid line thickness, separate dimensions for icons
-- self:Add_Icon(sec, w, h)
-- self:Add_Shadow(sec, w, h)
self:Add_Icon(sec, icon_w, icon_h)
self:Add_Shadow(sec, icon_w, icon_h)
-- Icon layers
self:Add_Layers(xml, obj, sec, clsid)
-- Update cell
local is_updated = self:Update(is_obj and obj)
if (not is_updated) then
self:Print(nil, "Updating failed for [%s] | Reset cell", sec)
self:Reset()
return false
end
self.cell:Show(true)
return true
end
@@ -0,0 +1,51 @@
function axr_companions.UICompanionList:InitControls()
-- Edited by Sota
-- local xml = utils_xml.get_hud_xml()
local xml = CScriptXmlInit()
xml:ParseFile("ui_hud_companion_list.xml")
self.dialog = xml:InitStatic("companion_list", self)
--utils_xml.correct_ratio(self.dialog, true)
-- Added by Sota
local scale = 0.75
local ratio = utils_xml.screen_ratio()
self.dialog:SetWndPos( vector2():set( 1024 - self.dialog:GetWidth() * ratio * scale , 0 ) )
self.companion_info = {}
for i=1,8 do
self.companion_info[i] = {}
self.companion_info[i].base = xml:InitStatic("companion_list:slot", self.dialog)
self.companion_info[i].background = xml:InitStatic("companion_list:slot:background", self.companion_info[i].base)
self.companion_info[i].icon = xml:InitStatic("companion_list:slot:icon", self.companion_info[i].base)
self.companion_info[i].danger_indicator = xml:InitStatic("companion_list:slot:danger_indicator", self.companion_info[i].base)
self.companion_info[i].team_role_shadow = xml:InitStatic("companion_list:slot:team_role", self.companion_info[i].base)
self.companion_info[i].team_role = xml:InitStatic("companion_list:slot:team_role", self.companion_info[i].base)
self.companion_info[i].distance_shadow = xml:InitTextWnd("companion_list:slot:distance", self.companion_info[i].base)
self.companion_info[i].distance = xml:InitTextWnd("companion_list:slot:distance", self.companion_info[i].base)
self.companion_info[i].prog_health = xml:InitProgressBar("companion_list:slot:health", self.companion_info[i].base)
for _,ele in pairs(self.companion_info[i]) do
-- Edited by Sota
-- utils_xml.correct_ratio(ele)
-- Added by Sota
local pos = ele:GetWndPos()
ele:SetWndPos( vector2():set( pos.x * ratio * scale , pos.y * scale ) )
local w, h = ele:GetWidth(), ele:GetHeight()
ele:SetWndSize( vector2():set( w * ratio * scale , h * scale ) )
end
local h = self.companion_info[i].background:GetHeight()
self.companion_info[i].distance:SetFont(GetFontSmall())
-- Edited by Sota
-- self.companion_info[i].base:SetWndPos( vector2():set( 0 , (8-i)*(h+10) ) )
self.companion_info[i].base:SetWndPos( vector2():set( 0 , self.dialog:GetHeight() - i * (h+5) ) )
local pos = self.companion_info[i].team_role:GetWndPos()
-- Edited by Sota
-- self.companion_info[i].team_role_shadow:SetWndPos( vector2():set( pos.x + 1 , pos.y + 2 ) )
self.companion_info[i].team_role_shadow:SetWndPos( vector2():set( pos.x + 1 * ratio * scale , pos.y + 1 * scale ) )
self.companion_info[i].team_role_shadow:SetTextureColor( GetARGB(255, 0, 0, 0) )
end
end
@@ -0,0 +1,116 @@
local cur_hint = inventory_upgrades.cur_hint
local char_ini = ini_file("item_upgrades.ltx")
local param_ini = ini_file("misc\\stalkers_upgrade_info.ltx")
local cur_price_percent = 2
local upg_ind = {
["a"] = 1,
["b"] = 1,
["c"] = 2,
["d"] = 2,
["e"] = 3,
["f"] = 3,
}
function inventory_upgrades.get_upgrade_cost(section)
cur_price_percent = inventory_upgrades.get_price_percent()
-- The text variable to be displayed
-- Edited by Sota
-- local str = " "
local str = ""
if db.actor then
-- Read the amount necessary for installation
local price = math.floor(char_ini:r_u32(section, "cost")*cur_price_percent)
-- Enter into the text variable the cost of the upgrade
-- Edited by Sota
-- str = " " .. game.translate_string("st_upgr_cost") .. ": " .. price
str = game.translate_string("st_upgr_cost") .. ": " .. price
end
return str
end
function inventory_upgrades.get_possibility_string(mechanic_name, possibility_table)
local str = ""
if (cur_hint) then
for k,v in pairs(cur_hint) do
-- Edited by Sota
-- str = str .. "\\n - " .. game.translate_string(v)
str = str .. "\\n • " .. game.translate_string(v)
end
end
if (str == "") then
str = " - add hints for this upgrade"
end
return str
end
function inventory_upgrades.prereq_functor_a( param3, section )
cur_price_percent = inventory_upgrades.get_price_percent()
local victim = get_speaker()
if not (victim) then
return ""
end
local mechanic_name = victim:section()
local str = ""
local custom = false
-- check section precondition
if (param_ini:line_exist(mechanic_name.."_upgr", section)) then
local param = param_ini:r_string_ex(mechanic_name.."_upgr", section)
if (param) then
custom = true
if (param=="false") then
return str
else
cur_hint = nil
local possibility_table = xr_logic.parse_condlist(victim, mechanic_name.."_upgr", section, param)
local possibility = xr_logic.pick_section_from_condlist(db.actor, victim, possibility_table)
if not(possibility) or (possibility=="false") then
str = str .. get_possibility_string(mechanic_name, possibility_table)
end
end
end
end
-- Check global precondition
if (not custom) then
local indx = section:sub(14,14)
local tier = indx and upg_ind[indx] or 1
local tier_con = param_ini:r_float_ex(mechanic_name, "def_upgr_tier_" .. tier)
--printf("upgrade global precond | mechanic_name: %s - tier: %s - tier_con: %s ", mechanic_name, tier, tier_con)
-- check if mechanic has tools suitable upgrade's tier
if (tier_con == 0) then
if (not has_alife_info(mechanic_name .. "_upgrade_tier_" .. tier)) then
-- Edited by Sota
-- str = str .. "\\n - " .. game.translate_string("st_upgr_condlist")
str = str .. "\\n • " .. game.translate_string("st_upgr_condlist")
end
-- permanently locked
elseif (tier_con == 1) then
-- Edited by Sota
-- str = str .. "\\n - " .. game.translate_string("st_upgr_cant_do")
str = str .. "\\n • " .. game.translate_string("st_upgr_cant_do")
end
end
-- Check money
local actor = db.actor
if actor then
-- We read from the upgrade section its price
local price = math.floor(char_ini:r_u32(section, "cost")*cur_price_percent)
-- Read the number of dough from YY
local cash = actor:money()
-- If the bubble is not enough, then we list the corresponding line
if (cash < price) then
-- Edited by Sota
-- str = str .. "\\n - "..game.translate_string("st_upgr_enough_money").."\\n • "..price-cash.." RU"
str = str .. "\\n • " .. game.translate_string("st_upgr_enough_money") .. ": " .. price-cash .. " RU"
end
end
return str
end
@@ -0,0 +1,947 @@
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
-- Added by Sota
local ratio = utils_xml.screen_ratio()
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()
-- Edited by Sota
--local cond_dot_w = cond_dot_h * 0.75
local cond_dot_w = cond_dot_h * ratio
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)) )
-- Edited by Sota
--local bg_padding = name_w * 0.08
local bg_padding = name_w * 0.025
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
-- Edited by Sota
--local bg_padding = name_w * 0.08
local bg_padding = name_w * 0.025
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)) )
-- Edited by Sota
--local bg_padding = name_w * 0.08
local bg_padding = name_w * 0.025
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,93 @@
function item_recipe.UIRecipe:Reset(section)
self.section = section
local name = ui_item.get_sec_name(section)
-- Edited by Sota
-- self.cap_shadow:SetText( name )
self.cap:SetText( name )
-- Reset recipes
empty_table(self.recipes)
self:LoadRecipes()
-- Clear scroll
local xml = self.xml
self.scroll:Clear()
empty_table(self.cells)
-- Collect valid items
local itm_counter = {}
db.actor:iterate_inventory( function(temp, item)
local sec = item:section()
local cnt = IsItem("multiuse",nil,item) and item:get_remaining_uses() or 1
itm_counter[sec] = (itm_counter[sec] or 0) + cnt
end)
-- Edited by Sota
-- local fnt = GetFontSmall()
for i=1,#self.recipes do
local _st = xml:InitStatic("recipe:form", nil)
self.cells[i] = {}
xml:InitFrame("recipe:list:frame_1", _st)
xml:InitFrame("recipe:list:frame_2", _st)
--xml:InitStatic("recipe:list:light", _st)
--xml:InitStatic("recipe:list:arrow", _st)
local line = xml:InitStatic("recipe:list:pic_line",_st)
-- Edited by Sota
-- line:InitTexture("ui_itm_line")
local j=1
while true do
if (j ~= 1) and (not self.recipes[i][j-1]) then
break
end
--xml_itm_shadow = xml:InitStatic("recipe:list:itm_" .. tostring(j) .. "_shadow", _st)
--xml_itm_shadow:InitTexture("ui_button_light_h")
local sec = (j == 1) and self.recipes[i].sec or self.recipes[i][j-1][1]
local amount_req = (j == 1) and 1 or self.recipes[i][j-1][2]
local multi = 1
if IsItem("ammo",sec) then
multi = IsItem("ammo",sec)
end
local txt = ""
local clr = GetARGB(255, 255, 255, 255)
if (j == 1) then
txt = "x" .. (multi * amount_req)
else
txt = (multi * (itm_counter[sec] or 0)) .. "/" .. (multi * amount_req)
-- Edited by Sota
if ( (itm_counter[sec] or 0) >= amount_req ) then
clr = GetARGB(255, 50, 255, 50)
-- added red text color if not enough items
else
clr = GetARGB(255, 255, 50, 50)
end
end
self.cells[i][j] = utils_ui.UICellItem( {path="container" , xml=xml , grid_size=35 } , { path="recipe:list:itm_" .. tostring(j) , base= _st } )
self.cells[i][j].showcase = 2
self.cells[i][j].disable_bar = true
self.cells[i][j]:Set(sec)
-- Edited by Sota - container with text can now be configured via xml file "ui_items_recipe.xml"
-- self.cells[i][j]:Add_CustomText( txt, 4, nil, clr, fnt)
self.cells[i][j].txt = xml:InitTextWnd("recipe:list:itm_" .. tostring(j), _st)
self.cells[i][j].txt:SetText(txt)
self.cells[i][j].txt:SetTextColor(clr)
j = j + 1
end
self.scroll:AddWindow(_st, true)
_st:SetAutoDelete(true)
end
-- Showing toolkit icon
if self.toolkit then
self.cells_tool:Set(self.toolkit)
end
end
@@ -0,0 +1,26 @@
local uisleep_initcontrols = ui_sleep_dialog.UISleep.InitControls
ui_sleep_dialog.UISleep.InitControls = function(self)
uisleep_initcontrols(self)
self.wide = false
end
local uisleep_initialize = ui_sleep_dialog.UISleep.Initialize
ui_sleep_dialog.UISleep.Initialize = function(self)
uisleep_initialize(self)
local ratio = utils_xml.screen_ratio()
self.sleep_static:SetWndSize(vector2():set(self.sleep_static:GetWidth() * ratio, self.sleep_static:GetHeight() ))
self.sleep_static2:SetWndSize(vector2():set(self.sleep_static2:GetWidth() * ratio, self.sleep_static:GetHeight() ))
self.sleep_static2:SetWndPos(vector2():set(self.sleep_static:GetWndPos().x + self.sleep_static:GetWidth(), self.sleep_static:GetWndPos().y ))
end
local uisleep_update = ui_sleep_dialog.UISleep.Update
ui_sleep_dialog.UISleep.Update = function(self)
uisleep_update(self)
local ratio = utils_xml.screen_ratio()
if self:IsShown() then
self.st_marker:SetWndPos(vector2():set(self.st_marker:GetWndPos().x * ratio, 5))
end
end
@@ -0,0 +1,413 @@
local SetTip = ui_workshop.SetTip
local clr_list = {
["g"] = utils_xml.get_color("d_green"),
["y"] = utils_xml.get_color("yellow"),
["o"] = utils_xml.get_color("d_orange"),
["r"] = utils_xml.get_color("d_red"),
["b"] = utils_xml.get_color("d_cyan"),
["b1"] = utils_xml.get_color("pda_blue"),
["b2"] = utils_xml.get_color("d_blue"),
["p"] = utils_xml.get_color("d_purple"),
["dark"] = utils_xml.get_color("ui_gray_2"),
}
local ui_workshop_init_controls = ui_workshop.UIWorkshop.InitControls
ui_workshop.UIWorkshop.InitControls = function(self)
ui_workshop_init_controls(self)
self.btn_back = self.xml:Init3tButton("workshop:btn_back", self.dialog)
self:Register(self.btn_back, "button_cancel")
end
local ui_workshop_init_callbacks = ui_workshop.UIWorkshop.InitCallBacks
ui_workshop.UIWorkshop.InitCallBacks = function(self)
ui_workshop_init_callbacks(self)
self:AddCallback("button_cancel", ui_events.BUTTON_CLICKED, self.Close, self)
end
--[[
local ui_workshop_reset = ui_workshop.UIWorkshop.Reset
ui_workshop.UIWorkshop.Reset = function(self, owner, mechanic, toolkits_workshop, dbg)
ui_workshop_reset(self, owner, mechanic, toolkits_workshop, dbg)
-- Fix by Grok from GAMMA - blocking the Workshop UI with a tooltip window
if self.owner.item_info then
self.owner.item_info:Update()
end
if self.owner.upgr_info then
self.owner.upgr_info:Update()
end
end
--]]
local ui_workshop_repair_init_controls = ui_workshop.UIWorkshopRepair.InitControls
ui_workshop.UIWorkshopRepair.InitControls = function(self, x, y)
ui_workshop_repair_init_controls(self, x, y)
self.toolkit = nil
end
function ui_workshop.UIWorkshopRepair:Update()
CUIScriptWnd.Update(self)
-- Updating item info box and item cell containers
local info_box = self.owner.item_info
local found_cell = false
for name,cc in pairs(self.CC) do
found_cell = cc:Update(info_box) or found_cell
end
if found_cell then
return
end
-- Added by Sota - Item repair toolkit
if self.itm_ico_rq and self.itm_ico_rq:IsCursorOverWindow() and self.toolkit then
info_box:Update(nil,self.toolkit)
return
end
local focused = false
for i=1,6 do
if self.parts[i] and self.parts[i].sec and (self.parts[i].sec ~= "na") and self.itm_ico[i]:IsCursorOverWindow() then
info_box:Update(nil, self.parts[i].sec)
focused = true
--return
end
if self.itm_btn[i] and self.itm_btn[i]:IsCursorOverWindow() then
self.highlight_btn = i
focused = true
--return
end
if focused then
return
end
end
info_box:Update()
end
local ui_workshop_state_reset = ui_workshop.UIWorkshopState.Reset
ui_workshop.UIWorkshopState.Reset = function(self)
ui_workshop_state_reset(self)
-- Mechanic availability
local mech_name = game.translate_string("st_ui_workshop_owner_nobody")
local str_intro = game.translate_string("st_ui_workshop_info_state_intro")
local str_owner = game.translate_string("st_ui_workshop_owner")
local mech_sec = self.owner.mechanic
if mech_sec then
local obj_mech = get_story_object(mech_sec)
if obj_mech then
mech_name = obj_mech:character_name()
end
end
self.info_text:SetText( str_intro .. clr_list["b2"] .. " \\n • " .. strformat(str_owner,mech_name) )
-- Fix by Grok from GAMMA - blocking the Workshop UI with a tooltip window
if self.owner.item_info then
self.owner.item_info:Update()
end
if self.owner.upgr_info then
self.owner.upgr_info:Update()
end
end
function ui_workshop.UIWorkshopState:OnKeyboard(dik, keyboard_action)
local res = CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
if (res == false) then
local bind = dik_to_bind(dik)
if keyboard_action == ui_events.WINDOW_KEY_PRESSED then
if dik == DIK_keys.DIK_ESCAPE then
-- Fix by Grok from GAMMA - blocking the Workshop UI with a tooltip window
self:Reset()
self:Close()
Unregister_UI("UIWorkshopState")
end
end
end
return res
end
local ui_workshop_repair_reset = ui_workshop.UIWorkshopRepair.Reset
ui_workshop.UIWorkshopRepair.Reset = function(self)
ui_workshop_repair_reset(self)
-- Fix by Grok from GAMMA - blocking the Workshop UI with a tooltip window
if self.owner.item_info then
self.owner.item_info:Update()
end
if self.owner.upgr_info then
self.owner.upgr_info:Update()
end
end
function ui_workshop.UIWorkshopRepair:OnKeyboard(dik, keyboard_action)
local res = CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
if (res == false) then
for name,cc in pairs(self.CC) do
cc:OnKeyboard(dik, keyboard_action)
end
local bind = dik_to_bind(dik)
if keyboard_action == ui_events.WINDOW_KEY_PRESSED then
if dik == DIK_keys.DIK_ESCAPE then
-- Fix by Grok from GAMMA - blocking the Workshop UI with a tooltip window
self:Reset()
self:Close()
Unregister_UI("UIWorkshopRepair")
end
end
end
return res
end
local ui_workshop_upgrade_reset = ui_workshop.UIWorkshopUpgrade.Reset
ui_workshop.UIWorkshopUpgrade.Reset = function(self)
ui_workshop_upgrade_reset(self)
-- Fix by Grok from GAMMA - blocking the Workshop UI with a tooltip window
if self.owner.item_info then
self.owner.item_info:Update()
end
if self.owner.upgr_info then
self.owner.upgr_info:Update()
end
end
function ui_workshop.UIWorkshopUpgrade:Update()
CUIScriptWnd.Update(self)
local info_box = self.owner.item_info
local upgr_box = self.owner.upgr_info
-- Item upgrade toolkit
if self.itm_ico_rq and self.itm_ico_rq:IsCursorOverWindow() and self.upgr_toolkit then
self.update_cache["type"] = 1 -- reset cache
upgr_box:Update()
info_box:Update(nil,self.upgr_toolkit)
return
end
-- Item cell containers
local found_cell = self.CC:Update(info_box)
if (found_cell) then
self.update_cache["type"] = 1 -- reset cache
upgr_box:Update()
return
end
-- Upgrade tree
for k1,v1 in pairs(self.upgr_xml) do
for k2,v2 in pairs(v1) do
if v2.pic:IsCursorOverWindow() and self.upgr[k1][k2] then
-- Cache
if (self.update_cache["type"] == 2) and (self.update_cache["k1"] == k1) and (self.update_cache["k2"] == k2) then
upgr_box:Update(self.update_cache["section"], self.update_cache["prereq"], self.update_cache["installed"])
return
end
local section = self.upgr[k1][k2].section
local installed = self.inst_upgr[section]
local prereq = ""
local t = self.upgr_flags[k1][k2]
local has_prereq = false
for i=1,#t do
if (not t[i]) then
local str = game.translate_string("st_ui_workshop_no_upgr_" .. tostring(i))
if (i == 1) then
local main_tool = self.upgr_toolkit or ""
str = strformat(str, ui_item.get_sec_name(main_tool))
elseif (i == 2) then
local tool = self.upgr[k1][k2].tool or ""
str = strformat(str, ui_item.get_sec_name(tool))
end
-- Edited by Sota
-- prereq = prereq .. "\\n - " .. str
prereq = prereq .. "\\n • " .. str
has_prereq = true
end
end
if has_prereq then
prereq = game.translate_string("st_upgr_disable") .. prereq
elseif installed then
prereq = game.translate_string("st_upgr_installed")
end
-- Cache
self.update_cache["type"] = 2
self.update_cache["k1"] = k1
self.update_cache["k2"] = k2
self.update_cache["section"] = section
self.update_cache["installed"] = installed
self.update_cache["prereq"] = prereq
upgr_box:Update(section, prereq, installed)
info_box:Update()
return
-- Upgrade kit
elseif v2.itm:IsCursorOverWindow() and self.upgr[k1][k2] then
self.update_cache["type"] = 1 -- reset cache
local tool = self.upgr[k1][k2].tool
if tool then
upgr_box:Update()
info_box:Update(nil,tool)
return
end
end
end
end
upgr_box:Update()
info_box:Update()
end
local ui_workshop_upgrade_list_upgrade_tree = ui_workshop.UIWorkshopUpgrade.ListUpgradeTree
ui_workshop.UIWorkshopUpgrade.ListUpgradeTree = function(self)
ui_workshop_upgrade_list_upgrade_tree(self)
local main_tool = self.upgr_toolkit
if main_tool and self.upgr_tools[main_tool] and is_not_empty(self.upgr_tools[main_tool]) then
SetTip("upgrade_tip_1", "upgrade_warning_2", "upgrade_solution_2", nil, false, self.info_text)
else
SetTip("upgrade_tip_1", "upgrade_warning_1", "upgrade_solution_1", self.upgr_toolkit, false, self.info_text)
end
end
function ui_workshop.UIWorkshopUpgrade:EvaluateUpgrades()
-- First we process the newely installed upgrade
for row,w in pairs(self.upgr) do
for col,v in pairs(w) do
if self.upgr_xml[row][col].btn:GetCheck()
and (not self.inst_upgr[v.section])
then
self:DischargeKit(self.upgr_toolkit)
self:DischargeKit(v.tool)
self.inst_upgr[v.section] = true
utils_obj.play_sound("interface\\inv_slot")
SetTip("upgrade_tip_3", nil, nil, nil, true, self.info_text)
self.btn_upgrade:Enable(true)
end
end
end
-- Lock/Unlock upgrades according to requirements
for row,w in pairs(self.upgr) do
for col,v in pairs(w) do
self:EvaluateUpgrade(row, col, v)
end
end
-- Workshop toolkit update
self:SetkitInfo(self.upgr_toolkit, self.itm_num_rq, self.itm_ico_rq, self.itm_ico_temp_rq)
-- Edited by Sota
--[[
local main_tool = self.upgr_toolkit
if main_tool and self.upgr_tools[main_tool] and is_not_empty(self.upgr_tools[main_tool]) then
SetTip("upgrade_tip_1", "upgrade_warning_2", "upgrade_solution_2", nil, false, self.info_text)
else
SetTip("upgrade_tip_1", "upgrade_warning_1", "upgrade_solution_1", self.upgr_toolkit, false, self.info_text)
end
--]]
end
function ui_workshop.UIWorkshopUpgrade:OnKeyboard(dik, keyboard_action)
local res = CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
if (res == false) then
self.CC:OnKeyboard(dik, keyboard_action)
local bind = dik_to_bind(dik)
if keyboard_action == ui_events.WINDOW_KEY_PRESSED then
if dik == DIK_keys.DIK_ESCAPE then
-- Fix by Grok from GAMMA - blocking the Workshop UI with a tooltip window
self:Reset()
self:Close()
Unregister_UI("UIWorkshopUpgrade")
end
end
end
return res
end
local ui_workshop_craft_reset = ui_workshop.UIWorkshopCraft.Reset
ui_workshop.UIWorkshopCraft.Reset = function(self)
ui_workshop_craft_reset(self)
-- Fix by Grok from GAMMA - blocking the Workshop UI with a tooltip window
if self.owner.item_info then
self.owner.item_info:Update()
end
if self.owner.upgr_info then
self.owner.upgr_info:Update()
end
end
function ui_workshop.UIWorkshopCraft:OnKeyboard(dik, keyboard_action)
local res = CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
if (res == false) then
for name,cc in pairs(self.CC) do
cc:OnKeyboard(dik, keyboard_action)
end
local bind = dik_to_bind(dik)
if keyboard_action == ui_events.WINDOW_KEY_PRESSED then
if dik == DIK_keys.DIK_ESCAPE then
-- Fix by Grok from GAMMA - blocking the Workshop UI with a tooltip window
self:Reset()
self:Close()
Unregister_UI("UIWorkshopCraft")
end
end
end
return res
end
function ui_workshop.UIWorkshopCraft:Update()
CUIScriptWnd.Update(self)
local info_box = self.owner.item_info
-- Item cells
local found_cell = false
for name,cc in pairs(self.CC) do
found_cell = cc:Update(info_box) or found_cell
end
if found_cell then
return
end
-- Added by Sota - Item craft toolkit
local item = self.last_type and self.last_index and self.recipes[self.last_type] and self.recipes[self.last_type][self.last_index]
if item then
local toolkit = ui_workshop.workshop_toolkits[item.tool]
if self.itm_ico_t:IsCursorOverWindow() and toolkit then
info_box:Update(nil,toolkit)
return
end
end
-- Added by Sota - Item result
if self.itm_ico_r:IsCursorOverWindow() and self.craft_item_r[1] then
info_box:Update(nil,self.craft_item_r[1])
return
end
-- Item of active recipe
for i=1,4 do
if self.itm_ico[i] and self.itm_ico[i]:IsCursorOverWindow() then
local item = self.last_type and self.last_index and self.recipes[self.last_type] and self.recipes[self.last_type][self.selected_index]
if item and item[i] then
info_box:Update(nil,item[i][1])
return
end
end
end
info_box:Update()
end
@@ -0,0 +1,84 @@
-- Inventory Weights Revised by demonized
local XMLP = CScriptXmlInit()
XMLP:ParseFile("ui_demonized_inventory_weights.xml")
ui_cell_item_update = utils_ui.UICellItem.Update
utils_ui.UICellItem.Update = function(self, obj)
local res = ui_cell_item_update(self, obj)
obj = obj or (self.ID and level.object_by_id(self.ID))
if (self.showcase == 0) and (not obj) then
return false
end
-- Init weight xml
if not self.weight then
self.weight = XMLP:InitStatic("weight", self.cell)
end
-- Update weight counter
self:Add_Weight(obj, self.section)
return res
end
ui_cell_item_reset = utils_ui.UICellItem.Reset
utils_ui.UICellItem.Reset = function(self)
ui_cell_item_reset(self)
if self.manual then
if self.weight then self.weight:Show(false) end
end
end
utils_ui.UICellItem.Get_Weight_Text_Template = function(self, weight)
return weight .. game.translate_string("st_kg")
end
utils_ui.UICellItem.Set_Weight_Text = function(self, weight)
self.weight:TextControl():SetText(self:Get_Weight_Text_Template(weight))
end
utils_ui.UICellItem.Add_Weight = function(self, obj, sec)
-- Hide counter
if self.weight then
self.weight:Show(false)
end
-- Edited by Sota - don't show labels if inventory weights is disabled
if (not obj) or (not ui_inventory.color_settings.use_inv_weights) then
return
end
local weight = obj:weight()
if self:HasChild() then
-- Add weight of stacked items
for id,_ in pairs(self.childs) do
local child_obj = level.object_by_id(id)
if child_obj then
weight = weight + child_obj:weight()
end
end
-- Move to below item count
-- Edited by Sota - x offset from xml file
--self.weight:SetWndPos(vector2():set(-1, 10))
self.weight:SetWndPos(vector2():set(self.weight:GetWndPos().x, 10))
else
-- If ammo - move it below always
if IsItem("ammo",sec) then
-- Edited by Sota - x offset from xml file
--self.weight:SetWndPos(vector2():set(-1, 10))
self.weight:SetWndPos(vector2():set(self.weight:GetWndPos().x, 10))
else
-- Move to top
-- Edited by Sota - x offset from xml file
--self.weight:SetWndPos(vector2():set(-1, 10))
self.weight:SetWndPos(vector2():set(self.weight:GetWndPos().x, -1))
end
end
self:Set_Weight_Text(round_100(weight))
self.weight:Show(true)
end
@@ -0,0 +1,204 @@
local clr_icon_1 = GetARGB(255, 255, 255, 255)
local clr_icon_2 = GetARGB(100, 255, 255, 255)
local ico_size, rw, rh, _le = 0.7,1,1,50
local ico_width
function utils_xml.set_icon(sec, hidden, XML_temp, XML_box, XML_box_small)
-- Edited by Sota
-- ico_width = ico_width or (is_widescreen() and 0.8 or 1)
ico_width = ico_width or utils_xml.screen_ratio()
if not (XML_temp and XML_box) then
callstack()
printe("!ERROR utils_xml.set_icon | XML_box or XML_temp doesn't exist")
return
end
if not (sec and ini_sys:section_exist(sec)) then
XML_box:Show(false)
callstack()
printe("!ERROR utils_xml.set_icon | section [%s] doesn't exist in system ini", sec)
return
end
-- Icon
local ico = utils_xml.get_item_axis(sec)
XML_box:InitTexture( utils_xml.get_icons_texture(sec) )
XML_box:SetTextureRect(Frect():set(ico.x1, ico.y1, ico.x2, ico.y2))
XML_box:SetTextureColor( hidden and clr_icon_2 or clr_icon_1 )
XML_box:SetStretchTexture(true)
XML_box:Show(true)
local pos = XML_temp:GetWndPos()
local _w = XML_temp:GetWidth()
local _h = XML_temp:GetHeight()
local ratio = ico.w/ico.h
local h, w
ico.w = ico.w * ico_size * ico_width
ico.h = ico.h * ico_size
for i=1,2 do
local w_t, h_t = 0, 0
local resize = false
if (ico.w > _w) then -- if icon width is bigger than frame width
-- Edited by Sota
-- w_t = ico.w - _w
w_t = (ico.w - _w) / ico_width -- remove width scaling for correct comparison with height
resize = true
end
if (ico.h > _h) then -- if icon height is bigger than frame height
h_t = ico.h - _h
resize = true
end
if resize then -- resize is required
if (w_t >= h_t) then -- if icon width is the big number (or square), use it as a base for resizing
w = _w
-- Edited by Sota
-- h = w / ratio
h = w / ratio / ico_width -- remove width scaling (no need for height)
elseif (w_t < h_t) then -- if icon width is the big number, use it as a base for resizing
h = _h
-- Edited by Sota
-- w = h * ratio
w = h * ratio * ico_width -- add width scaling because we get width from height
end
else -- no resize
w = ico.w
h = ico.h
end
end
local offset_x = (_w - w)/2
local offset_y = (_h - h)/2
XML_box:SetWndSize(vector2():set(w , h))
XML_box:SetWndPos(vector2():set(pos.x + offset_x , pos.y + offset_y))
local ico_layer = ini_sys:r_string_ex(sec,"1icon_layer")
if XML_box_small and ico_layer then
local ico_layer_x = ini_sys:r_float_ex(sec,"1icon_layer_x")
local ico_layer_y = ini_sys:r_float_ex(sec,"1icon_layer_y")
local ico_layer_scale = ini_sys:r_float_ex(sec,"1icon_layer_scale")
if (ico_layer_x == 0) and (ico_layer_y == 0) and (ico_layer_scale == 1) then
utils_xml.set_icon(ico_layer, hidden, XML_temp, XML_box_small)
end
end
end
local upgr_chk = {
["weapon"] = {
{ x = 1724 , y = 802 , w = 167 , h = 159 }
},
["outfit"] = {
{ x = 716 , y = 824 , w = 198 , h = 129 },
{ x = 814 , y = 579 , w = 159 , h = 137 },
{ x = 90 , y = 818 , w = 185 , h = 140 }
},
}
function utils_xml.set_upgr_icon(obj, sec, XML_box, XML_temp)
-- Edited by Sota
-- ico_width = ico_width or (utils_xml.is_widescreen() and 0.8 or 1)
ico_width = ico_width or utils_xml.screen_ratio()
local upgr_x = ini_sys:r_float_ex(sec,"upgr_icon_x")
local upgr_y = ini_sys:r_float_ex(sec,"upgr_icon_y")
local upgr_w = ini_sys:r_float_ex(sec,"upgr_icon_width")
local upgr_h = ini_sys:r_float_ex(sec,"upgr_icon_height")
if not (upgr_x and upgr_y and upgr_w and upgr_h) then
utils_xml.set_icon(sec, nil, XML_temp, XML_box)
return
end
-- Get upgrade dds
local upgr_path = ini_sys:r_string_ex(sec,"upgr_icon_path")
upgr_path = upgr_path or IsWeapon(obj) and "ui\\ui_actor_weapons" or "ui\\ui_actor_armor"
-- Decide if it should use normal icon instead
local use_ico = false
local t = {}
if IsWeapon(obj) then
for i=1,#upgr_chk["weapon"] do
t = upgr_chk["weapon"][i]
if (t.x == upgr_x) and (t.y == upgr_y) and (t.w == upgr_w) and (t.h == upgr_h) then
use_ico = true
break
end
end
elseif IsOutfit(obj) then
for i=1,#upgr_chk["outfit"] do
t = upgr_chk["outfit"][i]
if (t.x == upgr_x) and (t.y == upgr_y) and (t.w == upgr_w) and (t.h == upgr_h) then
use_ico = true
break
end
end
end
if use_ico then
utils_xml.set_icon(sec, nil, XML_temp, XML_box)
return
end
local ico = {}
ico.x1 = upgr_x
ico.y1 = upgr_y
ico.x2 = upgr_x + upgr_w
ico.y2 = upgr_y + upgr_h
ico.w = upgr_w
ico.h = upgr_h
XML_box:InitTexture(upgr_path)
XML_box:SetTextureRect(Frect():set(ico.x1, ico.y1, ico.x2, ico.y2))
XML_box:SetStretchTexture(true)
XML_box:Show(true)
local pos = XML_temp:GetWndPos()
local _w = XML_temp:GetWidth()
local _h = XML_temp:GetHeight()
local ratio = ico.w/ico.h
local h, w
ico.w = ico.w * ico_size * ico_width
ico.h = ico.h * ico_size
for i=1,2 do
local w_t, h_t = 0, 0
local resize = false
if (ico.w > _w) then -- if icon width is bigger than frame width
-- Edited by Sota
-- w_t = ico.w - _w
w_t = (ico.w - _w) / ico_width -- remove width scaling for correct comparison with height
resize = true
end
if (ico.h > _h) then -- if icon height is bigger than frame height
h_t = ico.h - _h
resize = true
end
if resize then -- resize is required
if (w_t >= h_t) then -- if icon width is the big number (or square), use it as a base for resizing
w = _w
-- Edited by Sota
-- h = w / ratio
h = w / ratio / ico_width -- remove width scaling (no need for height)
elseif (w_t < h_t) then -- if icon width is the big number, use it as a base for resizing
h = _h
-- Edited by Sota
-- w = h * ratio
w = h * ratio * ico_width -- add width scaling because we get width from height
end
else -- no resize
w = ico.w
h = ico.h
end
end
local offset_x = (_w - w)/2
local offset_y = (_h - h)/2
XML_box:SetWndSize(vector2():set(w , h))
XML_box:SetWndPos(vector2():set(pos.x + offset_x , pos.y + offset_y))
end
File diff suppressed because it is too large Load Diff