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 FOnlineSubsystemImpl::IsLocalPlayer(const FUniqueNetId& UniqueId) const { if (!IsDedicated()) { IOnlineIdentityPtr IdentityInt = GetIdentityInterface(); if (IdentityInt.IsValid()) { for (int32 LocalUserNum = 0; LocalUserNum < MAX_LOCAL_PLAYERS; LocalUserNum++) { TSharedPtr<const FUniqueNetId> LocalUniqueId = IdentityInt->GetUniquePlayerId(LocalUserNum); if (LocalUniqueId.IsValid() && UniqueId == *LocalUniqueId) { return true; } } } } return false; }
bool FOnlineSubsystemImpl::HandleFriendExecCommands(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar) { bool bWasHandled = false; if (FParse::Command(&Cmd, TEXT("BLOCK"))) { FString LocalNumStr = FParse::Token(Cmd, false); int32 LocalNum = FCString::Atoi(*LocalNumStr); FString UserId = FParse::Token(Cmd, false); if (UserId.IsEmpty() || LocalNum < 0 || LocalNum > MAX_LOCAL_PLAYERS) { UE_LOG_ONLINE(Warning, TEXT("usage: FRIEND BLOCK <localnum> <userid>")); } else { IOnlineIdentityPtr IdentityInt = GetIdentityInterface(); if (IdentityInt.IsValid()) { TSharedPtr<const FUniqueNetId> BlockUserId = IdentityInt->CreateUniquePlayerId(UserId); IOnlineFriendsPtr FriendsInt = GetFriendsInterface(); if (FriendsInt.IsValid()) { FriendsInt->BlockPlayer(0, *BlockUserId); } } } } else if (FParse::Command(&Cmd, TEXT("DUMPBLOCKED"))) { IOnlineFriendsPtr FriendsInt = GetFriendsInterface(); if (FriendsInt.IsValid()) { FriendsInt->DumpBlockedPlayers(); } bWasHandled = true; } return bWasHandled; }
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(); }