Formatting
This commit is contained in:
parent
456d83f1c0
commit
efe6291eaf
@ -1,5 +1,5 @@
|
|||||||
if (game:issingleplayer()) then
|
if (game:issingleplayer()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
require("settings")
|
require("settings")
|
||||||
|
@ -1,156 +1,158 @@
|
|||||||
local mphud = luiglobals.require("LUI.mp_hud.MPHud")
|
local mphud = luiglobals.require("LUI.mp_hud.MPHud")
|
||||||
|
local barheight = 16
|
||||||
|
local textheight = 13
|
||||||
|
local textoffsety = barheight / 2 - textheight / 2
|
||||||
|
|
||||||
function createinfobar()
|
function createinfobar()
|
||||||
local infobar = LUI.UIElement.new({
|
local infobar = LUI.UIElement.new({
|
||||||
left = luiglobals.GameX.IsHardcoreMode() and 160 or 228,
|
left = luiglobals.GameX.IsHardcoreMode() and 160 or 228,
|
||||||
top = luiglobals.GameX.IsHardcoreMode() and 5 or 9,
|
top = luiglobals.GameX.IsHardcoreMode() and 5 or 9,
|
||||||
height = 15,
|
height = barheight,
|
||||||
width = 70,
|
width = 70,
|
||||||
leftAnchor = true,
|
leftAnchor = true,
|
||||||
topAnchor = true
|
topAnchor = true
|
||||||
})
|
})
|
||||||
|
|
||||||
infobar:registerAnimationState("hud_on", {
|
infobar:registerAnimationState("hud_on", {
|
||||||
alpha = 1
|
alpha = 1
|
||||||
})
|
})
|
||||||
|
|
||||||
infobar:registerAnimationState("hud_off", {
|
infobar:registerAnimationState("hud_off", {
|
||||||
alpha = 0
|
alpha = 0
|
||||||
})
|
})
|
||||||
|
|
||||||
return infobar
|
return infobar
|
||||||
end
|
end
|
||||||
|
|
||||||
function populateinfobar(infobar)
|
function populateinfobar(infobar)
|
||||||
elementoffset = 0
|
elementoffset = 0
|
||||||
|
|
||||||
if (Engine.GetDvarBool("cg_infobar_fps")) then
|
if (Engine.GetDvarBool("cg_infobar_fps")) then
|
||||||
infobar:addElement(infoelement({
|
infobar:addElement(infoelement({
|
||||||
label = "FPS: ",
|
label = "FPS: ",
|
||||||
getvalue = function()
|
getvalue = function()
|
||||||
return game:getfps()
|
return game:getfps()
|
||||||
end,
|
end,
|
||||||
width = 70,
|
width = 70,
|
||||||
interval = 100
|
interval = 100
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
if (Engine.GetDvarBool("cg_infobar_ping")) then
|
if (Engine.GetDvarBool("cg_infobar_ping")) then
|
||||||
infobar:addElement(infoelement({
|
infobar:addElement(infoelement({
|
||||||
label = "Latency: ",
|
label = "Latency: ",
|
||||||
getvalue = function()
|
getvalue = function()
|
||||||
return game:getping() .. " ms"
|
return game:getping() .. " ms"
|
||||||
end,
|
end,
|
||||||
width = 115,
|
width = 115,
|
||||||
interval = 100
|
interval = 100
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function infoelement(data)
|
function infoelement(data)
|
||||||
local container = LUI.UIElement.new({
|
local container = LUI.UIElement.new({
|
||||||
bottomAnchor = true,
|
bottomAnchor = true,
|
||||||
leftAnchor = true,
|
leftAnchor = true,
|
||||||
topAnchor = true,
|
topAnchor = true,
|
||||||
width = data.width,
|
width = data.width,
|
||||||
left = elementoffset
|
left = elementoffset
|
||||||
})
|
})
|
||||||
|
|
||||||
elementoffset = elementoffset + data.width + 10
|
elementoffset = elementoffset + data.width + 10
|
||||||
|
|
||||||
local background = LUI.UIImage.new({
|
local background = LUI.UIImage.new({
|
||||||
bottomAnchor = true,
|
bottomAnchor = true,
|
||||||
leftAnchor = true,
|
leftAnchor = true,
|
||||||
topAnchor = true,
|
topAnchor = true,
|
||||||
rightAnchor = true,
|
rightAnchor = true,
|
||||||
material = luiglobals.RegisterMaterial("white"),
|
material = luiglobals.RegisterMaterial("white"),
|
||||||
color = luiglobals.Colors.black,
|
color = luiglobals.Colors.black,
|
||||||
alpha = 0.5
|
alpha = 0.5
|
||||||
})
|
})
|
||||||
|
|
||||||
local labelfont = CoD.TextSettings.FontBold110
|
local labelfont = CoD.TextSettings.FontBold110
|
||||||
local textheight = 13
|
|
||||||
|
|
||||||
local label = LUI.UIText.new({
|
local label = LUI.UIText.new({
|
||||||
left = 5,
|
left = 5,
|
||||||
top = 1,
|
top = textoffsety,
|
||||||
font = labelfont.Font,
|
font = labelfont.Font,
|
||||||
height = textheight,
|
height = textheight,
|
||||||
leftAnchor = true,
|
leftAnchor = true,
|
||||||
topAnchor = true,
|
topAnchor = true,
|
||||||
color = {
|
color = {
|
||||||
r = 0.8,
|
r = 0.8,
|
||||||
g = 0.8,
|
g = 0.8,
|
||||||
b = 0.8,
|
b = 0.8,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
label:setText(data.label)
|
label:setText(data.label)
|
||||||
|
|
||||||
local _, _, left = luiglobals.GetTextDimensions(data.label, labelfont.Font, textheight)
|
local _, _, left = luiglobals.GetTextDimensions(data.label, labelfont.Font, textheight)
|
||||||
local value = LUI.UIText.new({
|
local value = LUI.UIText.new({
|
||||||
left = left + 5,
|
left = left + 5,
|
||||||
top = 1,
|
top = textoffsety,
|
||||||
height = textheight,
|
height = textheight,
|
||||||
leftAnchor = true,
|
leftAnchor = true,
|
||||||
topAnchor = true,
|
topAnchor = true,
|
||||||
color = {
|
color = {
|
||||||
r = 0.6,
|
r = 0.6,
|
||||||
g = 0.6,
|
g = 0.6,
|
||||||
b = 0.6,
|
b = 0.6,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
value:addElement(LUI.UITimer.new(data.interval, "update"))
|
value:addElement(LUI.UITimer.new(data.interval, "update"))
|
||||||
value:setText(data.getvalue())
|
value:setText(data.getvalue())
|
||||||
value:addEventHandler("update", function()
|
value:addEventHandler("update", function()
|
||||||
value:setText(data.getvalue())
|
value:setText(data.getvalue())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
container:addElement(background)
|
container:addElement(background)
|
||||||
container:addElement(label)
|
container:addElement(label)
|
||||||
container:addElement(value)
|
container:addElement(value)
|
||||||
|
|
||||||
return container
|
return container
|
||||||
end
|
end
|
||||||
|
|
||||||
local updatehudvisibility = mphud.updateHudVisibility
|
local updatehudvisibility = mphud.updateHudVisibility
|
||||||
mphud.updateHudVisibility = function(a1, a2)
|
mphud.updateHudVisibility = function(a1, a2)
|
||||||
updatehudvisibility(a1, a2)
|
updatehudvisibility(a1, a2)
|
||||||
|
|
||||||
local root = Engine.GetLuiRoot()
|
local root = Engine.GetLuiRoot()
|
||||||
local menus = root:AnyActiveMenusInStack()
|
local menus = root:AnyActiveMenusInStack()
|
||||||
local infobar = root.infobar
|
local infobar = root.infobar
|
||||||
|
|
||||||
if (not infobar) then
|
if (not infobar) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (menus) then
|
if (menus) then
|
||||||
infobar:animateToState("hud_off")
|
infobar:animateToState("hud_off")
|
||||||
else
|
else
|
||||||
infobar:animateToState("hud_on")
|
infobar:animateToState("hud_on")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
LUI.onmenuopen("mp_hud", function(hud)
|
LUI.onmenuopen("mp_hud", function(hud)
|
||||||
if (Engine.InFrontend()) then
|
if (Engine.InFrontend()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local infobar = createinfobar()
|
local infobar = createinfobar()
|
||||||
local root = Engine.GetLuiRoot()
|
local root = Engine.GetLuiRoot()
|
||||||
root.infobar = infobar
|
root.infobar = infobar
|
||||||
populateinfobar(infobar)
|
populateinfobar(infobar)
|
||||||
|
|
||||||
root:registerEventHandler("update_hud_infobar_settings", function()
|
root:registerEventHandler("update_hud_infobar_settings", function()
|
||||||
infobar:removeAllChildren()
|
infobar:removeAllChildren()
|
||||||
populateinfobar(infobar)
|
populateinfobar(infobar)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
root:processEvent({
|
root:processEvent({
|
||||||
name = "update_hud_infobar_settings"
|
name = "update_hud_infobar_settings"
|
||||||
})
|
})
|
||||||
|
|
||||||
hud.static:addElement(infobar)
|
hud.static:addElement(infobar)
|
||||||
end)
|
end)
|
@ -28,152 +28,152 @@ end
|
|||||||
|
|
||||||
pcdisplay.CreateOptions = function( menu )
|
pcdisplay.CreateOptions = function( menu )
|
||||||
LUI.Options.AddButtonOptionVariant(
|
LUI.Options.AddButtonOptionVariant(
|
||||||
menu,
|
menu,
|
||||||
luiglobals.GenericButtonSettings.Variants.Select,
|
luiglobals.GenericButtonSettings.Variants.Select,
|
||||||
"@LUA_MENU_COLORBLIND_FILTER",
|
"@LUA_MENU_COLORBLIND_FILTER",
|
||||||
"@LUA_MENU_COLOR_BLIND_DESC",
|
"@LUA_MENU_COLOR_BLIND_DESC",
|
||||||
LUI.Options.GetRenderColorBlindText,
|
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(
|
LUI.Options.AddButtonOptionVariant(
|
||||||
menu,
|
menu,
|
||||||
luiglobals.GenericButtonSettings.Variants.Select,
|
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.GetDvarEnableTextFunc("cg_paintballFx", false),
|
||||||
LUI.Options.ToggleDvarFunc("cg_paintballFx"),
|
LUI.Options.ToggleDvarFunc("cg_paintballFx"),
|
||||||
LUI.Options.ToggleDvarFunc("cg_paintballFx")
|
LUI.Options.ToggleDvarFunc("cg_paintballFx")
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
LUI.Options.AddButtonOptionVariant(
|
LUI.Options.AddButtonOptionVariant(
|
||||||
menu,
|
menu,
|
||||||
luiglobals.GenericButtonSettings.Variants.Select,
|
luiglobals.GenericButtonSettings.Variants.Select,
|
||||||
"@LUA_MENU_BLOOD",
|
"@LUA_MENU_BLOOD",
|
||||||
"@LUA_MENU_BLOOD_DESC",
|
"@LUA_MENU_BLOOD_DESC",
|
||||||
LUI.Options.GetDvarEnableTextFunc("cg_blood", false),
|
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))
|
LUI.Options.ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0))
|
||||||
)
|
)
|
||||||
|
|
||||||
if not Engine.IsMultiplayer() then
|
if not Engine.IsMultiplayer() then
|
||||||
LUI.Options.AddButtonOptionVariant(
|
LUI.Options.AddButtonOptionVariant(
|
||||||
menu,
|
menu,
|
||||||
luiglobals.GenericButtonSettings.Variants.Select,
|
luiglobals.GenericButtonSettings.Variants.Select,
|
||||||
"@LUA_MENU_CROSSHAIR",
|
"@LUA_MENU_CROSSHAIR",
|
||||||
"@LUA_MENU_CROSSHAIR_DESC",
|
"@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(
|
LUI.Options.CreateOptionButton(
|
||||||
menu,
|
menu,
|
||||||
"cg_drawDamageFeedbackOption",
|
"cg_drawDamageFeedbackOption",
|
||||||
"@LUA_MENU_HIT_MARKER",
|
"@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(
|
LUI.Options.AddButtonOptionVariant(
|
||||||
menu,
|
menu,
|
||||||
luiglobals.GenericButtonSettings.Variants.Select,
|
luiglobals.GenericButtonSettings.Variants.Select,
|
||||||
"@MENU_DISPLAY_KILLSTREAK_COUNTER",
|
"@MENU_DISPLAY_KILLSTREAK_COUNTER",
|
||||||
"@MENU_DISPLAY_KILLSTREAK_COUNTER_DESC",
|
"@MENU_DISPLAY_KILLSTREAK_COUNTER_DESC",
|
||||||
pcdisplay.GetDisplayKillstreakCounterText,
|
pcdisplay.GetDisplayKillstreakCounterText,
|
||||||
pcdisplay.DisplayKillstreakCounterToggle,
|
pcdisplay.DisplayKillstreakCounterToggle,
|
||||||
pcdisplay.DisplayKillstreakCounterToggle
|
pcdisplay.DisplayKillstreakCounterToggle
|
||||||
)
|
)
|
||||||
|
|
||||||
LUI.Options.AddButtonOptionVariant(
|
LUI.Options.AddButtonOptionVariant(
|
||||||
menu,
|
menu,
|
||||||
luiglobals.GenericButtonSettings.Variants.Select,
|
luiglobals.GenericButtonSettings.Variants.Select,
|
||||||
"@MENU_DISPLAY_MEDAL_SPLASHES",
|
"@MENU_DISPLAY_MEDAL_SPLASHES",
|
||||||
"@MENU_DISPLAY_MEDAL_SPLASHES_DESC",
|
"@MENU_DISPLAY_MEDAL_SPLASHES_DESC",
|
||||||
pcdisplay.GetDisplayMedalSplashesText,
|
pcdisplay.GetDisplayMedalSplashesText,
|
||||||
pcdisplay.DisplayMedalSplashesToggle,
|
pcdisplay.DisplayMedalSplashesToggle,
|
||||||
pcdisplay.DisplayMedalSplashesToggle
|
pcdisplay.DisplayMedalSplashesToggle
|
||||||
)
|
)
|
||||||
|
|
||||||
LUI.Options.AddButtonOptionVariant(
|
LUI.Options.AddButtonOptionVariant(
|
||||||
menu,
|
menu,
|
||||||
luiglobals.GenericButtonSettings.Variants.Select,
|
luiglobals.GenericButtonSettings.Variants.Select,
|
||||||
"@MENU_DISPLAY_WEAPON_EMBLEMS",
|
"@MENU_DISPLAY_WEAPON_EMBLEMS",
|
||||||
"@MENU_DISPLAY_WEAPON_EMBLEMS_DESC",
|
"@MENU_DISPLAY_WEAPON_EMBLEMS_DESC",
|
||||||
pcdisplay.GetDisplayWeaponEmblemsText,
|
pcdisplay.GetDisplayWeaponEmblemsText,
|
||||||
pcdisplay.DisplayWeaponEmblemsToggle,
|
pcdisplay.DisplayWeaponEmblemsToggle,
|
||||||
pcdisplay.DisplayWeaponEmblemsToggle
|
pcdisplay.DisplayWeaponEmblemsToggle
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
LUI.Options.AddButtonOptionVariant(
|
LUI.Options.AddButtonOptionVariant(
|
||||||
menu,
|
menu,
|
||||||
luiglobals.GenericButtonSettings.Variants.Common,
|
luiglobals.GenericButtonSettings.Variants.Common,
|
||||||
"@MENU_BRIGHTNESS",
|
"@MENU_BRIGHTNESS",
|
||||||
"@MENU_BRIGHTNESS_DESC1",
|
"@MENU_BRIGHTNESS_DESC1",
|
||||||
nil, nil, nil,
|
nil, nil, nil,
|
||||||
pcdisplay.OpenBrightnessMenu,
|
pcdisplay.OpenBrightnessMenu,
|
||||||
nil, nil, nil
|
nil, nil, nil
|
||||||
)
|
)
|
||||||
|
|
||||||
createdivider(menu, "TELEMETRY")
|
createdivider(menu, "TELEMETRY")
|
||||||
|
|
||||||
LUI.Options.CreateOptionButton(
|
LUI.Options.CreateOptionButton(
|
||||||
menu,
|
menu,
|
||||||
"cg_infobar_ping",
|
"cg_infobar_ping",
|
||||||
"@LUA_MENU_LATENCY",
|
"@LUA_MENU_LATENCY",
|
||||||
"@LUA_MENU_LATENCY_DESC",
|
"@LUA_MENU_LATENCY_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
|
||||||
}
|
}
|
||||||
}, nil, nil, function(value)
|
}, nil, nil, function(value)
|
||||||
Engine.SetDvarBool("cg_infobar_ping", value)
|
Engine.SetDvarBool("cg_infobar_ping", value)
|
||||||
Engine.GetLuiRoot():processEvent({
|
Engine.GetLuiRoot():processEvent({
|
||||||
name = "update_hud_infobar_settings"
|
name = "update_hud_infobar_settings"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
LUI.Options.CreateOptionButton(
|
LUI.Options.CreateOptionButton(
|
||||||
menu,
|
menu,
|
||||||
"cg_infobar_fps",
|
"cg_infobar_fps",
|
||||||
"@LUA_MENU_FPS",
|
"@LUA_MENU_FPS",
|
||||||
"@LUA_MENU_FPS_DESC",
|
"@LUA_MENU_FPS_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
|
||||||
}
|
}
|
||||||
}, nil, nil, function(value)
|
}, nil, nil, function(value)
|
||||||
Engine.SetDvarBool("cg_infobar_fps", value)
|
Engine.SetDvarBool("cg_infobar_fps", value)
|
||||||
Engine.GetLuiRoot():processEvent({
|
Engine.GetLuiRoot():processEvent({
|
||||||
name = "update_hud_infobar_settings"
|
name = "update_hud_infobar_settings"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
LUI.Options.InitScrollingList(menu.list, nil)
|
LUI.Options.InitScrollingList(menu.list, nil)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user