iw6-lui/lui/mp_menus/mpmainmenu.dec.lua
2024-09-12 17:25:45 +02:00

703 lines
20 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
function mpMainMenuPushFunc()
Engine.StopMusic( 200 )
if Engine.IsAliensMode() then
Engine.PlayMusic( CoD.Music.MainExtinctMusic )
elseif SvS.IsSvS() then
Engine.PlayMusic( CoD.Music.MainSquadMusic )
else
Engine.PlayMusic( CoD.Music.MainMPMusic )
end
if Engine.SplitscreenPlayerCount() > 0 then
local f1_local0 = Engine.GetFirstActiveController()
if f1_local0 and Engine.IsUserSignedIn( f1_local0 ) then
Engine.PLMRefreshData()
end
end
end
function mpMainMenuCheckRequiredDLC( f2_arg0, f2_arg1 )
if Engine.IsXbox360() then
LUI.mp_menus.MPPopups.UpdateRequiredDLCNotification( f2_arg0, f2_arg1 )
end
end
function mpMainMenuCreateHandler( f3_arg0, f3_arg1 )
Engine.SetDvarString( "ui_version_show", "0" )
Engine.SetDvarBool( "ui_onlineRequired", false )
f3_arg0:processEvent( {
name = "add_button_helper_text",
button_ref = "button_secondary",
helper_text = Engine.Localize( "@MENU_MAIN_MENU" ),
side = "left",
clickable = true
} )
mpMainMenuCheckRequiredDLC( f3_arg0, f3_arg1 )
end
function resolveXboxLiveButtonAction( f4_arg0 )
Engine.ExecNow( "forcenosplitscreencontrol main_XBOXLIVE_1", f4_arg0 )
local f4_local0, f4_local1 = Engine.UserCanPlayOnline( f4_arg0 )
if not f4_local0 and f4_local1 == CoD.PlayOnlineFailure.OPFR_XBOXLIVE_MPNOTALLOWED and Engine.IsXB3() then
f4_local0 = Engine.ShowXB3GoldUpsell( f4_arg0 )
end
if not f4_local0 then
Engine.ExecWithResolve( "xrequirelivesignin", resolveXboxLiveButtonAction, f4_arg0 )
Engine.Exec( "forcenosplitscreencontrol main_XBOXLIVE_2", f4_arg0 )
else
if Engine.IsXbox360() and Engine.AnyContentDamaged and Engine.AnyContentDamaged() then
LUI.FlowManager.RequestPopupMenu( self, "mp_damaged_content_popup", false, f4_arg0 )
return
elseif SvS.IsSvS() then
Engine.Exec( "profile_SetHasEverPlayed_SP", f4_arg0 )
end
Engine.ExecNow( "resetSplitscreenSignIn", f4_arg0 )
Engine.ExecNow( "forcenosplitscreencontrol main_XBOXLIVE_3", f4_arg0 )
Engine.SetDvarBool( "systemlink", false )
Engine.SetDvarBool( "splitscreen", false )
Engine.SetDvarBool( "onlinegame", true )
Engine.SetDvarBool( "xblive_privatematch", false )
Engine.SetDvarBool( "ui_opensummary", false )
Engine.SetDvarBool( "squad_match", false )
if Engine.GetDvarBool( "xblive_competitionmatch" ) then
Engine.SetDvarBool( "xblive_competitionmatch", false )
Engine.Exec( "set remove_mlg_rules 1" )
end
Engine.ExecNow( MPConfig.default_xboxlive, f4_arg0 )
if not SvS.IsSvS() then
Engine.ExecNow( "xstartprivateparty", f4_arg0 )
end
Engine.Exec( "startentitlements", f4_arg0 )
Engine.CacheUserDataForController( f4_arg0 )
if SvS.IsSvS() then
LUI.FlowManager.RequestAddMenu( nil, "squads_mode_select_menu", false, f4_arg0, false )
else
LUI.FlowManager.RequestAddMenu( nil, "menu_xboxlive", false, f4_arg0, false )
end
end
end
function xboxLiveButtonAction( f5_arg0, f5_arg1 )
resolveXboxLiveButtonAction( f5_arg1.controller )
end
function splitScreenButtonAction( f6_arg0, f6_arg1 )
if Engine.IsXbox360() and Engine.AnyContentDamaged and Engine.AnyContentDamaged() then
LUI.FlowManager.RequestPopupMenu( f6_arg0, "mp_damaged_content_popup", false, controller )
return
elseif SvS.IsSvS() then
Engine.Exec( "profile_SetHasEverPlayed_SP", f6_arg1.controller )
end
Engine.Exec( "resetSplitscreenSignIn" )
Engine.Exec( "forcesplitscreencontrol main_SPLITSCREEN" )
Engine.SetDvarBool( "systemlink", false )
Engine.SetDvarBool( "splitscreen", true )
Engine.SetDvarBool( "onlinegame", false )
Engine.SetDvarBool( "xblive_privatematch", false )
Engine.SetDvarBool( "ui_opensummary", false )
Engine.Exec( MPConfig.default_splitscreen )
Engine.CacheUserDataForController( f6_arg1.controller )
if Engine.GetDvarBool( "lui_splitscreensignin_menu" ) then
LUI.FlowManager.RequestAddMenu( f6_arg0, "menu_splitscreensignin", false, f6_arg1.controller, false )
else
assert( not Engine.IsAliensMode(), "Splitscreen sign in UI not supported by .menu." )
LUI.FlowManager.RequestOldMenu( f6_arg0, "menu_splitscreensignin", false )
end
end
function systemLinkButtonResolveAction( f7_arg0 )
Engine.SetDvarBool( "systemlink", true )
Engine.SetDvarBool( "splitscreen", false )
Engine.SetDvarBool( "onlinegame", false )
Engine.SetDvarBool( "xblive_privatematch", false )
Engine.SetDvarBool( "ui_opensummary", false )
Engine.Exec( MPConfig.default_systemlink, f7_arg0 )
Engine.CacheUserDataForController( f7_arg0 )
if Engine.IsUserSignedIn( f7_arg0 ) == true and Engine.IsUserAGuest( f7_arg0 ) == false then
if Engine.IsPS3() then
if Engine.OfflineProfileIsSelected( Engine.GetFirstActiveController() ) then
Engine.Exec( "forcenosplitscreencontrol main_SYSTEMLINK_3", f7_arg0 )
LUI.FlowManager.RequestAddMenu( nil, "menu_systemlink", false, f7_arg0, false )
else
LUI.FlowManager.RequestPopupMenu( nil, "menu_ps3_profile", true, f7_arg0, false )
end
else
if Engine.IsXbox360() and Engine.AnyContentDamaged and Engine.AnyContentDamaged() then
LUI.FlowManager.RequestPopupMenu( self, "mp_damaged_content_popup", false, f7_arg0 )
return
end
Engine.Exec( "forcenosplitscreencontrol main_SYSTEMLINK_3", f7_arg0 )
LUI.FlowManager.RequestAddMenu( nil, "menu_systemlink", false, f7_arg0, false )
end
end
end
function systemLinkButtonAction( f8_arg0, f8_arg1 )
Engine.ExecNow( "forcenosplitscreencontrol main_SYSTEMLINK_1", f8_arg1.controller )
if not Engine.IsUserSignedIn( f8_arg1.controller ) or Engine.IsUserAGuest( f8_arg1.controller ) then
Engine.ExecWithResolve( "xrequiresignin", systemLinkButtonResolveAction, f8_arg1.controller )
Engine.Exec( "forcesplitscreencontrol main_SYSTEMLINK_2", f8_arg1.controller )
else
systemLinkButtonResolveAction( f8_arg1.controller )
end
end
function eliteButtonAction( f9_arg0, f9_arg1 )
if not Engine.IsEliteAppAvailable( f9_arg1.controller ) then
Engine.ExecNow( "incnosplitscreencontrol main_ELITE_1", f9_arg1.controller )
if not Engine.IsUserSignedInForCommerce( f9_arg1.controller ) then
Engine.Exec( "xrequirelivesigninforcommerce", f9_arg1.controller )
Engine.Exec( "decnosplitscreencontrol main_ELITE_2" )
else
Engine.ExecNow( "decnosplitscreencontrol main_ELITE_3" )
LUI.FlowManager.RequestPopupMenu( f9_arg0, "popup_elite_sell", false, f9_arg1.controller )
end
end
end
function resolveStoreButtonAction( f10_arg0 )
if not Engine.UserCanAccessStore( f10_arg0 ) then
Engine.ExecNow( "forcenosplitscreencontrol main_XBOXLIVE_STORE_1", f10_arg0 )
Engine.ExecWithResolve( "xrequirelivesigninforstore", resolveStoreButtonAction, f10_arg0 )
Engine.Exec( "forcesplitscreencontrol main_XBOXLIVE_STORE_2", f10_arg0 )
else
Engine.SetDvarBool( "ui_onlineRequired", true )
if not Sns.OpenStoreMenu( f10_arg0 ) then
Engine.SetDvarBool( "ui_onlineRequired", false )
end
end
end
function storeButtonAction( f11_arg0, f11_arg1 )
Engine.SetDvarBool( "systemlink", false )
resolveStoreButtonAction( f11_arg1.controller )
end
function optionsButtonAction( f12_arg0, f12_arg1 )
if Engine.IsConsoleGame() then
Engine.ExecNow( "forcenosplitscreencontrol main_options_menu", f12_arg1.controller )
LUI.FlowManager.RequestAddMenu( f12_arg0, "controls", true, f12_arg1.controller, false )
else
LUI.FlowManager.RequestAddMenu( f12_arg0, "pc_controls", true, f12_arg1.controller, false )
end
end
function mainMenuButtonAction( f13_arg0, f13_arg1 )
Engine.StartSingleplayer()
end
function updateDescText( f14_arg0, f14_arg1 )
f14_arg0:setText( Engine.Localize( f14_arg1.string ) )
end
function MainMenuChildFeeder( f15_arg0 )
local f15_local0 = SvS.IsSvS()
local f15_local1 = nil
if Engine.IsAliensMode() then
f15_local1 = Engine.Localize( "@LUA_MENU_ALIENS" )
elseif f15_local0 then
f15_local1 = Engine.Localize( "@LUA_MENU_SQUAD_TITLE_CAPS" )
else
f15_local1 = Engine.Localize( "@LUA_MENU_MULTIPLAYER_CAPS" )
end
local f15_local2 = {
[#f15_local2 + 1] = {
type = "generic_menu_title",
id = "mp_main_title_text_id",
properties = {
menu_title = f15_local1
}
},
[#f15_local2 + 1] = {
type = "main_mp_menu_options"
},
[#f15_local2 + 1] = {
type = "button_helper_text_main",
id = "mp_main_button_helper_text_id"
},
[#f15_local2 + 1] = {
type = "UICharacterWindow",
id = "characterwindow",
states = {
default = {
topAnchor = false,
bottomAnchor = true,
leftAnchor = false,
rightAnchor = true,
right = -150,
bottom = -150,
height = 256,
width = 154
}
},
children = {
{
type = "UITimer",
id = "createSceneTimer",
properties = {
event = "make_scene",
interval = 200
}
}
}
},
[#f15_local2 + 1] = {
type = "generic_back_button",
handlers = {
button_secondary = MBh.PopupMenu( "main_choose_exe_popup_menu", false, false )
}
}
}
if Engine.IsXbox360() then
f15_local2[#f15_local2 + 1] = {
type = "UITimer",
id = "checkRequiredDLCTimer",
properties = {
event = "check_required_dlc",
interval = 1000
}
}
end
return f15_local2
end
function mp_main_menu()
return {
type = "UIElement",
id = "mp_main_menu_id",
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0
}
},
handlers = {
menu_create = mpMainMenuCreateHandler,
check_required_dlc = mpMainMenuCheckRequiredDLC
},
childrenFeeder = MainMenuChildFeeder
}
end
function main_menu_options_feeder( f17_arg0 )
local f17_local0 = Engine.IsAliensMode()
local f17_local1 = SvS.IsSvS()
local f17_local2 = false
if Engine.GetDvarInt( "allow_online_squads" ) == 1 or not Engine.IsConsoleGame() then
f17_local2 = true
end
local f17_local3 = Engine.DoWeNeedCompatibilityPacks()
if f17_local1 then
local f17_local4 = f17_local2
end
local f17_local5 = f17_local4 or not f17_local1
local f17_local6 = {}
if Engine.AllowOnline() and f17_local5 then
local f17_local7, f17_local8 = nil
if f17_local1 then
f17_local8 = Engine.Localize( "@PLATFORM_PLAY_ONLINE_SQUADS_CAPS" )
f17_local7 = Engine.Localize( "@LUA_MENU_SQUADS_INTRO" )
elseif f17_local0 then
f17_local8 = Engine.Localize( "@PLATFORM_PLAY_ONLINE_CAPS" )
f17_local7 = Engine.Localize( "@LUA_MENU_PLAY_EXTINCTION_ONLINE_DESC" )
else
f17_local8 = Engine.Localize( "@PLATFORM_PLAY_ONLINE_CAPS" )
f17_local7 = Engine.Localize( "@PLATFORM_PLAY_ONLINE_DESC" )
end
f17_local6[#f17_local6 + 1] = {
type = "UIGenericButton",
id = "btn_MPMain_0",
disabled = f17_local3,
disabledFunc = Engine.DoWeNeedCompatibilityPacks,
properties = {
button_text = f17_local8,
button_action_func = xboxLiveButtonAction,
desc_text = f17_local7,
button_over_func = function ( f18_arg0, f18_arg1 )
PersistentBackground.SetToDefault()
end
}
}
end
if Engine.IsConsoleGame() then
local f17_local7 = "@LUA_MENU_SPLITSCREEN_CAPS"
if f17_local0 then
f17_local7 = "@LUA_MENU_LOCAL_CAPS"
elseif f17_local1 then
f17_local7 = "@LUA_MENU_LOCAL_CAPS"
end
local f17_local8 = #f17_local6 + 1
local f17_local9 = {
type = "UIGenericButton",
id = "btn_MPMain_1",
disabled = f17_local3,
disabledFunc = Engine.DoWeNeedCompatibilityPacks
}
local f17_local10 = {
button_text = Engine.Localize( f17_local7 ),
button_action_func = splitScreenButtonAction
}
local f17_local11
if f17_local1 then
f17_local11 = Engine.Localize( "@LUA_MENU_SQUAD_LOCAL_PLAY_DESC" )
if not f17_local11 then
else
f17_local10.desc_text = f17_local11
f17_local10.button_over_func = function ( f19_arg0, f19_arg1 )
PersistentBackground.SetToDefault()
end
f17_local9.properties = f17_local10
f17_local6[f17_local8] = f17_local9
if not f17_local1 then
f17_local6[#f17_local6 + 1] = {
type = "UIGenericButton",
id = "btn_MPMain_2",
disabled = f17_local3,
disabledFunc = Engine.DoWeNeedCompatibilityPacks,
properties = {
button_text = Engine.Localize( "@PLATFORM_SYSTEM_LINK_CAPS" ),
button_action_func = systemLinkButtonAction,
desc_text = Engine.Localize( "@PLATFORM_SYSTEM_LINK_DESC" ),
button_over_func = function ( f20_arg0, f20_arg1 )
PersistentBackground.SetToDefault()
end
}
}
end
end
end
f17_local11 = Engine.Localize( "@LUA_MENU_SPLITSCREEN_DESC" )
end
if not f17_local1 then
f17_local6[#f17_local6 + 1] = {
type = "UIGenericButton",
id = "btn_MPMain_5",
properties = {
button_text = Engine.Localize( "@LUA_MENU_STORE_CAPS" ),
button_action_func = storeButtonAction,
desc_text = Engine.Localize( "@LUA_MENU_STORE_DESC" ),
button_over_func = function ( f21_arg0, f21_arg1 )
PersistentBackground.SetToDefault()
end
}
}
end
f17_local6[#f17_local6 + 1] = {
type = "UIGenericButton",
id = "btn_MPMain_6",
properties = {
button_text = Engine.Localize( "@LUA_MENU_OPTIONS_CAPS" ),
button_action_func = optionsButtonAction,
desc_text = Engine.Localize( "@LUA_MENU_OPTIONS_DESC" ),
button_over_func = function ( f22_arg0, f22_arg1 )
PersistentBackground.SetToDefault()
end
}
}
f17_local6[#f17_local6 + 1] = {
type = "generic_separator",
id = "main_menu_spacer_id"
}
if not Engine.IsCoreMode() then
f17_local6[#f17_local6 + 1] = {
type = "UIGenericButton",
id = "btn_MPMain_7",
properties = {
text = Engine.Localize( "@LUA_MENU_MULTIPLAYER_CAPS" ),
button_action_func = function ( f23_arg0, f23_arg1 )
Engine.StopMusic( 200 )
Engine.SwitchToCoreMode()
Engine.PlayMusic( CoD.Music.MainMPMusic )
Engine.SetActiveMenu( ActiveMenus.None )
Engine.SetActiveMenu( ActiveMenus.Main )
end,
button_over_func = function ( f24_arg0, f24_arg1 )
PersistentBackground.Set( PersistentBackground.Variants.MPBackground )
end,
desc_text = Engine.Localize( "@PLATFORM_PLAY_ONLINE_DESC" )
}
}
end
if not SvS.IsSvS() then
f17_local6[#f17_local6 + 1] = {
type = "UIGenericButton",
id = "btn_MPMain_8",
properties = {
button_text = Engine.Localize( "@LUA_MENU_SQUAD_MODE_CAP" ),
button_action_func = function ( f25_arg0, f25_arg1 )
Engine.StopMusic( 200 )
Engine.SwitchToSquadVsSquadMode()
Engine.PlayMusic( CoD.Music.MainSquadMusic )
Engine.SetActiveMenu( ActiveMenus.None )
Engine.SetActiveMenu( ActiveMenus.Main )
end,
button_over_func = function ( f26_arg0, f26_arg1 )
PersistentBackground.Set( PersistentBackground.Variants.SvSBackground )
end,
desc_text = Engine.Localize( "@LUA_MENU_SVS_MAIN_MENU_DESC" )
}
}
end
if not Engine.IsAliensMode() and Engine.UnlockedAliens() then
f17_local6[#f17_local6 + 1] = {
type = "UIGenericButton",
id = "btn_MPMain_9",
properties = {
button_text = Engine.Localize( "@LUA_MENU_ALIENS_CAPS" ),
button_action_func = function ( f27_arg0, f27_arg1 )
Engine.StopMusic( 200 )
Engine.SwitchToAliensMode()
Engine.PlayMusic( CoD.Music.MainExtinctMusic )
Engine.SetActiveMenu( ActiveMenus.None )
Engine.SetActiveMenu( ActiveMenus.Main )
end,
button_over_func = function ( f28_arg0, f28_arg1 )
PersistentBackground.Set( PersistentBackground.Variants.AliensBackground )
end,
desc_text = Engine.Localize( "@LUA_MENU_ALIENS_MAIN_MENU_DESC" ),
additional_handlers = {
menu_create = AddExtinctionGlowBackground
}
}
}
end
f17_local6[#f17_local6 + 1] = {
type = "button_desc_text",
id = "mp_menu_button_description_id",
properties = {
lines = SvS.IsSvS() and 8 or nil
}
}
return f17_local6
end
f0_local0 = function ()
return {
type = "UIVerticalList",
id = "mp_main_menu_id",
childrenFeeder = main_menu_options_feeder,
states = {
default = {
topAnchor = true,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = false,
top = GenericMenuDims.menu_top,
bottom = GenericMenuDims.menu_bottom,
left = GenericMenuDims.menu_left,
right = GenericMenuDims.menu_right,
alignment = LUI.Alignment.Top
}
},
handlers = {
dlc_mount_complete = function ( f30_arg0, f30_arg1 )
f30_arg0:processEvent( {
name = "menu_refresh"
} )
end
,
dlc_mount_fail = function ( f31_arg0, f31_arg1 )
f31_arg0:processEvent( {
name = "menu_refresh"
} )
end
,
dlc_download_fail = function ( f32_arg0, f32_arg1 )
f32_arg0:processEvent( {
name = "menu_refresh"
} )
end
}
}
end
function SquadsDescTextFeeder( f33_arg0 )
local f33_local0 = {
[#f33_local0 + 1] = {
type = "UIText",
id = "squads_desc_text_main",
properties = {
text = Engine.Localize( "LUA_MENU_SQUADS_INTRO" )
},
states = {
default = {
topAnchor = true,
bottomAnchor = false,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = CoD.TextSettings.NormalFont.Height,
left = 0,
right = 0,
font = CoD.TextSettings.NormalFont.Font,
alignment = LUI.Alignment.Left
}
}
}
}
return f33_local0
end
function AddExtinctionGlowBackground( f34_arg0, f34_arg1 )
local f34_local0 = f34_arg0:getFirstDescendentById( "hlist" )
local f34_local1 = f34_local0:getChildById( "bgRightCap" )
if f34_local1 then
if Engine.IsConsoleGame() or Engine.IsGamepadEnabled() == 1 then
f34_local1:registerAnimationState( "focus", {
material = RegisterMaterial( "btn_alien_00a_rtcap_f" )
} )
else
f34_local1:registerAnimationState( "focus", {
material = RegisterMaterial( "btn_alien_00a_rtcap_f_pc" )
} )
end
local self = LUI.UIImage.new( {
material = RegisterMaterial( "btn_alien_overlay" ),
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = -44,
bottom = 16,
left = -208,
right = -48,
alpha = 0
} )
self.id = "blood_splat_glow"
self:registerAnimationState( "glow", {
alpha = 0.12
} )
self:registerAnimationState( "heavyglow", {
alpha = 0.5
} )
self:registerEventHandler( "button_over", MBh.AnimateLoop( {
{
"default",
0
},
{
"heavyglow",
1200
},
{
"default",
1200
}
} ) )
self:registerEventHandler( "button_up", MBh.AnimateLoop( {
{
"default",
0
},
{
"glow",
1200
},
{
"default",
1200
}
} ) )
local f34_local3 = MBh.AnimateLoop( {
{
"default",
1200
},
{
"glow",
1200
}
} )
f34_local3( self )
f34_local1:addElement( self )
f34_local3 = LUI.UIImage.new( {
material = RegisterMaterial( "btn_alien_overlay_02" ),
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = -28,
bottom = 32,
left = -208,
right = -48,
alpha = 0
} )
f34_local3.id = "blood_splat_glow_02"
f34_local3:registerAnimationState( "glow", {
alpha = 0.12
} )
f34_local3:registerAnimationState( "heavyglow", {
alpha = 0.5
} )
f34_local3:registerEventHandler( "button_over", MBh.AnimateLoop( {
{
"default",
0
},
{
"heavyglow",
1800
},
{
"default",
1800
}
} ) )
f34_local3:registerEventHandler( "button_up", MBh.AnimateLoop( {
{
"default",
0
},
{
"glow",
1800
},
{
"default",
1800
}
} ) )
local f34_local4 = MBh.AnimateLoop( {
{
"default",
1800
},
{
"glow",
1800
}
} )
f34_local4( f34_local3 )
f34_local1:addElement( f34_local3 )
end
local self = f34_local0:getChildById( "bgLeftCap" )
if self then
self:registerAnimationState( "focus", {
material = RegisterMaterial( "btn_alien_00a_ltcap_f" )
} )
end
local f34_local3 = f34_local0:getChildById( "bgMid" )
if f34_local3 then
f34_local3:registerAnimationState( "focus", {
material = RegisterMaterial( "btn_alien_00a_mid_f" )
} )
end
end
LUI.MenuBuilder.registerDef( "mp_main_menu", mp_main_menu )
LUI.MenuBuilder.registerDef( "main_mp_menu_options", f0_local0 )
LUI.FlowManager.RegisterStackPushBehaviour( "mp_main_menu", mpMainMenuPushFunc )
LockTable( _M )