207 lines
9.5 KiB
Plaintext
207 lines
9.5 KiB
Plaintext
--[[
|
|
DYNAMIC ZONE - MCM Options
|
|
|
|
Original Author(s)
|
|
VodoXleb <vodoxlebushek>
|
|
Singustromo <singustromo at disroot.org>
|
|
|
|
Edited by
|
|
|
|
License
|
|
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
|
|
(https://creativecommons.org/licenses/by-nc-sa/4.0)
|
|
--]]
|
|
|
|
CONST_ACRONYM = "dynamic_zone"
|
|
CONST_DEFAULT_CATEGORY = "general"
|
|
|
|
options = {} -- This contains cached option values indexed by option name
|
|
|
|
colors = { -- ARGB
|
|
title = {255, 255, 255, 0},
|
|
desc = {255, 109, 187, 164},
|
|
notice = {255, 232, 61, 102},
|
|
}
|
|
|
|
defaults = {
|
|
["general"] = {
|
|
["chance_path_closed"] = 30, -- for any given path between two maps
|
|
["chance_dz_trigger"] = 75, -- for the zone to change during an emission
|
|
["minimum_map_connections"] = 1,
|
|
["trigger_on_newgame"] = true, -- If some routes should already be disabled at the beginning
|
|
["newgame_grace_period"] = 12, -- For the delay after New game before first blockage (Grace Period)
|
|
["emission_trigger"] = "2ndwave", -- in which phase we trigger
|
|
["addon_removal"] = false,
|
|
},
|
|
["news"] = {
|
|
["percent_path_reveal_unblock"] = 60,
|
|
["percent_path_reveal_block"] = 50,
|
|
["chance_special_character"] = 25,
|
|
["news_play_discovery_sound"] = true,
|
|
},
|
|
["discovery"] = {
|
|
["discovery_msg_showtime"] = 4000,
|
|
["mapspot_blips_enabled"] = true,
|
|
["binoc_discovery_hud_enabled"] = true,
|
|
["binoc_discovery_holdtime"] = 3500,
|
|
["binoc_discovery_dist"] = 40,
|
|
["binoc_discovery_max_distance"] = 350,
|
|
},
|
|
["debug"] = {
|
|
["emission_check_interval"] = 10000, -- in milliseconds
|
|
["validate_parameter_types"] = false,
|
|
["verbose"] = false,
|
|
},
|
|
}
|
|
|
|
-- Getter for other scripts, using cached values
|
|
-- Simplifies getting the values through a unique id
|
|
function get(key)
|
|
return options[key]
|
|
end
|
|
|
|
function on_game_start()
|
|
RegisterScriptCallback("on_option_change", apply_settings)
|
|
apply_settings()
|
|
end
|
|
|
|
function apply_settings()
|
|
for category, settings in pairs(defaults) do
|
|
for option,_ in pairs(settings) do
|
|
options[option] = get_config(category, option)
|
|
end
|
|
end
|
|
end
|
|
|
|
function on_mcm_load()
|
|
local op = {
|
|
id = CONST_ACRONYM,
|
|
text = "ui_mcm_"..CONST_ACRONYM,
|
|
gr = {}
|
|
}
|
|
|
|
local general = {
|
|
id = "general",
|
|
sh = true,
|
|
text = "ui_mcm_"..CONST_ACRONYM.."_general",
|
|
gr = {
|
|
{ id = "title", type ="slide", link = "ui_options_slider_sound_environment",
|
|
text = "ui_mcm_"..CONST_ACRONYM.."_main_title", size = {512,50}, spacing = 20 },
|
|
|
|
{ id = "trigger_on_newgame", type = "check", val = 1,
|
|
def = defaults["general"]["trigger_on_newgame"] },
|
|
{ id = "newgame_grace_period", type = "track", val = 2, min = 0, max = 96, step = 12,
|
|
def = defaults["general"]["newgame_grace_period"] },
|
|
{ id = "chance_dz_trigger", type = "track", val = 2, min = 0, max = 100, step = 5,
|
|
def = defaults["general"]["chance_dz_trigger"] },
|
|
{ id = "emission_trigger", type = "list", val = 0, def = defaults["general"]["emission_trigger"],
|
|
content = {
|
|
{ "impact", CONST_ACRONYM.. "_emission_trigger_impact" },
|
|
{ "1stwave", CONST_ACRONYM.. "_emission_trigger_1stwave" },
|
|
{ "2ndwave", CONST_ACRONYM.. "_emission_trigger_2ndwave" },
|
|
{ "rumble", CONST_ACRONYM.. "_emission_trigger_rumble" },
|
|
},
|
|
},
|
|
{ id = "chance_path_closed", type = "track", val = 2, min = 0, max = 100, step = 5,
|
|
def = defaults["general"]["chance_path_closed"] },
|
|
{ id = "minimum_map_connections", type = "track", val = 2, min = 0, max = 4, step = 1,
|
|
def = defaults["general"]["minimum_map_connections"] },
|
|
|
|
{ id = "divider", type = "line" },
|
|
{ id = "addon_removal", type = "check", val = 1, def = defaults["addon_removal"] },
|
|
}
|
|
}
|
|
|
|
local news = {
|
|
id = "news",
|
|
sh = true,
|
|
text = "ui_mcm_"..CONST_ACRONYM.."_news",
|
|
gr = {
|
|
{ id = "title", type ="slide", link = "ui_options_slider_news",
|
|
text = "ui_mcm_"..CONST_ACRONYM.."_news_title", size = {512,50}, spacing = 20 },
|
|
|
|
{ id = "header", type = "desc", text = "ui_mcm_"..CONST_ACRONYM.."_news_desc", clr = colors.desc},
|
|
|
|
{ id = "news_play_discovery_sound", type = "check", val = 1,
|
|
def = defaults["news"]["news_play_discovery_sound"] },
|
|
{ id = "percent_path_reveal_unblock", type = "track", val = 2, min = 0, max = 100, step = 5,
|
|
def = defaults["news"]["percent_path_reveal_unblock"] },
|
|
{ id = "percent_path_reveal_block", type = "track", val = 2, min = 0, max = 100, step = 5,
|
|
def = defaults["news"]["percent_path_reveal_block"] },
|
|
{ id = "chance_special_character", type = "track", val = 2, min = 0, max = 100, step = 5,
|
|
def = defaults["news"]["chance_special_character"] },
|
|
}
|
|
}
|
|
|
|
local discovery = {
|
|
id = "discovery",
|
|
sh = true,
|
|
text = "ui_mcm_"..CONST_ACRONYM.."_discovery",
|
|
gr = {
|
|
{ id = "title", type ="slide", link = "ui_options_slider_emission",
|
|
text = "ui_mcm_"..CONST_ACRONYM.."_discovery_title", size = {512,50}, spacing = 20 },
|
|
|
|
{ id = "discovery_msg_showtime", type = "track", val = 2, min = 1000, max = 10000, step = 500,
|
|
def = defaults["discovery"]["discovery_msg_showtime"] },
|
|
{ id = "mapspot_blips_enabled", type = "check", val = 1,
|
|
def = defaults["discovery"]["mapspot_blips_enabled"] },
|
|
|
|
{ id = "divider", type = "line" },
|
|
|
|
{ id = "binoc_discovery_hud_enabled", type = "check", val = 1,
|
|
def = defaults["discovery"]["binoc_discovery_hud_enabled"] },
|
|
{ id = "binoc_discovery_holdtime", type = "track", val = 2, min = 1000, max = 10000, step = 500,
|
|
def = defaults["discovery"]["binoc_discovery_holdtime"] },
|
|
{ id = "binoc_discovery_dist", type = "track", val = 2, min = 20, max = 80, step = 5,
|
|
def = defaults["discovery"]["binoc_discovery_dist"] },
|
|
{ id = "binoc_discovery_max_distance", type = "track", val = 2, min = 150, max = 500, step = 25,
|
|
def = defaults["discovery"]["binoc_discovery_max_distance"] },
|
|
}
|
|
}
|
|
|
|
local debug = {
|
|
id = "debug",
|
|
sh = true,
|
|
text = "ui_mcm_"..CONST_ACRONYM.."_debug",
|
|
gr = {
|
|
{ id = "title", type ="slide", link = "ui_options_slider_sound_environment",
|
|
text = "ui_mcm_"..CONST_ACRONYM.."_debug_title", size = {512,50}, spacing = 20 },
|
|
|
|
{ id = "header", type = "desc", text = "ui_mcm_"..CONST_ACRONYM.."_debug_desc", clr = colors.desc},
|
|
|
|
{ id = "verbose", type = "check", val = 1,
|
|
def = defaults["debug"]["verbose"] },
|
|
{ id = "validate_parameter_types", type = "check", val = 1,
|
|
def = defaults["debug"]["validate_parameter_types"] },
|
|
{ id = "emission_check_interval", type = "track", val = 2, min = 2000, max = 20000, step = 500,
|
|
def = defaults["debug"]["emission_check_interval"] },
|
|
}
|
|
}
|
|
|
|
table.insert(op.gr, general)
|
|
table.insert(op.gr, news)
|
|
table.insert(op.gr, discovery)
|
|
table.insert(op.gr, debug)
|
|
|
|
return op
|
|
end
|
|
|
|
function get_config(id, key)
|
|
if not (key and type(key) == 'string') then return end
|
|
id = (id and type(id) == 'string') and id or CONST_DEFAULT_CATEGORY
|
|
|
|
if ui_mcm and type(ui_mcm.get) == 'function' then
|
|
return ui_mcm.get(CONST_ACRONYM .. "/".. id .. "/" .. key)
|
|
end
|
|
|
|
return defaults[id][key]
|
|
end
|
|
|
|
function set_config(id, key, value)
|
|
if not (key and type(key) == 'string') then return end
|
|
id = (id and type(id) == 'string') and id or CONST_DEFAULT_CATEGORY
|
|
|
|
if (not ui_mcm and type(ui_mcm.set) == 'function') then return end
|
|
ui_mcm.set(CONST_ACRONYM .. "/".. id .. "/" .. key, value)
|
|
end
|