Divergent/mods/UI Rework G.A.M.M.A. Style/gamedata/scripts/efp_ui_mcm.script

228 lines
13 KiB
Plaintext
Raw Permalink Normal View History

--[[
MCM script made for EFP UI
Author: HarukaSai
08/04/2022
]]
local mcm_id = "efp_ui"
local string_format = string.format
local faction_color_defs = {
["stalker"] = { a = 255, r = 228, g = 185, b = 69 },
["bandit"] = { a = 255, r = 217, g = 217, b = 217 },
["csky"] = { a = 255, r = 0, g = 182, b = 222 },
["dolg"] = { a = 255, r = 193, g = 32, b = 38 },
["freedom"] = { a = 255, r = 79, g = 162, b = 69 },
["killer"] = { a = 255, r = 3, g = 94, b = 168 },
["army"] = { a = 255, r = 184, g = 153, b = 84 },
["ecolog"] = { a = 255, r = 67, g = 134, b = 120 },
["monolith"] = { a = 255, r = 81, g = 231, b = 241 },
["renegade"] = { a = 255, r = 30, g = 123, b = 48 },
["greh"] = { a = 255, r = 255, g = 93, b = 0 },
["isg"] = { a = 255, r = 145, g = 5, b = 0 }
}
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 = {
["health"] = { a = 255, r = 255, g = 0, b = 0 },
["radia"] = { a = 255, r = 253, g = 208, b = 23 },
["acid"] = { a = 255, r = 0, g = 255, b = 0 },
["shock"] = { a = 255, r = 255, g = 255, b = 0 },
["fire"] = { a = 255, r = 255, g = 0, b = 128 },
["psi"] = { a = 255, r = 0, g = 255, b = 255 },
["wound"] = { a = 255, r = 255, g = 255, b = 255 },
["fire_wound"] = { a = 255, r = 255, g = 128, b = 0 },
["power"] = { a = 255, r = 128, g = 255, b = 255 },
["hunger"] = { a = 255, r = 165, g = 137, b = 193 },
["thirst"] = { a = 255, r = 154, g = 206, b = 223 },
["sleep"] = { a = 255, r = 253, g = 222, b = 238 }
}
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, 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, size= {512,50},spacing = 20 },
-- Edited by Sota
-- { id = "use_alt_ranks", hint = mcm_id .. "_use_alt_ranks", val = 1, type = "check", def = false},
{ id = "use_alt_ranks", hint = mcm_id .. "_use_alt_ranks", type = "list", val = 2, content = { {0, "rank_icons"} , {1, "rank_icons_mui"}, {2, "rank_icons_svui"}, {3, "rank_icons_svui_alt"}}, def = 0},
}}
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, 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, 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, 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", val = 1, type = "check", 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", val = 1, type = "check", 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
for faction, _ in pairs(faction_color_defs) do
options.gr[2].gr[#options.gr[2].gr + 1] = 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
for stat, _ in pairs(stat_defs) do
local stat_template = get_stats_color_template(stat)
for key = 1, #stat_template do
options.gr[3].gr[2].gr[#options.gr[3].gr[2].gr + 1] = 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)),
["use_alt_ranks"] = ui_mcm.get(string_format("%s/main_settings/use_alt_ranks", mcm_id)),
["text_color"] = ui_mcm.get(string_format("%s/base_settings/faction_banner/use_faction_text", mcm_id))
}
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