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 = {
r = 0.8,
g = 0.8,
b = 0.8,
b = 0.8
}
})
@ -99,7 +99,7 @@ function infoelement(data)
color = {
r = 0.6,
g = 0.6,
b = 0.6,
b = 0.6
}
})

View File

@ -7,7 +7,7 @@ game:addlocalizedstring("LUA_MENU_LATENCY", "Server Latency")
game:addlocalizedstring("LUA_MENU_LATENCY_DESC", "Show server latency")
function createdivider(menu, text)
local element = LUI.UIElement.new( {
local element = LUI.UIElement.new({
leftAnchor = true,
rightAnchor = true,
left = 0,
@ -26,154 +26,84 @@ function createdivider(menu, 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
)
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,
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")
)
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))
)
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.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.ToggleDvarFunc("cg_drawCrosshairOption"), LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption"))
LUI.Options.CreateOptionButton(
menu,
"cg_drawDamageFeedbackOption",
"@LUA_MENU_HIT_MARKER",
"@LUA_MENU_HIT_MARKER_DESC",
{
{
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_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_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
)
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
)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Common, "@MENU_BRIGHTNESS",
"@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",
{
{
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)
}}, nil, nil, function(value)
Engine.SetDvarBool("cg_infobar_ping", value)
Engine.GetLuiRoot():processEvent({
name = "update_hud_infobar_settings"
})
end
)
end)
LUI.Options.CreateOptionButton(
menu,
"cg_infobar_fps",
"@LUA_MENU_FPS",
"@LUA_MENU_FPS_DESC",
{
{
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)
}}, nil, nil, function(value)
Engine.SetDvarBool("cg_infobar_fps", value)
Engine.GetLuiRoot():processEvent({
name = "update_hud_infobar_settings"
})
end
)
end)
LUI.Options.InitScrollingList(menu.list, nil)
end

View File

@ -19,7 +19,7 @@ function menu_xboxlive(f16_arg0, f16_arg1)
menu:setClass(LUI.MPLobbyOnline)
local serverListButton = menu:AddButton("@LUA_MENU_SERVERLIST", function (a1, a2)
local serverListButton = menu:AddButton("@LUA_MENU_SERVERLIST", function(a1, a2)
LUI.FlowManager.RequestAddMenu(a1, "menu_systemlink_join", true, nil)
end)
serverListButton:setDisabledRefreshRate(500)
@ -30,7 +30,8 @@ function menu_xboxlive(f16_arg0, f16_arg1)
-- menu:AddDepotButton()
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:setDisabledRefreshRate(500)
if not Engine.IsCoreMode() then

View File

@ -8,21 +8,9 @@ end
game:addlocalizedstring("MENU_NUMPLAYERS", "Players")
game:addlocalizedstring("MENU_PING", "Ping")
local offsets = {
10,
500,
950,
700,
1100,
}
local offsets = {10, 500, 950, 700, 1100}
local columns = {
"@MENU_HOST_NAME",
"@MENU_MAP",
"@MENU_NUMPLAYERS",
"@MENU_TYPE1",
"@MENU_PING",
}
local columns = {"@MENU_HOST_NAME", "@MENU_MAP", "@MENU_NUMPLAYERS", "@MENU_TYPE1", "@MENU_PING"}
function textlength(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 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: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)
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_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_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_DESC", "Edit prestige level.")
@ -23,7 +25,7 @@ game:addlocalizedstring("LUA_MENU_SETTINGS", "Settings")
game:addlocalizedstring("LUA_MENU_EDIT_STATS", "Edit Stats")
function createdivider(menu, text)
local element = LUI.UIElement.new( {
local element = LUI.UIElement.new({
leftAnchor = true,
rightAnchor = true,
left = 0,
@ -53,48 +55,28 @@ end
LUI.MenuBuilder.registerType("stats_menu", function(a1)
local menu = LUI.MenuTemplate.new(a1, {
menu_title = Engine.ToUpperCase(Engine.Localize("@LUA_MENU_STATS")),
menu_width = luiglobals.GenericMenuDims.OptionMenuWidth,
menu_width = luiglobals.GenericMenuDims.OptionMenuWidth
})
createdivider(menu, "@LUA_MENU_SETTINGS")
LUI.Options.CreateOptionButton(
menu,
"cg_unlockall_items",
"@LUA_MENU_UNLOCKALL_ITEMS",
"@LUA_MENU_UNLOCKALL_ITEMS_DESC",
{
{
LUI.Options.CreateOptionButton(menu, "cg_unlockall_items", "@LUA_MENU_UNLOCKALL_ITEMS",
"@LUA_MENU_UNLOCKALL_ITEMS_DESC", {{
text = "@LUA_MENU_ENABLED",
value = true
},
{
}, {
text = "@LUA_MENU_DISABLED",
value = false
}
},
nil,
nil
)
}}, nil, nil)
LUI.Options.CreateOptionButton(
menu,
"cg_unlockall_classes",
"@LUA_MENU_UNLOCKALL_CLASSES",
"@LUA_MENU_UNLOCKALL_CLASSES_DESC",
{
{
LUI.Options.CreateOptionButton(menu, "cg_unlockall_classes", "@LUA_MENU_UNLOCKALL_CLASSES",
"@LUA_MENU_UNLOCKALL_CLASSES_DESC", {{
text = "@LUA_MENU_ENABLED",
value = true
},
{
}, {
text = "@LUA_MENU_DISABLED",
value = false
}
},
nil,
nil
)
}}, nil, nil)
createdivider(menu, "@LUA_MENU_EDIT_STATS")
@ -170,16 +152,8 @@ function prestigeeditbutton(menu, callback)
Engine.SetDvarFromString("ui_prestige_level", prestige .. "")
LUI.Options.CreateOptionButton(
menu,
"ui_prestige_level",
"@LUA_MENU_PRESTIGE",
"@LUA_MENU_PRESTIGE_DESC",
options,
nil,
nil,
callback
)
LUI.Options.CreateOptionButton(menu, "ui_prestige_level", "@LUA_MENU_PRESTIGE", "@LUA_MENU_PRESTIGE_DESC", options,
nil, nil, callback)
end
function rankeditbutton(menu, callback)
@ -202,16 +176,8 @@ function rankeditbutton(menu, callback)
Engine.SetDvarFromString("ui_rank_level_", rank .. "")
return LUI.Options.CreateOptionButton(
menu,
"ui_rank_level_",
"@LUA_MENU_RANK",
"@LUA_MENU_RANK_DESC",
options,
nil,
nil,
callback
)
return LUI.Options.CreateOptionButton(menu, "ui_rank_level_", "@LUA_MENU_RANK", "@LUA_MENU_RANK_DESC", options, nil,
nil, callback)
end
local isclasslocked = luiglobals.Cac.IsCustomClassLocked