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,56 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "OnlineSubSystemHeader.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h"
#include "OnlineSubsystem.h"
#include "BlueprintDataDefinitions.h"
//#include "OnlineFriendsInterface.h"
//#include "OnlineUserInterface.h"
//#include "OnlineMessageInterface.h"
//#include "OnlinePresenceInterface.h"
//#include "Engine/GameInstance.h"
#include "OnlineSessionInterface.h"
//#include "UObjectIterator.h"
#include "AdvancedExternalUILibrary.generated.h"
//General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedExternalUILog, Log, All);
UCLASS()
class UAdvancedExternalUILibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
//********* External UI Functions *************//
// Show the UI that handles the Friends list
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowFriendsUI(APlayerController *PlayerController, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
// Show the UI that handles inviting people to your game
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowInviteUI(APlayerController *PlayerController, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
// Show the UI that shows the leaderboard (doesn't work with steam)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowLeaderBoardUI(FString LeaderboardName, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
// Show the UI that shows a web URL
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowWebURLUI(FString URLToShow, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
// Show the UI that shows the profile of a uniquenetid
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowProfileUI(const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
// Show the UI that shows the account upgrade UI (doesn't work with steam)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result"))
static void ShowAccountUpgradeUI(const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, TEnumAsByte<EBlueprintResultSwitch::Type> &Result);
};

View File

@@ -20,7 +20,7 @@ class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
// Creates a session with the default online subsystem with advanced optional inputs
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true);
static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true);
// UOnlineBlueprintCallProxyBase interface
virtual void Activate() override;
@@ -49,6 +49,9 @@ private:
// Number of public connections
int NumPublicConnections;
// Number of private connections
int NumPrivateConnections;
// Whether or not to search LAN
bool bUseLAN;

View File

@@ -18,9 +18,9 @@ class UUpdateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnFailure;
// Creates a session with the default online subsystem with advanced optional inputs
// Creates a session with the default online subsystem with advanced optional inputs, you MUST fill in all categories or it will pass in values that you didn't want as default values
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
static UUpdateSessionCallbackProxyAdvanced* UpdateSession(UObject* WorldContextObject, int32 PublicConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, const TArray<FSessionPropertyKeyPair> &ExtraSettings, bool bRefreshOnlineData = true, bool bIsDedicatedServer = false);
static UUpdateSessionCallbackProxyAdvanced* UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = false, bool bAllowJoinInProgress = false, bool bRefreshOnlineData = true, bool bIsDedicatedServer = false);
// UOnlineBlueprintCallProxyBase interface
virtual void Activate() override;
@@ -39,6 +39,9 @@ private:
// Number of public connections
int NumPublicConnections;
// Number of private connections
int NumPrivateConnections;
// Whether or not to search LAN
bool bUseLAN;

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;