2022-03-11 15:44:29 -05:00
|
|
|
if (game:issingleplayer() or not Engine.InFrontend()) then
|
2022-05-20 15:11:58 -04:00
|
|
|
return
|
2022-03-09 19:30:03 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
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")
|
2022-03-11 17:35:50 -05:00
|
|
|
game:addlocalizedstring("LUA_MENU_UNLOCKALL_ITEMS_DESC",
|
2022-05-20 15:11:58 -04:00
|
|
|
"Whether items should be locked based on the player's stats or always unlocked.")
|
|
|
|
|
|
|
|
game:addlocalizedstring("LUA_MENU_UNLOCKALL_LOOT", "Unlock all loot")
|
|
|
|
game:addlocalizedstring("LUA_MENU_UNLOCKALL_LOOT_DESC",
|
|
|
|
"Whether loot should be locked based on the player's stats or always unlocked.")
|
2022-03-09 19:30:03 -05:00
|
|
|
|
|
|
|
game:addlocalizedstring("LUA_MENU_UNLOCKALL_CLASSES", "Unlock all classes")
|
2022-03-11 17:35:50 -05:00
|
|
|
game:addlocalizedstring("LUA_MENU_UNLOCKALL_CLASSES_DESC",
|
2022-05-20 15:11:58 -04:00
|
|
|
"Whether classes should be locked based on the player's stats or always unlocked.")
|
2022-03-09 19:30:03 -05:00
|
|
|
|
|
|
|
game:addlocalizedstring("LUA_MENU_PRESTIGE", "Prestige")
|
|
|
|
game:addlocalizedstring("LUA_MENU_PRESTIGE_DESC", "Edit prestige level.")
|
|
|
|
game:addlocalizedstring("LUA_MENU_RANK", "Rank")
|
|
|
|
game:addlocalizedstring("LUA_MENU_RANK_DESC", "Edit rank.")
|
|
|
|
|
|
|
|
game:addlocalizedstring("LUA_MENU_UNSAVED_CHANGES", "You have unsaved changes, are you sure you want to exit?")
|
|
|
|
game:addlocalizedstring("LUA_MENU_SAVE", "Save changes")
|
|
|
|
game:addlocalizedstring("LUA_MENU_SAVE_DESC", "Save changes.")
|
|
|
|
game:addlocalizedstring("LUA_MENU_SETTINGS", "Settings")
|
|
|
|
game:addlocalizedstring("LUA_MENU_EDIT_STATS", "Edit Stats")
|
|
|
|
|
|
|
|
function createdivider(menu, text)
|
2022-05-20 15:11:58 -04:00
|
|
|
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 = Engine.ToUpperCase(Engine.Localize(text))
|
|
|
|
}))
|
|
|
|
|
|
|
|
menu.list:addElement(element)
|
2022-03-09 19:30:03 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
local personalizationbutton = LUI.MPLobbyBase.AddPersonalizationButton
|
|
|
|
LUI.MPLobbyBase.AddPersonalizationButton = function(menu)
|
2022-05-20 15:11:58 -04:00
|
|
|
personalizationbutton(menu)
|
|
|
|
menu:AddButton("@LUA_MENU_STATS", function()
|
|
|
|
LUI.FlowManager.RequestAddMenu(nil, "stats_menu")
|
|
|
|
end)
|
2022-03-09 19:30:03 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
LUI.MenuBuilder.registerType("stats_menu", function(a1)
|
2022-05-20 15:11:58 -04:00
|
|
|
local menu = LUI.MenuTemplate.new(a1, {
|
|
|
|
menu_title = Engine.ToUpperCase(Engine.Localize("@LUA_MENU_STATS")),
|
|
|
|
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", {{
|
|
|
|
text = "@LUA_MENU_ENABLED",
|
|
|
|
value = true
|
|
|
|
}, {
|
|
|
|
text = "@LUA_MENU_DISABLED",
|
|
|
|
value = false
|
|
|
|
}}, nil, nil)
|
|
|
|
|
|
|
|
LUI.Options.CreateOptionButton(menu, "cg_unlockall_loot", "@LUA_MENU_UNLOCKALL_LOOT",
|
|
|
|
"@LUA_MENU_UNLOCKALL_LOOT_DESC", {{
|
|
|
|
text = "@LUA_MENU_ENABLED",
|
|
|
|
value = true
|
|
|
|
}, {
|
|
|
|
text = "@LUA_MENU_DISABLED",
|
|
|
|
value = false
|
|
|
|
}}, nil, nil)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
createdivider(menu, "@LUA_MENU_EDIT_STATS")
|
|
|
|
|
|
|
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
|
|
|
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
|
|
|
|
local rank = Lobby.GetRankForXP(experience, prestige)
|
|
|
|
|
|
|
|
prestigeeditbutton(menu, function(value)
|
|
|
|
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "prestige", tonumber(value))
|
|
|
|
end)
|
|
|
|
|
|
|
|
rankeditbutton(menu, function(value)
|
|
|
|
local rank = tonumber(value)
|
|
|
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
|
|
|
local experience = rank == 0 and 0 or Rank.GetRankMaxXP(tonumber(value) - 1, prestige)
|
|
|
|
|
|
|
|
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "experience", experience)
|
|
|
|
end)
|
|
|
|
|
|
|
|
LUI.Options.InitScrollingList(menu.list, nil)
|
|
|
|
LUI.Options.AddOptionTextInfo(menu)
|
|
|
|
|
|
|
|
menu:AddBackButton()
|
|
|
|
|
|
|
|
return menu
|
2022-03-09 19:30:03 -05:00
|
|
|
end)
|
|
|
|
|
|
|
|
function prestigeeditbutton(menu, callback)
|
2022-05-20 15:11:58 -04:00
|
|
|
local options = {}
|
|
|
|
local max = Lobby.GetMaxPrestigeLevel()
|
|
|
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
2022-03-11 17:35:50 -05:00
|
|
|
|
2022-05-20 15:11:58 -04:00
|
|
|
for i = 0, max do
|
|
|
|
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
2022-03-11 17:35:50 -05:00
|
|
|
|
2022-05-20 15:11:58 -04:00
|
|
|
table.insert(options, {
|
|
|
|
text = "@" .. i,
|
|
|
|
value = i .. ""
|
|
|
|
})
|
|
|
|
end
|
2022-03-11 17:35:50 -05:00
|
|
|
|
2022-05-20 15:11:58 -04:00
|
|
|
Engine.SetDvarFromString("ui_prestige_level", prestige .. "")
|
2022-03-11 17:35:50 -05:00
|
|
|
|
2022-05-20 15:11:58 -04:00
|
|
|
LUI.Options.CreateOptionButton(menu, "ui_prestige_level", "@LUA_MENU_PRESTIGE", "@LUA_MENU_PRESTIGE_DESC", options,
|
|
|
|
nil, nil, callback)
|
2022-03-09 19:30:03 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function rankeditbutton(menu, callback)
|
2022-05-20 15:11:58 -04:00
|
|
|
local options = {}
|
|
|
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
|
|
|
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
|
2022-03-11 17:35:50 -05:00
|
|
|
|
2022-05-20 15:11:58 -04:00
|
|
|
local rank = Lobby.GetRankForXP(experience, prestige)
|
|
|
|
local max = Rank.GetMaxRank(prestige)
|
|
|
|
local maxprestige = Lobby.GetMaxPrestigeLevel()
|
2022-03-11 17:35:50 -05:00
|
|
|
|
2022-05-20 15:11:58 -04:00
|
|
|
for i = 0, max do
|
|
|
|
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
2022-03-11 17:35:50 -05:00
|
|
|
|
2022-05-20 15:11:58 -04:00
|
|
|
table.insert(options, {
|
|
|
|
text = "@" .. (i + 1),
|
|
|
|
value = i .. ""
|
|
|
|
})
|
|
|
|
end
|
2022-03-11 17:35:50 -05:00
|
|
|
|
2022-05-20 15:11:58 -04:00
|
|
|
Engine.SetDvarFromString("ui_rank_level_", rank .. "")
|
2022-03-11 17:35:50 -05:00
|
|
|
|
2022-05-20 15:11:58 -04:00
|
|
|
return LUI.Options.CreateOptionButton(menu, "ui_rank_level_", "@LUA_MENU_RANK", "@LUA_MENU_RANK_DESC", options, nil,
|
|
|
|
nil, callback)
|
2022-03-09 19:30:03 -05:00
|
|
|
end
|
|
|
|
|
2022-05-20 15:11:58 -04:00
|
|
|
local isclasslocked = Cac.IsCustomClassLocked
|
|
|
|
Cac.IsCustomClassLocked = function(...)
|
|
|
|
if (Engine.GetDvarBool("cg_unlockall_classes")) then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
return isclasslocked(...)
|
|
|
|
end
|