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

513 lines
15 KiB
Lua

local f0_local0 = module
local f0_local1, f0_local2 = ...
f0_local0( f0_local1, package.seeall )
CoD.PrintModuleLoad( _NAME )
function PushSystemLinkGameSetupMenu()
Engine.SetDvarBool( "systemlink_host", true )
MatchRules.SetUsingMatchRulesData( 1 )
end
function SystemLinkStartGame( f2_arg0, f2_arg1 )
if Engine.GetDvarString( "ui_gametype" ) == "horde" then
Lobby.SetBotsConnectType( 0 )
elseif Lobby.GetBotsConnectType() == 0 then
Lobby.SetBotsConnectType( 1 )
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 )
Lobby.StartServer( f3_local0.startingController )
LUI.UIRoot.BlockButtonInput( Engine.GetLuiRoot(), false, "MenuTransition" )
end
function SystemLinkGameSetup( f4_arg0, f4_arg1 )
LUI.FlowManager.RequestAddMenu( f4_arg0, "gamesetup_menu_main", true, f4_arg1.controller, false )
end
function SystemLinkEditSquad( 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,
classLocation = "loadouts",
squadLocation = "privateMatchSquadMembers",
squadMemberIndex = Cac.GetEditSquadMember(),
allowMemberSwap = true
} )
end
function LeaveSystemLink( f6_arg0, f6_arg1 )
if Lobby.GetBotsConnectType() > 0 then
Lobby.SetBotsConnectType( 0 )
end
if MLG.AreMLGRulesEnabled() then
MLG.Toggle( f6_arg0, f6_arg1 )
end
LUI.FlowManager.RequestLeaveMenu( f6_arg0 )
end
function GameSetupCreateHandler( f7_arg0, f7_arg1 )
local f7_local0 = Engine.GetFirstActiveController()
f7_arg0:dispatchEventToRoot( LUI.ButtonHelperText.CommonEvents.addBackButton )
f7_arg0:processEvent( LUI.ButtonHelperText.CommonEvents.addGameSummaryButton )
Engine.Exec( MPConfig.default_dvars, f7_local0 )
if Engine.IsAliensMode() then
LUI.mp_menus.Aliens.AliensRunConfig( f7_local0 )
LUI.mp_menus.Aliens.InitGameTypeToAliens()
end
RefreshMLGRules( f7_arg0, f7_local0 )
MLG.Refresh( f7_arg0 )
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 = SystemLinkStartGame
}
}
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 = SystemLinkGameSetup
}
}
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 = SystemLinkEditSquad,
button_over_func = TriggerUpdateRestrictionsIcon,
button_up_func = TriggerUpdateRestrictionsIcon
},
handlers = {
create_class_update_restrictions = TriggerUpdateRestrictionsIcon
},
children = {
{
type = "lobby_restriction_icon"
}
}
}
else
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
end
local f8_local4 = Engine.GetDvarString( "ui_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
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
} )
}
}
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 = "systemlink_gamesetup_description_id"
}
return f8_local1
end
function menu_gamesetup_systemlink()
local f9_local0 = Engine.IsAliensMode()
return {
type = "UIElement",
id = "menu_systemlink_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,
lobby_transition_complete = StartTheGameHandler,
lobby_update_timer = function ( f10_arg0, f10_arg1 )
MLG.Refresh( f10_arg0 )
end
},
children = {
{
type = "UITimer",
id = "lobby_update_timer",
properties = {
event = {
name = "lobby_update_timer"
},
disposable = false,
interval = 200
}
},
{
type = "generic_menu_title",
id = "system_link_menu_title",
properties = {
menu_title = Engine.Localize( "@PLATFORM_SYSTEM_LINK_TITLE" )
},
handlers = {
lobby_transition_to_game = MBh.AnimateToState( "hidden", Lobby.TransitionTime ),
lobby_rollback_transition_to_game = MBh.AnimateToState( "default", Lobby.TransitionTime )
}
},
{
type = "character_playing_as",
id = "character_playing_as_id"
},
{
type = "lobby_loading_widget"
},
{
type = "lobby_game_type_title"
},
{
type = "lobby_game_type_icon"
},
{
type = "UIVerticalList",
id = "live_systemlink_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
}
},
{
type = "UIBindButton",
id = "lobby_bind_buttons_id",
handlers = {
button_secondary = LeaveSystemLink,
button_select = OpenAfterActionReport,
button_start = function ( f11_arg0, f11_arg1 )
MLG.Toggle( f11_arg0:getParent(), f11_arg1 )
if MatchRules.AllowCustomClasses( "loadouts" ) then
f11_arg0:dispatchEventToRoot( {
name = "create_class_update_restrictions",
controller = f11_arg1.controller
} )
end
end
}
},
{
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"
}
}
}
}
}
end
LUI.MenuBuilder.registerDef( "menu_gamesetup_systemlink", menu_gamesetup_systemlink )
LUI.FlowManager.RegisterStackPushBehaviour( "menu_gamesetup_systemlink", PushSystemLinkGameSetupMenu )
LUI.FlowManager.RegisterStackPopBehaviour( "menu_gamesetup_systemlink", function ()
Engine.SetDvarBool( "systemlink_host", false )
end )
LockTable( _M )