Various Changes; Updated and Added Mods
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
local BASE_MBLUR_MAX = 10
|
||||
local CALLBACK_REGISTERED = true
|
||||
|
||||
local ENABLED
|
||||
local BASE_MBLUR
|
||||
local CACHE
|
||||
|
||||
local print_dbg = fps_based_mblur_mcm.print_dbg
|
||||
local get_config = fps_based_mblur_mcm.get_config
|
||||
|
||||
function load_settings()
|
||||
ENABLED = get_config("ENABLED")
|
||||
BASE_MBLUR = get_config("BASE_MBLUR")
|
||||
CACHE = 1 / 50 * BASE_MBLUR / BASE_MBLUR_MAX
|
||||
|
||||
if ENABLED and not CALLBACK_REGISTERED then
|
||||
RegisterScriptCallback("actor_on_update", actor_on_update)
|
||||
CALLBACK_REGISTERED = true
|
||||
elseif not ENABLED and CALLBACK_REGISTERED then
|
||||
UnregisterScriptCallback("actor_on_update", actor_on_update)
|
||||
CALLBACK_REGISTERED = false
|
||||
|
||||
get_console():execute("r2_mblur " .. BASE_MBLUR / BASE_MBLUR_MAX)
|
||||
end
|
||||
end
|
||||
|
||||
function actor_on_update()
|
||||
local delta = device().f_time_delta
|
||||
|
||||
print_dbg("delta: %s", delta)
|
||||
print_dbg("not clamped amount: %s", CACHE / delta)
|
||||
|
||||
get_console():execute("r2_mblur " .. clamp(CACHE / delta, 0, 1))
|
||||
end
|
||||
|
||||
function on_game_start()
|
||||
RegisterScriptCallback("on_option_change", load_settings)
|
||||
RegisterScriptCallback("actor_on_first_update", load_settings)
|
||||
RegisterScriptCallback("actor_on_update", actor_on_update)
|
||||
end
|
||||
@@ -0,0 +1,49 @@
|
||||
-- If you don't use MCM, change your defaults from here.
|
||||
local defaults = {
|
||||
["ENABLED"] = true,
|
||||
["BASE_MBLUR"] = 1.0,
|
||||
["DEBUG"] = false,
|
||||
}
|
||||
|
||||
function get_config(key)
|
||||
if ui_mcm then
|
||||
return ui_mcm.get("fps_based_mblur/" .. key)
|
||||
else
|
||||
return defaults[key]
|
||||
end
|
||||
end
|
||||
|
||||
local dbg_log
|
||||
function print_dbg(text, ...)
|
||||
if get_config("DEBUG") or false then
|
||||
dbg_log = dbg_log or mcm_log and mcm_log.new("DBG")
|
||||
if dbg_log then
|
||||
dbg_log.enabled = true
|
||||
dbg_log:log(text, ...)
|
||||
else
|
||||
printf("fps based mblur: | %s | " .. text, time_global(), ...)
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function on_mcm_load()
|
||||
op = {
|
||||
id = "fps_based_mblur",
|
||||
sh = true,
|
||||
gr = {
|
||||
{
|
||||
id = "title",
|
||||
type = "slide",
|
||||
link = "ui_options_slider_player",
|
||||
text = "ui_mcm_fps_based_mblur_title",
|
||||
size = { 512, 50 },
|
||||
spacing = 20,
|
||||
},
|
||||
{ id = "ENABLED", type = "check", val = 1, def = true },
|
||||
{ id = "BASE_MBLUR", type = "track", val = 2, def = 1.0, min = 0.0, max = 10.0, step = 0.025 },
|
||||
{ id = "DEBUG", type = "check", val = 1, def = false },
|
||||
},
|
||||
}
|
||||
return op
|
||||
end
|
||||
Reference in New Issue
Block a user