Add red dot brightness slider

This commit is contained in:
Federico Cecchetto 2022-06-03 02:10:04 +02:00
parent 723a7d65eb
commit 51a5f31a3d

View File

@ -1,10 +1,13 @@
local pcdisplay = luiglobals.require("LUI.PCDisplay") local pcdisplay = luiglobals.require("LUI.PCDisplay")
game:addlocalizedstring("LUA_MENU_FPS", "FPS Counter") game:addlocalizedstring("LUA_MENU_FPS", "FPS Counter")
game:addlocalizedstring("LUA_MENU_FPS_DESC", "Show FPS Counter") game:addlocalizedstring("LUA_MENU_FPS_DESC", "Show FPS Counter.")
game:addlocalizedstring("LUA_MENU_LATENCY", "Server Latency") game:addlocalizedstring("LUA_MENU_LATENCY", "Server Latency")
game:addlocalizedstring("LUA_MENU_LATENCY_DESC", "Show server latency") game:addlocalizedstring("LUA_MENU_LATENCY_DESC", "Show server latency.")
game:addlocalizedstring("LUA_MENU_RED_DOT_BRIGHTNESS", "Red dot Brightness")
game:addlocalizedstring("LUA_MENU_RED_DOT_BRIGHTNESS_DESC", "Adjust the brightness of red dot reticles.")
function createdivider(menu, text) function createdivider(menu, text)
local element = LUI.UIElement.new({ local element = LUI.UIElement.new({
@ -77,6 +80,36 @@ pcdisplay.CreateOptions = function(menu)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Common, "@MENU_BRIGHTNESS", LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Common, "@MENU_BRIGHTNESS",
"@MENU_BRIGHTNESS_DESC1", nil, nil, nil, pcdisplay.OpenBrightnessMenu, nil, nil, nil) "@MENU_BRIGHTNESS_DESC1", nil, nil, nil, pcdisplay.OpenBrightnessMenu, nil, nil, nil)
local reddotbounds = {
step = 0.2,
max = 4,
min = 0.2
}
LUI.Options.AddButtonOptionVariant(
menu,
GenericButtonSettings.Variants.Slider,
"@LUA_MENU_RED_DOT_BRIGHTNESS",
"@LUA_MENU_RED_DOT_BRIGHTNESS_DESC",
function()
return (Engine.GetDvarFloat( "r_redDotBrightnessScale" ) -
reddotbounds.min) / (reddotbounds.max - reddotbounds.min)
end,
function()
Engine.SetDvarFloat("r_redDotBrightnessScale",
math.min(reddotbounds.max,
math.max(reddotbounds.min, Engine.GetDvarFloat("r_redDotBrightnessScale") - reddotbounds.step))
)
end,
function()
Engine.SetDvarFloat("r_redDotBrightnessScale",
math.min(reddotbounds.max,
math.max(reddotbounds.min, Engine.GetDvarFloat("r_redDotBrightnessScale") + reddotbounds.step))
)
end
)
createdivider(menu, "TELEMETRY") createdivider(menu, "TELEMETRY")
LUI.Options.CreateOptionButton(menu, "cg_infobar_ping", "@LUA_MENU_LATENCY", "@LUA_MENU_LATENCY_DESC", {{ LUI.Options.CreateOptionButton(menu, "cg_infobar_ping", "@LUA_MENU_LATENCY", "@LUA_MENU_LATENCY_DESC", {{