nicely format LUA files

This commit is contained in:
m 2022-03-11 16:35:50 -06:00
parent b4326f7177
commit 2d8a3bbe5c
6 changed files with 483 additions and 596 deletions

View File

@ -83,7 +83,7 @@ function infoelement(data)
color = { color = {
r = 0.8, r = 0.8,
g = 0.8, g = 0.8,
b = 0.8, b = 0.8
} }
}) })
@ -99,7 +99,7 @@ function infoelement(data)
color = { color = {
r = 0.6, r = 0.6,
g = 0.6, g = 0.6,
b = 0.6, b = 0.6
} }
}) })

View File

@ -27,153 +27,83 @@ function createdivider(menu, text)
end end
pcdisplay.CreateOptions = function(menu) pcdisplay.CreateOptions = function(menu)
LUI.Options.AddButtonOptionVariant( LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
menu, "@LUA_MENU_COLORBLIND_FILTER", "@LUA_MENU_COLOR_BLIND_DESC", LUI.Options.GetRenderColorBlindText,
luiglobals.GenericButtonSettings.Variants.Select, LUI.Options.RenderColorBlindToggle, LUI.Options.RenderColorBlindToggle)
"@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 if Engine.IsMultiplayer() and Engine.GetDvarType("cg_paintballFx") == luiglobals.DvarTypeTable.DvarBool then
LUI.Options.AddButtonOptionVariant( LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
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.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, luiglobals.GenericButtonSettings.Variants.Select, "@LUA_MENU_BLOOD",
menu, "@LUA_MENU_BLOOD_DESC", LUI.Options.GetDvarEnableTextFunc("cg_blood", false), LUI.Options
luiglobals.GenericButtonSettings.Variants.Select, .ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0)), LUI.Options
"@LUA_MENU_BLOOD", .ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0)))
"@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 if not Engine.IsMultiplayer() then
LUI.Options.AddButtonOptionVariant( LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
menu, "@LUA_MENU_CROSSHAIR", "@LUA_MENU_CROSSHAIR_DESC",
luiglobals.GenericButtonSettings.Variants.Select,
"@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( LUI.Options.CreateOptionButton(menu, "cg_drawDamageFeedbackOption", "@LUA_MENU_HIT_MARKER",
menu, "@LUA_MENU_HIT_MARKER_DESC", {{
"cg_drawDamageFeedbackOption",
"@LUA_MENU_HIT_MARKER",
"@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, luiglobals.GenericButtonSettings.Variants.Select,
menu, "@MENU_DISPLAY_KILLSTREAK_COUNTER", "@MENU_DISPLAY_KILLSTREAK_COUNTER_DESC",
luiglobals.GenericButtonSettings.Variants.Select, pcdisplay.GetDisplayKillstreakCounterText, pcdisplay.DisplayKillstreakCounterToggle,
"@MENU_DISPLAY_KILLSTREAK_COUNTER", pcdisplay.DisplayKillstreakCounterToggle)
"@MENU_DISPLAY_KILLSTREAK_COUNTER_DESC",
pcdisplay.GetDisplayKillstreakCounterText,
pcdisplay.DisplayKillstreakCounterToggle,
pcdisplay.DisplayKillstreakCounterToggle
)
LUI.Options.AddButtonOptionVariant( LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
menu, "@MENU_DISPLAY_MEDAL_SPLASHES", "@MENU_DISPLAY_MEDAL_SPLASHES_DESC", pcdisplay.GetDisplayMedalSplashesText,
luiglobals.GenericButtonSettings.Variants.Select, pcdisplay.DisplayMedalSplashesToggle, pcdisplay.DisplayMedalSplashesToggle)
"@MENU_DISPLAY_MEDAL_SPLASHES",
"@MENU_DISPLAY_MEDAL_SPLASHES_DESC",
pcdisplay.GetDisplayMedalSplashesText,
pcdisplay.DisplayMedalSplashesToggle,
pcdisplay.DisplayMedalSplashesToggle
)
LUI.Options.AddButtonOptionVariant( LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
menu, "@MENU_DISPLAY_WEAPON_EMBLEMS", "@MENU_DISPLAY_WEAPON_EMBLEMS_DESC", pcdisplay.GetDisplayWeaponEmblemsText,
luiglobals.GenericButtonSettings.Variants.Select, pcdisplay.DisplayWeaponEmblemsToggle, pcdisplay.DisplayWeaponEmblemsToggle)
"@MENU_DISPLAY_WEAPON_EMBLEMS",
"@MENU_DISPLAY_WEAPON_EMBLEMS_DESC",
pcdisplay.GetDisplayWeaponEmblemsText,
pcdisplay.DisplayWeaponEmblemsToggle,
pcdisplay.DisplayWeaponEmblemsToggle
)
end end
LUI.Options.AddButtonOptionVariant( LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Common, "@MENU_BRIGHTNESS",
menu, "@MENU_BRIGHTNESS_DESC1", nil, nil, nil, pcdisplay.OpenBrightnessMenu, nil, nil, nil)
luiglobals.GenericButtonSettings.Variants.Common,
"@MENU_BRIGHTNESS",
"@MENU_BRIGHTNESS_DESC1",
nil, nil, nil,
pcdisplay.OpenBrightnessMenu,
nil, nil, nil
)
createdivider(menu, "TELEMETRY") createdivider(menu, "TELEMETRY")
LUI.Options.CreateOptionButton( LUI.Options.CreateOptionButton(menu, "cg_infobar_ping", "@LUA_MENU_LATENCY", "@LUA_MENU_LATENCY_DESC", {{
menu,
"cg_infobar_ping",
"@LUA_MENU_LATENCY",
"@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, "cg_infobar_fps", "@LUA_MENU_FPS", "@LUA_MENU_FPS_DESC", {{
menu,
"cg_infobar_fps",
"@LUA_MENU_FPS",
"@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

View File

@ -30,7 +30,8 @@ function menu_xboxlive(f16_arg0, f16_arg1)
-- menu:AddDepotButton() -- menu:AddDepotButton()
end end
serverListButton = menu:AddButton("@MENU_PRIVATE_MATCH", MPLobbyOnline.OnPrivateMatch, MPLobbyOnline.disablePrivateMatchButton) serverListButton = menu:AddButton("@MENU_PRIVATE_MATCH", MPLobbyOnline.OnPrivateMatch,
MPLobbyOnline.disablePrivateMatchButton)
serverListButton:rename("menu_xboxlive_private_match") serverListButton:rename("menu_xboxlive_private_match")
serverListButton:setDisabledRefreshRate(500) serverListButton:setDisabledRefreshRate(500)
if not Engine.IsCoreMode() then if not Engine.IsCoreMode() then

View File

@ -8,21 +8,9 @@ end
game:addlocalizedstring("MENU_NUMPLAYERS", "Players") game:addlocalizedstring("MENU_NUMPLAYERS", "Players")
game:addlocalizedstring("MENU_PING", "Ping") game:addlocalizedstring("MENU_PING", "Ping")
local offsets = { local offsets = {10, 500, 950, 700, 1100}
10,
500,
950,
700,
1100,
}
local columns = { local columns = {"@MENU_HOST_NAME", "@MENU_MAP", "@MENU_NUMPLAYERS", "@MENU_TYPE1", "@MENU_PING"}
"@MENU_HOST_NAME",
"@MENU_MAP",
"@MENU_NUMPLAYERS",
"@MENU_TYPE1",
"@MENU_PING",
}
function textlength(text, font, height) function textlength(text, font, height)
local _, _, width = luiglobals.GetTextDimensions(text, font, height) local _, _, width = luiglobals.GetTextDimensions(text, font, height)
@ -43,9 +31,11 @@ SystemLinkJoinMenu.AddHeaderButton = function(menu, f12_arg1, width)
local element = LUI.UIElement.new(state) local element = LUI.UIElement.new(state)
local button = SystemLinkJoinMenu.CreateButton("header", 24) local button = SystemLinkJoinMenu.CreateButton("header", 24)
button:addElement(LUI.Divider.new(CoD.CreateState(nil, 0, nil, nil, CoD.AnchorTypes.TopLeftRight), 40, LUI.Divider.Grey)) button:addElement(LUI.Divider.new(CoD.CreateState(nil, 0, nil, nil, CoD.AnchorTypes.TopLeftRight), 40,
LUI.Divider.Grey))
button:makeNotFocusable() button:makeNotFocusable()
button:addElement(LUI.Divider.new(CoD.CreateState(nil, 0, nil, nil, CoD.AnchorTypes.BottomLeftRight), 40, LUI.Divider.Grey)) button:addElement(LUI.Divider.new(CoD.CreateState(nil, 0, nil, nil, CoD.AnchorTypes.BottomLeftRight), 40,
LUI.Divider.Grey))
local gettext = function(i) local gettext = function(i)
return Engine.Localize(columns[i]) return Engine.Localize(columns[i])

View File

@ -6,10 +6,12 @@ game:addlocalizedstring("LUA_MENU_STATS", "Stats")
game:addlocalizedstring("LUA_MENU_STATS_DESC", "Edit player stats settings.") game:addlocalizedstring("LUA_MENU_STATS_DESC", "Edit player stats settings.")
game:addlocalizedstring("LUA_MENU_UNLOCKALL_ITEMS", "Unlock all items") game:addlocalizedstring("LUA_MENU_UNLOCKALL_ITEMS", "Unlock all items")
game:addlocalizedstring("LUA_MENU_UNLOCKALL_ITEMS_DESC", "Whether items should be locked based on the player's stats or always unlocked.") game:addlocalizedstring("LUA_MENU_UNLOCKALL_ITEMS_DESC",
"Whether items should be locked based on the player's stats or always unlocked.")
game:addlocalizedstring("LUA_MENU_UNLOCKALL_CLASSES", "Unlock all classes") game:addlocalizedstring("LUA_MENU_UNLOCKALL_CLASSES", "Unlock all classes")
game:addlocalizedstring("LUA_MENU_UNLOCKALL_CLASSES_DESC", "Whether classes should be locked based on the player's stats or always unlocked.") game:addlocalizedstring("LUA_MENU_UNLOCKALL_CLASSES_DESC",
"Whether classes should be locked based on the player's stats or always unlocked.")
game:addlocalizedstring("LUA_MENU_PRESTIGE", "Prestige") game:addlocalizedstring("LUA_MENU_PRESTIGE", "Prestige")
game:addlocalizedstring("LUA_MENU_PRESTIGE_DESC", "Edit prestige level.") game:addlocalizedstring("LUA_MENU_PRESTIGE_DESC", "Edit prestige level.")
@ -53,48 +55,28 @@ end
LUI.MenuBuilder.registerType("stats_menu", function(a1) LUI.MenuBuilder.registerType("stats_menu", function(a1)
local menu = LUI.MenuTemplate.new(a1, { local menu = LUI.MenuTemplate.new(a1, {
menu_title = Engine.ToUpperCase(Engine.Localize("@LUA_MENU_STATS")), menu_title = Engine.ToUpperCase(Engine.Localize("@LUA_MENU_STATS")),
menu_width = luiglobals.GenericMenuDims.OptionMenuWidth, menu_width = luiglobals.GenericMenuDims.OptionMenuWidth
}) })
createdivider(menu, "@LUA_MENU_SETTINGS") createdivider(menu, "@LUA_MENU_SETTINGS")
LUI.Options.CreateOptionButton( LUI.Options.CreateOptionButton(menu, "cg_unlockall_items", "@LUA_MENU_UNLOCKALL_ITEMS",
menu, "@LUA_MENU_UNLOCKALL_ITEMS_DESC", {{
"cg_unlockall_items",
"@LUA_MENU_UNLOCKALL_ITEMS",
"@LUA_MENU_UNLOCKALL_ITEMS_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)
},
nil,
nil
)
LUI.Options.CreateOptionButton( LUI.Options.CreateOptionButton(menu, "cg_unlockall_classes", "@LUA_MENU_UNLOCKALL_CLASSES",
menu, "@LUA_MENU_UNLOCKALL_CLASSES_DESC", {{
"cg_unlockall_classes",
"@LUA_MENU_UNLOCKALL_CLASSES",
"@LUA_MENU_UNLOCKALL_CLASSES_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)
},
nil,
nil
)
createdivider(menu, "@LUA_MENU_EDIT_STATS") createdivider(menu, "@LUA_MENU_EDIT_STATS")
@ -170,16 +152,8 @@ function prestigeeditbutton(menu, callback)
Engine.SetDvarFromString("ui_prestige_level", prestige .. "") Engine.SetDvarFromString("ui_prestige_level", prestige .. "")
LUI.Options.CreateOptionButton( LUI.Options.CreateOptionButton(menu, "ui_prestige_level", "@LUA_MENU_PRESTIGE", "@LUA_MENU_PRESTIGE_DESC", options,
menu, nil, nil, callback)
"ui_prestige_level",
"@LUA_MENU_PRESTIGE",
"@LUA_MENU_PRESTIGE_DESC",
options,
nil,
nil,
callback
)
end end
function rankeditbutton(menu, callback) function rankeditbutton(menu, callback)
@ -202,16 +176,8 @@ function rankeditbutton(menu, callback)
Engine.SetDvarFromString("ui_rank_level_", rank .. "") Engine.SetDvarFromString("ui_rank_level_", rank .. "")
return LUI.Options.CreateOptionButton( return LUI.Options.CreateOptionButton(menu, "ui_rank_level_", "@LUA_MENU_RANK", "@LUA_MENU_RANK_DESC", options, nil,
menu, nil, callback)
"ui_rank_level_",
"@LUA_MENU_RANK",
"@LUA_MENU_RANK_DESC",
options,
nil,
nil,
callback
)
end end
local isclasslocked = luiglobals.Cac.IsCustomClassLocked local isclasslocked = luiglobals.Cac.IsCustomClassLocked