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

690 lines
21 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
function PushSplitScreenMenu()
MatchRules.SetUsingMatchRulesData( 1 )
Engine.PLMRefreshData()
end
function SplitScreenStartGame( f2_arg0, f2_arg1 )
if Engine.GetDvarString( "ui_gametype" ) == "horde" then
Lobby.SetBotsConnectType( 0 )
Engine.SetDvarBool( "squad_use_hosts_squad", false )
elseif SvS.IsSvS() then
if Lobby.GetBotsConnectType() == 0 then
Lobby.SetBotsConnectType( 1 )
end
Lobby.SetBotsTeamLimit( Lobby.BotTeams.Friendly, SvS.MaxSquadSize )
Lobby.SetBotsTeamLimit( Lobby.BotTeams.Enemy, SvS.MaxSquadSize )
Engine.SetDvarBool( "squad_use_hosts_squad", true )
elseif Lobby.GetBotsConnectType() == 0 then
Lobby.SetBotsConnectType( 1 )
Engine.SetDvarBool( "squad_use_hosts_squad", false )
end
local f2_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f2_arg0 )
f2_local0.startingController = f2_arg1.controller
CharacterScene.FreeCharacterScene()
local f2_local1 = LUI.mp_menus.Aliens.LobbyGetIntroVideo()
if f2_local1 and f2_local1 ~= "" and not LUI.mp_menus.Aliens.HasSeenVideo( f2_arg1.controller, f2_local1 ) then
LUI.mp_menus.Aliens.SetHasSeenVideo( f2_arg1.controller, f2_local1 )
LUI.mp_menus.Aliens.AliensPlayVideo( f2_arg1.controller, f2_local1, {
name = "start_transition_to_game",
immediate = true
} )
else
f2_arg0:dispatchEventToRoot( {
name = "start_transition_to_game",
immediate = true
} )
end
end
function StartTheGameHandler( f3_arg0, f3_arg1 )
local f3_local0 = LUI.FlowManager.GetMenuScopedDataFromElement( f3_arg0 )
Engine.SetDvarBool( "splitscreen_ingame", true )
Lobby.StartServer( f3_local0.startingController )
LUI.UIRoot.BlockButtonInput( Engine.GetLuiRoot(), false, "LobbyTransitionToGame" )
end
function SplitScreenGameSetup( f4_arg0, f4_arg1 )
LUI.FlowManager.RequestAddMenu( f4_arg0, "gamesetup_menu_main", true, f4_arg1.controller, false )
end
function SplitScreenEditSquad( f5_arg0, f5_arg1 )
Cac.SetEditSquadMember( Cac.GetActiveSquadMember( f5_arg1.controller ) )
LUI.FlowManager.RequestAddMenu( f5_arg0, "cac_edit_main", true, f5_arg1.controller, false, {
open_char_list = true,
squadLocation = "privateMatchSquadMembers",
squadMemberIndex = Cac.GetEditSquadMember(),
classLocation = "loadouts",
allowMemberSwap = true
} )
end
function LeaveSplitScreen( f6_arg0, f6_arg1 )
if Lobby.GetBotsConnectType() > 0 then
Lobby.SetBotsConnectType( 0 )
end
LUI.FlowManager.RequestLeaveMenu( f6_arg0 )
end
function GameSetupCreateHandler( f7_arg0, f7_arg1 )
LUI.FlowManager.RequestSetStack( f7_arg0, {
{
name = "mp_main_menu"
},
{
name = "menu_splitscreensignin"
}
} )
local f7_local0 = Engine.GetFirstActiveController()
f7_arg0:dispatchEventToRoot( LUI.ButtonHelperText.CommonEvents.addBackButton )
f7_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addGameSummaryButton )
Engine.SetDvarBool( "splitscreen_ingame", false )
Engine.Exec( MPConfig.default_dvars, f7_local0 )
if Engine.IsAliensMode() then
LUI.mp_menus.Aliens.AliensRunConfig( f7_local0 )
LUI.mp_menus.Aliens.InitGameTypeToAliens()
end
if Engine.IsXbox360() and Engine.AnyContentDamaged and Engine.AnyContentDamaged() then
LUI.FlowManager.RequestPopupMenu( f7_arg0, "mp_damaged_content_popup", false, f7_local0 )
else
TryForceOpenAfterActionReport( f7_arg0, f7_arg1 )
end
if Engine.GetDvarBool( "xblive_competitionmatch" ) and not Engine.IsAliensMode() then
MLG.SetUsingMLGRules( false )
MatchRules.LoadMatchRulesDataDefault()
f7_arg0:processEvent( {
name = "create_class_update_restrictions",
controller = f7_local0
} )
end
Cac.ValidateAllPlayersPrivateSquadMembers()
end
function GameSetupOptionsFeeder( f8_arg0 )
local f8_local0 = Engine.IsAliensMode()
local f8_local1 = {}
if not f8_arg0.slot then
DebugPrint( "[WARNING] CAC: using cac slot index 0, this is only ok if you are editing a menu" )
local f8_local2 = 0
end
local f8_local3 = Cac.GetCustomClassLoc( f8_arg0.classLocation )
f8_local1[#f8_local1 + 1] = {
type = "UIGenericButton",
id = "start_game_btn_id",
properties = {
button_text = Engine.Localize( "@LUA_MENU_START_GAME_CAPS" ),
desc_text = Engine.Localize( "@LUA_MENU_DESC_START_MATCH" ),
button_action_func = SplitScreenStartGame
}
}
if not f8_local0 then
f8_local1[#f8_local1 + 1] = {
type = "UIGenericButton",
id = "game_setup_btn_id",
properties = {
button_text = Engine.Localize( "@LUA_MENU_GAME_SETUP_CAPS" ),
desc_text = Engine.Localize( "@LUA_MENU_DESC_GAME_SETUP" ),
button_action_func = SplitScreenGameSetup
}
}
f8_local1[#f8_local1 + 1] = {
type = "UIGenericButton",
id = "create_squad_btn_id",
properties = {
button_text = Engine.Localize( "@LUA_MENU_CREATE_A_CLASS_CAPS" ),
desc_text = Engine.Localize( "@LUA_MENU_DESC_CREATE_A_CLASS" ),
button_action_func = SplitScreenEditSquad,
button_over_func = TriggerUpdateRestrictionsIcon,
button_up_func = TriggerUpdateRestrictionsIcon
},
handlers = {
create_class_update_restrictions = TriggerUpdateRestrictionsIcon
},
children = {
{
type = "lobby_restriction_icon"
}
}
}
else
f8_local1[#f8_local1 + 1] = LUI.mp_menus.AliensLoadout.GetAliensLoadoutButton()
if LUI.mp_menus.Aliens.ExtinctionHasMapSelection() then
f8_local1[#f8_local1 + 1] = LUI.mp_menus.Aliens.MapSelectionButton()
end
if LUI.mp_menus.Aliens.ExtinctionHasModeSelection() then
f8_local1[#f8_local1 + 1] = LUI.mp_menus.Aliens.ModeSelectionButton()
end
if LUI.mp_menus.Aliens.ExtinctionHasDifficultySelection() then
f8_local1[#f8_local1 + 1] = LUI.mp_menus.Aliens.DifficultySelectionButton()
end
if LUI.mp_menus.Aliens.CanAccessIntelMenu() then
f8_local1[#f8_local1 + 1] = LUI.mp_menus.AliensIntel.GetAliensIntelButton()
end
end
local f8_local4 = MatchRules.GetData( "gametype" )
if not f8_local0 and f8_local4 ~= "horde" then
local f8_local5 = tonumber( Engine.TableLookup( GameTypesTable.File, GameTypesTable.Cols.Ref, f8_local4, GameTypesTable.Cols.TeamChoice ) )
if f8_local5 and f8_local5 == 1 then
if not SvS.IsSvS() then
f8_local1[#f8_local1 + 1] = {
type = "UIGenericButton",
id = "friendly_bot_button_id",
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
left = 0,
right = GenericMenuDims.menu_right_more,
top = 0,
bottom = GenericButtonSettings.Styles.GradientButton.height
}
},
properties = {
variant = GenericButtonSettings.Variants.Select,
content_margin = 40,
content_width = 225,
text_padding_with_content = 275,
button_text = Engine.Localize( "@LUA_MENU_FRIENDLY_BOTS_CAPS" ),
desc_text = Engine.Localize( "@LUA_MENU_FRIENDLY_BOTS_DESC" ),
button_display_func = FriendlyBotButtonDisplayText,
button_left_func = FriendlyBotButtonLeft,
button_right_func = FriendlyBotButtonRight,
button_over_func = MBh.EmitEventToRoot( {
name = "lobby_slide_disable",
dispatchChildren = true,
immediate = true
} )
}
}
f8_local1[#f8_local1 + 1] = {
type = "UIGenericButton",
id = "friendly_bots_difficulty_button_id",
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
left = 0,
right = GenericMenuDims.menu_right_more,
top = 0,
bottom = GenericButtonSettings.Styles.GradientButton.height
}
},
properties = {
variant = GenericButtonSettings.Variants.Select,
content_margin = 40,
content_width = 225,
text_padding_with_content = 275,
button_text = Engine.Localize( "@LUA_MENU_BOTDIFFICULTY_CAPS" ),
desc_text = Engine.Localize( "@LUA_MENU_FRIENDLY_BOTDIFFICULTY_DESC" ),
button_display_func = FriendlyBotsDifficultyButtonDisplayText,
button_left_func = FriendlyBotsDifficultyButtonLeft,
button_right_func = FriendlyBotsDifficultyButtonRight,
button_over_func = MBh.EmitEventToRoot( {
name = "lobby_slide_disable",
dispatchChildren = true,
immediate = true
} )
}
}
f8_local1[#f8_local1 + 1] = {
type = "UIGenericButton",
id = "enemy_bot_button_id",
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
left = 0,
right = GenericMenuDims.menu_right_more,
top = 0,
bottom = GenericButtonSettings.Styles.GradientButton.height
}
},
properties = {
variant = GenericButtonSettings.Variants.Select,
content_margin = 40,
content_width = 225,
text_padding_with_content = 275,
button_text = Engine.Localize( "@LUA_MENU_ENEMY_BOTS_CAPS" ),
desc_text = Engine.Localize( "@LUA_MENU_ENEMY_BOTS_DESC" ),
button_display_func = EnemyBotButtonDisplayText,
button_left_func = EnemyBotButtonLeft,
button_right_func = EnemyBotButtonRight,
button_over_func = MBh.EmitEventToRoot( {
name = "lobby_slide_disable",
dispatchChildren = true,
immediate = true
} )
}
}
end
f8_local1[#f8_local1 + 1] = {
type = "UIGenericButton",
id = "enemy_bots_difficulty_button_id",
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
left = 0,
right = GenericMenuDims.menu_right_more,
top = 0,
bottom = GenericButtonSettings.Styles.GradientButton.height
}
},
properties = {
variant = GenericButtonSettings.Variants.Select,
content_margin = 40,
content_width = 225,
text_padding_with_content = 275,
button_text = Engine.Localize( "@LUA_MENU_BOTDIFFICULTY_CAPS" ),
desc_text = Engine.Localize( "@LUA_MENU_ENEMY_BOTDIFFICULTY_DESC" ),
button_display_func = EnemyBotsDifficultyButtonDisplayText,
button_left_func = EnemyBotsDifficultyButtonLeft,
button_right_func = EnemyBotsDifficultyButtonRight,
button_over_func = MBh.EmitEventToRoot( {
name = "lobby_slide_disable",
dispatchChildren = true,
immediate = true
} )
}
}
else
f8_local1[#f8_local1 + 1] = {
type = "UIGenericButton",
id = "bot_button_id",
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
left = 0,
right = GenericMenuDims.menu_right_more,
top = 0,
bottom = GenericButtonSettings.Styles.GradientButton.height
}
},
properties = {
variant = GenericButtonSettings.Variants.Select,
content_margin = 40,
content_width = 225,
text_padding_with_content = 275,
button_text = Engine.Localize( "@LUA_MENU_BOTS_CAPS" ),
desc_text = Engine.Localize( "@LUA_MENU_BOTS_DESC" ),
button_display_func = FFABotButtonDisplayText,
button_left_func = FFABotButtonLeft,
button_right_func = FFABotButtonRight,
button_over_func = MBh.EmitEventToRoot( {
name = "lobby_slide_disable",
dispatchChildren = true,
immediate = true
} )
}
}
f8_local1[#f8_local1 + 1] = {
type = "UIGenericButton",
id = "bots_difficulty_button_id",
states = {
default = {
leftAnchor = true,
rightAnchor = false,
topAnchor = true,
bottomAnchor = false,
left = 0,
right = GenericMenuDims.menu_right_more,
top = 0,
bottom = GenericButtonSettings.Styles.GradientButton.height
}
},
properties = {
variant = GenericButtonSettings.Variants.Select,
content_margin = 40,
content_width = 225,
text_padding_with_content = 275,
button_text = Engine.Localize( "@LUA_MENU_BOTDIFFICULTY_CAPS" ),
desc_text = Engine.Localize( "@LUA_MENU_BOTDIFFICULTY_DESC" ),
button_display_func = FFABotsDifficultyButtonDisplayText,
button_left_func = FFABotsDifficultyButtonLeft,
button_right_func = FFABotsDifficultyButtonRight,
button_over_func = MBh.EmitEventToRoot( {
name = "lobby_slide_disable",
dispatchChildren = true,
immediate = true
} )
}
}
end
f8_local1[#f8_local1 + 1] = {
type = "UITimer",
id = "bot_button_timer_id",
properties = {
event = "bot_button_refresh",
interval = 200
}
}
end
f8_local1[#f8_local1 + 1] = {
type = "button_desc_text",
id = "splitscreen_gamesetup_description_id"
}
return f8_local1
end
function menu_gamesetup_splitscreen()
local f9_local0 = Engine.IsAliensMode()
local f9_local1 = {
type = "UIElement",
id = "menu_splitscreen_gamesetup_root",
states = {
default = {
topAnchor = true,
bottomAnchor = true,
leftAnchor = true,
rightAnchor = true,
top = 0,
bottom = 0,
left = 0,
right = 0
}
},
handlers = {
menu_create = GameSetupCreateHandler,
start_transition_to_game = HandleStartTransitionToGame,
open_after_action_report = OpenAfterActionReport,
lobby_transition_complete = StartTheGameHandler
}
}
local f9_local2 = {}
local f9_local3 = {
type = "generic_menu_title",
id = "splitscreen_menu_title"
}
local f9_local4 = {}
local f9_local5
if f9_local0 then
f9_local5 = Engine.Localize( "@LUA_MENU_LOCAL_PLAY_CAPS" )
if not f9_local5 then
else
f9_local4.menu_title = f9_local5
f9_local3.properties = f9_local4
f9_local3.handlers = {
lobby_transition_to_game = MBh.AnimateToState( "hidden", Lobby.TransitionTime ),
lobby_rollback_transition_to_game = MBh.AnimateToState( "default", Lobby.TransitionTime )
}
f9_local4 = {
type = "UIVerticalList",
id = "live_splitscreen_options_id",
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,
alpha = 1
},
hidden = {
alpha = 0
}
},
childrenFeeder = GameSetupOptionsFeeder,
handlers = {
lobby_transition_to_game = MBh.AnimateToState( "hidden", Lobby.TransitionTime ),
lobby_rollback_transition_to_game = MBh.AnimateToState( "default", Lobby.TransitionTime ),
bot_button_refresh = BotButtonRefresh,
menu_create = BotButtonRefresh
}
}
f9_local5 = {
type = "splitscreen_member_list"
}
local f9_local6 = {
type = "lobby_loading_widget"
}
local f9_local7 = {
type = "lobby_game_type_title"
}
local f9_local8 = {
type = "lobby_game_type_icon"
}
local f9_local9 = {
type = "UIBindButton",
id = "lobby_bind_buttons_id",
handlers = {
button_secondary = LeaveSplitScreen,
button_select = OpenAfterActionReport
}
}
local f9_local10 = {
type = "UIElement",
id = "LowerSliderID",
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = 0,
right = 0,
top = 0,
bottom = 0,
alpha = 1
},
hidden = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = 0,
right = 0,
top = 100,
bottom = 100,
alpha = 0
}
},
handlers = {
lobby_transition_to_game = MBh.AnimateToState( "hidden", Lobby.TransitionTime ),
lobby_rollback_transition_to_game = MBh.AnimateToState( "default", Lobby.TransitionTime )
},
children = {
{
type = "map_info_text",
id = "map_info_text_id"
},
{
type = "button_helper_text_main",
id = "cac_button_helper_text_id"
},
{
type = "online_friends_widget",
id = "online_friends_widget_id"
}
}
}
f9_local2[1] = f9_local3
f9_local2[2] = f9_local4
f9_local2[3] = f9_local5
f9_local2[4] = f9_local6
f9_local2[5] = f9_local7
f9_local2[6] = f9_local8
f9_local2[7] = f9_local9
f9_local2[8] = f9_local10
f9_local1.children = f9_local2
return f9_local1
end
end
f9_local5 = Engine.Localize( "@LUA_MENU_SPLITSCREEN_CAPS" )
end
function PlayerCardDummyData( f10_arg0, f10_arg1, f10_arg2 )
f10_arg0:processEvent( {
gamertag = "player" .. f10_arg2 + 1,
clantag = "NVST",
rank = 18,
prestige = 0,
background = "0",
patchEmblem = "0",
patchShape = "0",
name = "update_playercard"
} )
end
function FillPlayerData( f11_arg0, f11_arg1, f11_arg2 )
if not Lobby.GetControllerForSplitScreenSlot then
PlayerCardDummyData( f11_arg0, f11_arg1, f11_arg2 )
return
end
local f11_local0 = Lobby.GetControllerForSplitScreenSlot( f11_arg2 )
if f11_local0 and Engine.HasPlayerData( f11_local0 ) then
local f11_local1 = LUI.mp_menus.Aliens
local f11_local2 = nil
if Engine.IsAliensMode() then
f11_local2 = Lobby.GetAlienRankForXP( f11_local1.getAliensExperience( f11_local0 ) )
else
f11_local2 = Lobby.GetRankForXP( Engine.GetPlayerDataEx( f11_local0, CoD.StatsGroup.Ranked, "experience" ) )
end
local f11_local3 = {
gamertag = Engine.GetUsernameByController( f11_local0 ),
clantag = Engine.GetCustomClanTag( f11_local0 ) or "",
rank = f11_local2
}
if Engine.IsAliensMode() then
f11_local3.prestige = f11_local1.getAliensPrestigeLevel( f11_local0 )
else
f11_local3.prestige = Engine.GetPlayerDataEx( f11_local0, CoD.StatsGroup.Ranked, "prestige" )
end
if Engine.IsAliensMode() then
local f11_local4 = "squadMembers"
local f11_local5 = 0
f11_local3.background = Engine.GetPlayerDataEx( f11_local0, CoD.StatsGroup.Ranked, f11_local4, f11_local5, "background" )
f11_local3.patchEmblem = Engine.GetPlayerDataEx( f11_local0, CoD.StatsGroup.Ranked, f11_local4, f11_local5, "patch" )
f11_local3.patchShape = Engine.GetPlayerDataEx( f11_local0, CoD.StatsGroup.Ranked, f11_local4, f11_local5, "patchbacking" )
else
local f11_local4 = Cac.GetSquadLoc()
local f11_local5 = AAR.GetRoundSquadMember( f11_local0 )
f11_local3.background = Cac.GetBackgroundIndex( f11_local0, f11_local4, f11_local5 )
f11_local3.patchEmblem = Cac.GetPatchIndex( f11_local0, f11_local4, f11_local5 )
f11_local3.patchShape = Cac.GetPatchbackingIndex( f11_local0, f11_local4, f11_local5 )
end
f11_local3.name = "update_playercard"
f11_arg0:processEvent( f11_local3 )
end
end
function splitscreenMemberFeeder( f12_arg0 )
local f12_local0 = {}
local f12_local1 = Engine.SplitscreenPlayerCount()
local f12_local2 = 70
for f12_local3 = 1, f12_local1, 1 do
local f12_local6 = f12_local3
f12_local0[#f12_local0 + 1] = {
type = "playercard",
id = "playercard_id" .. f12_local6,
properties = {
additional_handlers = {
menu_create = function ( f13_arg0, f13_arg1 )
FillPlayerData( f13_arg0, f13_arg1, f12_local6 - 1 )
end,
update_cards = function ( f14_arg0, f14_arg1 )
FillPlayerData( f14_arg0, f14_arg1, f12_local6 - 1 )
end
}
},
states = {
default = {
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
bottomAnchor = false,
left = 0,
right = 0,
top = 0,
bottom = f12_local2
}
}
}
end
f12_local0[#f12_local0 + 1] = {
type = "UITimer",
properties = {
event = "update_player_cards",
interval = 750,
disposable = false
}
}
return f12_local0
end
function HandleUpdatePlayerCards( f15_arg0, f15_arg1 )
if f15_arg0.properties.numPlayers ~= Engine.SplitscreenPlayerCount() then
f15_arg0.properties.numPlayers = Engine.SplitscreenPlayerCount()
f15_arg0:closeChildren()
f15_arg0:processEvent( {
name = "menu_refresh"
} )
end
f15_arg0:processEvent( {
name = "update_cards"
} )
end
function splitscreen_member_list()
return {
type = "UIVerticalList",
id = "splitscreen_memberlist_id",
properties = {
numPlayers = Engine.SplitscreenPlayerCount()
},
childrenFeeder = splitscreenMemberFeeder,
states = {
default = {
leftAnchor = false,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = -500,
right = -50,
top = 150,
bottom = 0,
spacing = 60
},
hidden = {
leftAnchor = false,
rightAnchor = true,
topAnchor = true,
bottomAnchor = true,
left = 100,
right = 650,
top = 150,
bottom = 0,
spacing = 60
}
},
handlers = {
lobby_transition_to_game = MBh.AnimateToState( "hidden", Lobby.TransitionTime ),
lobby_rollback_transition_to_game = MBh.AnimateToState( "default", Lobby.TransitionTime ),
update_player_cards = HandleUpdatePlayerCards
}
}
end
LUI.MenuBuilder.registerDef( "menu_gamesetup_splitscreen", menu_gamesetup_splitscreen )
LUI.MenuBuilder.registerDef( "splitscreen_member_list", splitscreen_member_list )
LUI.FlowManager.RegisterStackPushBehaviour( "menu_gamesetup_splitscreen", PushSplitScreenMenu )
LockTable( _M )