local f0_local0 = module local f0_local1, f0_local2 = ... f0_local0( f0_local1, package.seeall ) CoD.PrintModuleLoad( _NAME ) function GameModeChooseAction( f1_arg0, f1_arg1 ) local f1_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f1_arg0 ) if f1_local0.squadBaseSelect then Engine.SetPlayerDataEx( f1_local0.exclusiveControllerIndex, CoD.StatsGroup.Ranked, "squadHQ", "squad_mode", f1_arg0.properties.gameType ) else local f1_local1 = MatchRules.GetData( "gametype" ) if f1_local1 then FixTeamLimitsAndDifficultiesIfNecessary( f1_local1, f1_arg0.properties.gameType ) end MatchRules.SetData( "gametype", f1_arg0.properties.gameType ) if MLG.AreMLGRulesEnabled() then MLG.LoadMatchRulesData() else MatchRules.LoadMatchRulesDataDefault() end if Engine.GetDvarBool( "splitscreen" ) == 1 then Engine.ExecNow( MPConfig.default_splitscreen, f1_arg1.controller ) end if Engine.GetDvarBool( "systemlink" ) == 1 then Engine.ExecNow( MPConfig.default_systemlink, f1_arg1.controller ) end if Engine.GetDvarBool( "xblive_privatematch" ) == 1 then Engine.ExecNow( MPConfig.default_xboxlive, f1_arg1.controller ) end if Engine.GetDvarBool( "xblive_privatematch" ) == true and not Engine.IsAliensMode() then local f1_local2 = Engine.GetDvarInt( "party_maxPrivatePartyPlayers" ) if f1_arg0.properties.gameType == "horde" then f1_local2 = CoD.MaxSafeguardPlayers end if f1_local2 ~= Engine.GetDvarInt( "party_maxplayers" ) then Engine.SetDvarInt( "party_maxplayers", f1_local2 ) Engine.Exec( "xtogprivateslots; xtogprivateslots; xsessionupdate;" ) end end end GameModeSelectMenuClose( f1_arg0, f1_arg1 ) if f1_local0.squadBaseSelect then LUI.FlowManager.RequestLeaveMenu( f1_arg0 ) else LUI.FlowManager.RequestRestoreMenu( f1_arg0, "gamesetup_menu_main", true, f1_arg1.controller, true ) end if SvS.IsSvS() then MatchRules.SetData( "commonOption", "allowCustomClasses", false ) end end function ShouldHordeBeDisabled() if Engine.GetDvarBool( "xblive_privatematch" ) == true then local f2_local0 = Lobby.GetMemberCount( Lobby.MemberListStates.Lobby ) assert( f2_local0 > 0 ) return f2_local0 > CoD.MaxSafeguardPlayers else end end function UpdateHordeButtonDisabled( f3_arg0, f3_arg1 ) local f3_local0 = ShouldHordeBeDisabled() if f3_local0 ~= f3_arg0.disabled then local f3_local1 = f3_arg0 local f3_local2 = f3_arg0.processEvent local f3_local3 = {} local f3_local4 if f3_local0 then f3_local4 = "disable" if not f3_local4 then else f3_local3.name = f3_local4 f3_local2( f3_local1, f3_local3 ) end end f3_local4 = "enable" end end function HordeButtonFeeder( f4_arg0 ) local f4_local0 = { [#f4_local0 + 1] = { type = "UITimer", id = "horde_button_refresh_timer", properties = { event = "mode_button_disabled", interval = 100, disposable = false, broadcastToRoot = false } } } return f4_local0 end function EmitGameModeSelectionUpdate( f5_arg0, f5_arg1 ) f5_arg0:dispatchEventToRoot( { name = "gamemode_selection_update", gameType = f5_arg0.properties.gameType, dispatchChildren = true, immediate = true, disabled = f5_arg0.disabled } ) end function GameModeSelectFeeder( f6_arg0 ) local f6_local0 = Cac.GetGameModeList( f6_arg0.requestedGameMode ) local f6_local1 = LUI.FlowManager.GetMenuScopedDataByMenuName( "settings_recipe_choosetype" ) local f6_local2 = {} for f6_local11, f6_local12 in ipairs( f6_local0 ) do local f6_local6 = false local f6_local7 = true local f6_local8, f6_local9, f6_local10 = nil if f6_local1.squadBaseSelect then f6_local6 = f6_local12 == Engine.GetPlayerDataEx( f6_local1.exclusiveControllerIndex, CoD.StatsGroup.Ranked, "squadHQ", "squad_mode" ) f6_local7 = Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f6_local12, GameTypesTable.Cols.Squads ) == "1" else if f6_local1.teamsOnly then f6_local7 = Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f6_local12, GameTypesTable.Cols.TeamChoice ) == "1" end if f6_local12 == Engine.GetDvarString( "ui_gametype" ) then f6_local6 = true end if f6_local12 == "horde" and Engine.GetDvarBool( "xblive_privatematch" ) == true then f6_local8 = HordeButtonFeeder f6_local9 = UpdateHordeButtonDisabled f6_local10 = ShouldHordeBeDisabled end end if f6_local7 then f6_local2[#f6_local2 + 1] = { type = "UIGenericButton", id = "gameMode_" .. f6_local12, listDefaultFocus = f6_local6, disabled = f6_local10 and f6_local10(), properties = { button_text = Engine.Localize( Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f6_local12, GameTypesTable.Cols.Name ) .. "_CAPS" ), gameType = f6_local12, button_over_func = EmitGameModeSelectionUpdate, button_over_disable_func = EmitGameModeSelectionUpdate, additional_handlers = { button_action = GameModeChooseAction } }, handlers = { mode_button_disabled = f6_local9 }, childrenFeeder = f6_local8 } end end return f6_local2 end function GameModeSelectMenuCreate( f7_arg0, f7_arg1 ) f7_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addBackButton ) end function GameModeSelectMenuClose( f8_arg0, f8_arg1 ) local f8_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f8_arg0 ) if not f8_local0.squadBaseSelect then Engine.ExecNow( "xupdatepartystate" ) end end function UpdateGamemodeIcon( f9_arg0, f9_arg1 ) f9_arg0:setImage( RegisterMaterial( Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f9_arg1.gameType, GameTypesTable.Cols.Image ) or "" ) ) end function UpdateGamemodeTitle( f10_arg0, f10_arg1 ) f10_arg0:setText( Engine.Localize( Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f10_arg1.gameType, GameTypesTable.Cols.Name ) or "" ) ) end function UpdateGamemodeDesc( f11_arg0, f11_arg1 ) f11_arg0:setText( Engine.Localize( Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f11_arg1.gameType, GameTypesTable.Cols.Desc ) or "" ) ) end function UpdateDisabledDesc( f12_arg0, f12_arg1 ) if f12_arg1.disabled then f12_arg0:animateToState( "default" ) else f12_arg0:animateToState( "hidden" ) end end function gamemode_desc_pane() return { type = "UIElement", id = "gamemode_desc_pane_id", states = { default = { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = 0, right = 0 } }, children = { { type = "generic_menu_titlebar", id = "gamemode_header_id", properties = { title_bar_text_indent = GenericTitleBarDims.TitleBarLCapWidth, title_bar_alignment = LUI.Alignment.Left, title_bar_text = Engine.Localize( "@LUA_MENU_MODE_DETAILS_CAPS" ), font = CoD.TextSettings.BoldFont } }, { type = "generic_menu_background_withfade", id = "gamemode_bg_fade_id", children = { { type = "UIImage", id = "gamemode_image_id", states = { default = { topAnchor = true, bottomAnchor = false, leftAnchor = false, rightAnchor = false, top = 16, bottom = 272, left = -128, right = 128, material = RegisterMaterial( "icon_playlist_generic" ) } }, handlers = { gamemode_selection_update = UpdateGamemodeIcon } }, { type = "UIText", id = "gamemode_name_id", properties = { text = "" }, states = { default = { left = -144, top = 32, width = 240, height = CoD.TextSettings.BoldFont.Height, font = CoD.TextSettings.BoldFont.Font, alignment = LUI.Alignment.Left } }, handlers = { gamemode_selection_update = UpdateGamemodeTitle } }, { type = "UIText", id = "gamemode_desc_id", properties = { text = "" }, states = { default = { left = -144, top = 52, width = 296, height = CoD.TextSettings.NormalFont.Height, font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b } }, handlers = { gamemode_selection_update = UpdateGamemodeDesc } }, { type = "UIImage", id = "gamemode_disabled_icon_id", states = { default = { material = RegisterMaterial( "icon_new" ), topAnchor = false, bottomAnchor = true, leftAnchor = true, rightAnchor = false, left = 10, top = -82, right = 42, bottom = -50, alpha = 1 }, hidden = { alpha = 0 } }, handlers = { gamemode_selection_update = UpdateDisabledDesc } }, { type = "UIText", id = "gamemode_disabled_desc_id", properties = { text = Engine.Localize( "LUA_MENU_DESC_TOO_MANY_PLAYERS_HORDE" ) }, states = { default = { topAnchor = false, bottomAnchor = true, leftAnchor = true, rightAnchor = true, left = 48, top = -65 - CoD.TextSettings.NormalFont.Height, right = -10, bottom = -65, font = CoD.TextSettings.NormalFont.Font, alignment = LUI.Alignment.Left, red = Colors.primary_text_color.r, green = Colors.primary_text_color.g, blue = Colors.primary_text_color.b, alpha = 1 }, hidden = { alpha = 0 } }, handlers = { gamemode_selection_update = UpdateDisabledDesc } } } } } } end function settings_recipe_choosetype() return { type = "UIElement", id = "settings_recipe_choosetype_root", states = { default = { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = 0, right = 0 } }, properties = { requestedGameMode = "Standard", menu_title = Cac.GetGameModeTypeString( "Standard" ) }, handlers = { menu_close = GameModeSelectMenuClose, menu_create = GameModeSelectMenuCreate }, children = { { type = "generic_menu_title", id = "settings_recipe_choosetype_title_text_id", properties = { menu_title = MBh.Property( "menu_title" ) } }, { type = "UIStencil", states = { default = { alignment = LUI.Alignment.Top, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = GenericMenuDims.menu_left, right = GenericMenuDims.menu_right, top = GenericMenuDims.menu_top, bottom = GenericMenuDims.menu_bottom } }, children = { { type = "settings_recipe_choosetype_options_vlist", id = "settings_recipe_choosetype_options_vlist_id", childrenFeeder = GameModeSelectFeeder, properties = { requestedGameMode = MBh.Property( "requestedGameMode" ) } } } }, { type = "gamemode_desc_pane", states = { default = { leftAnchor = false, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = -64, right = 288, top = GenericMenuDims.menu_top, bottom = GenericMenuDims.menu_bottom } } }, { type = "generic_back_button" }, { type = "button_helper_text_main", id = "button_helper_text_id" }, { type = "online_friends_widget", id = "online_friends_widget_id" } } } end function settings_recipe_choosetype_options_vlist() return { type = "UIVerticalList", states = { default = { alignment = LUI.Alignment.Top, leftAnchor = true, rightAnchor = true, topAnchor = true, bottomAnchor = true, left = 0, right = -45, top = 0, bottom = 0 } } } end function SquadsTypeChildrenFeeder( f16_arg0 ) local f16_local0 = { [#f16_local0 + 1] = { type = "UIGenericButton", id = "settings_squads_type_safeguard_button", properties = { button_text = Engine.Localize( "LUA_MENU_HORDE" ), gameType = "horde", additional_handlers = { button_action = GameModeChooseAction } } }, [#f16_local0 + 1] = { type = "UIGenericButton", id = "settings_squads_type_wargames_button", properties = { button_text = Engine.Localize( "LUA_MENU_WARGAME" ), additional_handlers = { button_action = function ( f17_arg0, f17_arg1 ) LUI.FlowManager.RequestAddMenu( f17_arg0, "settings_recipe_choosetype", true, f17_arg1.controller, false, { requestedGameMode = "Standard", menu_title = Cac.GetGameModeTypeString( "Standard" ), teamsOnly = true } ) end } } }, [#f16_local0 + 1] = { type = "UIGenericButton", id = "recent_modes_id", properties = { button_text = Engine.Localize( "@LUA_MENU_RECENT_MODES" ), button_action_func = function ( f18_arg0, f18_arg1 ) MatchRules.OpenSelectionMenu( f18_arg1.controller, { savedMode = "history", menu_title = Engine.Localize( "@LUA_MENU_RECENT_MODES" ), teamsOnly = SvS.IsSvS() } ) end } }, [#f16_local0 + 1] = { type = "UIGenericButton", id = "my_modes_id", properties = { button_text = Engine.Localize( "@LUA_MENU_MY_MODES" ), button_action_func = LUI.mp_menus.MPGameSetupModeMenu.ChooseMyModeMenu } } } return f16_local0 end function settings_recipe_choosetype_squads() return { type = "UIElement", id = "settings_recipe_choosetype_squads_root", states = { default = { topAnchor = true, bottomAnchor = true, leftAnchor = true, rightAnchor = true, top = 0, bottom = 0, left = 0, right = 0 } }, handlers = { menu_close = GameModeSelectMenuClose, menu_create = function ( f20_arg0, f20_arg1 ) f20_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addBackButton ) end }, children = { { type = "generic_menu_title", id = "settings_recipe_choosetype_title_text_id", properties = { menu_title = Engine.Localize( "LUA_MENU_MODE_CAPS" ) } }, { type = "UIVerticalList", states = { default = { alignment = LUI.Alignment.Top, leftAnchor = true, rightAnchor = false, topAnchor = true, bottomAnchor = false, left = GenericMenuDims.menu_left, right = GenericMenuDims.menu_right, top = GenericMenuDims.menu_top, bottom = GenericMenuDims.menu_bottom } }, childrenFeeder = SquadsTypeChildrenFeeder }, { type = "generic_back_button" }, { type = "button_helper_text_main", id = "button_helper_text_id" }, { type = "online_friends_widget", id = "online_friends_widget_id" } } } end LUI.MenuBuilder.registerDef( "gamemode_desc_pane", gamemode_desc_pane ) LUI.MenuBuilder.registerDef( "settings_recipe_choosetype", settings_recipe_choosetype ) LUI.MenuBuilder.registerDef( "settings_recipe_choosetype_options_vlist", settings_recipe_choosetype_options_vlist ) LUI.MenuBuilder.registerDef( "settings_recipe_choosetype_squads", settings_recipe_choosetype_squads ) LockTable( _M )