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,109 +1,142 @@
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({
leftAnchor = true, leftAnchor = true,
rightAnchor = true, rightAnchor = true,
left = 0, left = 0,
right = 0, right = 0,
topAnchor = true, topAnchor = true,
bottomAnchor = false, bottomAnchor = false,
top = 0, top = 0,
bottom = 33.33 bottom = 33.33
}) })
element.scrollingToNext = true element.scrollingToNext = true
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", { element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
title_bar_text = text title_bar_text = text
})) }))
menu.list:addElement(element) menu.list:addElement(element)
end end
pcdisplay.CreateOptions = function(menu) pcdisplay.CreateOptions = function(menu)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select, LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@LUA_MENU_COLORBLIND_FILTER", "@LUA_MENU_COLOR_BLIND_DESC", LUI.Options.GetRenderColorBlindText, "@LUA_MENU_COLORBLIND_FILTER", "@LUA_MENU_COLOR_BLIND_DESC", LUI.Options.GetRenderColorBlindText,
LUI.Options.RenderColorBlindToggle, LUI.Options.RenderColorBlindToggle) LUI.Options.RenderColorBlindToggle, LUI.Options.RenderColorBlindToggle)
if Engine.IsMultiplayer() and Engine.GetDvarType("cg_paintballFx") == luiglobals.DvarTypeTable.DvarBool then if Engine.IsMultiplayer() and Engine.GetDvarType("cg_paintballFx") == luiglobals.DvarTypeTable.DvarBool then
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select, LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@LUA_MENU_PAINTBALL", "@LUA_MENU_PAINTBALL_DESC", "@LUA_MENU_PAINTBALL", "@LUA_MENU_PAINTBALL_DESC",
LUI.Options.GetDvarEnableTextFunc("cg_paintballFx", false), LUI.Options.ToggleDvarFunc("cg_paintballFx"), LUI.Options.GetDvarEnableTextFunc("cg_paintballFx", false), LUI.Options.ToggleDvarFunc("cg_paintballFx"),
LUI.Options.ToggleDvarFunc("cg_paintballFx")) LUI.Options.ToggleDvarFunc("cg_paintballFx"))
end end
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select, "@LUA_MENU_BLOOD", LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select, "@LUA_MENU_BLOOD",
"@LUA_MENU_BLOOD_DESC", LUI.Options.GetDvarEnableTextFunc("cg_blood", false), LUI.Options "@LUA_MENU_BLOOD_DESC", LUI.Options.GetDvarEnableTextFunc("cg_blood", false), LUI.Options
.ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0)), LUI.Options .ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0)), LUI.Options
.ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0))) .ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0)))
if not Engine.IsMultiplayer() then if not Engine.IsMultiplayer() then
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select, LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@LUA_MENU_CROSSHAIR", "@LUA_MENU_CROSSHAIR_DESC", "@LUA_MENU_CROSSHAIR", "@LUA_MENU_CROSSHAIR_DESC",
LUI.Options.GetDvarEnableTextFunc("cg_drawCrosshairOption", false), LUI.Options.GetDvarEnableTextFunc("cg_drawCrosshairOption", false),
LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption"), LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption")) LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption"), LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption"))
LUI.Options.CreateOptionButton(menu, "cg_drawDamageFeedbackOption", "@LUA_MENU_HIT_MARKER", LUI.Options.CreateOptionButton(menu, "cg_drawDamageFeedbackOption", "@LUA_MENU_HIT_MARKER",
"@LUA_MENU_HIT_MARKER_DESC", {{ "@LUA_MENU_HIT_MARKER_DESC", {{
text = "@LUA_MENU_ENABLED", text = "@LUA_MENU_ENABLED",
value = true value = true
}, { }, {
text = "@LUA_MENU_DISABLED", text = "@LUA_MENU_DISABLED",
value = false value = false
}}) }})
end end
if Engine.IsMultiplayer() then if Engine.IsMultiplayer() then
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select, LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@MENU_DISPLAY_KILLSTREAK_COUNTER", "@MENU_DISPLAY_KILLSTREAK_COUNTER_DESC", "@MENU_DISPLAY_KILLSTREAK_COUNTER", "@MENU_DISPLAY_KILLSTREAK_COUNTER_DESC",
pcdisplay.GetDisplayKillstreakCounterText, pcdisplay.DisplayKillstreakCounterToggle, pcdisplay.GetDisplayKillstreakCounterText, pcdisplay.DisplayKillstreakCounterToggle,
pcdisplay.DisplayKillstreakCounterToggle) pcdisplay.DisplayKillstreakCounterToggle)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select, LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@MENU_DISPLAY_MEDAL_SPLASHES", "@MENU_DISPLAY_MEDAL_SPLASHES_DESC", pcdisplay.GetDisplayMedalSplashesText, "@MENU_DISPLAY_MEDAL_SPLASHES", "@MENU_DISPLAY_MEDAL_SPLASHES_DESC", pcdisplay.GetDisplayMedalSplashesText,
pcdisplay.DisplayMedalSplashesToggle, pcdisplay.DisplayMedalSplashesToggle) pcdisplay.DisplayMedalSplashesToggle, pcdisplay.DisplayMedalSplashesToggle)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select, LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@MENU_DISPLAY_WEAPON_EMBLEMS", "@MENU_DISPLAY_WEAPON_EMBLEMS_DESC", pcdisplay.GetDisplayWeaponEmblemsText, "@MENU_DISPLAY_WEAPON_EMBLEMS", "@MENU_DISPLAY_WEAPON_EMBLEMS_DESC", pcdisplay.GetDisplayWeaponEmblemsText,
pcdisplay.DisplayWeaponEmblemsToggle, pcdisplay.DisplayWeaponEmblemsToggle) pcdisplay.DisplayWeaponEmblemsToggle, pcdisplay.DisplayWeaponEmblemsToggle)
end end
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)
createdivider(menu, "TELEMETRY")
LUI.Options.CreateOptionButton(menu, "cg_infobar_ping", "@LUA_MENU_LATENCY", "@LUA_MENU_LATENCY_DESC", {{ local reddotbounds = {
text = "@LUA_MENU_ENABLED", step = 0.2,
value = true max = 4,
}, { min = 0.2
text = "@LUA_MENU_DISABLED", }
value = false
}}, nil, nil, function(value)
Engine.SetDvarBool("cg_infobar_ping", value)
Engine.GetLuiRoot():processEvent({
name = "update_hud_infobar_settings"
})
end)
LUI.Options.CreateOptionButton(menu, "cg_infobar_fps", "@LUA_MENU_FPS", "@LUA_MENU_FPS_DESC", {{ LUI.Options.AddButtonOptionVariant(
text = "@LUA_MENU_ENABLED", menu,
value = true GenericButtonSettings.Variants.Slider,
}, { "@LUA_MENU_RED_DOT_BRIGHTNESS",
text = "@LUA_MENU_DISABLED", "@LUA_MENU_RED_DOT_BRIGHTNESS_DESC",
value = false function()
}}, nil, nil, function(value) return (Engine.GetDvarFloat( "r_redDotBrightnessScale" ) -
Engine.SetDvarBool("cg_infobar_fps", value) reddotbounds.min) / (reddotbounds.max - reddotbounds.min)
Engine.GetLuiRoot():processEvent({ end,
name = "update_hud_infobar_settings" function()
}) Engine.SetDvarFloat("r_redDotBrightnessScale",
end) 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")
LUI.Options.InitScrollingList(menu.list, nil) LUI.Options.CreateOptionButton(menu, "cg_infobar_ping", "@LUA_MENU_LATENCY", "@LUA_MENU_LATENCY_DESC", {{
text = "@LUA_MENU_ENABLED",
value = true
}, {
text = "@LUA_MENU_DISABLED",
value = false
}}, nil, nil, function(value)
Engine.SetDvarBool("cg_infobar_ping", value)
Engine.GetLuiRoot():processEvent({
name = "update_hud_infobar_settings"
})
end)
LUI.Options.CreateOptionButton(menu, "cg_infobar_fps", "@LUA_MENU_FPS", "@LUA_MENU_FPS_DESC", {{
text = "@LUA_MENU_ENABLED",
value = true
}, {
text = "@LUA_MENU_DISABLED",
value = false
}}, nil, nil, function(value)
Engine.SetDvarBool("cg_infobar_fps", value)
Engine.GetLuiRoot():processEvent({
name = "update_hud_infobar_settings"
})
end)
LUI.Options.InitScrollingList(menu.list, nil)
end end