virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override { const FKey Key = InKeyEvent.GetKey(); if (Key == EKeys::Enter) { MenuOwner->HandleLoginUIClosed(TSharedPtr<const FUniqueNetId>(), 0); } else if (!MenuOwner->GetControlsLocked() && Key == EKeys::Gamepad_FaceButton_Bottom) { bool bSkipToMainMenu = true; { const auto OnlineSub = IOnlineSubsystem::Get(); if (OnlineSub) { const auto IdentityInterface = OnlineSub->GetIdentityInterface(); if (IdentityInterface.IsValid()) { TSharedPtr<GenericApplication> GenericApplication = FSlateApplication::Get().GetPlatformApplication(); const bool bIsLicensed = GenericApplication->ApplicationLicenseValid(); const auto LoginStatus = IdentityInterface->GetLoginStatus(InKeyEvent.GetUserIndex()); if (LoginStatus == ELoginStatus::NotLoggedIn || !bIsLicensed) { // Show the account picker. const auto ExternalUI = OnlineSub->GetExternalUIInterface(); if (ExternalUI.IsValid()) { ExternalUI->ShowLoginUI(InKeyEvent.GetUserIndex(), false, IOnlineExternalUI::FOnLoginUIClosedDelegate::CreateSP(MenuOwner, &FShooterWelcomeMenu::HandleLoginUIClosed)); bSkipToMainMenu = false; } } } } } if (bSkipToMainMenu) { const auto OnlineSub = IOnlineSubsystem::Get(); if (OnlineSub) { const auto IdentityInterface = OnlineSub->GetIdentityInterface(); if (IdentityInterface.IsValid()) { TSharedPtr<const FUniqueNetId> UserId = IdentityInterface->GetUniquePlayerId(InKeyEvent.GetUserIndex()); // If we couldn't show the external login UI for any reason, or if the user is // already logged in, just advance to the main menu immediately. MenuOwner->HandleLoginUIClosed(UserId, InKeyEvent.GetUserIndex()); } } } return FReply::Handled(); } return FReply::Unhandled(); }
bool ShooterUIHelpers::ProfileSwapUI(const int ControllerIndex, bool bShowOnlineOnly, const IOnlineExternalUI::FOnLoginUIClosedDelegate* Delegate) const { const auto OnlineSub = IOnlineSubsystem::Get(); if (OnlineSub) { // Show the profile UI. const auto ExternalUI = OnlineSub->GetExternalUIInterface(); if (ExternalUI.IsValid()) { // Create a dummy delegate, if one wasn't specified struct Local { static void DummyOnProfileSwapUIClosedDelegate(TSharedPtr<const FUniqueNetId> UniqueId, const int InControllerIndex) { // do nothing } }; return ExternalUI->ShowLoginUI(ControllerIndex, bShowOnlineOnly, Delegate ? *Delegate : IOnlineExternalUI::FOnLoginUIClosedDelegate::CreateStatic(&Local::DummyOnProfileSwapUIClosedDelegate) ); } } return false; }
virtual FReply OnControllerButtonPressed( const FGeometry& MyGeometry, const FControllerEvent& ControllerEvent ) override { const FKey Key = ControllerEvent.GetEffectingButton(); if (Key == EKeys::Gamepad_FaceButton_Bottom) { bool bSkipToMainMenu = true; const auto OnlineSub = IOnlineSubsystem::Get(); if(OnlineSub) { const auto IdentityInterface = OnlineSub->GetIdentityInterface(); if(IdentityInterface.IsValid()) { const auto LoginStatus = IdentityInterface->GetLoginStatus(ControllerEvent.GetUserIndex()); if(LoginStatus == ELoginStatus::NotLoggedIn) { // Show the account picker. const auto ExternalUI = OnlineSub->GetExternalUIInterface(); if(ExternalUI.IsValid()) { ExternalUI->ShowLoginUI(ControllerEvent.GetUserIndex(), false, IOnlineExternalUI::FOnLoginUIClosedDelegate::CreateSP(MenuOwner, &FShooterWelcomeMenu::HandleLoginUIClosed)); bSkipToMainMenu = false; } } } } if(bSkipToMainMenu) { // If we couldn't show the external login UI for any reason, or if the user is // already logged in, just advance to the main menu immediately. MenuOwner->SetControllerAndAdvanceToMainMenu(ControllerEvent.GetUserIndex()); } return FReply::Handled(); } return FReply::Unhandled(); }