nicely format LUA files
This commit is contained in:
parent
8484dfc2db
commit
4ef4bea351
@ -1,5 +1,5 @@
|
|||||||
if (game:issingleplayer()) then
|
if (game:issingleplayer()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
require("settings")
|
require("settings")
|
||||||
|
@ -4,155 +4,155 @@ local textheight = 13
|
|||||||
local textoffsety = barheight / 2 - textheight / 2
|
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 = barheight,
|
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 label = LUI.UIText.new({
|
local label = LUI.UIText.new({
|
||||||
left = 5,
|
left = 5,
|
||||||
top = textoffsety,
|
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 = textoffsety,
|
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)
|
@ -7,173 +7,103 @@ 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")
|
||||||
|
|
||||||
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(
|
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,
|
"@LUA_MENU_PAINTBALL", "@LUA_MENU_PAINTBALL_DESC",
|
||||||
luiglobals.GenericButtonSettings.Variants.Select,
|
LUI.Options.GetDvarEnableTextFunc("cg_paintballFx", false), LUI.Options.ToggleDvarFunc("cg_paintballFx"),
|
||||||
"@LUA_MENU_PAINTBALL", "@LUA_MENU_PAINTBALL_DESC",
|
LUI.Options.ToggleDvarFunc("cg_paintballFx"))
|
||||||
LUI.Options.GetDvarEnableTextFunc("cg_paintballFx", false),
|
end
|
||||||
LUI.Options.ToggleDvarFunc("cg_paintballFx"),
|
|
||||||
LUI.Options.ToggleDvarFunc("cg_paintballFx")
|
|
||||||
)
|
|
||||||
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,
|
LUI.Options.GetDvarEnableTextFunc("cg_drawCrosshairOption", false),
|
||||||
"@LUA_MENU_CROSSHAIR",
|
LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption"), LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption"))
|
||||||
"@LUA_MENU_CROSSHAIR_DESC",
|
|
||||||
LUI.Options.GetDvarEnableTextFunc("cg_drawCrosshairOption", false),
|
|
||||||
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",
|
text = "@LUA_MENU_ENABLED",
|
||||||
"@LUA_MENU_HIT_MARKER",
|
value = true
|
||||||
"@LUA_MENU_HIT_MARKER_DESC",
|
}, {
|
||||||
{
|
text = "@LUA_MENU_DISABLED",
|
||||||
{
|
value = false
|
||||||
text = "@LUA_MENU_ENABLED",
|
}})
|
||||||
value = true
|
end
|
||||||
},
|
|
||||||
{
|
|
||||||
text = "@LUA_MENU_DISABLED",
|
|
||||||
value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
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",
|
end
|
||||||
"@MENU_DISPLAY_WEAPON_EMBLEMS_DESC",
|
|
||||||
pcdisplay.GetDisplayWeaponEmblemsText,
|
|
||||||
pcdisplay.DisplayWeaponEmblemsToggle,
|
|
||||||
pcdisplay.DisplayWeaponEmblemsToggle
|
|
||||||
)
|
|
||||||
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,
|
text = "@LUA_MENU_ENABLED",
|
||||||
"cg_infobar_ping",
|
value = true
|
||||||
"@LUA_MENU_LATENCY",
|
}, {
|
||||||
"@LUA_MENU_LATENCY_DESC",
|
text = "@LUA_MENU_DISABLED",
|
||||||
{
|
value = false
|
||||||
{
|
}}, nil, nil, function(value)
|
||||||
text = "@LUA_MENU_ENABLED",
|
Engine.SetDvarBool("cg_infobar_ping", value)
|
||||||
value = true
|
Engine.GetLuiRoot():processEvent({
|
||||||
},
|
name = "update_hud_infobar_settings"
|
||||||
{
|
})
|
||||||
text = "@LUA_MENU_DISABLED",
|
end)
|
||||||
value = false
|
|
||||||
}
|
|
||||||
}, nil, nil, function(value)
|
|
||||||
Engine.SetDvarBool("cg_infobar_ping", value)
|
|
||||||
Engine.GetLuiRoot():processEvent({
|
|
||||||
name = "update_hud_infobar_settings"
|
|
||||||
})
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
LUI.Options.CreateOptionButton(
|
LUI.Options.CreateOptionButton(menu, "cg_infobar_fps", "@LUA_MENU_FPS", "@LUA_MENU_FPS_DESC", {{
|
||||||
menu,
|
text = "@LUA_MENU_ENABLED",
|
||||||
"cg_infobar_fps",
|
value = true
|
||||||
"@LUA_MENU_FPS",
|
}, {
|
||||||
"@LUA_MENU_FPS_DESC",
|
text = "@LUA_MENU_DISABLED",
|
||||||
{
|
value = false
|
||||||
{
|
}}, nil, nil, function(value)
|
||||||
text = "@LUA_MENU_ENABLED",
|
Engine.SetDvarBool("cg_infobar_fps", value)
|
||||||
value = true
|
Engine.GetLuiRoot():processEvent({
|
||||||
},
|
name = "update_hud_infobar_settings"
|
||||||
{
|
})
|
||||||
text = "@LUA_MENU_DISABLED",
|
end)
|
||||||
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)
|
LUI.Options.InitScrollingList(menu.list, nil)
|
||||||
end
|
end
|
||||||
|
@ -4,65 +4,66 @@ local MPLobbyOnline = LUI.mp_menus.MPLobbyOnline
|
|||||||
game:addlocalizedstring("LUA_MENU_SERVERLIST", "SERVER LIST")
|
game:addlocalizedstring("LUA_MENU_SERVERLIST", "SERVER LIST")
|
||||||
|
|
||||||
function LeaveLobby(f5_arg0)
|
function LeaveLobby(f5_arg0)
|
||||||
LeaveXboxLive()
|
LeaveXboxLive()
|
||||||
if Lobby.IsInPrivateParty() == false or Lobby.IsPrivatePartyHost() then
|
if Lobby.IsInPrivateParty() == false or Lobby.IsPrivatePartyHost() then
|
||||||
LUI.FlowManager.RequestLeaveMenuByName("menu_xboxlive")
|
LUI.FlowManager.RequestLeaveMenuByName("menu_xboxlive")
|
||||||
Engine.ExecNow("clearcontrollermap")
|
Engine.ExecNow("clearcontrollermap")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function menu_xboxlive(f16_arg0, f16_arg1)
|
function menu_xboxlive(f16_arg0, f16_arg1)
|
||||||
local menu = LUI.MPLobbyBase.new(f16_arg0, {
|
local menu = LUI.MPLobbyBase.new(f16_arg0, {
|
||||||
menu_title = "@PLATFORM_UI_HEADER_PLAY_MP_CAPS",
|
menu_title = "@PLATFORM_UI_HEADER_PLAY_MP_CAPS",
|
||||||
memberListState = Lobby.MemberListStates.Prelobby
|
memberListState = Lobby.MemberListStates.Prelobby
|
||||||
})
|
})
|
||||||
|
|
||||||
menu:setClass(LUI.MPLobbyOnline)
|
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)
|
LUI.FlowManager.RequestAddMenu(a1, "menu_systemlink_join", true, nil)
|
||||||
end)
|
end)
|
||||||
serverListButton:setDisabledRefreshRate(500)
|
serverListButton:setDisabledRefreshRate(500)
|
||||||
if Engine.IsCoreMode() then
|
if Engine.IsCoreMode() then
|
||||||
menu:AddCACButton()
|
menu:AddCACButton()
|
||||||
menu:AddBarracksButton()
|
menu:AddBarracksButton()
|
||||||
menu:AddPersonalizationButton()
|
menu:AddPersonalizationButton()
|
||||||
-- menu:AddDepotButton()
|
-- menu:AddDepotButton()
|
||||||
end
|
end
|
||||||
|
|
||||||
serverListButton = menu:AddButton("@MENU_PRIVATE_MATCH", MPLobbyOnline.OnPrivateMatch, MPLobbyOnline.disablePrivateMatchButton)
|
serverListButton = menu:AddButton("@MENU_PRIVATE_MATCH", MPLobbyOnline.OnPrivateMatch,
|
||||||
serverListButton:rename("menu_xboxlive_private_match")
|
MPLobbyOnline.disablePrivateMatchButton)
|
||||||
serverListButton:setDisabledRefreshRate(500)
|
serverListButton:rename("menu_xboxlive_private_match")
|
||||||
if not Engine.IsCoreMode() then
|
serverListButton:setDisabledRefreshRate(500)
|
||||||
local leaderboardButton = menu:AddButton("@LUA_MENU_LEADERBOARD", "OpLeaderboardMain")
|
if not Engine.IsCoreMode() then
|
||||||
leaderboardButton:rename("OperatorMenu_leaderboard")
|
local leaderboardButton = menu:AddButton("@LUA_MENU_LEADERBOARD", "OpLeaderboardMain")
|
||||||
end
|
leaderboardButton:rename("OperatorMenu_leaderboard")
|
||||||
|
end
|
||||||
|
|
||||||
menu:AddOptionsButton()
|
menu:AddOptionsButton()
|
||||||
local natType = Lobby.GetNATType()
|
local natType = Lobby.GetNATType()
|
||||||
if natType then
|
if natType then
|
||||||
local natTypeText = Engine.Localize("NETWORK_YOURNATTYPE", natType)
|
local natTypeText = Engine.Localize("NETWORK_YOURNATTYPE", natType)
|
||||||
local properties = CoD.CreateState(nil, nil, 2, -62, CoD.AnchorTypes.BottomRight)
|
local properties = CoD.CreateState(nil, nil, 2, -62, CoD.AnchorTypes.BottomRight)
|
||||||
properties.width = 250
|
properties.width = 250
|
||||||
properties.height = CoD.TextSettings.BodyFontVeryTiny.Height
|
properties.height = CoD.TextSettings.BodyFontVeryTiny.Height
|
||||||
properties.font = CoD.TextSettings.BodyFontVeryTiny.Font
|
properties.font = CoD.TextSettings.BodyFontVeryTiny.Font
|
||||||
properties.color = luiglobals.Colors.white
|
properties.color = luiglobals.Colors.white
|
||||||
properties.alpha = 0.25
|
properties.alpha = 0.25
|
||||||
local self = LUI.UIText.new(properties)
|
local self = LUI.UIText.new(properties)
|
||||||
self:setText(natTypeText)
|
self:setText(natTypeText)
|
||||||
menu:addElement(self)
|
menu:addElement(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu.isSignInMenu = true
|
menu.isSignInMenu = true
|
||||||
menu:registerEventHandler("gain_focus", LUI.MPLobbyOnline.OnGainFocus)
|
menu:registerEventHandler("gain_focus", LUI.MPLobbyOnline.OnGainFocus)
|
||||||
menu:registerEventHandler("player_joined", luiglobals.Cac.PlayerJoinedEvent)
|
menu:registerEventHandler("player_joined", luiglobals.Cac.PlayerJoinedEvent)
|
||||||
menu:registerEventHandler("exit_live_lobby", LeaveLobby)
|
menu:registerEventHandler("exit_live_lobby", LeaveLobby)
|
||||||
|
|
||||||
if Engine.IsCoreMode() then
|
if Engine.IsCoreMode() then
|
||||||
Engine.ExecNow("eliteclan_refresh", Engine.GetFirstActiveController())
|
Engine.ExecNow("eliteclan_refresh", Engine.GetFirstActiveController())
|
||||||
end
|
end
|
||||||
|
|
||||||
return menu
|
return menu
|
||||||
end
|
end
|
||||||
|
|
||||||
LUI.MenuBuilder.m_types_build["menu_xboxlive"] = menu_xboxlive
|
LUI.MenuBuilder.m_types_build["menu_xboxlive"] = menu_xboxlive
|
||||||
|
@ -2,161 +2,151 @@ local Lobby = luiglobals.Lobby
|
|||||||
local SystemLinkJoinMenu = LUI.mp_menus.SystemLinkJoinMenu
|
local SystemLinkJoinMenu = LUI.mp_menus.SystemLinkJoinMenu
|
||||||
|
|
||||||
if (not SystemLinkJoinMenu) then
|
if (not SystemLinkJoinMenu) then
|
||||||
return
|
return
|
||||||
end
|
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)
|
||||||
return width
|
return width
|
||||||
end
|
end
|
||||||
|
|
||||||
function trimtext(text, font, height, maxwidth)
|
function trimtext(text, font, height, maxwidth)
|
||||||
while (textlength(text, font, height) > maxwidth) do
|
while (textlength(text, font, height) > maxwidth) do
|
||||||
text = text:sub(1, #text - 1)
|
text = text:sub(1, #text - 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
SystemLinkJoinMenu.AddHeaderButton = function(menu, f12_arg1, width)
|
SystemLinkJoinMenu.AddHeaderButton = function(menu, f12_arg1, width)
|
||||||
local state = CoD.CreateState(0, f12_arg1, nil, nil, CoD.AnchorTypes.TopLeft)
|
local state = CoD.CreateState(0, f12_arg1, nil, nil, CoD.AnchorTypes.TopLeft)
|
||||||
state.width = width
|
state.width = 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,
|
||||||
button:makeNotFocusable()
|
LUI.Divider.Grey))
|
||||||
button:addElement(LUI.Divider.new(CoD.CreateState(nil, 0, nil, nil, CoD.AnchorTypes.BottomLeftRight), 40, LUI.Divider.Grey))
|
button:makeNotFocusable()
|
||||||
|
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])
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, #offsets do
|
for i = 1, #offsets do
|
||||||
SystemLinkJoinMenu.MakeText(button.textHolder, offsets[i], gettext(i), nil)
|
SystemLinkJoinMenu.MakeText(button.textHolder, offsets[i], gettext(i), nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
element:addElement(button)
|
element:addElement(button)
|
||||||
menu:addElement(element)
|
menu:addElement(element)
|
||||||
end
|
end
|
||||||
|
|
||||||
SystemLinkJoinMenu.AddServerButton = function(menu, controller, index)
|
SystemLinkJoinMenu.AddServerButton = function(menu, controller, index)
|
||||||
local button = SystemLinkJoinMenu.CreateButton(index or "header", 24)
|
local button = SystemLinkJoinMenu.CreateButton(index or "header", 24)
|
||||||
button:makeFocusable()
|
button:makeFocusable()
|
||||||
button.index = index
|
button.index = index
|
||||||
button:addEventHandler("button_action", SystemLinkJoinMenu.OnJoinGame)
|
button:addEventHandler("button_action", SystemLinkJoinMenu.OnJoinGame)
|
||||||
|
|
||||||
local gettext = function(i)
|
local gettext = function(i)
|
||||||
local text = Lobby.GetServerData(controller, index, i - 1)
|
local text = Lobby.GetServerData(controller, index, i - 1)
|
||||||
return trimtext(text, CoD.TextSettings.TitleFontSmall.Font, 14, 400)
|
return trimtext(text, CoD.TextSettings.TitleFontSmall.Font, 14, 400)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, #offsets do
|
for i = 1, #offsets do
|
||||||
SystemLinkJoinMenu.MakeText(button.textHolder, offsets[i], gettext(i), luiglobals.Colors.h1.medium_grey)
|
SystemLinkJoinMenu.MakeText(button.textHolder, offsets[i], gettext(i), luiglobals.Colors.h1.medium_grey)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu.list:addElement(button)
|
menu.list:addElement(button)
|
||||||
return button
|
return button
|
||||||
end
|
end
|
||||||
|
|
||||||
SystemLinkJoinMenu.MakeText = function(menu, f5_arg1, text, color)
|
SystemLinkJoinMenu.MakeText = function(menu, f5_arg1, text, color)
|
||||||
local state = CoD.CreateState(f5_arg1, nil, f5_arg1 + 200, nil, CoD.AnchorTypes.Left)
|
local state = CoD.CreateState(f5_arg1, nil, f5_arg1 + 200, nil, CoD.AnchorTypes.Left)
|
||||||
state.font = CoD.TextSettings.TitleFontSmall.Font
|
state.font = CoD.TextSettings.TitleFontSmall.Font
|
||||||
state.top = -6
|
state.top = -6
|
||||||
state.height = 14
|
state.height = 14
|
||||||
state.alignment = LUI.Alignment.Left
|
state.alignment = LUI.Alignment.Left
|
||||||
state.glow = LUI.GlowState.None
|
state.glow = LUI.GlowState.None
|
||||||
state.color = color
|
state.color = color
|
||||||
|
|
||||||
local el = LUI.UIText.new(state)
|
local el = LUI.UIText.new(state)
|
||||||
el:registerAnimationState("focused", {
|
el:registerAnimationState("focused", {
|
||||||
color = luiglobals.Colors.white
|
color = luiglobals.Colors.white
|
||||||
})
|
})
|
||||||
|
|
||||||
el:registerEventHandler("focused", function(element, event)
|
el:registerEventHandler("focused", function(element, event)
|
||||||
element:animateToState("focused", 0)
|
element:animateToState("focused", 0)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
el:registerEventHandler("unfocused", function(element, event)
|
el:registerEventHandler("unfocused", function(element, event)
|
||||||
element:animateToState("default", 0)
|
element:animateToState("default", 0)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
el:setText(text)
|
el:setText(text)
|
||||||
menu:addElement(el)
|
menu:addElement(el)
|
||||||
end
|
end
|
||||||
|
|
||||||
function menu_systemlink_join(f19_arg0, f19_arg1)
|
function menu_systemlink_join(f19_arg0, f19_arg1)
|
||||||
local width = 1145
|
local width = 1145
|
||||||
|
|
||||||
local menu = LUI.MenuTemplate.new(f19_arg0, {
|
local menu = LUI.MenuTemplate.new(f19_arg0, {
|
||||||
menu_title = "@PLATFORM_SYSTEM_LINK_TITLE",
|
menu_title = "@PLATFORM_SYSTEM_LINK_TITLE",
|
||||||
menu_width = width,
|
menu_width = width,
|
||||||
menu_top_indent = 20,
|
menu_top_indent = 20,
|
||||||
disableDeco = true,
|
disableDeco = true,
|
||||||
spacing = 1
|
spacing = 1
|
||||||
})
|
})
|
||||||
|
|
||||||
SystemLinkJoinMenu.AddHeaderButton(menu, 80, width)
|
SystemLinkJoinMenu.AddHeaderButton(menu, 80, width)
|
||||||
SystemLinkJoinMenu.AddLowerCounter(menu, width)
|
SystemLinkJoinMenu.AddLowerCounter(menu, width)
|
||||||
SystemLinkJoinMenu.UpdateCounterText(menu, nil)
|
SystemLinkJoinMenu.UpdateCounterText(menu, nil)
|
||||||
Lobby.BuildServerList(Engine.GetFirstActiveController())
|
Lobby.BuildServerList(Engine.GetFirstActiveController())
|
||||||
|
|
||||||
menu.list:registerEventHandler(LUI.UIScrollIndicator.UpdateEvent, function(element, event)
|
menu.list:registerEventHandler(LUI.UIScrollIndicator.UpdateEvent, function(element, event)
|
||||||
SystemLinkJoinMenu.UpdateCounterText(menu, event)
|
SystemLinkJoinMenu.UpdateCounterText(menu, event)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
SystemLinkJoinMenu.UpdateGameList(menu)
|
SystemLinkJoinMenu.UpdateGameList(menu)
|
||||||
menu:registerEventHandler("updateGameList", SystemLinkJoinMenu.UpdateGameList)
|
menu:registerEventHandler("updateGameList", SystemLinkJoinMenu.UpdateGameList)
|
||||||
menu:addElement(LUI.UITimer.new(250, "updateGameList"))
|
menu:addElement(LUI.UITimer.new(250, "updateGameList"))
|
||||||
|
|
||||||
LUI.ButtonHelperText.ClearHelperTextObjects(menu.help, {
|
LUI.ButtonHelperText.ClearHelperTextObjects(menu.help, {
|
||||||
side = "all"
|
side = "all"
|
||||||
})
|
})
|
||||||
|
|
||||||
menu:AddHelp({
|
menu:AddHelp({
|
||||||
name = "add_button_helper_text",
|
name = "add_button_helper_text",
|
||||||
button_ref = "button_alt1",
|
button_ref = "button_alt1",
|
||||||
helper_text = Engine.Localize("@MENU_SB_TOOLTIP_BTN_REFRESH"),
|
helper_text = Engine.Localize("@MENU_SB_TOOLTIP_BTN_REFRESH"),
|
||||||
side = "right",
|
side = "right",
|
||||||
clickable = true,
|
clickable = true,
|
||||||
priority = -1000
|
priority = -1000
|
||||||
}, function(f21_arg0, f21_arg1)
|
}, function(f21_arg0, f21_arg1)
|
||||||
SystemLinkJoinMenu.RefreshServers(f21_arg0, f21_arg1, menu)
|
SystemLinkJoinMenu.RefreshServers(f21_arg0, f21_arg1, menu)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
menu:AddHelp({
|
menu:AddHelp({
|
||||||
name = "add_button_helper_text",
|
name = "add_button_helper_text",
|
||||||
button_ref = "button_action",
|
button_ref = "button_action",
|
||||||
helper_text = Engine.Localize("@MENU_JOIN_GAME1"),
|
helper_text = Engine.Localize("@MENU_JOIN_GAME1"),
|
||||||
side = "left",
|
side = "left",
|
||||||
clickable = false,
|
clickable = false,
|
||||||
priority = -1000
|
priority = -1000
|
||||||
}, nil, nil, true)
|
}, nil, nil, true)
|
||||||
|
|
||||||
menu:AddBackButton()
|
menu:AddBackButton()
|
||||||
|
|
||||||
Lobby.RefreshServerList(Engine.GetFirstActiveController())
|
Lobby.RefreshServerList(Engine.GetFirstActiveController())
|
||||||
|
|
||||||
return menu
|
return menu
|
||||||
end
|
end
|
||||||
|
|
||||||
LUI.MenuBuilder.m_types_build["menu_systemlink_join"] = menu_systemlink_join
|
LUI.MenuBuilder.m_types_build["menu_systemlink_join"] = menu_systemlink_join
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
if (game:issingleplayer() or not Engine.InFrontend()) then
|
if (game:issingleplayer() or not Engine.InFrontend()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
game:addlocalizedstring("LUA_MENU_STATS", "Stats")
|
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.")
|
||||||
@ -23,202 +25,166 @@ game:addlocalizedstring("LUA_MENU_SETTINGS", "Settings")
|
|||||||
game:addlocalizedstring("LUA_MENU_EDIT_STATS", "Edit Stats")
|
game:addlocalizedstring("LUA_MENU_EDIT_STATS", "Edit Stats")
|
||||||
|
|
||||||
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 = Engine.ToUpperCase(Engine.Localize(text))
|
title_bar_text = Engine.ToUpperCase(Engine.Localize(text))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
menu.list:addElement(element)
|
menu.list:addElement(element)
|
||||||
end
|
end
|
||||||
|
|
||||||
local personalizationbutton = LUI.MPLobbyBase.AddPersonalizationButton
|
local personalizationbutton = LUI.MPLobbyBase.AddPersonalizationButton
|
||||||
LUI.MPLobbyBase.AddPersonalizationButton = function(menu)
|
LUI.MPLobbyBase.AddPersonalizationButton = function(menu)
|
||||||
personalizationbutton(menu)
|
personalizationbutton(menu)
|
||||||
menu:AddButton("@LUA_MENU_STATS", function()
|
menu:AddButton("@LUA_MENU_STATS", function()
|
||||||
LUI.FlowManager.RequestAddMenu(nil, "stats_menu")
|
LUI.FlowManager.RequestAddMenu(nil, "stats_menu")
|
||||||
end)
|
end)
|
||||||
end
|
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",
|
text = "@LUA_MENU_ENABLED",
|
||||||
"@LUA_MENU_UNLOCKALL_ITEMS",
|
value = true
|
||||||
"@LUA_MENU_UNLOCKALL_ITEMS_DESC",
|
}, {
|
||||||
{
|
text = "@LUA_MENU_DISABLED",
|
||||||
{
|
value = false
|
||||||
text = "@LUA_MENU_ENABLED",
|
}}, nil, nil)
|
||||||
value = true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text = "@LUA_MENU_DISABLED",
|
|
||||||
value = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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",
|
text = "@LUA_MENU_ENABLED",
|
||||||
"@LUA_MENU_UNLOCKALL_CLASSES",
|
value = true
|
||||||
"@LUA_MENU_UNLOCKALL_CLASSES_DESC",
|
}, {
|
||||||
{
|
text = "@LUA_MENU_DISABLED",
|
||||||
{
|
value = false
|
||||||
text = "@LUA_MENU_ENABLED",
|
}}, nil, nil)
|
||||||
value = true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text = "@LUA_MENU_DISABLED",
|
|
||||||
value = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
nil,
|
|
||||||
nil
|
|
||||||
)
|
|
||||||
|
|
||||||
createdivider(menu, "@LUA_MENU_EDIT_STATS")
|
createdivider(menu, "@LUA_MENU_EDIT_STATS")
|
||||||
|
|
||||||
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
||||||
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
|
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
|
||||||
local rank = luiglobals.Lobby.GetRankForXP(experience, prestige)
|
local rank = luiglobals.Lobby.GetRankForXP(experience, prestige)
|
||||||
|
|
||||||
local saved = true
|
local saved = true
|
||||||
local prestigevalue = prestige
|
local prestigevalue = prestige
|
||||||
local rankvalue = rank
|
local rankvalue = rank
|
||||||
local rankbutton = nil
|
local rankbutton = nil
|
||||||
|
|
||||||
prestigeeditbutton(menu, function(value)
|
prestigeeditbutton(menu, function(value)
|
||||||
prestigevalue = value
|
prestigevalue = value
|
||||||
saved = false
|
saved = false
|
||||||
end)
|
end)
|
||||||
|
|
||||||
rankbutton = rankeditbutton(menu, function(value)
|
rankbutton = rankeditbutton(menu, function(value)
|
||||||
rankvalue = value
|
rankvalue = value
|
||||||
saved = false
|
saved = false
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local savebutton = menu:AddButton("@LUA_MENU_SAVE", function()
|
local savebutton = menu:AddButton("@LUA_MENU_SAVE", function()
|
||||||
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "prestige", tonumber(prestigevalue))
|
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "prestige", tonumber(prestigevalue))
|
||||||
|
|
||||||
local rank = tonumber(rankvalue)
|
local rank = tonumber(rankvalue)
|
||||||
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
||||||
local experience = rank == 0 and 0 or luiglobals.Rank.GetRankMaxXP(tonumber(rankvalue) - 1, prestige)
|
local experience = rank == 0 and 0 or luiglobals.Rank.GetRankMaxXP(tonumber(rankvalue) - 1, prestige)
|
||||||
|
|
||||||
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "experience", experience)
|
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "experience", experience)
|
||||||
|
|
||||||
saved = true
|
saved = true
|
||||||
end, nil, nil, nil, {
|
end, nil, nil, nil, {
|
||||||
desc_text = Engine.Localize("LUA_MENU_SAVE_DESC")
|
desc_text = Engine.Localize("LUA_MENU_SAVE_DESC")
|
||||||
})
|
})
|
||||||
|
|
||||||
LUI.Options.InitScrollingList(menu.list, nil)
|
LUI.Options.InitScrollingList(menu.list, nil)
|
||||||
LUI.Options.AddOptionTextInfo(menu)
|
LUI.Options.AddOptionTextInfo(menu)
|
||||||
|
|
||||||
menu:AddBackButton(function()
|
menu:AddBackButton(function()
|
||||||
if (saved) then
|
if (saved) then
|
||||||
LUI.FlowManager.RequestLeaveMenu(menu)
|
LUI.FlowManager.RequestLeaveMenu(menu)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
LUI.yesnopopup({
|
LUI.yesnopopup({
|
||||||
title = Engine.Localize("@MENU_NOTICE"),
|
title = Engine.Localize("@MENU_NOTICE"),
|
||||||
text = Engine.Localize("@LUA_MENU_UNSAVED_CHANGES"),
|
text = Engine.Localize("@LUA_MENU_UNSAVED_CHANGES"),
|
||||||
callback = function(result)
|
callback = function(result)
|
||||||
if (result) then
|
if (result) then
|
||||||
LUI.FlowManager.RequestLeaveMenu(menu)
|
LUI.FlowManager.RequestLeaveMenu(menu)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return menu
|
return menu
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function prestigeeditbutton(menu, callback)
|
function prestigeeditbutton(menu, callback)
|
||||||
local options = {}
|
local options = {}
|
||||||
local max = luiglobals.Lobby.GetMaxPrestigeLevel()
|
local max = luiglobals.Lobby.GetMaxPrestigeLevel()
|
||||||
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
||||||
|
|
||||||
for i = 0, max do
|
for i = 0, max do
|
||||||
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
||||||
|
|
||||||
table.insert(options, {
|
table.insert(options, {
|
||||||
text = "@" .. i,
|
text = "@" .. i,
|
||||||
value = i .. ""
|
value = i .. ""
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
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)
|
||||||
local options = {}
|
local options = {}
|
||||||
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
||||||
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
|
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
|
||||||
|
|
||||||
local rank = luiglobals.Lobby.GetRankForXP(experience, prestige)
|
local rank = luiglobals.Lobby.GetRankForXP(experience, prestige)
|
||||||
local max = luiglobals.Rank.GetMaxRank(prestige)
|
local max = luiglobals.Rank.GetMaxRank(prestige)
|
||||||
local maxprestige = luiglobals.Lobby.GetMaxPrestigeLevel()
|
local maxprestige = luiglobals.Lobby.GetMaxPrestigeLevel()
|
||||||
|
|
||||||
for i = 0, max do
|
for i = 0, max do
|
||||||
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
||||||
|
|
||||||
table.insert(options, {
|
table.insert(options, {
|
||||||
text = "@" .. (i + 1),
|
text = "@" .. (i + 1),
|
||||||
value = i .. ""
|
value = i .. ""
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
luiglobals.Cac.IsCustomClassLocked = function(...)
|
luiglobals.Cac.IsCustomClassLocked = function(...)
|
||||||
if (Engine.GetDvarBool("cg_unlockall_classes")) then
|
if (Engine.GetDvarBool("cg_unlockall_classes")) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return isclasslocked(table.unpack({...}))
|
return isclasslocked(table.unpack({...}))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user