h1-mod/data/cdata/ui_scripts/patches/sp_unlockall.lua
Vlad d71e656341
Add 'Unlock All' button in SP (#358)
* Add 'Unlock All' button in SP

* Add 'Unlock All' button in SP
* Hide useless 'Leaderboard' button

* cleanup and format

* fix errors i think

* Revert "fix errors i think"

This reverts commit bbd0287d6fa7a3fd8b4f487b1331250f39522b28.

* Revert "cleanup and format"

This reverts commit a0aeced689e10d0855510784d5cc1ba0aa7362ad.

Co-authored-by: fed <58637860+fedddddd@users.noreply.github.com>
Co-authored-by: m <mjkzyalt@gmail.com>
2022-11-20 15:11:10 -06:00

54 lines
2.5 KiB
Lua

if Engine.InFrontend() then
local levelselectmenu = LUI.sp_menus.LevelSelectMenu
levelselectmenu.SetupInfoBoxRightForArcadeMode = function(f44_arg0, f44_arg1)
return false
end
LUI.LevelSelect.AddLevelListButtons = function(f50_arg0, f50_arg1)
for f50_local0 = 1, #f50_arg1, 1 do
if not Engine.GetDvarBool("arcademode") or not f50_arg1[f50_local0].narativeLevel then
f50_arg0:AddLevelListEntry(f50_local0, f50_arg1[f50_local0])
end
end
if not Engine.GetDvarBool("arcademode") then
if Engine.GetDvarBool("profileMenuOption_hasUnlockedAll_SP") then
f50_arg0:AddHelp({
name = "add_button_helper_text",
button_ref = "button_alt2",
helper_text = Engine.Localize("@LUA_MENU_CANCEL_UNLOCK_CAPS"),
side = "right",
clickable = true
}, levelselectmenu.SetUnlockAll)
else
f50_arg0:AddHelp({
name = "add_button_helper_text",
button_ref = "button_alt2",
helper_text = Engine.Localize("@LUA_MENU_CAMPAIGN_UNLOCKED_ALL_TITLE"),
side = "right",
clickable = true
}, levelselectmenu.UnlockAllPopup)
end
end
end
levelselectmenu.UnlockAllPopup = function(f56_arg0, f56_arg1)
LUI.FlowManager.RequestAddMenu(nil, "request_yesno_popup_generic", true, f56_arg1.controller, nil, {
popup_title = Engine.Localize("@LUA_MENU_CAMPAIGN_UNLOCKED_ALL_TITLE"),
yes_action = levelselectmenu.SetUnlockAll,
message_text = Engine.Localize("@MENU_COMPLETED_CHEAT") .. ". " ..
Engine.Localize("@LUA_MENU_CAMPAIGN_UNLOCKED_ALL_DESC")
})
end
levelselectmenu.SetUnlockAll = function(f57_arg0, f57_arg1)
Engine.SetDvarBool("profileMenuOption_hasUnlockedAll_SP",
not Engine.GetDvarBool("profileMenuOption_hasUnlockedAll_SP"))
Engine.SetDvarBool("mis_cheat", not Engine.GetDvarBool("mis_cheat"))
Engine.ExecNow("profile_menuDvarsFinish")
Engine.Exec("updategamerprofile")
local f57_local0 = LUI.FlowManager.GetTopOpenAndVisibleMenuName()
LUI.FlowManager.RequestAddMenu(nil, f57_local0, true, f57_arg1.controller, true,
LUI.LevelSelect.FindActData(f57_local0), {
reload = true
})
end
end