aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Northstar.Client/scripts')
-rw-r--r--Northstar.Client/scripts/vscripts/ui/menu_main.nut608
-rw-r--r--Northstar.Client/scripts/vscripts/ui/menu_private_match.nut777
-rw-r--r--Northstar.Client/scripts/vscripts/ui/panel_mainmenu.nut829
3 files changed, 2214 insertions, 0 deletions
diff --git a/Northstar.Client/scripts/vscripts/ui/menu_main.nut b/Northstar.Client/scripts/vscripts/ui/menu_main.nut
new file mode 100644
index 00000000..5f292f5c
--- /dev/null
+++ b/Northstar.Client/scripts/vscripts/ui/menu_main.nut
@@ -0,0 +1,608 @@
+global function InitMainMenu
+global function EULA_Dialog
+global function UpdateDataCenterFooter
+global function LaunchGamePurchase
+global function SP_Trial_LaunchGamePurchase
+global function LaunchSPNew
+global function LaunchSPContinue
+global function LaunchSPMissionSelect
+global function LaunchMP
+global function LaunchGame
+global function LaunchSPTrialMission
+global function GetUserSignInState
+
+struct
+{
+ var menu
+ var versionDisplay
+ var trialLabel
+} file
+
+
+void function InitMainMenu()
+{
+ RegisterSignal( "EndOnMainMenu_Open" )
+
+ var menu = GetMenu( "MainMenu" )
+ file.menu = menu
+
+ AddMenuEventHandler( menu, eUIEvent.MENU_OPEN, OnMainMenu_Open )
+ AddMenuEventHandler( menu, eUIEvent.MENU_NAVIGATE_BACK, OnMainMenu_NavigateBack )
+
+ var titleRui = Hud_GetRui( Hud_GetChild( file.menu, "TitleRui" ) )
+ RuiSetImage( titleRui, "basicImage", $"rui/menu/main_menu/title")
+
+ file.versionDisplay = Hud_GetChild( menu, "versionDisplay" )
+ file.trialLabel = Hud_GetChild( menu, "TrialLabel" )
+
+ #if CONSOLE_PROG
+ AddMenuFooterOption( menu, BUTTON_A, "#A_BUTTON_SELECT", "", null, IsConsoleSignedIn )
+ #if DURANGO_PROG
+ AddMenuFooterOption( menu, BUTTON_B, "#B_BUTTON_SWITCH_PROFILE", "", null, IsConsoleSignedIn )
+ #endif // DURANGO_PROG
+
+ AddMenuVarChangeHandler( "CONSOLE_isSignedIn", UpdateFooterOptions )
+ #endif // CONSOLE_PROG
+
+ #if PC_PROG
+ AddMenuFooterOption( menu, BUTTON_A, "#A_BUTTON_SELECT", "" )
+ #endif // PC_PROG
+
+ AddMenuFooterOption( menu, BUTTON_X, "#X_BUTTON_INBOX_ACCEPT", "#INBOX_ACCEPT", OpenDataCenterDialog, IsDataCenterFooterValid, UpdateDataCenterFooter )
+
+#if DEV
+ if ( DevStartPoints() )
+ AddMenuFooterOption( menu, BUTTON_Y, "#Y_BUTTON_DEV_MENU", "#DEV_MENU", OpenSinglePlayerDevMenu )
+#endif // DEV
+}
+
+#if CONSOLE_PROG
+ bool function IsConsoleSignedIn()
+ {
+ return ( GetMenuVarBool( "CONSOLE_isSignedIn" ) )
+ }
+#endif // CONSOLE_PROG
+
+void function OnMainMenu_Open()
+{
+ Signal( uiGlobal.signalDummy, "EndOnMainMenu_Open" )
+ EndSignal( uiGlobal.signalDummy, "EndOnMainMenu_Open" )
+
+ UpdatePromoData() // On script restarts this gives us the last data until the new request is complete
+ RequestMainMenuPromos() // This will be ignored if there was a recent request. "infoblock_requestInterval"
+
+ TryUnlockCollectiblesAchievement()
+ TryUnlockCompletedGameAchievements()
+
+ Hud_SetText( file.versionDisplay, GetPublicGameVersion() )
+ Hud_Show( file.versionDisplay )
+
+ thread UpdateTrialLabel()
+
+#if PC_PROG
+ ActivatePanel( GetPanel( "MainMenuPanel" ) )
+ return
+#endif // PC_PROG
+
+ int state
+ int lastState = -1
+ var panel
+ var lastPanel
+
+ while ( GetTopNonDialogMenu() == file.menu )
+ {
+ state = GetUserSignInState()
+
+ if ( state != lastState )
+ {
+ if ( state == userSignInState.SIGNED_IN )
+ panel = GetPanel( "MainMenuPanel" )
+ else
+ panel = GetPanel( "EstablishUserPanel" )
+
+ if ( panel != lastPanel )
+ {
+ ActivatePanel( panel )
+ lastPanel = panel
+ }
+ }
+
+ lastState = state
+
+ WaitFrame()
+ }
+}
+
+void function ActivatePanel( var panel )
+{
+ Assert( panel != null )
+
+ array<var> elems = GetElementsByClassname( file.menu, "MainMenuPanelClass" )
+ foreach ( elem in elems )
+ {
+ if ( elem != panel && Hud_IsVisible( elem ) )
+ HidePanel( elem )
+ }
+
+ ShowPanel( panel )
+}
+
+void function OnMainMenu_NavigateBack()
+{
+#if DURANGO_PROG
+ Durango_ShowAccountPicker()
+#endif // DURANGO_PROG
+}
+
+int function GetUserSignInState()
+{
+#if DURANGO_PROG
+ if ( Durango_InErrorScreen() )
+ {
+ return userSignInState.ERROR
+ }
+ else if ( Durango_IsSigningIn() )
+ {
+ return userSignInState.SIGNING_IN
+ }
+ else if ( !Console_IsSignedIn() && !Console_SkippedSignIn() )
+ {
+ //printt( "Console_IsSignedIn():", Console_IsSignedIn(), "Console_SkippedSignIn:", Console_SkippedSignIn() )
+ return userSignInState.SIGNED_OUT
+ }
+
+ Assert( Console_IsSignedIn() || Console_SkippedSignIn() )
+#endif
+ return userSignInState.SIGNED_IN
+}
+
+void function UpdateDataCenterFooter( InputDef data )
+{
+ EndSignal( uiGlobal.signalDummy, "EndFooterUpdateFuncs" )
+
+ int index = int( Hud_GetScriptID( data.vguiElem ) )
+ int ping
+ string name
+
+ while ( data.conditionCheckFunc() )
+ {
+ ping = GetDatacenterPing()
+ name = GetDatacenterName()
+
+ if ( ping > 0 )
+ {
+ if ( IsControllerModeActive() )
+ SetFooterText( file.menu, index, Localize( "#X_BUTTON_DATACENTER_INFO", name, ping ) )
+ else
+ SetFooterText( file.menu, index, Localize( "#DATACENTER_INFO", name, ping ) )
+ }
+ else
+ {
+ if ( IsControllerModeActive() )
+ SetFooterText( file.menu, index, "#X_BUTTON_DATACENTER_CALCULATING" )
+ else
+ SetFooterText( file.menu, index, "#DATACENTER_CALCULATING" )
+ }
+
+ WaitFrame()
+ }
+}
+
+bool function IsDataCenterFooterValid()
+{
+ #if PC_PROG
+ return ( uiGlobal.activeMenu == file.menu )
+ #else
+ return ( uiGlobal.activeMenu == file.menu ) && Console_IsOnline() && Console_IsSignedIn()
+ #endif
+}
+
+void function SP_Trial_LaunchGamePurchase()
+{
+ Disconnect()
+ LaunchGamePurchase()
+}
+
+void function LaunchGamePurchase()
+{
+ ShowGamePurchaseStore()
+}
+
+void function LaunchSPNew()
+{
+ uiGlobal.launching = eLaunching.SINGLEPLAYER_NEW
+ LaunchGame()
+}
+
+void function LaunchSPContinue()
+{
+ uiGlobal.launching = eLaunching.SINGLEPLAYER_CONTINUE
+ LaunchGame()
+}
+
+void function LaunchSPMissionSelect()
+{
+ uiGlobal.launching = eLaunching.SINGLEPLAYER_MISSION_SELECT
+ LaunchGame()
+}
+
+void function LaunchSPTrialMission()
+{
+ uiGlobal.launching = eLaunching.SINGLEPLAYER_MISSION_SELECT
+ SPTrialMission_Start()
+}
+
+void function LaunchMP()
+{
+ uiGlobal.launching = eLaunching.MULTIPLAYER
+ LaunchGame()
+}
+
+void function LaunchGame()
+{
+ Assert( uiGlobal.launching == eLaunching.SINGLEPLAYER_NEW ||
+ uiGlobal.launching == eLaunching.SINGLEPLAYER_CONTINUE ||
+ uiGlobal.launching == eLaunching.SINGLEPLAYER_MISSION_SELECT ||
+ uiGlobal.launching == eLaunching.MULTIPLAYER ||
+ uiGlobal.launching == eLaunching.MULTIPLAYER_INVITE )
+
+ if ( uiGlobal.activeMenu == GetMenu( "PlayVideoMenu" ) )
+ {
+ SetVideoCompleteFunc( null )
+ CloseActiveMenu()
+ }
+
+ if ( !IsGamePartiallyInstalled() )
+ {
+ DoGameNeedsToInstallDialog()
+ return
+ }
+
+ // Because accepting an invite tries to launch the game we need this here
+ if ( !IsGameFullyInstalled() )
+ {
+ printt( "Game is not fully installed." )
+
+ if ( uiGlobal.launching == eLaunching.SINGLEPLAYER_CONTINUE )
+ {
+ string saveName = GetSaveName()
+ string mapName = SaveGame_GetMapName( saveName )
+ int startPointIndex = SaveGame_GetStartPoint( saveName )
+
+ printt( mapName )
+ printt( startPointIndex )
+
+ bool isInTraining = (mapName == "sp_training" && startPointIndex < 5) // "Titanfall" start point
+
+ if ( !isInTraining )
+ {
+ DoGameNeedsToInstallDialog()
+ return
+ }
+
+ printt( "Allowing 'continue' option to load into training." )
+ }
+ else if ( uiGlobal.launching != eLaunching.SINGLEPLAYER_NEW )
+ {
+ DoGameNeedsToInstallDialog()
+ return
+ }
+ }
+
+ #if CONSOLE_PROG
+ if ( !Console_IsSignedIn() )
+ {
+ printt( "Not signed in." )
+ return
+ }
+
+ if ( GetEULAVersionAccepted() < 1 ) // Treat as binary for now, as discussed with Preston.
+ {
+ if ( uiGlobal.activeMenu == GetMenu( "EULADialog" ) )
+ return
+
+ if ( IsDialog( uiGlobal.activeMenu ) )
+ CloseActiveMenu( true )
+
+ EULA_Dialog()
+ return
+ }
+
+ if ( Nucleus_GetState() == NUCLEUS_STATE_INACTIVE )
+ Nucleus_Login()
+
+ if ( !uiGlobal.triedNucleusRegistration && uiGlobal.launching == eLaunching.MULTIPLAYER && !Nucleus_GetSkipRegistration() )
+ {
+ uiGlobal.triedNucleusRegistration = true
+ thread Nucleus_HandleLoginResponse()
+ return
+ }
+
+ if ( !GetConVarBool( "gamma_adjusted" ) )
+ {
+ if ( IsDialog( uiGlobal.activeMenu ) )
+ CloseActiveMenu( true )
+
+ AdvanceMenu( GetMenu( "GammaMenu" ) )
+ return
+ }
+ #endif // CONSOLE_PROG
+
+ if ( ( uiGlobal.launching == eLaunching.MULTIPLAYER || uiGlobal.launching == eLaunching.MULTIPLAYER_INVITE ) && !IsAdvocateGiftComplete() )
+ {
+ if ( IsDialog( uiGlobal.activeMenu ) )
+ CloseActiveMenu( true )
+
+ AdvanceMenu( GetMenu( "AdvocateGiftDialog" ) )
+ return
+ }
+
+ SetMenuWasMultiplayerPlayedLast( true )
+ if ( uiGlobal.launching == eLaunching.SINGLEPLAYER_NEW )
+ NewGameSelected()
+ else if ( uiGlobal.launching == eLaunching.SINGLEPLAYER_CONTINUE )
+ LoadLastCheckpoint()
+ else if ( uiGlobal.launching == eLaunching.SINGLEPLAYER_MISSION_SELECT )
+ AdvanceMenu( GetMenu( "SinglePlayerMenu" ) )
+ else
+ thread StartSearchForPartyServer()
+
+ uiGlobal.launching = eLaunching.FALSE
+}
+
+void function StartSearchForPartyServer()
+{
+ printt( "StartSearchForPartyServer" )
+
+#if DURANGO_PROG
+ // IMPORTANT: As a safety measure leave any party view we are in at this point.
+ // Otherwise, if you are unlucky enough to get stuck in a party view, you will
+ // trash its state by pointing it to your private lobby.
+ Durango_LeaveParty()
+
+ // IMPORTANT: It's possible that you have permission to play multiplayer
+ // because your friend is signed in with his gold account on your machine,
+ // but once that guy signs out, you shouldn't be able to play like you have
+ // xboxlive gold anymore. To fix this, we need to check permissions periodically.
+ // One of the places where we do this periodic check is when you press "PLAY"
+ printt( "Durango - verifying MP permissions" )
+ if ( !Console_HasPermissionToPlayMultiplayer() )
+ Durango_VerifyMultiplayerPermissions()
+#endif // DURANGO_PROG
+
+ Signal( uiGlobal.signalDummy, "OnCancelConnect" )
+ EndSignal( uiGlobal.signalDummy, "OnCancelConnect" )
+
+ if ( IsDialog( uiGlobal.activeMenu ) )
+ CloseActiveMenu( true )
+ OpenConnectingDialog()
+
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "" )
+ Hud_SetText( uiGlobal.ConfirmMenuErrorCode, "" )
+
+ Hud_Show( uiGlobal.ConfirmMenuMessage )
+ Hud_Show( uiGlobal.ConfirmMenuErrorCode )
+
+#if DURANGO_PROG
+ if( !Console_IsOnline() )
+ {
+ printt( "Durango - finding empty party server failed - not online" )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#DURANGO_NOT_ONLINE" )
+ return
+ }
+#endif // DURANGO_PROG
+
+#if PS4_PROG
+ if( !Console_IsOnline() )
+ {
+ printt( "PS4 - finding empty party server failed - not online" )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#INTERNET_NOT_FOUND" )
+ return
+ }
+
+ if ( PS4_isNetworkingDown() )
+ {
+ printt( "PS4 - finding empty party server failed - networking is down" )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#PSN_CANNOT_CONNECT" )
+ return
+ }
+
+ if( !PS4_isUserNetworkingEnabled() )
+ {
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#PSN_CHECKING_USABILITY" )
+ PS4_ScheduleUserNetworkingEnabledTest()
+ WaitFrame()
+
+ if( !PS4_isUserNetworkingResolved() )
+ {
+ printt( "PS4 - finding empty party server stalled - networking isn't resolved yet" )
+ // offer cancel ??
+ while( !PS4_isUserNetworkingResolved())
+ WaitFrame()
+ }
+
+ if( PS4_getUserNetworkingResolution() == PS4_NETWORK_STATUS_NOT_LOGGED_IN )
+ {
+ Hud_SetText( uiGlobal.ConfirmMenuErrorCode, string(PS4_getUserNetworkingErrorStatus()) )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#PSN_LOGIN" )
+
+ Ps4_LoginDialog_Schedule()
+ while( Ps4_LoginDialog_Running() )
+ WaitFrame()
+
+ PS4_ScheduleUserNetworkingEnabledTest()
+ WaitFrame()
+ if( !PS4_isUserNetworkingResolved() )
+ {
+ Hud_SetText( uiGlobal.ConfirmMenuErrorCode, "" )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#PSN_CHECKING_USABILITY" )
+ while( !PS4_isUserNetworkingResolved())
+ WaitFrame()
+ }
+ }
+
+ if( PS4_getUserNetworkingResolution() == PS4_NETWORK_STATUS_AGE_RESTRICTION )
+ {
+ Hud_SetText( uiGlobal.ConfirmMenuErrorCode, string(PS4_getUserNetworkingErrorStatus()) )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#MULTIPLAYER_AGE_RESTRICTED" )
+ return
+ }
+
+ if( PS4_getUserNetworkingResolution() == PS4_NETWORK_STATUS_IN_ERROR )
+ {
+ Hud_SetText( uiGlobal.ConfirmMenuErrorCode, string(PS4_getUserNetworkingErrorStatus()) )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#PSN_HAD_ERROR" )
+ return
+ }
+
+ if( !PS4_isUserNetworkingEnabled() )
+ {
+ Hud_SetText( uiGlobal.ConfirmMenuErrorCode, string(PS4_getUserNetworkingErrorStatus()) )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#PSN_NOT_ALLOWED" )
+ return
+ }
+
+ Hud_SetText( uiGlobal.ConfirmMenuErrorCode, "" )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "" )
+ }
+
+ if ( !Ps4_PSN_Is_Loggedin() )
+ {
+ Ps4_LoginDialog_Schedule()
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#PSN_LOGIN" )
+
+ while( Ps4_LoginDialog_Running() )
+ WaitFrame()
+
+ if ( !Ps4_PSN_Is_Loggedin() )
+ return
+ }
+
+ if( Ps4_CheckPlus_Schedule() )
+ {
+ while( Ps4_CheckPlus_Running() )
+ WaitFrame()
+ if( !Ps4_CheckPlus_Allowed() )
+ {
+ if( Ps4_CheckPlus_GetLastRequestResults() != 0 )
+ {
+ Hud_SetText( uiGlobal.ConfirmMenuErrorCode, string( Ps4_CheckPlus_GetLastRequestResults()) )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#PSN_HAD_ERROR" )
+ return
+ }
+
+ if( Ps4_ScreenPlusDialog_Schedule() )
+ {
+ while( Ps4_ScreenPlusDialog_Running() )
+ WaitFrame()
+ if( !Ps4_ScreenPlusDialog_Allowed() )
+ {
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#PSN_MUST_BE_PLUS_USER" )
+ return
+ }
+ }
+ else
+ {
+ return
+ }
+ }
+ }
+
+ Hud_SetText( uiGlobal.ConfirmMenuErrorCode, "" )
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "" )
+#endif // #if PS4_PROG
+
+ printt( "Checking if this user has permission to play MP\n" )
+ if ( !Console_HasPermissionToPlayMultiplayer() )
+ {
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#MULTIPLAYER_NOT_AVAILABLE" )
+ return
+ }
+
+ Plat_ShowUGCRestrictionNotice()
+ while ( Plat_IsSystemMessageDialogOpen() )
+ WaitFrame()
+
+ Plat_ShowChatRestrictionNotice()
+ while ( Plat_IsSystemMessageDialogOpen() )
+ WaitFrame()
+
+#if PC_PROG
+ if ( Origin_IsEnabled() )
+ {
+ Origin_RequestTicket()
+ Hud_SetText( uiGlobal.ConfirmMenuMessage, "#WAITING_FOR_ORIGIN" )
+
+ while ( !Origin_IsReady() )
+ WaitFrame()
+ }
+#endif // PC_PROG
+
+ printt( "SearchForPartyServer" )
+ SetMenuWasMultiplayerPlayedLast( true )
+ SearchForPartyServer()
+
+ Hud_SetAutoText( uiGlobal.ConfirmMenuMessage, "", HATT_MATCHMAKING_EMPTY_SERVER_SEARCH_STATE, 0 )
+ Hud_SetAutoText( uiGlobal.ConfirmMenuErrorCode, "", HATT_MATCHMAKING_EMPTY_SERVER_SEARCH_ERROR, 0 )
+}
+
+void function EULA_Dialog()
+{
+ if ( GetUserSignInState() != userSignInState.SIGNED_IN )
+ return
+
+ if ( GetEULAVersionAccepted() >= 1 )
+ return
+
+ AdvanceMenu( GetMenu( "EULADialog" ) )
+}
+
+void function DoGameNeedsToInstallDialog()
+{
+ DialogData dialogData
+ dialogData.header = "#MENU_WAIT_FOR_INTALL"
+
+ int installProgress = int( GetGameFullyInstalledProgress()*100 )
+
+ if ( uiGlobal.launching == eLaunching.MULTIPLAYER && IsGamePartiallyInstalled() && !Script_IsRunningTrialVersion() )
+ {
+ dialogData.message = Localize("#MENU_WAIT_FOR_INTALL_HINT", installProgress )
+ AddDialogButton( dialogData, "#YES", LaunchSPNew )
+ AddDialogButton( dialogData, "#NO" )
+ }
+ else
+ {
+ dialogData.message = Localize("#MENU_WAIT_FOR_INTALL_HINT_NOTRAINING", installProgress )
+ AddDialogButton( dialogData, "#OK" )
+ }
+
+ AddDialogFooter( dialogData, "#A_BUTTON_SELECT" )
+ AddDialogFooter( dialogData, "#B_BUTTON_CANCEL" )
+
+ OpenDialog( dialogData )
+}
+
+void function UpdateTrialLabel()
+{
+ bool isTrialVersion
+ bool lastIsTrialVersion = Script_IsRunningTrialVersion()
+
+ Hud_SetVisible( file.trialLabel, lastIsTrialVersion )
+
+ while ( GetTopNonDialogMenu() == file.menu )
+ {
+ isTrialVersion = Script_IsRunningTrialVersion()
+
+ if ( isTrialVersion != lastIsTrialVersion )
+ Hud_SetVisible( file.trialLabel, isTrialVersion )
+
+ lastIsTrialVersion = isTrialVersion
+
+ WaitFrame()
+ }
+}
+
+void function OpenSinglePlayerDevMenu( var button )
+{
+ AdvanceMenu( GetMenu( "SinglePlayerDevMenu" ) )
+}
diff --git a/Northstar.Client/scripts/vscripts/ui/menu_private_match.nut b/Northstar.Client/scripts/vscripts/ui/menu_private_match.nut
new file mode 100644
index 00000000..13218cd3
--- /dev/null
+++ b/Northstar.Client/scripts/vscripts/ui/menu_private_match.nut
@@ -0,0 +1,777 @@
+untyped
+
+global function MenuPrivateMatch_Init
+
+global function InitPrivateMatchMenu
+
+global function HandleLockedCustomMenuItem
+global function GetMapImageForMapName
+
+struct
+{
+ var menu
+
+ array matchStatusRuis
+
+ array MMDevStringElems
+
+ array teamSlotBackgrounds
+ array teamSlotBackgroundsNeutral
+
+ var enemyTeamBackgroundPanel
+ var friendlyTeamBackgroundPanel
+ var enemyTeamBackground
+ var friendlyTeamBackground
+ var enemyPlayersPanel
+ var friendlyPlayersPanel
+
+ var listFriendlies
+ var listEnemies
+
+ var nextMapNameLabel
+ var nextGameModeLabel
+
+ var inviteRoomButton
+ var inviteFriendsButton
+
+ int inboxHeaderIndex
+
+ int customizeHeaderIndex
+ var pilotButton
+ var titanButton
+ var boostsButton
+ var storeButton
+ var factionButton
+ var bannerButton
+ var patchButton
+ var statsButton
+ var dpadCommsButton
+
+ var playHeader
+ var customizeHeader
+ var callsignHeader
+ var storeHeader
+
+ var startMatchButton
+ var selectMapButton
+ var selectModeButton
+ var matchSettingsButton
+
+ var callsignCard
+
+ var spectatorLabel
+
+ var matchSettingsPanel
+
+ ComboStruct &lobbyComboStruct
+} file
+
+const table<asset> mapImages =
+{
+ mp_forwardbase_kodai = $"loadscreens/mp_forwardbase_kodai_lobby",
+ mp_grave = $"loadscreens/mp_grave_lobby",
+ mp_homestead = $"loadscreens/mp_homestead_lobby",
+ mp_thaw = $"loadscreens/mp_thaw_lobby",
+ mp_black_water_canal = $"loadscreens/mp_black_water_canal_lobby",
+ mp_eden = $"loadscreens/mp_eden_lobby",
+ mp_drydock = $"loadscreens/mp_drydock_lobby",
+ mp_crashsite3 = $"loadscreens/mp_crashsite3_lobby",
+ mp_complex3 = $"loadscreens/mp_complex3_lobby",
+ mp_angel_city = $"loadscreens/mp_angle_city_r2_lobby",
+ mp_colony02 = $"loadscreens/mp_colony02_lobby",
+ mp_glitch = $"loadscreens/mp_glitch_lobby",
+ mp_lf_stacks = $"loadscreens/mp_stacks_lobby",
+ mp_lf_meadow = $"loadscreens/mp_meadow_lobby",
+ mp_lf_deck = $"loadscreens/mp_lf_deck_lobby",
+ mp_lf_traffic = $"loadscreens/mp_lf_traffic_lobby",
+ mp_coliseum = $"loadscreens/mp_coliseum_lobby",
+ mp_coliseum_column = $"loadscreens/mp_coliseum_column_lobby",
+ mp_relic02 = $"loadscreens/mp_relic02_lobby",
+ mp_wargames = $"loadscreens/mp_wargames_lobby",
+ mp_rise = $"loadscreens/mp_rise_lobby",
+ mp_lf_township = $"loadscreens/mp_lf_township_lobby",
+ mp_lf_uma = $"loadscreens/mp_lf_uma_lobby",
+}
+
+void function MenuPrivateMatch_Init()
+{
+ PrecacheHUDMaterial( $"ui/menu/common/menu_background_neutral" )
+ PrecacheHUDMaterial( $"ui/menu/common/menu_background_imc" )
+ PrecacheHUDMaterial( $"ui/menu/common/menu_background_militia" )
+ PrecacheHUDMaterial( $"ui/menu/common/menu_background_imc_blur" )
+ PrecacheHUDMaterial( $"ui/menu/common/menu_background_militia_blur" )
+ PrecacheHUDMaterial( $"ui/menu/common/menu_background_neutral_blur" )
+ PrecacheHUDMaterial( $"ui/menu/common/menu_background_blackMarket" )
+ PrecacheHUDMaterial( $"ui/menu/rank_menus/ranked_FE_background" )
+
+ PrecacheHUDMaterial( $"ui/menu/lobby/friendly_slot" )
+ PrecacheHUDMaterial( $"ui/menu/lobby/friendly_player" )
+ PrecacheHUDMaterial( $"ui/menu/lobby/enemy_slot" )
+ PrecacheHUDMaterial( $"ui/menu/lobby/enemy_player" )
+ PrecacheHUDMaterial( $"ui/menu/lobby/neutral_slot" )
+ PrecacheHUDMaterial( $"ui/menu/lobby/neutral_player" )
+ PrecacheHUDMaterial( $"ui/menu/lobby/player_hover" )
+ PrecacheHUDMaterial( $"ui/menu/main_menu/motd_background" )
+ PrecacheHUDMaterial( $"ui/menu/main_menu/motd_background_happyhour" )
+
+ AddUICallback_OnLevelInit( OnPrivateLobbyLevelInit )
+}
+
+asset function GetMapImageForMapName( string mapName )
+{
+ if ( mapName in mapImages )
+ return mapImages[mapName]
+
+ return $""
+}
+
+
+void function InitPrivateMatchMenu()
+{
+ var menu = GetMenu( "PrivateLobbyMenu" )
+ file.menu = menu
+
+ AddMenuEventHandler( menu, eUIEvent.MENU_OPEN, OnPrivateMatchMenu_Open )
+ AddMenuEventHandler( menu, eUIEvent.MENU_CLOSE, OnLobbyMenu_Close )
+ AddMenuEventHandler( menu, eUIEvent.MENU_NAVIGATE_BACK, OnLobbyMenu_NavigateBack )
+
+ file.startMatchButton = Hud_GetChild( menu, "StartMatchButton" )
+ Hud_AddEventHandler( file.startMatchButton, UIE_CLICK, OnStartMatchButton_Activate )
+
+ RegisterUIVarChangeCallback( "privatematch_map", Privatematch_map_Changed )
+ RegisterUIVarChangeCallback( "privatematch_mode", Privatematch_mode_Changed )
+ RegisterUIVarChangeCallback( "privatematch_starting", Privatematch_starting_Changed )
+ RegisterUIVarChangeCallback( "gameStartTime", GameStartTime_Changed )
+
+ file.matchStatusRuis = GetElementsByClassnameForMenus( "MatchmakingStatusRui", uiGlobal.allMenus )
+ file.MMDevStringElems = GetElementsByClassnameForMenus( "MMDevStringClass", uiGlobal.allMenus )
+
+ file.friendlyPlayersPanel = Hud_GetChild( menu, "MatchFriendliesPanel" )
+ file.enemyPlayersPanel = Hud_GetChild( menu, "MatchEnemiesPanel" )
+
+ file.listFriendlies = Hud_GetChild( file.friendlyPlayersPanel, "ListFriendlies" )
+ file.listEnemies = Hud_GetChild( file.enemyPlayersPanel, "ListEnemies" )
+
+ file.friendlyTeamBackgroundPanel = Hud_GetChild( file.friendlyPlayersPanel, "LobbyFriendlyTeamBackground" )
+ file.enemyTeamBackgroundPanel = Hud_GetChild( file.enemyPlayersPanel, "LobbyEnemyTeamBackground" )
+
+#if PC_PROG
+ var panelSize = Hud_GetSize( file.enemyPlayersPanel )
+ Hud_SetSize( Hud_GetChild( menu, "LobbyChatBox" ), panelSize[0], panelSize[1] )
+#endif // #if PC_PROG
+
+ file.friendlyTeamBackground = Hud_GetChild( file.friendlyTeamBackgroundPanel, "TeamBackground" )
+ file.enemyTeamBackground = Hud_GetChild( file.enemyTeamBackgroundPanel, "TeamBackground" )
+
+ file.teamSlotBackgrounds = GetElementsByClassnameForMenus( "LobbyTeamSlotBackgroundClass", uiGlobal.allMenus )
+ file.teamSlotBackgroundsNeutral = GetElementsByClassnameForMenus( "LobbyTeamSlotBackgroundNeutralClass", uiGlobal.allMenus )
+
+ file.nextMapNameLabel = Hud_GetChild( menu, "NextMapName" )
+ file.nextGameModeLabel = Hud_GetChild( menu, "NextGameModeName" )
+
+ file.callsignCard = Hud_GetChild( menu, "CallsignCard" )
+
+ file.spectatorLabel = Hud_GetChild( menu, "SpectatorLabel" )
+
+ file.matchSettingsPanel = Hud_GetChild( menu, "MatchSettings" )
+
+ SetupComboButtons( menu, file.startMatchButton, file.listFriendlies )
+
+ AddMenuFooterOption( menu, BUTTON_A, "#A_BUTTON_SELECT", "" )
+ AddMenuFooterOption( menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" )
+
+ AddMenuFooterOption( menu, BUTTON_Y, "#Y_BUTTON_SWITCH_TEAMS", "#SWITCH_TEAMS", PCSwitchTeamsButton_Activate, CanSwitchTeams )
+ AddMenuFooterOption( menu, BUTTON_X, "#X_BUTTON_MUTE", "#MOUSE2_MUTE", null, CanMute )
+ AddMenuFooterOption( menu, BUTTON_SHOULDER_RIGHT, "#RB_TRIGGER_TOGGLE_SPECTATE", "#SPECTATE_TEAM", PCToggleSpectateButton_Activate, CanSwitchTeams )
+
+ AddMenuVarChangeHandler( "focus", UpdateFooterOptions )
+ AddMenuVarChangeHandler( "isFullyConnected", UpdateFooterOptions )
+ AddMenuVarChangeHandler( "isPartyLeader", UpdateFooterOptions )
+ AddMenuVarChangeHandler( "isPrivateMatch", UpdateFooterOptions )
+ #if DURANGO_PROG
+ AddMenuVarChangeHandler( "DURANGO_canInviteFriends", UpdateFooterOptions )
+ AddMenuVarChangeHandler( "DURANGO_isJoinable", UpdateFooterOptions )
+ AddMenuVarChangeHandler( "DURANGO_isGameFullyInstalled", UpdateFooterOptions )
+ #elseif PS4_PROG
+ AddMenuVarChangeHandler( "PS4_canInviteFriends", UpdateFooterOptions )
+ #elseif PC_PROG
+ AddMenuVarChangeHandler( "ORIGIN_isEnabled", UpdateFooterOptions )
+ AddMenuVarChangeHandler( "ORIGIN_isJoinable", UpdateFooterOptions )
+ #endif
+}
+
+
+void function OnSelectMapButton_Activate( var button )
+{
+ if ( Hud_IsLocked( button ) )
+ return
+
+ AdvanceMenu( GetMenu( "MapsMenu" ) )
+}
+
+void function OnSelectModeButton_Activate( var button )
+{
+ if ( Hud_IsLocked( button ) )
+ return
+
+ AdvanceMenu( GetMenu( "ModesMenu" ) )
+}
+
+void function OnSelectMatchSettings_Activate( var button )
+{
+ if ( Hud_IsLocked( button ) )
+ return
+
+ AdvanceMenu( GetMenu( "MatchSettingsMenu" ) )
+}
+
+void function SetupComboButtons( var menu, var navUpButton, var navDownButton )
+{
+ ComboStruct comboStruct = ComboButtons_Create( menu )
+ file.lobbyComboStruct = comboStruct
+
+ comboStruct.navUpButton = navUpButton
+ comboStruct.navDownButton = navDownButton
+
+ int headerIndex = 0
+ int buttonIndex = 0
+ file.playHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_PRIVATE_MATCH" )
+ var selectModeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_SELECT_MODE" )
+ file.selectModeButton = selectModeButton
+ Hud_AddEventHandler( selectModeButton, UIE_CLICK, OnSelectModeButton_Activate )
+ var selectMapButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_SELECT_MAP" )
+ file.selectMapButton = selectMapButton
+ Hud_AddEventHandler( selectMapButton, UIE_CLICK, OnSelectMapButton_Activate )
+
+ file.matchSettingsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_MATCH_SETTINGS" )
+ Hud_AddEventHandler( file.matchSettingsButton, UIE_CLICK, OnSelectMatchSettings_Activate )
+
+ var friendsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_INVITE_FRIENDS" )
+ file.inviteFriendsButton = friendsButton
+ Hud_AddEventHandler( friendsButton, UIE_CLICK, InviteFriendsIfAllowed )
+
+ headerIndex++
+ buttonIndex = 0
+ file.customizeHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_LOADOUTS" )
+ file.customizeHeaderIndex = headerIndex
+ var pilotButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_PILOT" )
+ file.pilotButton = pilotButton
+
+ Hud_AddEventHandler( pilotButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "EditPilotLoadoutsMenu" ) ) )
+ var titanButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_TITAN" )
+ file.titanButton = titanButton
+ Hud_AddEventHandler( titanButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "EditTitanLoadoutsMenu" ) ) )
+ file.boostsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_BOOSTS" )
+ Hud_AddEventHandler( file.boostsButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "BurnCardMenu" ) ) )
+ file.dpadCommsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_COMMS" )
+ Hud_AddEventHandler( file.dpadCommsButton, UIE_CLICK, OnDpadCommsButton_Activate )
+
+ headerIndex++
+ buttonIndex = 0
+ file.callsignHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_CALLSIGN" )
+ file.bannerButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_BANNER" )
+ Hud_AddEventHandler( file.bannerButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "CallsignCardSelectMenu" ) ) )
+ file.patchButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_PATCH" )
+ Hud_AddEventHandler( file.patchButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "CallsignIconSelectMenu" ) ) )
+ file.factionButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_FACTION" )
+ Hud_AddEventHandler( file.factionButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "FactionChoiceMenu" ) ) )
+ file.statsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_STATS" )
+ Hud_AddEventHandler( file.statsButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "ViewStatsMenu" ) ) )
+
+ file.callsignCard = Hud_GetChild( menu, "CallsignCard" )
+
+ headerIndex++
+ buttonIndex = 0
+ file.storeHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_STORE" )
+ file.storeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_STORE_BROWSE" )
+ Hud_AddEventHandler( file.storeButton, UIE_CLICK, OnStoreButton_Activate )
+ var storeNewReleasesButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_STORE_NEW_RELEASES" )
+ Hud_AddEventHandler( storeNewReleasesButton, UIE_CLICK, OnStoreNewReleasesButton_Activate )
+ var storeBundlesButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_STORE_BUNDLES" )
+ Hud_AddEventHandler( storeBundlesButton, UIE_CLICK, OnStoreBundlesButton_Activate )
+
+ headerIndex++
+ buttonIndex = 0
+ var settingsHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_SETTINGS" )
+ var controlsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_TITLE_CONTROLS" )
+ Hud_AddEventHandler( controlsButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "ControlsMenu" ) ) )
+ #if CONSOLE_PROG
+ var avButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#AUDIO_VIDEO" )
+ Hud_AddEventHandler( avButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "AudioVideoMenu" ) ) )
+ #elseif PC_PROG
+ var videoButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#AUDIO" )
+ Hud_AddEventHandler( videoButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "AudioMenu" ) ) )
+ var soundButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#VIDEO" )
+ Hud_AddEventHandler( soundButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "VideoMenu" ) ) )
+ #endif
+ var knbButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#KNB_MENU_HEADER" )
+ Hud_AddEventHandler( knbButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "KnowledgeBaseMenu" ) ) )
+
+ ComboButtons_Finalize( comboStruct )
+}
+
+
+bool function IsPlayerListFocused()
+{
+ var focusedItem = GetFocus()
+
+ // The check for GetScriptID existing isn't ideal, but if the text chat text output element has focus it will script error otherwise
+ return ( (focusedItem != null) && ("GetScriptID" in focusedItem) && (Hud_GetScriptID( focusedItem ) == "PlayerListButton") )
+}
+
+bool function MatchResultsExist()
+{
+ return true // TODO
+}
+
+bool function CanSwitchTeams()
+{
+ return ( GetMenuVarBool( "isPrivateMatch" ) && ( level.ui.privatematch_starting != ePrivateMatchStartState.STARTING ) )
+}
+
+bool function CanMute()
+{
+ return IsPlayerListFocused()
+}
+
+void function OnLobbyMenu_Open()
+{
+ Assert( IsConnected() )
+
+ UpdatePrivateMatchButtons()
+
+ thread UpdateLobbyUI()
+ thread LobbyMenuUpdate( GetMenu( "PrivateLobbyMenu" ) )
+
+ if ( uiGlobal.activeMenu == GetMenu( "PrivateLobbyMenu" ) )
+ UI_SetPresentationType( ePresentationType.NO_MODELS )
+
+ if ( IsFullyConnected() )
+ {
+ entity player = GetUIPlayer()
+ if ( !IsValid( player ) )
+ return
+
+ while ( player.GetPersistentVarAsInt( "initializedVersion" ) < PERSISTENCE_INIT_VERSION )
+ {
+ WaitFrame()
+ }
+
+ UpdateCallsignElement( file.callsignCard )
+ RefreshCreditsAvailable()
+
+ bool emotesAreEnabled = EmotesEnabled()
+ // "Customize"
+ {
+ bool anyNewPilotItems = HasAnyNewPilotItems( player )
+ bool anyNewTitanItems = HasAnyNewTitanItems( player )
+ bool anyNewBoosts = HasAnyNewBoosts( player )
+ bool anyNewCommsIcons = false // emotesAreEnabled ? HasAnyNewDpadCommsIcons( player ) : false
+ bool anyNewCustomizeHeader = (anyNewPilotItems || anyNewTitanItems || anyNewBoosts || anyNewCommsIcons)
+
+ RuiSetBool( Hud_GetRui( file.customizeHeader ), "isNew", anyNewCustomizeHeader )
+ ComboButton_SetNew( file.pilotButton, anyNewPilotItems )
+ ComboButton_SetNew( file.titanButton, anyNewTitanItems )
+ ComboButton_SetNew( file.boostsButton, anyNewBoosts )
+ ComboButton_SetNew( file.dpadCommsButton, anyNewCommsIcons )
+
+ if ( !emotesAreEnabled )
+ {
+ Hud_Hide( file.dpadCommsButton )
+ ComboButtons_ResetColumnFocus( file.lobbyComboStruct )
+ }
+ else
+ {
+ Hud_Show( file.dpadCommsButton )
+ }
+ }
+
+ // "Store"
+ {
+ bool storeIsNew = DLCStoreShouldBeMarkedAsNew()
+ RuiSetBool( Hud_GetRui( file.storeHeader ), "isNew", storeIsNew )
+ ComboButton_SetNew( file.storeButton, storeIsNew )
+ }
+
+ // "Callsign"
+ {
+ bool anyNewBanners = HasAnyNewCallsignBanners( player )
+ bool anyNewPatches = HasAnyNewCallsignPatches( player )
+ bool anyNewFactions = HasAnyNewFactions( player )
+ bool anyNewCallsignHeader = (anyNewBanners || anyNewPatches || anyNewFactions)
+
+ RuiSetBool( Hud_GetRui( file.callsignHeader ), "isNew", anyNewCallsignHeader )
+ ComboButton_SetNew( file.bannerButton, anyNewBanners )
+ ComboButton_SetNew( file.patchButton, anyNewPatches )
+ ComboButton_SetNew( file.factionButton, anyNewFactions )
+ }
+ }
+}
+
+void function LobbyMenuUpdate( var menu )
+{
+ EndSignal( uiGlobal.signalDummy, "CleanupInGameMenus" )
+
+ while ( GetTopNonDialogMenu() == menu )
+ {
+ WaitFrame()
+ }
+}
+
+
+
+void function OnLobbyMenu_Close()
+{
+ Signal( uiGlobal.signalDummy, "OnCloseLobbyMenu" )
+}
+
+void function OnLobbyMenu_NavigateBack()
+{
+ LeaveDialog()
+}
+
+function GameStartTime_Changed()
+{
+ printt( "GameStartTime_Changed", level.ui.gameStartTime )
+ UpdateGameStartTimeCounter()
+}
+
+function UpdateGameStartTimeCounter()
+{
+ if ( level.ui.gameStartTime == null )
+ {
+ MatchmakingSetSearchText( "" )
+ MatchmakingSetCountdownTimer( 0.0 )
+ HideMatchmakingStatusIcons()
+ return
+ }
+
+ MatchmakingSetSearchText( "#STARTING_IN_LOBBY" )
+ MatchmakingSetCountdownTimer( expect float( level.ui.gameStartTime + 0.0 ) )
+ ShowMatchmakingStatusIcons()
+}
+
+function UpdateDebugStatus()
+{
+ EndSignal( uiGlobal.signalDummy, "CleanupInGameMenus" )
+
+ OnThreadEnd(
+ function() : ()
+ {
+ foreach ( elem in file.MMDevStringElems )
+ Hud_Hide( elem )
+ }
+ )
+
+ foreach ( elem in file.MMDevStringElems )
+ Hud_Show( elem )
+
+ while ( true )
+ {
+ local strstr = GetLobbyDevString()
+ foreach ( elem in file.MMDevStringElems )
+ Hud_SetText( elem, strstr )
+
+ WaitFrameOrUntilLevelLoaded()
+ }
+}
+
+void function SetMapInfo( string mapName )
+{
+ var nextMapImage = Hud_GetChild( file.menu, "NextMapImage" )
+
+ asset mapImage = GetMapImageForMapName( mapName )
+ RuiSetImage( Hud_GetRui( nextMapImage ), "basicImage", mapImage )
+ Hud_Show( nextMapImage )
+
+ Hud_SetText( file.nextMapNameLabel, GetMapDisplayName( mapName ) )
+}
+
+void function SetModeInfo( string modeName )
+{
+ var nextModeIcon = Hud_GetChild( file.menu, "NextModeIcon" )
+ RuiSetImage( Hud_GetRui( nextModeIcon ), "basicImage", GetPlaylistThumbnailImage( modeName ) )
+ Hud_Show( nextModeIcon )
+
+ Hud_SetText( file.nextGameModeLabel, GetGameModeDisplayName( modeName ) )
+}
+
+function Privatematch_map_Changed()
+{
+ if ( !IsPrivateMatch() )
+ return
+ if ( !IsLobby() )
+ return
+
+ string mapName = PrivateMatch_GetSelectedMap()
+ SetMapInfo( mapName )
+}
+
+function Privatematch_mode_Changed()
+{
+ if ( !IsPrivateMatch() )
+ return
+ if ( !IsLobby() )
+ return
+
+ string modeName = PrivateMatch_GetSelectedMode()
+ SetModeInfo( modeName )
+
+ UpdatePrivateMatchButtons()
+ UpdateMatchSettingsForGamemode()
+}
+
+
+function Privatematch_starting_Changed()
+{
+ if ( !IsPrivateMatch() )
+ return
+ if ( !IsLobby() )
+ return
+
+ UpdatePrivateMatchButtons()
+ UpdateFooterOptions()
+}
+
+
+function UpdatePrivateMatchButtons()
+{
+ var menu = file.menu
+
+ if ( level.ui.privatematch_starting == ePrivateMatchStartState.STARTING )
+ {
+ RHud_SetText( file.startMatchButton, "#STOP_MATCH" )
+ Hud_SetLocked( file.selectMapButton, true )
+ Hud_SetLocked( file.selectModeButton, true )
+ Hud_SetLocked( file.matchSettingsButton, true )
+ Hud_SetLocked( file.inviteFriendsButton, true )
+ }
+ else
+ {
+ RHud_SetText( file.startMatchButton, "#START_MATCH" )
+ Hud_SetLocked( file.selectMapButton, false )
+ Hud_SetLocked( file.selectModeButton, false )
+ Hud_SetLocked( file.inviteFriendsButton, false )
+
+ string modeName = PrivateMatch_GetSelectedMode()
+ bool settingsLocked = IsFDMode( modeName )
+
+ if ( settingsLocked && uiGlobal.activeMenu == GetMenu( "MatchSettingsMenu" ) )
+ CloseActiveMenu()
+
+ Hud_SetLocked( file.matchSettingsButton, settingsLocked )
+ }
+}
+
+function UpdateLobbyUI()
+{
+ if ( uiGlobal.updatingLobbyUI )
+ return
+ uiGlobal.updatingLobbyUI = true
+
+ thread UpdateLobby()
+ thread UpdateDebugStatus()
+ thread UpdatePlayerInfo()
+
+ if ( uiGlobal.EOGOpenInLobby )
+ EOGOpen()
+
+ WaitSignal( uiGlobal.signalDummy, "CleanupInGameMenus" )
+ uiGlobal.updatingLobbyUI = false
+}
+
+function UpdateLobby()
+{
+ EndSignal( uiGlobal.signalDummy, "CleanupInGameMenus" )
+
+ var menu = file.menu
+
+ WaitFrameOrUntilLevelLoaded()
+
+ while ( true )
+ {
+ if ( !IsConnected() )
+ {
+ WaitFrameOrUntilLevelLoaded()
+ continue
+ }
+
+ menu.RunAnimationScript( "PrivateMatchLobby" )
+ // Force the animation scripts (which have zero duration) to complete before anything can cancel them.
+ ForceUpdateHUDAnimations()
+
+ UpdatePrivateMatchButtons()
+
+ int gamemodeIdx = expect int( level.ui.privatematch_mode )
+ int numPlaylistOverrides = GetPlaylistVarOverridesCount()
+ string playlistOverridesDesc = ""
+ for ( int varIdx = 0; varIdx < numPlaylistOverrides; ++varIdx )
+ {
+ // temp fix for playlistoverrides that aren't handled by private match
+ string varName = GetPlaylistVarOverrideNameByIndex( varIdx )
+
+ if ( varName in MatchSettings_PlaylistVarLabels )
+ {
+ float varOrigVal = float( GetCurrentPlaylistGamemodeByIndexVar( gamemodeIdx, varName, false ) )
+ float varOverrideVal = float( GetCurrentPlaylistGamemodeByIndexVar( gamemodeIdx, varName, true ) )
+ if ( varOrigVal == varOverrideVal )
+ continue
+
+ string label = Localize( MatchSettings_PlaylistVarLabels[varName] ) + ": "
+ string value = MatchSettings_FormatPlaylistVarValue( varName, varOverrideVal )
+ playlistOverridesDesc = playlistOverridesDesc + label + "`2" + value + " `0\n"
+ }
+ }
+
+ if ( playlistOverridesDesc.len() )
+ {
+ RuiSetString( Hud_GetRui( file.matchSettingsPanel ), "description", playlistOverridesDesc )
+ Hud_Show( file.matchSettingsPanel )
+ }
+ else
+ {
+ Hud_Hide( file.matchSettingsPanel )
+ }
+
+ if ( GetUIPlayer() && GetPersistentVar( "privateMatchState" ) == 1 )
+ Hud_SetVisible( file.spectatorLabel, true )
+ else
+ Hud_SetVisible( file.spectatorLabel, false )
+
+ WaitFrameOrUntilLevelLoaded()
+ }
+}
+
+void function OnSettingsButton_Activate( var button )
+{
+ if ( level.ui.privatematch_starting == ePrivateMatchStartState.STARTING )
+ return
+
+ AdvanceMenu( GetMenu( "MatchSettingsMenu" ) )
+}
+
+
+void function OnPrivateMatchButton_Activate( var button )
+{
+ ShowPrivateMatchConnectDialog()
+ ClientCommand( "match_playlist private_match" )
+ ClientCommand( "StartPrivateMatchSearch" )
+}
+
+void function OnStartMatchButton_Activate( var button )
+{
+ if ( AmIPartyLeader() || GetPartySize() == 1 )
+ ClientCommand( "PrivateMatchLaunch" )
+}
+
+function HandleLockedCustomMenuItem( menu, button, tipInfo, hideTip = false )
+{
+ array<var> elements = GetElementsByClassname( menu, "HideWhenLocked" )
+ var buttonTooltip = Hud_GetChild( menu, "ButtonTooltip" )
+ var toolTipLabel = Hud_GetChild( buttonTooltip, "Label" )
+
+ if ( Hud_IsLocked( button ) && !hideTip )
+ {
+ foreach( elem in elements )
+ Hud_Hide( elem )
+
+ local tipArray = clone tipInfo
+ tipInfo.resize( 6, null )
+
+ Hud_SetText( toolTipLabel, tipInfo[0], tipInfo[1], tipInfo[2], tipInfo[3], tipInfo[4], tipInfo[5] )
+
+ local buttonPos = button.GetAbsPos()
+ local buttonHeight = button.GetHeight()
+ local tooltipHeight = buttonTooltip.GetHeight()
+ local yOffset = ( tooltipHeight - buttonHeight ) / 2.0
+
+ buttonTooltip.SetPos( buttonPos[0] + button.GetWidth() * 0.9, buttonPos[1] - yOffset )
+ Hud_Show( buttonTooltip )
+
+ return true
+ }
+ else
+ {
+ foreach( elem in elements )
+ Hud_Show( elem )
+ Hud_Hide( buttonTooltip )
+ }
+ return false
+}
+
+void function PrivateMatchSwitchTeams( button )
+{
+ if ( !IsPrivateMatch() )
+ return
+
+ if ( !IsConnected() )
+ return
+
+ if ( uiGlobal.activeMenu != file.menu )
+ return
+
+ EmitUISound( "Menu_GameSummary_ScreenSlideIn" )
+
+ ClientCommand( "PrivateMatchSwitchTeams" )
+}
+
+void function HideMatchmakingStatusIcons()
+{
+ foreach ( element in file.matchStatusRuis )
+ RuiSetBool( Hud_GetRui( element ), "iconVisible", false )
+}
+
+void function ShowMatchmakingStatusIcons()
+{
+ foreach ( element in file.matchStatusRuis )
+ RuiSetBool( Hud_GetRui( element ), "iconVisible", true )
+}
+
+void function MatchmakingSetSearchText( string searchText, var param1 = "", var param2 = "", var param3 = "", var param4 = "" )
+{
+ foreach ( element in file.matchStatusRuis )
+ {
+ RuiSetBool( Hud_GetRui( element ), "statusHasText", searchText != "" )
+
+ RuiSetString( Hud_GetRui( element ), "statusText", Localize( searchText, param1, param2, param3, param4 ) )
+ }
+}
+
+
+void function MatchmakingSetCountdownTimer( float time )
+{
+ foreach ( element in file.matchStatusRuis )
+ {
+ RuiSetBool( Hud_GetRui( element ), "timerHasText", time != 0.0 )
+ RuiSetGameTime( Hud_GetRui( element ), "timerEndTime", time )
+ }
+}
+
+
+void function OnPrivateLobbyLevelInit()
+{
+ UpdateCallsignElement( file.callsignCard )
+ RefreshCreditsAvailable()
+}
+
+
+function UpdatePlayerInfo()
+{
+ EndSignal( uiGlobal.signalDummy, "CleanupInGameMenus" )
+
+ var menu = file.menu
+
+ WaitFrameOrUntilLevelLoaded()
+
+ while ( true )
+ {
+ RefreshCreditsAvailable()
+ WaitFrame()
+ }
+}
+
+void function OnPrivateMatchMenu_Open()
+{
+ Lobby_SetFDMode( false )
+ OnLobbyMenu_Open()
+} \ No newline at end of file
diff --git a/Northstar.Client/scripts/vscripts/ui/panel_mainmenu.nut b/Northstar.Client/scripts/vscripts/ui/panel_mainmenu.nut
new file mode 100644
index 00000000..49c71bc5
--- /dev/null
+++ b/Northstar.Client/scripts/vscripts/ui/panel_mainmenu.nut
@@ -0,0 +1,829 @@
+untyped
+
+global function InitMainMenuPanel
+global function UpdatePromoData
+
+global function UICodeCallback_GetOnPartyServer
+global function UICodeCallback_MainMenuPromosUpdated
+
+struct
+{
+ var menu
+ var panel
+ array<var> spButtons
+ array<void functionref()> spButtonFuncs
+ var mpButton
+ var fdButton
+ void functionref() mpButtonActivateFunc = null
+ var buttonData
+ array<var> menuButtons
+ var activeProfile
+ var serviceStatus
+
+ MainMenuPromos& promoData
+ var whatsNew
+ var spotlightPanel
+ array<var> spotlightButtons
+
+ bool installing = false
+} file
+
+const DEBUG_PERMISSIONS = false
+
+void function InitMainMenuPanel()
+{
+ RegisterSignal( "EndShowMainMenuPanel" )
+
+ file.panel = GetPanel( "MainMenuPanel" )
+ file.menu = GetParentMenu( file.panel )
+
+ AddPanelEventHandler( file.panel, eUIEvent.PANEL_SHOW, OnShowMainMenuPanel )
+ AddPanelEventHandler( file.panel, eUIEvent.PANEL_HIDE, OnHideMainMenuPanel )
+
+ file.menuButtons = GetElementsByClassname( file.menu, "MainMenuButtonClass" )
+ AddEventHandlerToButtonClass( file.menu, "MainMenuButtonClass", UIE_CLICK, MainMenuButton_Activate )
+
+ file.spotlightPanel = Hud_GetChild( file.panel, "SpotlightPanel" )
+ file.spotlightButtons = GetElementsByClassname( file.menu, "SpotlightButtonClass" )
+ foreach ( button in file.spotlightButtons )
+ button.s.link <- ""
+ AddEventHandlerToButtonClass( file.menu, "SpotlightButtonClass", UIE_CLICK, SpotlightButton_Activate )
+
+ file.activeProfile = Hud_GetChild( file.panel, "ActiveProfile" )
+ file.serviceStatus = Hud_GetRui( Hud_GetChild( file.panel, "ServiceStatus" ) )
+ file.whatsNew = Hud_GetRui( Hud_GetChild( file.panel, "WhatsNew" ) )
+
+ ComboStruct comboStruct = ComboButtons_Create( file.panel )
+
+ int headerIndex = 0
+ int buttonIndex = 0
+ var campaignHeader = AddComboButtonHeader( comboStruct, headerIndex, "#GAMEMODE_SOLO" )
+ file.spButtons.append( AddComboButton( comboStruct, headerIndex, buttonIndex, "" ) )
+ file.spButtonFuncs.append( DoNothing() )
+ Hud_AddEventHandler( file.spButtons[buttonIndex], UIE_CLICK, RunSPButton0 )
+ buttonIndex++
+ file.spButtons.append( AddComboButton( comboStruct, headerIndex, buttonIndex, "" ) )
+ file.spButtonFuncs.append( DoNothing() )
+ Hud_AddEventHandler( file.spButtons[buttonIndex], UIE_CLICK, RunSPButton1 )
+ buttonIndex++
+ file.spButtons.append( AddComboButton( comboStruct, headerIndex, buttonIndex, "" ) )
+ file.spButtonFuncs.append( DoNothing() )
+ Hud_AddEventHandler( file.spButtons[buttonIndex], UIE_CLICK, RunSPButton2 )
+ buttonIndex++
+ UpdateSPButtons()
+
+ headerIndex++
+ buttonIndex = 0
+ var multiplayerHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MULTIPLAYER_ALLCAPS" )
+ file.mpButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MULTIPLAYER_LAUNCH" )
+ Hud_AddEventHandler( file.mpButton, UIE_CLICK, OnPlayMPButton_Activate )
+ file.fdButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#GAMEMODE_COOP" )
+ Hud_AddEventHandler( file.fdButton, UIE_CLICK, OnPlayFDButton_Activate )
+
+ headerIndex++
+ buttonIndex = 0
+ var settingsHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_SETTINGS" )
+ var controlsButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#CONTROLS" )
+ Hud_AddEventHandler( controlsButton, UIE_CLICK, ActivateControlsMenu )
+ #if CONSOLE_PROG
+ var avButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#AUDIO_VIDEO" )
+ Hud_AddEventHandler( avButton, UIE_CLICK, ActivateAudioVisualMenu )
+ #elseif PC_PROG
+ var audioButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#AUDIO" )
+ Hud_AddEventHandler( audioButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "AudioMenu" ) ) )
+ var videoButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#VIDEO" )
+ Hud_AddEventHandler( videoButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "VideoMenu" ) ) )
+ #endif
+
+ var spotlightLargeButton = Hud_GetChild( file.spotlightPanel, "SpotlightLarge" )
+ spotlightLargeButton.SetNavLeft( file.spButtons[0] )
+
+ var spotlightSmall0Button = Hud_GetChild( file.spotlightPanel, "SpotlightSmall0" )
+ spotlightSmall0Button.SetNavLeft( file.spButtons[0] )
+
+ file.buttonData = []
+
+ #if PC_PROG
+ file.buttonData.append( { name = "#QUIT", activateFunc = OnQuitButton_Activate } )
+ #endif // PC_PROG
+
+ if ( file.buttonData.len() )
+ {
+ comboStruct.navUpButton = file.menuButtons[ expect int( file.buttonData.len() ) - 1 ]
+ comboStruct.navDownButton = file.menuButtons[0]
+
+ foreach ( button in file.menuButtons )
+ button.SetNavRight( spotlightLargeButton )
+ }
+
+ comboStruct.navRightButton = spotlightLargeButton
+
+ ComboButtons_Finalize( comboStruct )
+
+ //AddPanelFooterOption( file.panel, BUTTON_A, "#A_BUTTON_SELECT" )
+ //AddPanelFooterOption( file.panel, BUTTON_B, "#B_BUTTON_CLOSE", "#CLOSE" )
+ //AddPanelFooterOption( file.panel, BUTTON_BACK, "", "", ClosePostGameMenu )
+
+ thread TrackInstallProgress()
+}
+
+void function OnShowMainMenuPanel()
+{
+ Signal( uiGlobal.signalDummy, "EndShowMainMenuPanel" )
+ EndSignal( uiGlobal.signalDummy, "EndShowMainMenuPanel" )
+
+ foreach ( button in file.menuButtons )
+ {
+ int buttonID = int( Hud_GetScriptID( button ) )
+
+ if ( buttonID < file.buttonData.len() )
+ {
+ if ( "updateFunc" in file.buttonData[buttonID] )
+ file.buttonData[buttonID].updateFunc.call( this, button )
+ else
+ Hud_SetEnabled( button, true )
+
+ RuiSetString( Hud_GetRui( button ), "buttonText", file.buttonData[buttonID].name )
+ Hud_Show( button )
+ }
+ else
+ {
+ Hud_Hide( button )
+ }
+ }
+
+ #if PS4_PROG
+ thread EnableCheckPlus()
+ #endif // PS4_PROG
+
+ UpdateSPButtons()
+ thread UpdatePlayButton( file.mpButton )
+ thread MonitorTrialVersionChange()
+
+ #if DURANGO_PROG
+ SetLabelRuiText( file.activeProfile, Durango_GetGameDisplayName() )
+ Hud_Show( file.activeProfile )
+ #endif // DURANGO_PROG
+
+ ExecCurrentGamepadButtonConfig()
+ ExecCurrentGamepadStickConfig()
+
+
+ string defaultButtonRowFocus = "ButtonRow0x0"
+ bool shouldFocusMultiplayer = GetMenuWasMultiplayerPlayedLast()
+ if ( shouldFocusMultiplayer )
+ defaultButtonRowFocus = "ButtonRow1x0"
+
+ SetPanelDefaultFocus( file.panel, Hud_GetChild( file.panel, defaultButtonRowFocus ) )
+ PanelFocusDefault( file.panel )
+}
+
+void function EnableCheckPlus()
+{
+ WaitFrame() // ???: doesn't work without a wait
+ if ( !Ps4_CheckPlus_Allowed() && !IsSingleplayer() )
+ {
+ printt( "scheduling plus check" )
+ Ps4_CheckPlus_Schedule()
+ }
+}
+
+void function OnHideMainMenuPanel()
+{
+ Signal( uiGlobal.signalDummy, "EndShowMainMenuPanel" )
+}
+
+void function UpdatePlayButton( var button )
+{
+ #if CONSOLE_PROG
+ bool isOnline
+ bool hasPermission
+ bool isFullyInstalled
+ #endif
+
+ #if DURANGO_PROG
+ bool isGuest
+ #elseif PS4_PROG
+ bool isPSNConnected
+ bool isOverAge
+ bool hasPlus
+ bool hasLatestPatch
+ #elseif PC_PROG
+ bool isOriginConnected
+ bool hasLatestPatch
+ #endif
+
+ bool isStryderAuthenticated
+ bool isMPAllowed
+ bool isLocked
+ string buttonText
+ string message
+ bool isMessageVisible
+
+ while ( GetTopNonDialogMenu() == file.menu )
+ {
+ bool isSpotlightReady = file.promoData.version != 0 ? true : false
+ Hud_SetVisible( file.spotlightPanel, isSpotlightReady )
+
+ if ( !Hud_IsFocused( button ) )
+ {
+ RuiSetBool( file.serviceStatus, "isVisible", false )
+ WaitFrame()
+ continue
+ }
+
+ #if DURANGO_PROG
+ isFullyInstalled = IsGameFullyInstalled()
+ isOnline = Console_IsOnline()
+ isGuest = Durango_IsGuest()
+ hasPermission = Console_HasPermissionToPlayMultiplayer()
+ isStryderAuthenticated = IsStryderAuthenticated()
+ isMPAllowed = IsStryderAllowingMP()
+
+ if ( DEBUG_PERMISSIONS )
+ {
+ printt( "isFullyInstalled:", isFullyInstalled )
+ printt( "isOnline:", isOnline )
+ printt( "isGuest:", isGuest )
+ printt( "hasPermission:", hasPermission )
+ printt( "isStryderAuthenticated:", isStryderAuthenticated )
+ printt( "isMPAllowedByStryder:", isMPAllowed )
+ }
+
+ buttonText = "#MULTIPLAYER_LAUNCH"
+ message = ""
+
+ if ( !isOnline )
+ {
+ message = "#INTERNET_NOT_FOUND"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( isGuest )
+ {
+ buttonText = "#SWITCH_PROFILE"
+ message = "#GUESTS_NOT_SUPPORTED"
+ file.mpButtonActivateFunc = XB1_SwitchAccount
+ }
+ else if ( !hasPermission || !isMPAllowed )
+ {
+ message = "#MULTIPLAYER_NOT_AVAILABLE"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( !isStryderAuthenticated )
+ {
+ message = "#CONTACTING_RESPAWN_SERVERS"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( !isFullyInstalled )
+ {
+ //message = "#INSTALL_IN_PROGRESS"
+ file.mpButtonActivateFunc = LaunchMP
+ }
+ else
+ {
+ file.mpButtonActivateFunc = LaunchMP
+ }
+
+ isLocked = file.mpButtonActivateFunc == null ? true : false
+ Hud_SetLocked( button, isLocked )
+
+ #elseif PS4_PROG
+
+ isFullyInstalled = IsGameFullyInstalled()
+ hasLatestPatch = HasLatestPatch()
+ isOnline = Console_IsOnline()
+ isPSNConnected = Ps4_PSN_Is_Loggedin()
+ hasPermission = Console_HasPermissionToPlayMultiplayer()
+ isOverAge = !PS4_is_NetworkStatusAgeRestriction()
+ hasPlus = Ps4_CheckPlus_Allowed()
+ isStryderAuthenticated = IsStryderAuthenticated()
+ isMPAllowed = IsStryderAllowingMP()
+
+ if ( DEBUG_PERMISSIONS )
+ {
+ printt( "isFullyInstalled:", isFullyInstalled )
+ printt( "hasLatestPatch:", hasLatestPatch )
+ printt( "isOnline:", isOnline )
+ printt( "isPSNConnected:", isPSNConnected )
+ printt( "hasPermission:", hasPermission )
+ printt( "isOverAge:", isOverAge )
+ printt( "hasPlus:", hasPlus )
+ printt( "isStryderAuthenticated:", isStryderAuthenticated )
+ printt( "isMPAllowedByStryder:", isMPAllowed )
+ }
+
+ buttonText = "#MULTIPLAYER_LAUNCH"
+ message = ""
+
+ if ( !isOnline )
+ {
+ message = "#INTERNET_NOT_FOUND"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( PS4_getUserNetworkingResolution() == PS4_NETWORK_STATUS_UNKNOWN )
+ {
+ message = "#INTERNET_NOT_FOUND"
+ file.mpButtonActivateFunc = LaunchMP
+ }
+ else if ( !hasLatestPatch )
+ {
+ message = "#UPDATE_AVAILABLE"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( PS4_getUserNetworkingResolution() == PS4_NETWORK_STATUS_IN_ERROR )
+ {
+ message = "#PSN_HAD_ERROR"
+ file.mpButtonActivateFunc = LaunchMP
+ }
+ else if ( !isPSNConnected )
+ {
+ buttonText = "#PS4_SIGN_IN"
+ message = "#PS4_DISCONNECT_NOT_SIGNED_IN_TO_PSN"
+ file.mpButtonActivateFunc = PS4_PSNSignIn
+ }
+ else if ( !isFullyInstalled )
+ {
+ //message = "#INSTALL_IN_PROGRESS"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( !isOverAge )
+ {
+ message = "#MULTIPLAYER_AGE_RESTRICTED"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( !hasPermission || !isMPAllowed ) // A more general permission check. Can fail if not patched, underage profile logged in to another controller, network issue, etc.
+ {
+ message = "#MULTIPLAYER_NOT_AVAILABLE"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( !hasPlus )
+ {
+ //buttonText = "#PS4_GET_PLAYSTATION_PLUS"
+ //message = "#PSN_MUST_BE_PLUS_USER"
+ //file.mpButtonActivateFunc = PS4_PlusSignUp
+ // Their is a race on this. The function may not be completed.
+
+
+ // The LaunchMP handles this race and will retry/ issue an error dialog if needed.
+ file.mpButtonActivateFunc = LaunchMP
+ }
+ else if ( !isStryderAuthenticated )
+ {
+ message = "#CONTACTING_RESPAWN_SERVERS"
+ file.mpButtonActivateFunc = null
+ }
+ else
+ {
+ file.mpButtonActivateFunc = LaunchMP
+ }
+
+ isLocked = file.mpButtonActivateFunc == null ? true : false
+ Hud_SetLocked( button, isLocked )
+
+ #elseif PC_PROG
+
+ hasLatestPatch = Origin_IsUpToDate()
+ isOriginConnected = Origin_IsEnabled() ? Origin_IsOnline() : true
+ isStryderAuthenticated = IsStryderAuthenticated()
+ isMPAllowed = IsStryderAllowingMP()
+
+ if ( DEBUG_PERMISSIONS )
+ {
+ printt( "isOriginConnected:", isOriginConnected )
+ printt( "isStryderAuthenticated:", isStryderAuthenticated )
+ }
+
+ buttonText = "#MULTIPLAYER_LAUNCH"
+ message = ""
+
+ if ( !isOriginConnected )
+ {
+ message = "#ORIGIN_IS_OFFLINE"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( !isStryderAuthenticated )
+ {
+ message = "#CONTACTING_RESPAWN_SERVERS"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( !isMPAllowed )
+ {
+ message = "#MULTIPLAYER_NOT_AVAILABLE"
+ file.mpButtonActivateFunc = null
+ }
+ else if ( !hasLatestPatch )
+ {
+ message = "#ORIGIN_UPDATE_AVAILABLE"
+ file.mpButtonActivateFunc = null
+ }
+ else
+ {
+ file.mpButtonActivateFunc = LaunchMP
+ }
+
+ isLocked = file.mpButtonActivateFunc == null ? true : false
+ Hud_SetLocked( button, isLocked )
+ #endif
+
+ if ( Script_IsRunningTrialVersion() && !IsTrialPeriodActive() && file.mpButtonActivateFunc != LaunchGamePurchase )
+ {
+ buttonText = "#MENU_GET_THE_FULL_GAME"
+ file.mpButtonActivateFunc = LaunchGamePurchase
+ Hud_SetLocked( button, false )
+ message = ""
+ }
+
+ ComboButton_SetText( file.mpButton, buttonText )
+
+ //if ( Hud_IsLocked( button ) || buttonText == "#MENU_GET_THE_FULL_GAME" )
+ //{
+ // ComboButton_SetText( file.fdButton, "" )
+ // Hud_SetEnabled( file.fdButton, false )
+ //}
+ //else
+ //{
+ //ComboButton_SetText( file.fdButton, "#MULTIPLAYER_LAUNCH_FD" )
+ ComboButton_SetText( file.fdButton, "Launch Northstar" ) // this needs to use localised text at some point when we have a modular way of doing that
+ Hud_SetEnabled( file.fdButton, true )
+ //}
+
+ if ( file.installing )
+ message = ""
+ else if ( message == "" )
+ message = GetConVarString( "rspn_motd" )
+
+ RuiSetString( file.serviceStatus, "messageText", message )
+
+ isMessageVisible = message != "" ? true : false
+ RuiSetBool( file.serviceStatus, "isVisible", isMessageVisible )
+
+ WaitFrame()
+ //wait 2
+ }
+}
+
+void function XB1_SwitchAccount()
+{
+ Durango_ShowAccountPicker()
+}
+
+void function PS4_PSNSignIn()
+{
+ Ps4_LoginDialog_Schedule()
+}
+
+void function PS4_PlusSignUp()
+{
+ if ( Ps4_ScreenPlusDialog_Schedule() )
+ {
+ while ( Ps4_ScreenPlusDialog_Running() )
+ WaitFrame()
+
+ if ( Ps4_ScreenPlusDialog_Allowed() )
+ Ps4_CheckPlus_Schedule()
+ }
+}
+
+void function MainMenuButton_Activate( var button )
+{
+ int buttonID = int( Hud_GetScriptID( button ) )
+
+ Assert( file.buttonData )
+
+ if ( file.buttonData[buttonID].activateFunc )
+ file.buttonData[buttonID].activateFunc.call( this )
+}
+
+void function OnPlayFDButton_Activate( var button ) // repurposed for launching northstar lobby
+{
+ //if ( file.mpButtonActivateFunc == null )
+ // printt( "file.mpButtonActivateFunc is null" )
+
+ if ( !Hud_IsLocked( button ) )// && file.mpButtonActivateFunc != null )
+ {
+ //Lobby_SetAutoFDOpen( true )
+ //// Lobby_SetFDMode( true )
+ //thread file.mpButtonActivateFunc()
+
+ ClientCommand( "everything_unlocked 1" ) // todo super temp, need this removed when server autoexecs are good
+ ClientCommand( "map mp_lobby" )
+ }
+}
+
+void function OnPlayMPButton_Activate( var button )
+{
+ if ( file.mpButtonActivateFunc == null )
+ printt( "file.mpButtonActivateFunc is null" )
+
+ if ( !Hud_IsLocked( button ) && file.mpButtonActivateFunc != null )
+ {
+ Lobby_SetAutoFDOpen( false )
+ // Lobby_SetFDMode( false )
+ thread file.mpButtonActivateFunc()
+ }
+}
+
+void function UICodeCallback_GetOnPartyServer()
+{
+ uiGlobal.launching = eLaunching.MULTIPLAYER_INVITE
+ Lobby_SetAutoFDOpen( false )
+ // Lobby_SetFDMode( false )
+ LaunchGame()
+}
+
+#if PC_PROG
+void function OnQuitButton_Activate()
+{
+ DialogData dialogData
+ dialogData.header = "#MENU_QUIT_GAME_CONFIRM"
+
+ AddDialogButton( dialogData, "#CANCEL" )
+ AddDialogButton( dialogData, "#QUIT", Quit )
+
+ AddDialogFooter( dialogData, "#A_BUTTON_SELECT" )
+ AddDialogFooter( dialogData, "#B_BUTTON_CANCEL" )
+
+ OpenDialog( dialogData )
+}
+
+void function Quit()
+{
+ ClientCommand( "quit" )
+}
+#endif // #if PC_PROG
+
+void function MonitorTrialVersionChange()
+{
+ bool isTrialVersion
+ bool lastIsTrialVersion = Script_IsRunningTrialVersion()
+
+ while ( GetTopNonDialogMenu() == file.menu )
+ {
+ isTrialVersion = Script_IsRunningTrialVersion()
+
+ if ( isTrialVersion != lastIsTrialVersion )
+ UpdateSPButtons()
+
+ lastIsTrialVersion = isTrialVersion
+
+ WaitFrame()
+ }
+}
+
+void function UpdateSPButtons()
+{
+ foreach( button in file.spButtons )
+ {
+ ComboButton_SetText( button, "" )
+ Hud_SetEnabled( button, false )
+ }
+
+ int buttonIndex = 0
+
+ if ( Script_IsRunningTrialVersion() )
+ {
+ if ( HasStartedGameEver() )
+ AddSPButton( buttonIndex, TrainingModeSelect, "#SP_TRIAL_MENU_TRAINING" )
+ else
+ AddSPButton( buttonIndex, LaunchSPNew, "#SP_TRIAL_MENU_TRAINING" )
+ buttonIndex++
+
+ if ( HasStartedGameEver() )
+ {
+ AddSPButton( buttonIndex, TrialMissionSelect, "#SP_TRIAL_MENU_MISSION" )
+ buttonIndex++
+ }
+
+ AddSPButton( buttonIndex, LaunchGamePurchase, "#MENU_GET_THE_FULL_GAME" )
+ buttonIndex++
+ }
+ else
+ {
+ if ( HasValidSaveGame() )
+ {
+ AddSPButton( buttonIndex, LaunchSPContinue, "#MENU_CONTINUE_GAME" )
+ buttonIndex++
+ }
+
+ if ( HasStartedGameEver() )
+ {
+ AddSPButton( buttonIndex, LaunchSPMissionSelect, "#MENU_MISSION_SELECT" )
+ buttonIndex++
+ }
+
+ AddSPButton( buttonIndex, LaunchSPNew, "#MENU_NEW_GAME" )
+ }
+}
+
+void function AddSPButton( int index, void functionref() func, string text )
+{
+ var button = file.spButtons[ index ]
+ ComboButton_SetText( button, text )
+ Hud_SetEnabled( button, true )
+ file.spButtonFuncs[ index ] = func
+}
+
+void function DoNothing()
+{
+}
+
+void function RunSPButton0( var button )
+{
+ void functionref() func = file.spButtonFuncs[ 0 ]
+ func()
+}
+
+void function RunSPButton1( var button )
+{
+ void functionref() func = file.spButtonFuncs[ 1 ]
+ func()
+}
+
+void function RunSPButton2( var button )
+{
+ void functionref() func = file.spButtonFuncs[ 2 ]
+ func()
+}
+
+void function ActivateControlsMenu( var button )
+{
+ #if CONSOLE_PROG
+ if ( GetEULAVersionAccepted() < 1 ) // Treat as binary for now, as discussed with Preston.
+ {
+ if ( uiGlobal.activeMenu == GetMenu( "EULADialog" ) )
+ return
+
+ if ( IsDialog( uiGlobal.activeMenu ) )
+ CloseActiveMenu( true )
+
+ uiGlobal.consoleSettingMenu = eConsoleSettingsMenu.CONTROLS_MENU
+
+ EULA_Dialog()
+ return
+ }
+ else
+ {
+ AdvanceMenu( GetMenu( "ControlsMenu" ) )
+ return
+ }
+ #endif
+
+ #if PC_PROG
+ AdvanceMenu( GetMenu( "ControlsMenu" ) )
+ #endif
+}
+
+void function ActivateAudioVisualMenu( var button ) //This is only run on console
+{
+ if ( GetEULAVersionAccepted() < 1 ) // Treat as binary for now, as discussed with Preston.
+ {
+ if ( uiGlobal.activeMenu == GetMenu( "EULADialog" ) )
+ return
+
+ if ( IsDialog( uiGlobal.activeMenu ) )
+ CloseActiveMenu( true )
+
+ uiGlobal.consoleSettingMenu = eConsoleSettingsMenu.AUDIO_VISUAL_MENU
+
+ EULA_Dialog()
+ return
+ }
+ else
+ {
+ AdvanceMenu( GetMenu( "AudioVideoMenu" ) )
+ return
+ }
+}
+
+void function TrackInstallProgress()
+{
+ var rui = Hud_GetRui( Hud_GetChild( file.panel, "InstallProgress" ) )
+
+ while ( GetGameFullyInstalledProgress() < 1.0 )
+ {
+ file.installing = true
+ RuiSetFloat( rui, "installProgress", GetGameFullyInstalledProgress() )
+ wait 0.5
+ }
+
+ file.installing = false
+ RuiSetFloat( rui, "installProgress", 1.0 )
+}
+
+bool function IsStryderAuthenticated()
+{
+ return GetConVarInt( "mp_allowed" ) != -1
+}
+
+bool function IsStryderAllowingMP()
+{
+ return GetConVarInt( "mp_allowed" ) == 1
+}
+
+#if PS4_PROG
+bool function HasLatestPatch()
+{
+ int status = PS4_getUserNetworkingErrorStatus()
+
+ if ( status == -2141913073 ) // SCE_NP_ERROR_LATEST_PATCH_PKG_EXIST
+ return false
+
+ return true
+}
+#endif // PS4_PROG
+
+void function UpdatePromoData()
+{
+ file.promoData = GetMainMenuPromos()
+
+ UpdateWhatsNewData()
+ UpdateSpotlightData()
+}
+
+void function UICodeCallback_MainMenuPromosUpdated()
+{
+ printt( "MainMenuPromos updated" )
+
+ UpdatePromoData()
+}
+
+void function UpdateWhatsNewData()
+{
+ // file.promoData.newInfo_ImageIndex
+ //RuiSetString( file.whatsNew, "line1Text", "`2%$rui/menu/main_menu/whats_new_bulletpoint%`0 Updated Live Fire Maps!\n`2%$rui/menu/main_menu/whats_new_bulletpoint%`0 Prime Titans`0 in the Store\n`2%$rui/menu/main_menu/whats_new_bulletpoint% DOUBLE XP`0 weekend!" )//file.promoData.newInfo_Title1 )
+ RuiSetString( file.whatsNew, "line1Text", file.promoData.newInfo_Title1 )
+ RuiSetString( file.whatsNew, "line2Text", file.promoData.newInfo_Title2 )
+ RuiSetString( file.whatsNew, "line3Text", file.promoData.newInfo_Title3 )
+
+ bool isVisible = true
+ if ( file.promoData.newInfo_Title1 == "" && file.promoData.newInfo_Title2 == "" && file.promoData.newInfo_Title3 == "" )
+ isVisible = false
+
+ RuiSetBool( file.whatsNew, "isVisible", isVisible )
+}
+
+void function UpdateSpotlightData()
+{
+ SetSpotlightButtonData( file.spotlightButtons[0], file.promoData.largeButton_Url, file.promoData.largeButton_ImageIndex, file.promoData.largeButton_Title, file.promoData.largeButton_Text )
+ SetSpotlightButtonData( file.spotlightButtons[1], file.promoData.smallButton1_Url, file.promoData.smallButton1_ImageIndex, file.promoData.smallButton1_Title )
+ SetSpotlightButtonData( file.spotlightButtons[2], file.promoData.smallButton2_Url, file.promoData.smallButton2_ImageIndex, file.promoData.smallButton2_Title )
+}
+
+void function SetSpotlightButtonData( var button, string link, int imageIndex, string title, string details = "skip" )
+{
+ var rui = Hud_GetRui( button )
+
+ var dataTable = GetDataTable( $"datatable/spotlight_images.rpak" )
+ asset image = GetDataTableAsset( dataTable, imageIndex, GetDataTableColumnByName( dataTable, "image" ) )
+
+ RuiSetImage( rui, "buttonImage", image )
+ RuiSetString( rui, "titleText", title )
+
+ if ( details != "skip" )
+ RuiSetString( rui, "detailsText", details )
+
+ button.s.link = link
+}
+
+void function SpotlightButton_Activate( var button )
+{
+ string link = expect string( button.s.link )
+
+ if ( link == "" )
+ return
+
+ if ( link.find( "menu:" ) == 0 )
+ {
+ var menu
+
+ switch ( link )
+ {
+ //case "menu:new":
+ // menu = GetMenu( "StoreMenu_NewReleases" )
+ // break
+
+ case "menu:new":
+ case "menu:weaponskins":
+ menu = GetMenu( "StoreMenu_WeaponSkins" )
+ break
+
+ //case "menu:limited":
+ // menu = GetMenu( "StoreMenu_Limited" )
+ // break
+
+ case "menu:sales":
+ menu = GetMenu( "StoreMenu_Sales" )
+ break
+ }
+
+ if ( menu != null )
+ {
+ uiGlobal.menuToOpenFromPromoButton = menu
+ LaunchMP()
+ }
+ }
+ else
+ {
+ LaunchExternalWebBrowser( link, WEBBROWSER_FLAG_MUTEGAME )
+ }
+}