add new data directory, and update updater

This commit is contained in:
m
2022-09-03 06:00:31 -05:00
parent b913ea7129
commit 748ab6899e
34 changed files with 286 additions and 265 deletions

View File

@ -0,0 +1,6 @@
if (game:issingleplayer()) then
return
end
require("settings")
require("hud")

View File

@ -0,0 +1,198 @@
local mphud = luiglobals.require("LUI.mp_hud.MPHud")
local barheight = 16
local textheight = 13
local textoffsety = barheight / 2 - textheight / 2
function createinfobar()
local infobar = LUI.UIElement.new({
left = 213,
top = -6,
height = barheight,
width = 70,
leftAnchor = true,
topAnchor = true
})
infobar:registerAnimationState("minimap_on", {
left = 213,
top = -6,
height = barheight,
width = 70,
leftAnchor = true,
topAnchor = true
})
infobar:registerAnimationState("minimap_off", {
left = 0,
top = 0,
height = barheight,
width = 70,
leftAnchor = true,
topAnchor = true
})
infobar:registerAnimationState("hud_on", {
alpha = 1
})
infobar:registerAnimationState("hud_off", {
alpha = 0
})
return infobar
end
function updateinfobarvisibility()
local root = Engine.GetLuiRoot()
local menus = root:AnyActiveMenusInStack()
local infobar = root.infobar
if (not infobar) then
return
end
if (menus or Game.InKillCam()) then
infobar:animateToState("hud_off")
else
infobar:animateToState("hud_on")
end
local validstates = {
"hud_on",
"active",
"nosignal",
"scrambled"
}
infobar:animateToState("minimap_off")
for i = 1, #validstates do
if (validstates[i] == root.hud.minimap.current_state) then
infobar:animateToState("minimap_on")
break
end
end
end
function populateinfobar(infobar)
elementoffset = 0
if (Engine.GetDvarBool("cg_infobar_fps")) then
infobar:addElement(infoelement({
label = "FPS: ",
getvalue = function()
return game:getfps()
end,
width = 70,
interval = 100
}))
end
if (Engine.GetDvarBool("cg_infobar_ping")) then
infobar:addElement(infoelement({
label = "Latency: ",
getvalue = function()
return game:getping() .. " ms"
end,
width = 115,
interval = 100
}))
end
updateinfobarvisibility()
end
function infoelement(data)
local container = LUI.UIElement.new({
bottomAnchor = true,
leftAnchor = true,
topAnchor = true,
width = data.width,
left = elementoffset
})
elementoffset = elementoffset + data.width + 10
local background = LUI.UIImage.new({
bottomAnchor = true,
leftAnchor = true,
topAnchor = true,
rightAnchor = true,
material = luiglobals.RegisterMaterial("white"),
color = luiglobals.Colors.black,
alpha = 0.5
})
local labelfont = CoD.TextSettings.FontBold110
local label = LUI.UIText.new({
left = 5,
top = textoffsety,
font = labelfont.Font,
height = textheight,
leftAnchor = true,
topAnchor = true,
color = {
r = 0.8,
g = 0.8,
b = 0.8
}
})
label:setText(data.label)
local _, _, left = luiglobals.GetTextDimensions(data.label, labelfont.Font, textheight)
local value = LUI.UIText.new({
left = left + 5,
top = textoffsety,
font = labelfont.Font,
height = textheight,
leftAnchor = true,
topAnchor = true,
color = {
r = 0.6,
g = 0.6,
b = 0.6
}
})
value:addElement(LUI.UITimer.new(data.interval, "update"))
value:setText(data.getvalue())
value:addEventHandler("update", function()
value:setText(data.getvalue())
end)
container:addElement(background)
container:addElement(label)
container:addElement(value)
return container
end
local updatehudvisibility = mphud.updateHudVisibility
mphud.updateHudVisibility = function(a1, a2)
updatehudvisibility(a1, a2)
updateinfobarvisibility()
end
LUI.onmenuopen("mp_hud", function(hud)
if (Engine.InFrontend()) then
return
end
local infobar = createinfobar()
local root = Engine.GetLuiRoot()
root.infobar = infobar
root.hud = hud
populateinfobar(infobar)
root:registerEventHandler("update_hud_infobar_settings", function()
infobar:removeAllChildren()
populateinfobar(infobar)
end)
root:processEvent({
name = "update_hud_infobar_settings"
})
hud.static.scalable:addElement(infobar)
end)

View File

@ -0,0 +1,133 @@
local pcdisplay = luiglobals.require("LUI.PCDisplay")
function createdivider(menu, text)
local element = LUI.UIElement.new({
leftAnchor = true,
rightAnchor = true,
left = 0,
right = 0,
topAnchor = true,
bottomAnchor = false,
top = 0,
bottom = 33.33
})
element.scrollingToNext = true
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
title_bar_text = text
}))
menu.list:addElement(element)
end
pcdisplay.CreateOptions = function(menu)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@LUA_MENU_COLORBLIND_FILTER", "@LUA_MENU_COLOR_BLIND_DESC", LUI.Options.GetRenderColorBlindText,
LUI.Options.RenderColorBlindToggle, LUI.Options.RenderColorBlindToggle)
if Engine.IsMultiplayer() and Engine.GetDvarType("cg_paintballFx") == luiglobals.DvarTypeTable.DvarBool then
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@LUA_MENU_PAINTBALL", "@LUA_MENU_PAINTBALL_DESC",
LUI.Options.GetDvarEnableTextFunc("cg_paintballFx", false), LUI.Options.ToggleDvarFunc("cg_paintballFx"),
LUI.Options.ToggleDvarFunc("cg_paintballFx"))
end
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select, "@LUA_MENU_BLOOD",
"@LUA_MENU_BLOOD_DESC", LUI.Options.GetDvarEnableTextFunc("cg_blood", false), LUI.Options
.ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0)), LUI.Options
.ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0)))
if not Engine.IsMultiplayer() then
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@LUA_MENU_CROSSHAIR", "@LUA_MENU_CROSSHAIR_DESC",
LUI.Options.GetDvarEnableTextFunc("cg_drawCrosshairOption", false),
LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption"), LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption"))
LUI.Options.CreateOptionButton(menu, "cg_drawDamageFeedbackOption", "@LUA_MENU_HIT_MARKER",
"@LUA_MENU_HIT_MARKER_DESC", {{
text = "@LUA_MENU_ENABLED",
value = true
}, {
text = "@LUA_MENU_DISABLED",
value = false
}})
end
if Engine.IsMultiplayer() then
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@MENU_DISPLAY_KILLSTREAK_COUNTER", "@MENU_DISPLAY_KILLSTREAK_COUNTER_DESC",
pcdisplay.GetDisplayKillstreakCounterText, pcdisplay.DisplayKillstreakCounterToggle,
pcdisplay.DisplayKillstreakCounterToggle)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@MENU_DISPLAY_MEDAL_SPLASHES", "@MENU_DISPLAY_MEDAL_SPLASHES_DESC", pcdisplay.GetDisplayMedalSplashesText,
pcdisplay.DisplayMedalSplashesToggle, pcdisplay.DisplayMedalSplashesToggle)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@MENU_DISPLAY_WEAPON_EMBLEMS", "@MENU_DISPLAY_WEAPON_EMBLEMS_DESC", pcdisplay.GetDisplayWeaponEmblemsText,
pcdisplay.DisplayWeaponEmblemsToggle, pcdisplay.DisplayWeaponEmblemsToggle)
end
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Common, "@MENU_BRIGHTNESS",
"@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")
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