This commit is contained in:
mordentral
2016-03-04 14:10:37 -05:00
parent 450b58839d
commit 3679675bc3
9 changed files with 251 additions and 6 deletions

View File

@@ -0,0 +1,133 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "OnlineSubSystemHeader.h"
#include "AdvancedExternalUILibrary.h"
//General Log
DEFINE_LOG_CATEGORY(AdvancedExternalUILog);
void UAdvancedExternalUILibrary::ShowAccountUpgradeUI(const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, TEnumAsByte<EBlueprintResultSwitch::Type> &Result)
{
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid())
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowAccountUpgradeUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::Type::OnFailure;
return;
}
ExternalUIInterface->ShowAccountUpgradeUI(*PlayerRequestingAccountUpgradeUI.GetUniqueNetId());
Result = EBlueprintResultSwitch::Type::OnSuccess;
}
void UAdvancedExternalUILibrary::ShowProfileUI(const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, TEnumAsByte<EBlueprintResultSwitch::Type> &Result)
{
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid())
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowProfileUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::Type::OnFailure;
return;
}
ExternalUIInterface->ShowProfileUI(*PlayerViewingProfile.GetUniqueNetId(), *PlayerToViewProfileOf.GetUniqueNetId(), NULL);
Result = EBlueprintResultSwitch::Type::OnSuccess;
}
void UAdvancedExternalUILibrary::ShowWebURLUI(FString URLToShow, TEnumAsByte<EBlueprintResultSwitch::Type> &Result)
{
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid())
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowWebURLUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::Type::OnFailure;
return;
}
ExternalUIInterface->ShowWebURL(URLToShow);
Result = EBlueprintResultSwitch::Type::OnSuccess;
}
void UAdvancedExternalUILibrary::ShowLeaderBoardUI(FString LeaderboardName, TEnumAsByte<EBlueprintResultSwitch::Type> &Result)
{
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid())
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowLeaderboardsUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::Type::OnFailure;
return;
}
ExternalUIInterface->ShowLeaderboardUI(LeaderboardName);
Result = EBlueprintResultSwitch::Type::OnSuccess;
}
void UAdvancedExternalUILibrary::ShowInviteUI(APlayerController *PlayerController, TEnumAsByte<EBlueprintResultSwitch::Type> &Result)
{
if (!PlayerController)
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Had a bad Player Controller!"));
Result = EBlueprintResultSwitch::Type::OnFailure;
return;
}
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid())
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::Type::OnFailure;
return;
}
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player)
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get ULocalPlayer for the given PlayerController!"));
Result = EBlueprintResultSwitch::Type::OnFailure;
return;
}
ExternalUIInterface->ShowInviteUI(Player->GetControllerId(), GameSessionName);
Result = EBlueprintResultSwitch::Type::OnSuccess;
}
void UAdvancedExternalUILibrary::ShowFriendsUI(APlayerController *PlayerController, TEnumAsByte<EBlueprintResultSwitch::Type> &Result)
{
if (!PlayerController)
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Had a bad Player Controller!"));
Result = EBlueprintResultSwitch::Type::OnFailure;
return;
}
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid())
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::Type::OnFailure;
return;
}
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player)
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get ULocalPlayer for the given PlayerController!"));
Result = EBlueprintResultSwitch::Type::OnFailure;
return;
}
ExternalUIInterface->ShowFriendsUI(Player->GetControllerId());
Result = EBlueprintResultSwitch::Type::OnSuccess;
}

View File

@@ -410,8 +410,17 @@ void UAdvancedFriendsLibrary::GetStoredFriendsList(APlayerController *PlayerCont
BPF.OnlineState = ((EBPOnlinePresenceState::Type)((int32)Friend->GetPresence().Status.State));
BPF.DisplayName = Friend->GetDisplayName();
BPF.RealName = Friend->GetRealName();
BPF.RealName = Friend->GetRealName();
BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId());
BPF.bIsPlayingSameGame = Friend->GetPresence().bIsPlayingThisGame;
BPF.PresenceInfo.bIsOnline = Friend->GetPresence().bIsOnline;
BPF.PresenceInfo.bIsPlaying = Friend->GetPresence().bIsPlaying;
BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState::Type)((int32)Friend->GetPresence().Status.State));
BPF.PresenceInfo.StatusString = Friend->GetPresence().Status.StatusStr;
BPF.PresenceInfo.bIsJoinable = Friend->GetPresence().bIsJoinable;
BPF.PresenceInfo.bIsPlayingThisGame = Friend->GetPresence().bIsPlayingThisGame;
FriendsList.Add(BPF);
}
}

View File

@@ -175,6 +175,32 @@ public:
FString LastSeen;
};
USTRUCT(BlueprintType)
struct FBPFriendPresenceInfo
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsOnline;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsPlaying;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsPlayingThisGame;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsJoinable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bHasVoiceSupport;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
TEnumAsByte<EBPOnlinePresenceState::Type> PresenceState;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString StatusString;
};
USTRUCT(BlueprintType)
struct FBPFriendInfo
{
@@ -192,6 +218,8 @@ public:
FBPUniqueNetId UniqueNetId;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsPlayingSameGame;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FBPFriendPresenceInfo PresenceInfo;
};
/** The types of comparison operations for a given search query */

View File

@@ -13,11 +13,12 @@ UCreateSessionCallbackProxyAdvanced::UCreateSessionCallbackProxyAdvanced(const F
{
}
UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise)
UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise)
{
UCreateSessionCallbackProxyAdvanced* Proxy = NewObject<UCreateSessionCallbackProxyAdvanced>();
Proxy->PlayerControllerWeakPtr = PlayerController;
Proxy->NumPublicConnections = PublicConnections;
Proxy->NumPrivateConnections = PrivateConnections;
Proxy->bUseLAN = bUseLAN;
Proxy->WorldContextObject = WorldContextObject;
Proxy->bAllowInvites = bAllowInvites;
@@ -48,6 +49,7 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
FOnlineSessionSettings Settings;
Settings.NumPublicConnections = NumPublicConnections;
Settings.NumPrivateConnections = NumPrivateConnections;
Settings.bShouldAdvertise = true;
Settings.bAllowJoinInProgress = true;
Settings.bIsLANMatch = bUseLAN;

View File

@@ -67,6 +67,15 @@ void UGetFriendsCallbackProxy::OnReadFriendsListCompleted(int32 LocalUserNum, bo
BPF.DisplayName = Friend->GetDisplayName();
BPF.RealName = Friend->GetRealName();
BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId());
BPF.bIsPlayingSameGame = Friend->GetPresence().bIsPlayingThisGame;
BPF.PresenceInfo.bIsOnline = Friend->GetPresence().bIsOnline;
BPF.PresenceInfo.bIsPlaying = Friend->GetPresence().bIsPlaying;
BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState::Type)((int32)Friend->GetPresence().Status.State));
BPF.PresenceInfo.StatusString = Friend->GetPresence().Status.StatusStr;
BPF.PresenceInfo.bIsJoinable = Friend->GetPresence().bIsJoinable;
BPF.PresenceInfo.bIsPlayingThisGame = Friend->GetPresence().bIsPlayingThisGame;
FriendsListOut.Add(BPF);
}

View File

@@ -12,10 +12,11 @@ UUpdateSessionCallbackProxyAdvanced::UUpdateSessionCallbackProxyAdvanced(const F
{
}
UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, int32 PublicConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, const TArray<FSessionPropertyKeyPair> &ExtraSettings, bool bRefreshOnlineData, bool bIsDedicatedServer)
UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer)
{
UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject<UUpdateSessionCallbackProxyAdvanced>();
Proxy->NumPublicConnections = PublicConnections;
Proxy->NumPrivateConnections = PrivateConnections;
Proxy->bUseLAN = bUseLAN;
Proxy->WorldContextObject = WorldContextObject;
Proxy->bAllowInvites = bAllowInvites;
@@ -57,6 +58,7 @@ void UUpdateSessionCallbackProxyAdvanced::Activate()
// FOnlineSessionSettings Settings;
//Settings->BuildUniqueId = GetBuildUniqueId();
Settings->NumPublicConnections = NumPublicConnections;
Settings->NumPrivateConnections = NumPrivateConnections;
//Settings->bShouldAdvertise = true;
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
Settings->bIsLANMatch = bUseLAN;