normalizing EOL

This commit is contained in:
Joshua
2022-03-07 11:03:10 -05:00
parent 0de641f7d9
commit e1ed0f22b6
44 changed files with 5716 additions and 5716 deletions

View File

@@ -1,34 +1,34 @@
{ {
"FileVersion": 3, "FileVersion": 3,
"FriendlyName": "Advanced Sessions", "FriendlyName": "Advanced Sessions",
"Version": 4, "Version": 4,
"VersionName": "5.0", "VersionName": "5.0",
"Description": "Adds new blueprint functions to handle more advanced session operations.", "Description": "Adds new blueprint functions to handle more advanced session operations.",
"Category": "Advanced Sessions Plugin", "Category": "Advanced Sessions Plugin",
"CreatedBy": "Joshua Statzer", "CreatedBy": "Joshua Statzer",
"CreatedByURL": "N/A", "CreatedByURL": "N/A",
"Modules": [ "Modules": [
{ {
"Name": "AdvancedSessions", "Name": "AdvancedSessions",
"Type": "Runtime", "Type": "Runtime",
"LoadingPhase": "PreDefault" "LoadingPhase": "PreDefault"
} }
], ],
"Plugins": [ "Plugins": [
{ {
"Name": "OnlineSubsystem", "Name": "OnlineSubsystem",
"Enabled": true "Enabled": true
}, },
{ {
"Name": "OnlineSubsystemUtils", "Name": "OnlineSubsystemUtils",
"Enabled": true "Enabled": true
} }
], ],
"DocsURL": "", "DocsURL": "",
"MarketplaceURL": "", "MarketplaceURL": "",
"SupportURL": "", "SupportURL": "",
"CanContainContent": false, "CanContainContent": false,
"IsBetaVersion": false, "IsBetaVersion": false,
"IsExperimentalVersion": false, "IsExperimentalVersion": false,
"Installed": false "Installed": false
} }

View File

@@ -1,18 +1,18 @@
using UnrealBuildTool; using UnrealBuildTool;
using System.IO; using System.IO;
public class AdvancedSessions : ModuleRules public class AdvancedSessions : ModuleRules
{ {
public AdvancedSessions(ReadOnlyTargetRules Target) : base(Target) public AdvancedSessions(ReadOnlyTargetRules Target) : base(Target)
{ {
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
//bEnforceIWYU = true; //bEnforceIWYU = true;
PublicDefinitions.Add("WITH_ADVANCED_SESSIONS=1"); PublicDefinitions.Add("WITH_ADVANCED_SESSIONS=1");
// PrivateIncludePaths.AddRange(new string[] { "AdvancedSessions/Private"/*, "OnlineSubsystemSteam/Private"*/ }); // PrivateIncludePaths.AddRange(new string[] { "AdvancedSessions/Private"/*, "OnlineSubsystemSteam/Private"*/ });
// PublicIncludePaths.AddRange(new string[] { "AdvancedSessions/Public" }); // PublicIncludePaths.AddRange(new string[] { "AdvancedSessions/Public" });
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets"/*"Voice", "OnlineSubsystemSteam"*/ }); PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets"/*"Voice", "OnlineSubsystemSteam"*/ });
PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/}); PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/});
} }
} }

View File

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

View File

@@ -1,145 +1,145 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Engine/Engine.h" #include "Engine/Engine.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "Interfaces/OnlineFriendsInterface.h" #include "Interfaces/OnlineFriendsInterface.h"
#include "Interfaces/OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "Interfaces/OnlineMessageInterface.h" #include "Interfaces/OnlineMessageInterface.h"
#include "Interfaces/OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "Interfaces/OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "OnlineSessionSettings.h" #include "OnlineSessionSettings.h"
#include "UObject/UObjectIterator.h" #include "UObject/UObjectIterator.h"
#include "AdvancedFriendsInterface.h" #include "AdvancedFriendsInterface.h"
#include "AdvancedFriendsGameInstance.generated.h" #include "AdvancedFriendsGameInstance.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsInterfaceLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsInterfaceLog, Log, All);
UCLASS() UCLASS()
class ADVANCEDSESSIONS_API UAdvancedFriendsGameInstance : public UGameInstance class ADVANCEDSESSIONS_API UAdvancedFriendsGameInstance : public UGameInstance
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
UAdvancedFriendsGameInstance(const FObjectInitializer& ObjectInitializer); UAdvancedFriendsGameInstance(const FObjectInitializer& ObjectInitializer);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallFriendInterfaceEventsOnPlayerControllers; bool bCallFriendInterfaceEventsOnPlayerControllers;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallIdentityInterfaceEventsOnPlayerControllers; bool bCallIdentityInterfaceEventsOnPlayerControllers;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallVoiceInterfaceEventsOnPlayerControllers; bool bCallVoiceInterfaceEventsOnPlayerControllers;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedVoiceInterface) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedVoiceInterface)
bool bEnableTalkingStatusDelegate; bool bEnableTalkingStatusDelegate;
//virtual void PostLoad() override; //virtual void PostLoad() override;
virtual void Shutdown() override; virtual void Shutdown() override;
virtual void Init() override; virtual void Init() override;
//*** Session invite received by local ***// //*** Session invite received by local ***//
FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate; FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate;
FDelegateHandle SessionInviteReceivedDelegateHandle; FDelegateHandle SessionInviteReceivedDelegateHandle;
//const FUniqueNetId& /*UserId*/, const FUniqueNetId& /*FromId*/, const FString& /*AppId*/, const FOnlineSessionSearchResult& /*InviteResult*/ //const FUniqueNetId& /*UserId*/, const FUniqueNetId& /*FromId*/, const FString& /*AppId*/, const FOnlineSessionSearchResult& /*InviteResult*/
void OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString & AppId, const FOnlineSessionSearchResult& SessionToJoin); void OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString & AppId, const FOnlineSessionSearchResult& SessionToJoin);
// After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it // After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends") UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnSessionInviteReceived(int32 LocalPlayerNum, FBPUniqueNetId PersonInviting, const FString& AppId, const FBlueprintSessionResult& SessionToJoin); void OnSessionInviteReceived(int32 LocalPlayerNum, FBPUniqueNetId PersonInviting, const FString& AppId, const FBlueprintSessionResult& SessionToJoin);
//*** Session invite accepted by local ***// //*** Session invite accepted by local ***//
FOnSessionUserInviteAcceptedDelegate SessionInviteAcceptedDelegate; FOnSessionUserInviteAcceptedDelegate SessionInviteAcceptedDelegate;
FDelegateHandle SessionInviteAcceptedDelegateHandle; FDelegateHandle SessionInviteAcceptedDelegateHandle;
void OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInviting, const FOnlineSessionSearchResult& SessionToJoin); void OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInviting, const FOnlineSessionSearchResult& SessionToJoin);
// After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it // After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
// This function is currently not hooked up in any of Epics default subsystems, it is here for custom subsystems // This function is currently not hooked up in any of Epics default subsystems, it is here for custom subsystems
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends") UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnSessionInviteAccepted(int32 LocalPlayerNum, FBPUniqueNetId PersonInvited, const FBlueprintSessionResult& SessionToJoin); void OnSessionInviteAccepted(int32 LocalPlayerNum, FBPUniqueNetId PersonInvited, const FBlueprintSessionResult& SessionToJoin);
// After a voice status has changed this event is triggered if the bEnableTalkingStatusDelegate property is true // After a voice status has changed this event is triggered if the bEnableTalkingStatusDelegate property is true
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedVoice") UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedVoice")
void OnPlayerTalkingStateChanged(FBPUniqueNetId PlayerId, bool bIsTalking); void OnPlayerTalkingStateChanged(FBPUniqueNetId PlayerId, bool bIsTalking);
void OnPlayerTalkingStateChangedMaster(TSharedRef<const FUniqueNetId> PlayerId, bool bIsTalking); void OnPlayerTalkingStateChangedMaster(TSharedRef<const FUniqueNetId> PlayerId, bool bIsTalking);
FOnPlayerTalkingStateChangedDelegate PlayerTalkingStateChangedDelegate; FOnPlayerTalkingStateChangedDelegate PlayerTalkingStateChangedDelegate;
FDelegateHandle PlayerTalkingStateChangedDelegateHandle; FDelegateHandle PlayerTalkingStateChangedDelegateHandle;
// Called when the designated LocalUser has changed login state // Called when the designated LocalUser has changed login state
UFUNCTION(BlueprintImplementableEvent , Category = "AdvancedIdentity", meta = (DisplayName = "OnPlayerLoginChanged")) UFUNCTION(BlueprintImplementableEvent , Category = "AdvancedIdentity", meta = (DisplayName = "OnPlayerLoginChanged"))
void OnPlayerLoginChanged(int32 PlayerNum); void OnPlayerLoginChanged(int32 PlayerNum);
void OnPlayerLoginChangedMaster(int32 PlayerNum); void OnPlayerLoginChangedMaster(int32 PlayerNum);
FOnLoginChangedDelegate PlayerLoginChangedDelegate; FOnLoginChangedDelegate PlayerLoginChangedDelegate;
FDelegateHandle PlayerLoginChangedDelegateHandle; FDelegateHandle PlayerLoginChangedDelegateHandle;
// Called when the designated LocalUser has changed login status // Called when the designated LocalUser has changed login status
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedIdentity", meta = (DisplayName = "OnPlayerLoginStatusChanged")) UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedIdentity", meta = (DisplayName = "OnPlayerLoginStatusChanged"))
void OnPlayerLoginStatusChanged(int32 PlayerNum, EBPLoginStatus PreviousStatus, EBPLoginStatus NewStatus, FBPUniqueNetId NewPlayerUniqueNetID); void OnPlayerLoginStatusChanged(int32 PlayerNum, EBPLoginStatus PreviousStatus, EBPLoginStatus NewStatus, FBPUniqueNetId NewPlayerUniqueNetID);
void OnPlayerLoginStatusChangedMaster(int32 PlayerNum, ELoginStatus::Type PreviousStatus, ELoginStatus::Type NewStatus, const FUniqueNetId & NewPlayerUniqueNetID); void OnPlayerLoginStatusChangedMaster(int32 PlayerNum, ELoginStatus::Type PreviousStatus, ELoginStatus::Type NewStatus, const FUniqueNetId & NewPlayerUniqueNetID);
FOnLoginStatusChangedDelegate PlayerLoginStatusChangedDelegate; FOnLoginStatusChangedDelegate PlayerLoginStatusChangedDelegate;
FDelegateHandle PlayerLoginStatusChangedDelegateHandle; FDelegateHandle PlayerLoginStatusChangedDelegateHandle;
//*** Session Invite Received From Friend ***// //*** Session Invite Received From Friend ***//
// REMOVED BECAUSE IT NEVER GETS CALLED // REMOVED BECAUSE IT NEVER GETS CALLED
/*FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate; /*FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate;
FDelegateHandle SessionInviteReceivedDelegateHandle; FDelegateHandle SessionInviteReceivedDelegateHandle;
void OnSessionInviteReceivedMaster(const FUniqueNetId &InvitedPlayer, const FUniqueNetId &FriendInviting, const FOnlineSessionSearchResult& Session); void OnSessionInviteReceivedMaster(const FUniqueNetId &InvitedPlayer, const FUniqueNetId &FriendInviting, const FOnlineSessionSearchResult& Session);
// After a session invite has been sent from a friend this event is triggered, call JoinSession on the session result to join it // After a session invite has been sent from a friend this event is triggered, call JoinSession on the session result to join it
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends") UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnSessionInviteReceived(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &FriendInviting, const FBlueprintSessionResult &Session); void OnSessionInviteReceived(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &FriendInviting, const FBlueprintSessionResult &Session);
*/ */
//*** Friend Invite Accepted ***// //*** Friend Invite Accepted ***//
/*FOnInviteAcceptedDelegate FriendInviteAcceptedDelegate; /*FOnInviteAcceptedDelegate FriendInviteAcceptedDelegate;
FDelegateHandle FriendInviteAcceptedDelegateHandle; FDelegateHandle FriendInviteAcceptedDelegateHandle;
void OnFriendInviteAcceptedDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &PlayerInvited); void OnFriendInviteAcceptedDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &PlayerInvited);
// After a session invite has been accepted by a friend this event is triggered // After a session invite has been accepted by a friend this event is triggered
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends") UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnFriendInviteAccepted(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &PlayerInvited); void OnFriendInviteAccepted(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &PlayerInvited);
*/ */
//*** Friend Invite Rejected ***// //*** Friend Invite Rejected ***//
/*FOnInviteRejectedDelegate SessionInviteRejectedByFriendDelegate; /*FOnInviteRejectedDelegate SessionInviteRejectedByFriendDelegate;
FDelegateHandle InviteRejectedByFriendDelegateHandle; FDelegateHandle InviteRejectedByFriendDelegateHandle;
void OnFriendInviteRejectedDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &PlayerDeclined); void OnFriendInviteRejectedDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &PlayerDeclined);
// After a friend invite has been rejected this event is triggered // After a friend invite has been rejected this event is triggered
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends") UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnFriendInviteRejected(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &PlayerDeclined); void OnFriendInviteRejected(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &PlayerDeclined);
*/ */
//*** Removed By Friend ***// //*** Removed By Friend ***//
/*FOnFriendRemovedDelegate RemovedByFriendDelegate; /*FOnFriendRemovedDelegate RemovedByFriendDelegate;
FDelegateHandle RemovedByFriendDelegateHandle; FDelegateHandle RemovedByFriendDelegateHandle;
void OnRemovedByFriendDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &FriendRemoved); void OnRemovedByFriendDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &FriendRemoved);
// After a friend removed the player this event is triggered // After a friend removed the player this event is triggered
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends") UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnRemovedByFriend(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &FriendRemoved);*/ void OnRemovedByFriend(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &FriendRemoved);*/
}; };

View File

@@ -1,56 +1,56 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "Interfaces/OnlineFriendsInterface.h" #include "Interfaces/OnlineFriendsInterface.h"
#include "Interfaces/OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "Interfaces/OnlineMessageInterface.h" #include "Interfaces/OnlineMessageInterface.h"
#include "Interfaces/OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "Interfaces/OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "OnlineSessionSettings.h" #include "OnlineSessionSettings.h"
#include "UObject/UObjectIterator.h" #include "UObject/UObjectIterator.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "AdvancedFriendsInterface.generated.h" #include "AdvancedFriendsInterface.generated.h"
UINTERFACE(MinimalAPI) UINTERFACE(MinimalAPI)
class UAdvancedFriendsInterface : public UInterface class UAdvancedFriendsInterface : public UInterface
{ {
GENERATED_UINTERFACE_BODY() GENERATED_UINTERFACE_BODY()
}; };
class IAdvancedFriendsInterface class IAdvancedFriendsInterface
{ {
GENERATED_IINTERFACE_BODY() GENERATED_IINTERFACE_BODY()
public: public:
// Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect // Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnSessionInviteReceived")) UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnSessionInviteReceived"))
void OnSessionInviteReceived(FBPUniqueNetId PersonInviting, const FBlueprintSessionResult& SearchResult); void OnSessionInviteReceived(FBPUniqueNetId PersonInviting, const FBlueprintSessionResult& SearchResult);
// Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect // Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnSessionInviteAccepted")) UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnSessionInviteAccepted"))
void OnSessionInviteAccepted(FBPUniqueNetId PersonInvited, const FBlueprintSessionResult& SearchResult); void OnSessionInviteAccepted(FBPUniqueNetId PersonInvited, const FBlueprintSessionResult& SearchResult);
// Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect // Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerVoiceStateChanged")) UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerVoiceStateChanged"))
void OnPlayerVoiceStateChanged(FBPUniqueNetId PlayerId, bool bIsTalking); void OnPlayerVoiceStateChanged(FBPUniqueNetId PlayerId, bool bIsTalking);
// Called when the designated LocalUser has changed login state // Called when the designated LocalUser has changed login state
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerLoginChanged")) UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerLoginChanged"))
void OnPlayerLoginChanged(int32 PlayerNum); void OnPlayerLoginChanged(int32 PlayerNum);
// Called when the designated LocalUser has changed login state // Called when the designated LocalUser has changed login state
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerLoginStatusChanged")) UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerLoginStatusChanged"))
void OnPlayerLoginStatusChanged(EBPLoginStatus PreviousStatus, EBPLoginStatus NewStatus, FBPUniqueNetId PlayerUniqueNetID); void OnPlayerLoginStatusChanged(EBPLoginStatus PreviousStatus, EBPLoginStatus NewStatus, FBPUniqueNetId PlayerUniqueNetID);
// REMOVED BECAUSE IT WAS NEVER BEING CALLED // REMOVED BECAUSE IT WAS NEVER BEING CALLED
// Called when the designated LocalUser has received a session invite, use JoinSession on result to connect // Called when the designated LocalUser has received a session invite, use JoinSession on result to connect
//UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "OnSessionInviteReceived")) //UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "OnSessionInviteReceived"))
//void OnSessionInviteReceived(const FBPUniqueNetId &FriendInviting, const FBlueprintSessionResult &Session); //void OnSessionInviteReceived(const FBPUniqueNetId &FriendInviting, const FBlueprintSessionResult &Session);
}; };

View File

@@ -1,56 +1,56 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "Interfaces/OnlineFriendsInterface.h" #include "Interfaces/OnlineFriendsInterface.h"
#include "Interfaces/OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "Interfaces/OnlineMessageInterface.h" #include "Interfaces/OnlineMessageInterface.h"
#include "Interfaces/OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "Interfaces/OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "UObject/UObjectIterator.h" #include "UObject/UObjectIterator.h"
#include "AdvancedFriendsLibrary.generated.h" #include "AdvancedFriendsLibrary.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsLog, Log, All);
UCLASS() UCLASS()
class UAdvancedFriendsLibrary : public UBlueprintFunctionLibrary class UAdvancedFriendsLibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* Friend List Functions *************// //********* Friend List Functions *************//
// Sends an Invite to the current online session to a list of friends // Sends an Invite to the current online session to a list of friends
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result"))
static void SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result); static void SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result);
// Sends an Invite to the current online session to a friend // Sends an Invite to the current online session to a friend
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result"))
static void SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result); static void SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result);
// Get a friend from the previously read/saved friends list (Must Call GetFriends first for this to return anything) // Get a friend from the previously read/saved friends list (Must Call GetFriends first for this to return anything)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList")
static void GetFriend(APlayerController *PlayerController, const FBPUniqueNetId FriendUniqueNetId, FBPFriendInfo &Friend); static void GetFriend(APlayerController *PlayerController, const FBPUniqueNetId FriendUniqueNetId, FBPFriendInfo &Friend);
// Get the previously read/saved friends list (Must Call GetFriends first for this to return anything) // Get the previously read/saved friends list (Must Call GetFriends first for this to return anything)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList")
static void GetStoredFriendsList(APlayerController *PlayerController, TArray<FBPFriendInfo> &FriendsList); static void GetStoredFriendsList(APlayerController *PlayerController, TArray<FBPFriendInfo> &FriendsList);
// Get the previously read/saved recent players list (Must Call GetRecentPlayers first for this to return anything) // Get the previously read/saved recent players list (Must Call GetRecentPlayers first for this to return anything)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|RecentPlayersList") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|RecentPlayersList")
static void GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray<FBPOnlineRecentPlayer> &PlayersList); static void GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray<FBPOnlineRecentPlayer> &PlayersList);
// Check if a UniqueNetId is a friend // Check if a UniqueNetId is a friend
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|FriendsList") UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|FriendsList")
static void IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend); static void IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend);
}; };

View File

@@ -1,81 +1,81 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "Interfaces/OnlineIdentityInterface.h" #include "Interfaces/OnlineIdentityInterface.h"
#include "Interfaces/OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "Interfaces/OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "UObject/UObjectIterator.h" #include "UObject/UObjectIterator.h"
#include "AdvancedIdentityLibrary.generated.h" #include "AdvancedIdentityLibrary.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedIdentityLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedIdentityLog, Log, All);
UCLASS() UCLASS()
class UAdvancedIdentityLibrary : public UBlueprintFunctionLibrary class UAdvancedIdentityLibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* Identity Functions *************// //********* Identity Functions *************//
// Get the login status of a local player // Get the login status of a local player
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result"))
static void GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result); static void GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result);
// Get the auth token for a local player // Get the auth token for a local player
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result"))
static void GetPlayerAuthToken(APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result); static void GetPlayerAuthToken(APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result);
// Get a players nickname // Get a players nickname
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity") UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity")
static void GetPlayerNickname(const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname); static void GetPlayerNickname(const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname);
//********* User Account Functions *************// //********* User Account Functions *************//
// Get a users account // Get a users account
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
static void GetUserAccount(const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result); static void GetUserAccount(const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result);
// Get all known users accounts // Get all known users accounts
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
static void GetAllUserAccounts(TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result); static void GetAllUserAccounts(TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result);
// Get a user account access token // Get a user account access token
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount") UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
static void GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken); static void GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken);
// Get a user account Auth attribute (depends on subsystem) // Get a user account Auth attribute (depends on subsystem)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
static void GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result); static void GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result);
// Set a user account attribute (depends on subsystem) // Set a user account attribute (depends on subsystem)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
static void SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result); static void SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result);
// Get user ID // Get user ID
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount") UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
static void GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID); static void GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID);
// Get user accounts real name if possible // Get user accounts real name if possible
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount") UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
static void GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName); static void GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName);
// Get user account display name if possible // Get user account display name if possible
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount") UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
static void GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName); static void GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName);
// Get user account attribute (depends on subsystem) // Get user account attribute (depends on subsystem)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
static void GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result); static void GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result);
}; };

View File

@@ -1,11 +1,11 @@
#pragma once #pragma once
#include "Modules/ModuleManager.h" #include "Modules/ModuleManager.h"
class AdvancedSessions : public IModuleInterface class AdvancedSessions : public IModuleInterface
{ {
public: public:
/** IModuleInterface implementation */ /** IModuleInterface implementation */
void StartupModule(); void StartupModule();
void ShutdownModule(); void ShutdownModule();
}; };

View File

@@ -1,204 +1,204 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Engine/Engine.h" #include "Engine/Engine.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "Interfaces/OnlineFriendsInterface.h" #include "Interfaces/OnlineFriendsInterface.h"
#include "Interfaces/OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "Interfaces/OnlineMessageInterface.h" #include "Interfaces/OnlineMessageInterface.h"
#include "Interfaces/OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "Interfaces/OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "GameFramework/GameModeBase.h" #include "GameFramework/GameModeBase.h"
#include "GameFramework/GameSession.h" #include "GameFramework/GameSession.h"
//#include "UObjectIterator.h" //#include "UObjectIterator.h"
#include "AdvancedSessionsLibrary.generated.h" #include "AdvancedSessionsLibrary.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSessionsLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedSessionsLog, Log, All);
UCLASS() UCLASS()
class UAdvancedSessionsLibrary : public UBlueprintFunctionLibrary class UAdvancedSessionsLibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* Session Admin Functions *************// //********* Session Admin Functions *************//
// Kick a player from the currently active game session, only available on the server // Kick a player from the currently active game session, only available on the server
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions", meta = (WorldContext = "WorldContextObject")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions", meta = (WorldContext = "WorldContextObject"))
static bool KickPlayer(UObject* WorldContextObject, APlayerController* PlayerToKick, FText KickReason); static bool KickPlayer(UObject* WorldContextObject, APlayerController* PlayerToKick, FText KickReason);
// Ban a player from the currently active game session, only available on the server // Ban a player from the currently active game session, only available on the server
// Note that the default gamesession class does not implement an actual ban list and just kicks when this is called // Note that the default gamesession class does not implement an actual ban list and just kicks when this is called
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions", meta = (WorldContext = "WorldContextObject")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions", meta = (WorldContext = "WorldContextObject"))
static bool BanPlayer(UObject* WorldContextObject, APlayerController* PlayerToBan, FText BanReason); static bool BanPlayer(UObject* WorldContextObject, APlayerController* PlayerToBan, FText BanReason);
//********* Session Search Functions *************// //********* Session Search Functions *************//
// Adds or modifies session settings in an existing array depending on if they exist already or not // Adds or modifies session settings in an existing array depending on if they exist already or not
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
static void AddOrModifyExtraSettings(UPARAM(ref) TArray<FSessionPropertyKeyPair> & SettingsArray, UPARAM(ref) TArray<FSessionPropertyKeyPair> & NewOrChangedSettings, TArray<FSessionPropertyKeyPair> & ModifiedSettingsArray); static void AddOrModifyExtraSettings(UPARAM(ref) TArray<FSessionPropertyKeyPair> & SettingsArray, UPARAM(ref) TArray<FSessionPropertyKeyPair> & NewOrChangedSettings, TArray<FSessionPropertyKeyPair> & ModifiedSettingsArray);
// Get an array of the session settings from a session search result // Get an array of the session settings from a session search result
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
static void GetExtraSettings(FBlueprintSessionResult SessionResult, TArray<FSessionPropertyKeyPair> & ExtraSettings); static void GetExtraSettings(FBlueprintSessionResult SessionResult, TArray<FSessionPropertyKeyPair> & ExtraSettings);
// Get the current session state // Get the current session state
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject"))
static void GetSessionState(UObject* WorldContextObject, EBPOnlineSessionState &SessionState); static void GetSessionState(UObject* WorldContextObject, EBPOnlineSessionState &SessionState);
// Get the current session settings // Get the current session settings
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void GetSessionSettings(UObject* WorldContextObject, int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result); static void GetSessionSettings(UObject* WorldContextObject, int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result);
// Check if someone is in the current session // Check if someone is in the current session
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject"))
static void IsPlayerInSession(UObject* WorldContextObject, const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession); static void IsPlayerInSession(UObject* WorldContextObject, const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession);
// Make a literal session search parameter // Make a literal session search parameter
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
static FSessionsSearchSetting MakeLiteralSessionSearchProperty(FSessionPropertyKeyPair SessionSearchProperty, EOnlineComparisonOpRedux ComparisonOp); static FSessionsSearchSetting MakeLiteralSessionSearchProperty(FSessionPropertyKeyPair SessionSearchProperty, EOnlineComparisonOpRedux ComparisonOp);
//********* Session Information Functions ***********// //********* Session Information Functions ***********//
// Check if a session result is valid or not // Check if a session result is valid or not
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
static bool IsValidSession(const FBlueprintSessionResult & SessionResult); static bool IsValidSession(const FBlueprintSessionResult & SessionResult);
// Get a string copy of a session ID // Get a string copy of a session ID
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
static void GetSessionID_AsString(const FBlueprintSessionResult & SessionResult, FString& SessionID); static void GetSessionID_AsString(const FBlueprintSessionResult & SessionResult, FString& SessionID);
// Get a string copy of the current session ID // Get a string copy of the current session ID
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject")) UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject"))
static void GetCurrentSessionID_AsString(UObject* WorldContextObject, FString& SessionID); static void GetCurrentSessionID_AsString(UObject* WorldContextObject, FString& SessionID);
// Get the Unique Current Build ID // Get the Unique Current Build ID
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
static void GetCurrentUniqueBuildID(int32 &UniqueBuildId); static void GetCurrentUniqueBuildID(int32 &UniqueBuildId);
// Get the Unique Build ID from a session search result // Get the Unique Build ID from a session search result
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
static void GetUniqueBuildID(FBlueprintSessionResult SessionResult, int32 &UniqueBuildId); static void GetUniqueBuildID(FBlueprintSessionResult SessionResult, int32 &UniqueBuildId);
// Thanks CriErr for submission // Thanks CriErr for submission
// Get session property Key Name value // Get session property Key Name value
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
static FName GetSessionPropertyKey(const FSessionPropertyKeyPair& SessionProperty); static FName GetSessionPropertyKey(const FSessionPropertyKeyPair& SessionProperty);
// Find session property by Name // Find session property by Name
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result"))
static void FindSessionPropertyByName(const TArray<FSessionPropertyKeyPair>& ExtraSettings, FName SettingsName, EBlueprintResultSwitch &Result, FSessionPropertyKeyPair& OutProperty); static void FindSessionPropertyByName(const TArray<FSessionPropertyKeyPair>& ExtraSettings, FName SettingsName, EBlueprintResultSwitch &Result, FSessionPropertyKeyPair& OutProperty);
// Find session property index by Name // Find session property index by Name
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result"))
static void FindSessionPropertyIndexByName(const TArray<FSessionPropertyKeyPair>& ExtraSettings, FName SettingName, EBlueprintResultSwitch &Result, int32& OutIndex); static void FindSessionPropertyIndexByName(const TArray<FSessionPropertyKeyPair>& ExtraSettings, FName SettingName, EBlueprintResultSwitch &Result, int32& OutIndex);
/// Removed the Index_None part of the last function, that isn't accessible in blueprint, better to return success/failure /// Removed the Index_None part of the last function, that isn't accessible in blueprint, better to return success/failure
// End Thanks CriErr :p // End Thanks CriErr :p
// Get session custom information key/value as Byte (For Enums) // Get session custom information key/value as Byte (For Enums)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, uint8 &SettingValue); static void GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, uint8 &SettingValue);
// Get session custom information key/value as Bool // Get session custom information key/value as Bool
// Steam only currently supports Int,Float,String,BYTE values for search filtering!!! // Steam only currently supports Int,Float,String,BYTE values for search filtering!!!
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, bool &SettingValue); static void GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, bool &SettingValue);
// Get session custom information key/value as String // Get session custom information key/value as String
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyString(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, FString &SettingValue); static void GetSessionPropertyString(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, FString &SettingValue);
// Get session custom information key/value as Int // Get session custom information key/value as Int
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyInt(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, int32 &SettingValue); static void GetSessionPropertyInt(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, int32 &SettingValue);
// Get session custom information key/value as Float // Get session custom information key/value as Float
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyFloat(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, float &SettingValue); static void GetSessionPropertyFloat(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, float &SettingValue);
// Make a literal session custom information key/value pair from Byte (For Enums) // Make a literal session custom information key/value pair from Byte (For Enums)
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
static FSessionPropertyKeyPair MakeLiteralSessionPropertyByte(FName Key, uint8 Value); static FSessionPropertyKeyPair MakeLiteralSessionPropertyByte(FName Key, uint8 Value);
// Make a literal session custom information key/value pair from Bool // Make a literal session custom information key/value pair from Bool
// Steam only currently supports Int,Float,String,BYTE values for search filtering! // Steam only currently supports Int,Float,String,BYTE values for search filtering!
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
static FSessionPropertyKeyPair MakeLiteralSessionPropertyBool(FName Key, bool Value); static FSessionPropertyKeyPair MakeLiteralSessionPropertyBool(FName Key, bool Value);
// Make a literal session custom information key/value pair from String // Make a literal session custom information key/value pair from String
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
static FSessionPropertyKeyPair MakeLiteralSessionPropertyString(FName Key, FString Value); static FSessionPropertyKeyPair MakeLiteralSessionPropertyString(FName Key, FString Value);
// Make a literal session custom information key/value pair from Int // Make a literal session custom information key/value pair from Int
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
static FSessionPropertyKeyPair MakeLiteralSessionPropertyInt(FName Key, int32 Value); static FSessionPropertyKeyPair MakeLiteralSessionPropertyInt(FName Key, int32 Value);
// Make a literal session custom information key/value pair from Float // Make a literal session custom information key/value pair from Float
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
static FSessionPropertyKeyPair MakeLiteralSessionPropertyFloat(FName Key, float Value); static FSessionPropertyKeyPair MakeLiteralSessionPropertyFloat(FName Key, float Value);
//******* Player ID functions *********// //******* Player ID functions *********//
// Get the unique net id of a network player attached to the given controller // Get the unique net id of a network player attached to the given controller
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
static void GetUniqueNetID(APlayerController *PlayerController, FBPUniqueNetId &UniqueNetId); static void GetUniqueNetID(APlayerController *PlayerController, FBPUniqueNetId &UniqueNetId);
// Get the unique net id of a network player who is assigned the the given player state // Get the unique net id of a network player who is assigned the the given player state
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
static void GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId); static void GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId);
// Return True if Unique Net ID is valid // Return True if Unique Net ID is valid
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
static bool IsValidUniqueNetID(const FBPUniqueNetId &UniqueNetId); static bool IsValidUniqueNetID(const FBPUniqueNetId &UniqueNetId);
/* Returns true if the values are equal (A == B) */ /* Returns true if the values are equal (A == B) */
UFUNCTION(BlueprintPure, meta = (DisplayName = "Equal Unique Net ID", CompactNodeTitle = "==", Keywords = "== equal"), Category = "Online|AdvancedSessions|PlayerInfo|PlayerID") UFUNCTION(BlueprintPure, meta = (DisplayName = "Equal Unique Net ID", CompactNodeTitle = "==", Keywords = "== equal"), Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
static bool EqualEqual_UNetIDUnetID(const FBPUniqueNetId &A, const FBPUniqueNetId &B); static bool EqualEqual_UNetIDUnetID(const FBPUniqueNetId &A, const FBPUniqueNetId &B);
// Check if a UniqueNetId is a friend // Check if a UniqueNetId is a friend
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|UniqueNetId") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|UniqueNetId")
static void UniqueNetIdToString(const FBPUniqueNetId &UniqueNetId, FString &String); static void UniqueNetIdToString(const FBPUniqueNetId &UniqueNetId, FString &String);
//******** Player Name Functions **********// //******** Player Name Functions **********//
// Get the player name of a network player attached to the given controller // Get the player name of a network player attached to the given controller
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerName") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerName")
static void GetPlayerName(APlayerController *PlayerController, FString &PlayerName); static void GetPlayerName(APlayerController *PlayerController, FString &PlayerName);
// Set the player name of a network player attached to the given controller // Set the player name of a network player attached to the given controller
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|PlayerInfo|PlayerName") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|PlayerInfo|PlayerName")
static void SetPlayerName(APlayerController *PlayerController, FString PlayerName); static void SetPlayerName(APlayerController *PlayerController, FString PlayerName);
//********** Misc Player Info Functions *********// //********** Misc Player Info Functions *********//
// Get the number of network players // Get the number of network players
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|Misc", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", DisplayName = "GetNumNetworkPlayers")) UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|Misc", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", DisplayName = "GetNumNetworkPlayers"))
static void GetNumberOfNetworkPlayers(UObject* WorldContextObject, int32 &NumNetPlayers); static void GetNumberOfNetworkPlayers(UObject* WorldContextObject, int32 &NumNetPlayers);
// Get the network player index of the given controller // Get the network player index of the given controller
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|Misc") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|Misc")
static void GetNetPlayerIndex(APlayerController *PlayerController, int32 &NetPlayerIndex); static void GetNetPlayerIndex(APlayerController *PlayerController, int32 &NetPlayerIndex);
// Checks if the stated session subsystem is active // Checks if the stated session subsystem is active
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc")
static bool HasOnlineSubsystem(FName SubSystemName); static bool HasOnlineSubsystem(FName SubSystemName);
}; };

View File

@@ -1,99 +1,99 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "Interfaces/VoiceInterface.h" #include "Interfaces/VoiceInterface.h"
//#include "OnlineFriendsInterface.h" //#include "OnlineFriendsInterface.h"
//#include "OnlineUserInterface.h" //#include "OnlineUserInterface.h"
//#include "OnlineMessageInterface.h" //#include "OnlineMessageInterface.h"
//#include "OnlinePresenceInterface.h" //#include "OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
//#include "OnlineSessionInterface.h" //#include "OnlineSessionInterface.h"
#include "UObject/UObjectIterator.h" #include "UObject/UObjectIterator.h"
#include "AdvancedVoiceLibrary.generated.h" #include "AdvancedVoiceLibrary.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedVoiceLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedVoiceLog, Log, All);
UCLASS() UCLASS()
class UAdvancedVoiceLibrary : public UBlueprintFunctionLibrary class UAdvancedVoiceLibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* Voice Library Functions *************// //********* Voice Library Functions *************//
// Get if a headset is present for the specified local user // Get if a headset is present for the specified local user
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
static void IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum = 0); static void IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum = 0);
// Starts networked voice, allows push to talk in coordination with StopNetworkedVoice // Starts networked voice, allows push to talk in coordination with StopNetworkedVoice
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static void StartNetworkedVoice(uint8 LocalPlayerNum = 0); static void StartNetworkedVoice(uint8 LocalPlayerNum = 0);
// Stops networked voice, allows push to talk in coordination with StartNetworkedVoice // Stops networked voice, allows push to talk in coordination with StartNetworkedVoice
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static void StopNetworkedVoice(uint8 LocalPlayerNum = 0); static void StopNetworkedVoice(uint8 LocalPlayerNum = 0);
// Registers a local player as someone interested in voice data // Registers a local player as someone interested in voice data
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static bool RegisterLocalTalker(uint8 LocalPlayerNum = 0); static bool RegisterLocalTalker(uint8 LocalPlayerNum = 0);
// Registers all signed in players as local talkers // Registers all signed in players as local talkers
// This is already done automatically, only do it manually if you unregistered someone // This is already done automatically, only do it manually if you unregistered someone
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static void RegisterAllLocalTalkers(); static void RegisterAllLocalTalkers();
// UnRegisters local player as a local talker // UnRegisters local player as a local talker
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static void UnRegisterLocalTalker(uint8 LocalPlayerNum = 0); static void UnRegisterLocalTalker(uint8 LocalPlayerNum = 0);
// UnRegisters all signed in players as local talkers // UnRegisters all signed in players as local talkers
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static void UnRegisterAllLocalTalkers(); static void UnRegisterAllLocalTalkers();
// Registers a remote player as a talker // Registers a remote player as a talker
// This is already done automatically, only do it manually if you unregistered someone // This is already done automatically, only do it manually if you unregistered someone
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static bool RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId); static bool RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId);
// UnRegisters a remote player as a talker // UnRegisters a remote player as a talker
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static bool UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId); static bool UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId);
// UnRegisters all remote players as talkers // UnRegisters all remote players as talkers
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static void RemoveAllRemoteTalkers(); static void RemoveAllRemoteTalkers();
// Returns whether a local player is currently talking // Returns whether a local player is currently talking
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
static bool IsLocalPlayerTalking(uint8 LocalPlayerNum); static bool IsLocalPlayerTalking(uint8 LocalPlayerNum);
// Returns whether a remote player is currently talking // Returns whether a remote player is currently talking
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
static bool IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId); static bool IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId);
// Returns whether a player is muted for the specified local player // Returns whether a player is muted for the specified local player
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
static bool IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId); static bool IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId);
// Mutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to mute globally for the player // Mutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to mute globally for the player
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static bool MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false); static bool MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false);
// UnMutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to unmute globally for the player // UnMutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to unmute globally for the player
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static bool UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false); static bool UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false);
// Gets the number of local talkers for this system // Gets the number of local talkers for this system
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
static void GetNumLocalTalkers(int32 & NumLocalTalkers); static void GetNumLocalTalkers(int32 & NumLocalTalkers);
}; };

View File

@@ -1,435 +1,435 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
//#include "EngineMinimal.h" //#include "EngineMinimal.h"
#include "Engine/Engine.h" #include "Engine/Engine.h"
#include "GameFramework/PlayerState.h" #include "GameFramework/PlayerState.h"
//#include "Core.h" //#include "Core.h"
#include "Interfaces/OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "OnlineSessionSettings.h" #include "OnlineSessionSettings.h"
#include "OnlineDelegateMacros.h" #include "OnlineDelegateMacros.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "OnlineSubsystemImpl.h" #include "OnlineSubsystemImpl.h"
#include "OnlineSubsystemUtils.h" #include "OnlineSubsystemUtils.h"
#include "OnlineSubsystemUtilsModule.h" #include "OnlineSubsystemUtilsModule.h"
#include "GameFramework/PlayerController.h" #include "GameFramework/PlayerController.h"
#include "Modules/ModuleManager.h" #include "Modules/ModuleManager.h"
#include "OnlineSubsystemUtilsClasses.h" #include "OnlineSubsystemUtilsClasses.h"
#include "BlueprintDataDefinitions.generated.h" #include "BlueprintDataDefinitions.generated.h"
UENUM(BlueprintType) UENUM(BlueprintType)
enum class EBPUserPrivileges : uint8 enum class EBPUserPrivileges : uint8
{ {
/** Whether the user can play at all, online or offline - may be age restricted */ /** Whether the user can play at all, online or offline - may be age restricted */
CanPlay, CanPlay,
/** Whether the user can play in online modes */ /** Whether the user can play in online modes */
CanPlayOnline, CanPlayOnline,
/** Whether the user can use voice and text chat */ /** Whether the user can use voice and text chat */
CanCommunicateOnline, CanCommunicateOnline,
/** Whether the user can use content generated by other users */ /** Whether the user can use content generated by other users */
CanUseUserGeneratedContent CanUseUserGeneratedContent
}; };
UENUM(BlueprintType) UENUM(BlueprintType)
enum class EBPLoginStatus : uint8 enum class EBPLoginStatus : uint8
{ {
/** Player has not logged in or chosen a local profile */ /** Player has not logged in or chosen a local profile */
NotLoggedIn, NotLoggedIn,
/** Player is using a local profile but is not logged in */ /** Player is using a local profile but is not logged in */
UsingLocalProfile, UsingLocalProfile,
/** Player has been validated by the platform specific authentication service */ /** Player has been validated by the platform specific authentication service */
LoggedIn LoggedIn
}; };
USTRUCT(BlueprintType) USTRUCT(BlueprintType)
struct FBPUserOnlineAccount struct FBPUserOnlineAccount
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
public: public:
TSharedPtr<FUserOnlineAccount> UserAccountInfo; TSharedPtr<FUserOnlineAccount> UserAccountInfo;
FBPUserOnlineAccount() FBPUserOnlineAccount()
{ {
} }
FBPUserOnlineAccount(TSharedPtr<FUserOnlineAccount> UserAccount) FBPUserOnlineAccount(TSharedPtr<FUserOnlineAccount> UserAccount)
{ {
UserAccountInfo = UserAccount; UserAccountInfo = UserAccount;
} }
}; };
UENUM() UENUM()
enum class ESessionSettingSearchResult : uint8 enum class ESessionSettingSearchResult : uint8
{ {
// Found the setting // Found the setting
Found, Found,
// Did not find the setting // Did not find the setting
NotFound, NotFound,
// Was not the correct type // Was not the correct type
WrongType WrongType
}; };
// This makes a lot of the blueprint functions cleaner // This makes a lot of the blueprint functions cleaner
UENUM() UENUM()
enum class EBlueprintResultSwitch : uint8 enum class EBlueprintResultSwitch : uint8
{ {
// On Success // On Success
OnSuccess, OnSuccess,
// On Failure // On Failure
OnFailure OnFailure
}; };
// This makes a lot of the blueprint functions cleaner // This makes a lot of the blueprint functions cleaner
UENUM() UENUM()
enum class EBlueprintAsyncResultSwitch : uint8 enum class EBlueprintAsyncResultSwitch : uint8
{ {
// On Success // On Success
OnSuccess, OnSuccess,
// Still loading // Still loading
AsyncLoading, AsyncLoading,
// On Failure // On Failure
OnFailure OnFailure
}; };
// This is to define server type searches // This is to define server type searches
UENUM(BlueprintType) UENUM(BlueprintType)
enum class EBPServerPresenceSearchType : uint8 enum class EBPServerPresenceSearchType : uint8
{ {
AllServers, AllServers,
ClientServersOnly, ClientServersOnly,
DedicatedServersOnly DedicatedServersOnly
}; };
// Wanted this to be switchable in the editor // Wanted this to be switchable in the editor
UENUM(BlueprintType) UENUM(BlueprintType)
enum class EBPOnlinePresenceState : uint8 enum class EBPOnlinePresenceState : uint8
{ {
Online, Online,
Offline, Offline,
Away, Away,
ExtendedAway, ExtendedAway,
DoNotDisturb, DoNotDisturb,
Chat Chat
}; };
UENUM(BlueprintType) UENUM(BlueprintType)
enum class EBPOnlineSessionState : uint8 enum class EBPOnlineSessionState : uint8
{ {
/** An online session has not been created yet */ /** An online session has not been created yet */
NoSession, NoSession,
/** An online session is in the process of being created */ /** An online session is in the process of being created */
Creating, Creating,
/** Session has been created but the session hasn't started (pre match lobby) */ /** Session has been created but the session hasn't started (pre match lobby) */
Pending, Pending,
/** Session has been asked to start (may take time due to communication with backend) */ /** Session has been asked to start (may take time due to communication with backend) */
Starting, Starting,
/** The current session has started. Sessions with join in progress disabled are no longer joinable */ /** The current session has started. Sessions with join in progress disabled are no longer joinable */
InProgress, InProgress,
/** The session is still valid, but the session is no longer being played (post match lobby) */ /** The session is still valid, but the session is no longer being played (post match lobby) */
Ending, Ending,
/** The session is closed and any stats committed */ /** The session is closed and any stats committed */
Ended, Ended,
/** The session is being destroyed */ /** The session is being destroyed */
Destroying Destroying
}; };
// Boy oh boy is this a dirty hack, but I can't figure out a good way to do it otherwise at the moment // Boy oh boy is this a dirty hack, but I can't figure out a good way to do it otherwise at the moment
// The UniqueNetId is an abstract class so I can't exactly re-initialize it to make a shared pointer on some functions // The UniqueNetId is an abstract class so I can't exactly re-initialize it to make a shared pointer on some functions
// So I made the blueprintable UniqueNetID into a dual variable struct with access functions and I am converting the const var for the pointer // So I made the blueprintable UniqueNetID into a dual variable struct with access functions and I am converting the const var for the pointer
// I really need to re-think this later // I really need to re-think this later
USTRUCT(BlueprintType) USTRUCT(BlueprintType)
struct FBPUniqueNetId struct FBPUniqueNetId
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
private: private:
bool bUseDirectPointer; bool bUseDirectPointer;
public: public:
TSharedPtr<const FUniqueNetId> UniqueNetId; TSharedPtr<const FUniqueNetId> UniqueNetId;
const FUniqueNetId * UniqueNetIdPtr; const FUniqueNetId * UniqueNetIdPtr;
void SetUniqueNetId(const TSharedPtr<const FUniqueNetId> &ID) void SetUniqueNetId(const TSharedPtr<const FUniqueNetId> &ID)
{ {
bUseDirectPointer = false; bUseDirectPointer = false;
UniqueNetIdPtr = nullptr; UniqueNetIdPtr = nullptr;
UniqueNetId = ID; UniqueNetId = ID;
} }
void SetUniqueNetId(const FUniqueNetId *ID) void SetUniqueNetId(const FUniqueNetId *ID)
{ {
bUseDirectPointer = true; bUseDirectPointer = true;
UniqueNetIdPtr = ID; UniqueNetIdPtr = ID;
} }
bool IsValid() const bool IsValid() const
{ {
if (bUseDirectPointer && UniqueNetIdPtr != nullptr && UniqueNetIdPtr->IsValid()) if (bUseDirectPointer && UniqueNetIdPtr != nullptr && UniqueNetIdPtr->IsValid())
{ {
return true; return true;
} }
else if (UniqueNetId.IsValid()) else if (UniqueNetId.IsValid())
{ {
return true; return true;
} }
else else
return false; return false;
} }
const FUniqueNetId* GetUniqueNetId() const const FUniqueNetId* GetUniqueNetId() const
{ {
if (bUseDirectPointer && UniqueNetIdPtr != nullptr) if (bUseDirectPointer && UniqueNetIdPtr != nullptr)
{ {
// No longer converting to non const as all functions now pass const UniqueNetIds // No longer converting to non const as all functions now pass const UniqueNetIds
return /*const_cast<FUniqueNetId*>*/(UniqueNetIdPtr); return /*const_cast<FUniqueNetId*>*/(UniqueNetIdPtr);
} }
else if (UniqueNetId.IsValid()) else if (UniqueNetId.IsValid())
{ {
return UniqueNetId.Get(); return UniqueNetId.Get();
} }
else else
return nullptr; return nullptr;
} }
// Adding in a compare operator so that std functions will work with this struct // Adding in a compare operator so that std functions will work with this struct
FORCEINLINE bool operator==(const FBPUniqueNetId& Other) const FORCEINLINE bool operator==(const FBPUniqueNetId& Other) const
{ {
return (IsValid() && Other.IsValid() && (*GetUniqueNetId() == *Other.GetUniqueNetId())); return (IsValid() && Other.IsValid() && (*GetUniqueNetId() == *Other.GetUniqueNetId()));
} }
FORCEINLINE bool operator!=(const FBPUniqueNetId& Other) const FORCEINLINE bool operator!=(const FBPUniqueNetId& Other) const
{ {
return !(IsValid() && Other.IsValid() && (*GetUniqueNetId() == *Other.GetUniqueNetId())); return !(IsValid() && Other.IsValid() && (*GetUniqueNetId() == *Other.GetUniqueNetId()));
} }
FBPUniqueNetId() FBPUniqueNetId()
{ {
bUseDirectPointer = false; bUseDirectPointer = false;
UniqueNetIdPtr = nullptr; UniqueNetIdPtr = nullptr;
} }
}; };
USTRUCT(BluePrintType) USTRUCT(BluePrintType)
struct FBPOnlineUser struct FBPOnlineUser
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
public: public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FBPUniqueNetId UniqueNetId; FBPUniqueNetId UniqueNetId;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString DisplayName; FString DisplayName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString RealName; FString RealName;
}; };
USTRUCT(BluePrintType) USTRUCT(BluePrintType)
struct FBPOnlineRecentPlayer : public FBPOnlineUser struct FBPOnlineRecentPlayer : public FBPOnlineUser
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
public: public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString LastSeen; FString LastSeen;
}; };
USTRUCT(BlueprintType) USTRUCT(BlueprintType)
struct FBPFriendPresenceInfo struct FBPFriendPresenceInfo
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
public: public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsOnline = false; bool bIsOnline = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsPlaying = false; bool bIsPlaying = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsPlayingThisGame = false; bool bIsPlayingThisGame = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsJoinable = false; bool bIsJoinable = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bHasVoiceSupport = false; bool bHasVoiceSupport = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
EBPOnlinePresenceState PresenceState = EBPOnlinePresenceState::Offline; EBPOnlinePresenceState PresenceState = EBPOnlinePresenceState::Offline;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString StatusString; FString StatusString;
FBPFriendPresenceInfo() FBPFriendPresenceInfo()
{ {
bIsOnline = false; bIsOnline = false;
bIsPlaying = false; bIsPlaying = false;
bIsPlayingThisGame = false; bIsPlayingThisGame = false;
bIsJoinable = false; bIsJoinable = false;
bHasVoiceSupport = false; bHasVoiceSupport = false;
PresenceState = EBPOnlinePresenceState::Offline; PresenceState = EBPOnlinePresenceState::Offline;
} }
}; };
USTRUCT(BlueprintType) USTRUCT(BlueprintType)
struct FBPFriendInfo struct FBPFriendInfo
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
public: public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString DisplayName; FString DisplayName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString RealName; FString RealName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
EBPOnlinePresenceState OnlineState = EBPOnlinePresenceState::Offline; EBPOnlinePresenceState OnlineState = EBPOnlinePresenceState::Offline;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FBPUniqueNetId UniqueNetId; FBPUniqueNetId UniqueNetId;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsPlayingSameGame = false; bool bIsPlayingSameGame = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FBPFriendPresenceInfo PresenceInfo; FBPFriendPresenceInfo PresenceInfo;
FBPFriendInfo() FBPFriendInfo()
{ {
OnlineState = EBPOnlinePresenceState::Offline; OnlineState = EBPOnlinePresenceState::Offline;
bIsPlayingSameGame = false; bIsPlayingSameGame = false;
} }
}; };
/** The types of comparison operations for a given search query */ /** The types of comparison operations for a given search query */
// Used to compare session properties // Used to compare session properties
UENUM(BlueprintType) UENUM(BlueprintType)
enum class EOnlineComparisonOpRedux : uint8 enum class EOnlineComparisonOpRedux : uint8
{ {
Equals, Equals,
NotEquals, NotEquals,
GreaterThan, GreaterThan,
GreaterThanEquals, GreaterThanEquals,
LessThan, LessThan,
LessThanEquals, LessThanEquals,
}; };
// Used to store session properties before converting to FVariantData // Used to store session properties before converting to FVariantData
USTRUCT(BlueprintType) USTRUCT(BlueprintType)
struct FSessionPropertyKeyPair struct FSessionPropertyKeyPair
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
FName Key; FName Key;
FVariantData Data; FVariantData Data;
}; };
// Sent to the FindSessionsAdvanced to filter the end results // Sent to the FindSessionsAdvanced to filter the end results
USTRUCT(BlueprintType) USTRUCT(BlueprintType)
struct FSessionsSearchSetting struct FSessionsSearchSetting
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
//UPROPERTY() //UPROPERTY()
// Had to make a copy of this to account for the original not being exposed to blueprints // Had to make a copy of this to account for the original not being exposed to blueprints
/** How is this session setting compared on the backend searches */ /** How is this session setting compared on the backend searches */
EOnlineComparisonOpRedux ComparisonOp; EOnlineComparisonOpRedux ComparisonOp;
// The key pair to search for // The key pair to search for
FSessionPropertyKeyPair PropertyKeyPair; FSessionPropertyKeyPair PropertyKeyPair;
}; };
// Couldn't use the default one as it is not exposed to other modules, had to re-create it here // Couldn't use the default one as it is not exposed to other modules, had to re-create it here
// Helper class for various methods to reduce the call hierarchy // Helper class for various methods to reduce the call hierarchy
struct FOnlineSubsystemBPCallHelperAdvanced struct FOnlineSubsystemBPCallHelperAdvanced
{ {
public: public:
FOnlineSubsystemBPCallHelperAdvanced(const TCHAR* CallFunctionContext, UWorld* World, FName SystemName = NAME_None) FOnlineSubsystemBPCallHelperAdvanced(const TCHAR* CallFunctionContext, UWorld* World, FName SystemName = NAME_None)
: OnlineSub(Online::GetSubsystem(World, SystemName)) : OnlineSub(Online::GetSubsystem(World, SystemName))
, FunctionContext(CallFunctionContext) , FunctionContext(CallFunctionContext)
{ {
if (OnlineSub == nullptr) if (OnlineSub == nullptr)
{ {
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Invalid or uninitialized OnlineSubsystem"), FunctionContext), ELogVerbosity::Warning); FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Invalid or uninitialized OnlineSubsystem"), FunctionContext), ELogVerbosity::Warning);
} }
} }
void QueryIDFromPlayerController(APlayerController* PlayerController) void QueryIDFromPlayerController(APlayerController* PlayerController)
{ {
UserID.Reset(); UserID.Reset();
//return const_cast<FUniqueNetId*>(UniqueNetIdPtr); //return const_cast<FUniqueNetId*>(UniqueNetIdPtr);
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL) if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
{ {
UserID = PlayerState->GetUniqueId().GetUniqueNetId(); UserID = PlayerState->GetUniqueId().GetUniqueNetId();
if (!UserID.IsValid()) if (!UserID.IsValid())
{ {
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Cannot map local player to unique net ID"), FunctionContext), ELogVerbosity::Warning); FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Cannot map local player to unique net ID"), FunctionContext), ELogVerbosity::Warning);
} }
} }
else else
{ {
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Invalid player state"), FunctionContext), ELogVerbosity::Warning); FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Invalid player state"), FunctionContext), ELogVerbosity::Warning);
} }
} }
bool IsValid() const bool IsValid() const
{ {
return UserID.IsValid() && (OnlineSub != nullptr); return UserID.IsValid() && (OnlineSub != nullptr);
} }
public: public:
//TSharedPtr<const FUniqueNetId>& GetUniqueNetId() //TSharedPtr<const FUniqueNetId>& GetUniqueNetId()
TSharedPtr</*class*/ const FUniqueNetId> UserID; TSharedPtr</*class*/ const FUniqueNetId> UserID;
IOnlineSubsystem* const OnlineSub; IOnlineSubsystem* const OnlineSub;
const TCHAR* FunctionContext; const TCHAR* FunctionContext;
}; };
class FOnlineSearchSettingsEx : public FOnlineSearchSettings class FOnlineSearchSettingsEx : public FOnlineSearchSettings
{ {
/** /**
* Sets a key value pair combination that defines a search parameter * Sets a key value pair combination that defines a search parameter
* *
* @param Key key for the setting * @param Key key for the setting
* @param Value value of the setting * @param Value value of the setting
* @param InType type of comparison * @param InType type of comparison
*/ */
public: public:
void HardSet(FName Key, const FVariantData& Value, EOnlineComparisonOpRedux CompOp) void HardSet(FName Key, const FVariantData& Value, EOnlineComparisonOpRedux CompOp)
{ {
FOnlineSessionSearchParam* SearchParam = SearchParams.Find(Key); FOnlineSessionSearchParam* SearchParam = SearchParams.Find(Key);
TEnumAsByte<EOnlineComparisonOp::Type> op; TEnumAsByte<EOnlineComparisonOp::Type> op;
switch (CompOp) switch (CompOp)
{ {
case EOnlineComparisonOpRedux::Equals: op = EOnlineComparisonOp::Equals; break; case EOnlineComparisonOpRedux::Equals: op = EOnlineComparisonOp::Equals; break;
case EOnlineComparisonOpRedux::GreaterThan: op = EOnlineComparisonOp::GreaterThan; break; case EOnlineComparisonOpRedux::GreaterThan: op = EOnlineComparisonOp::GreaterThan; break;
case EOnlineComparisonOpRedux::GreaterThanEquals: op = EOnlineComparisonOp::GreaterThanEquals; break; case EOnlineComparisonOpRedux::GreaterThanEquals: op = EOnlineComparisonOp::GreaterThanEquals; break;
case EOnlineComparisonOpRedux::LessThan: op = EOnlineComparisonOp::LessThan; break; case EOnlineComparisonOpRedux::LessThan: op = EOnlineComparisonOp::LessThan; break;
case EOnlineComparisonOpRedux::LessThanEquals: op = EOnlineComparisonOp::LessThanEquals; break; case EOnlineComparisonOpRedux::LessThanEquals: op = EOnlineComparisonOp::LessThanEquals; break;
case EOnlineComparisonOpRedux::NotEquals: op = EOnlineComparisonOp::NotEquals; break; case EOnlineComparisonOpRedux::NotEquals: op = EOnlineComparisonOp::NotEquals; break;
default: op = EOnlineComparisonOp::Equals; break; default: op = EOnlineComparisonOp::Equals; break;
} }
if (SearchParam) if (SearchParam)
{ {
SearchParam->Data = Value; SearchParam->Data = Value;
SearchParam->ComparisonOp = op; SearchParam->ComparisonOp = op;
} }
else else
{ {
FOnlineSessionSearchParam searchSetting((int)0, op); FOnlineSessionSearchParam searchSetting((int)0, op);
searchSetting.Data = Value; searchSetting.Data = Value;
SearchParams.Add(Key, searchSetting); SearchParams.Add(Key, searchSetting);
} }
} }
}; };
#define INVALID_INDEX -1 #define INVALID_INDEX -1

View File

@@ -1,103 +1,103 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Engine/Engine.h" #include "Engine/Engine.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "CreateSessionCallbackProxyAdvanced.generated.h" #include "CreateSessionCallbackProxyAdvanced.generated.h"
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
// Called when the session was created successfully // Called when the session was created successfully
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnSuccess; FEmptyOnlineDelegate OnSuccess;
// Called when there was an error creating the session // Called when there was an error creating the session
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnFailure; FEmptyOnlineDelegate OnFailure;
/** /**
* Creates a session with the default online subsystem with advanced optional inputs, for dedicated servers leave UsePresence as false and set IsDedicatedServer to true. Dedicated servers don't use presence. * Creates a session with the default online subsystem with advanced optional inputs, for dedicated servers leave UsePresence as false and set IsDedicatedServer to true. Dedicated servers don't use presence.
* @param PublicConnections When doing a 'listen' server, this must be >=2 (ListenServer itself counts as a connection) * @param PublicConnections When doing a 'listen' server, this must be >=2 (ListenServer itself counts as a connection)
* @param bUseLAN When you want to play LAN, the level to play on must be loaded with option 'bIsLanMatch' * @param bUseLAN When you want to play LAN, the level to play on must be loaded with option 'bIsLanMatch'
* @param bUsePresence Must be true for a 'listen' server (Map must be loaded with option 'listen'), false for a 'dedicated' server. * @param bUsePresence Must be true for a 'listen' server (Map must be loaded with option 'listen'), false for a 'dedicated' server.
* @param bUseLobbiesIfAvailable Used to flag the subsystem to use a lobby api instead of general hosting if the API supports it, generally true on steam for listen servers and false for dedicated * @param bUseLobbiesIfAvailable Used to flag the subsystem to use a lobby api instead of general hosting if the API supports it, generally true on steam for listen servers and false for dedicated
* @param bShouldAdvertise Set to true when the OnlineSubsystem should list your server when someone is searching for servers. Otherwise the server is hidden and only join via invite is possible. * @param bShouldAdvertise Set to true when the OnlineSubsystem should list your server when someone is searching for servers. Otherwise the server is hidden and only join via invite is possible.
* @param bUseLobbiesVoiceChatIfAvailable Set to true to setup voice chat lobbies if the API supports it * @param bUseLobbiesVoiceChatIfAvailable Set to true to setup voice chat lobbies if the API supports it
*/ */
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions") 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, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bUseLobbiesIfAvailable = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true, bool bUseLobbiesVoiceChatIfAvailable = false); 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 bUseLobbiesIfAvailable = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true, bool bUseLobbiesVoiceChatIfAvailable = false);
// UOnlineBlueprintCallProxyBase interface // UOnlineBlueprintCallProxyBase interface
virtual void Activate() override; virtual void Activate() override;
// End of UOnlineBlueprintCallProxyBase interface // End of UOnlineBlueprintCallProxyBase interface
private: private:
// Internal callback when session creation completes, calls StartSession // Internal callback when session creation completes, calls StartSession
void OnCreateCompleted(FName SessionName, bool bWasSuccessful); void OnCreateCompleted(FName SessionName, bool bWasSuccessful);
// Internal callback when session creation completes, calls StartSession // Internal callback when session creation completes, calls StartSession
void OnStartCompleted(FName SessionName, bool bWasSuccessful); void OnStartCompleted(FName SessionName, bool bWasSuccessful);
// The player controller triggering things // The player controller triggering things
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr; TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
// The delegate executed by the online subsystem // The delegate executed by the online subsystem
FOnCreateSessionCompleteDelegate CreateCompleteDelegate; FOnCreateSessionCompleteDelegate CreateCompleteDelegate;
// The delegate executed by the online subsystem // The delegate executed by the online subsystem
FOnStartSessionCompleteDelegate StartCompleteDelegate; FOnStartSessionCompleteDelegate StartCompleteDelegate;
// Handles to the registered delegates above // Handles to the registered delegates above
FDelegateHandle CreateCompleteDelegateHandle; FDelegateHandle CreateCompleteDelegateHandle;
FDelegateHandle StartCompleteDelegateHandle; FDelegateHandle StartCompleteDelegateHandle;
// Number of public connections // Number of public connections
int NumPublicConnections; int NumPublicConnections;
// Number of private connections // Number of private connections
int NumPrivateConnections; int NumPrivateConnections;
// Whether or not to search LAN // Whether or not to search LAN
bool bUseLAN; bool bUseLAN;
// Whether or not to allow invites // Whether or not to allow invites
bool bAllowInvites; bool bAllowInvites;
// Whether this is a dedicated server or not // Whether this is a dedicated server or not
bool bDedicatedServer; bool bDedicatedServer;
// Whether to use the presence option // Whether to use the presence option
bool bUsePresence; bool bUsePresence;
// Whether to prefer the use of lobbies for hosting if the api supports them // Whether to prefer the use of lobbies for hosting if the api supports them
bool bUseLobbiesIfAvailable; bool bUseLobbiesIfAvailable;
// Whether to allow joining via presence // Whether to allow joining via presence
bool bAllowJoinViaPresence; bool bAllowJoinViaPresence;
// Allow joining via presence for friends only // Allow joining via presence for friends only
bool bAllowJoinViaPresenceFriendsOnly; bool bAllowJoinViaPresenceFriendsOnly;
// Delcare the server to be anti cheat protected // Delcare the server to be anti cheat protected
bool bAntiCheatProtected; bool bAntiCheatProtected;
// Record Stats // Record Stats
bool bUsesStats; bool bUsesStats;
// Should advertise server? // Should advertise server?
bool bShouldAdvertise; bool bShouldAdvertise;
// Whether to prefer the use of voice chat lobbies if the api supports them // Whether to prefer the use of voice chat lobbies if the api supports them
bool bUseLobbiesVoiceChatIfAvailable; bool bUseLobbiesVoiceChatIfAvailable;
// Store extra settings // Store extra settings
TArray<FSessionPropertyKeyPair> ExtraSettings; TArray<FSessionPropertyKeyPair> ExtraSettings;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; UObject* WorldContextObject;
}; };

View File

@@ -1,51 +1,51 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "FindFriendSessionCallbackProxy.generated.h" #include "FindFriendSessionCallbackProxy.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFindFriendSessionLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedFindFriendSessionLog, Log, All);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintFindFriendSessionDelegate, const TArray<FBlueprintSessionResult> &, SessionInfo); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintFindFriendSessionDelegate, const TArray<FBlueprintSessionResult> &, SessionInfo);
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class UFindFriendSessionCallbackProxy : public UOnlineBlueprintCallProxyBase class UFindFriendSessionCallbackProxy : public UOnlineBlueprintCallProxyBase
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
// Called when the friends list successfully was retrieved // Called when the friends list successfully was retrieved
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintFindFriendSessionDelegate OnSuccess; FBlueprintFindFriendSessionDelegate OnSuccess;
// Called when there was an error retrieving the friends list // Called when there was an error retrieving the friends list
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintFindFriendSessionDelegate OnFailure; FBlueprintFindFriendSessionDelegate OnFailure;
// Attempts to get the current session that a friend is in // Attempts to get the current session that a friend is in
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
static UFindFriendSessionCallbackProxy* FindFriendSession(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId); static UFindFriendSessionCallbackProxy* FindFriendSession(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId);
virtual void Activate() override; virtual void Activate() override;
private: private:
// Internal callback when the friends list is retrieved // Internal callback when the friends list is retrieved
void OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const TArray<FOnlineSessionSearchResult>& SessionInfo); void OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const TArray<FOnlineSessionSearchResult>& SessionInfo);
// The player controller triggering things // The player controller triggering things
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr; TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
// The UniqueNetID of the person to invite // The UniqueNetID of the person to invite
FBPUniqueNetId cUniqueNetId; FBPUniqueNetId cUniqueNetId;
// The delegate to call on completion // The delegate to call on completion
FOnFindFriendSessionCompleteDelegate OnFindFriendSessionCompleteDelegate; FOnFindFriendSessionCompleteDelegate OnFindFriendSessionCompleteDelegate;
// Handles to the registered delegates above // Handles to the registered delegates above
FDelegateHandle FindFriendSessionCompleteDelegateHandle; FDelegateHandle FindFriendSessionCompleteDelegateHandle;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; UObject* WorldContextObject;
}; };

View File

@@ -52,9 +52,9 @@ private:
// Internal callback when the session search completes, calls out to the public success/failure callbacks // Internal callback when the session search completes, calls out to the public success/failure callbacks
void OnCompleted(bool bSuccess); void OnCompleted(bool bSuccess);
bool bRunSecondSearch; bool bRunSecondSearch;
bool bIsOnSecondSearch; bool bIsOnSecondSearch;
TArray<FBlueprintSessionResult> SessionSearchResults; TArray<FBlueprintSessionResult> SessionSearchResults;
private: private:

View File

@@ -1,49 +1,49 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "GetFriendsCallbackProxy.generated.h" #include "GetFriendsCallbackProxy.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(AdvancedGetFriendsLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedGetFriendsLog, Log, All);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGetFriendsListDelegate, const TArray<FBPFriendInfo>&, Results); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGetFriendsListDelegate, const TArray<FBPFriendInfo>&, Results);
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class UGetFriendsCallbackProxy : public UOnlineBlueprintCallProxyBase class UGetFriendsCallbackProxy : public UOnlineBlueprintCallProxyBase
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
// Called when the friends list successfully was retrieved // Called when the friends list successfully was retrieved
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGetFriendsListDelegate OnSuccess; FBlueprintGetFriendsListDelegate OnSuccess;
// Called when there was an error retrieving the friends list // Called when there was an error retrieving the friends list
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGetFriendsListDelegate OnFailure; FBlueprintGetFriendsListDelegate OnFailure;
// Gets the players list of friends from the OnlineSubsystem and returns it, can be retrieved later with GetStoredFriendsList // Gets the players list of friends from the OnlineSubsystem and returns it, can be retrieved later with GetStoredFriendsList
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
static UGetFriendsCallbackProxy* GetAndStoreFriendsList(UObject* WorldContextObject, class APlayerController* PlayerController); static UGetFriendsCallbackProxy* GetAndStoreFriendsList(UObject* WorldContextObject, class APlayerController* PlayerController);
virtual void Activate() override; virtual void Activate() override;
private: private:
// Internal callback when the friends list is retrieved // Internal callback when the friends list is retrieved
void OnReadFriendsListCompleted(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorString); void OnReadFriendsListCompleted(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorString);
// The player controller triggering things // The player controller triggering things
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr; TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
// The delegate executed // The delegate executed
FOnReadFriendsListComplete FriendListReadCompleteDelegate; FOnReadFriendsListComplete FriendListReadCompleteDelegate;
// The Type of friends list to get // The Type of friends list to get
// Removed because all but the facebook interfaces don't even currently support anything but the default friends list. // Removed because all but the facebook interfaces don't even currently support anything but the default friends list.
//EBPFriendsLists FriendListToGet; //EBPFriendsLists FriendListToGet;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; UObject* WorldContextObject;
}; };

View File

@@ -1,49 +1,49 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "GetRecentPlayersCallbackProxy.generated.h" #include "GetRecentPlayersCallbackProxy.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(AdvancedGetRecentPlayersLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedGetRecentPlayersLog, Log, All);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGetRecentPlayersDelegate, const TArray<FBPOnlineRecentPlayer>&, Results); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGetRecentPlayersDelegate, const TArray<FBPOnlineRecentPlayer>&, Results);
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class UGetRecentPlayersCallbackProxy : public UOnlineBlueprintCallProxyBase class UGetRecentPlayersCallbackProxy : public UOnlineBlueprintCallProxyBase
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
// Called when the friends list successfully was retrieved // Called when the friends list successfully was retrieved
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGetRecentPlayersDelegate OnSuccess; FBlueprintGetRecentPlayersDelegate OnSuccess;
// Called when there was an error retrieving the friends list // Called when there was an error retrieving the friends list
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGetRecentPlayersDelegate OnFailure; FBlueprintGetRecentPlayersDelegate OnFailure;
// Gets the list of recent players from the OnlineSubsystem and returns it, can be retrieved later with GetStoredRecentPlayersList, can fail if no recent players are found // Gets the list of recent players from the OnlineSubsystem and returns it, can be retrieved later with GetStoredRecentPlayersList, can fail if no recent players are found
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
static UGetRecentPlayersCallbackProxy* GetAndStoreRecentPlayersList(UObject* WorldContextObject, const FBPUniqueNetId &UniqueNetId); static UGetRecentPlayersCallbackProxy* GetAndStoreRecentPlayersList(UObject* WorldContextObject, const FBPUniqueNetId &UniqueNetId);
virtual void Activate() override; virtual void Activate() override;
private: private:
// Internal callback when the friends list is retrieved // Internal callback when the friends list is retrieved
void OnQueryRecentPlayersCompleted(const FUniqueNetId &UserID, const FString &Namespace, bool bWasSuccessful, const FString& ErrorString); void OnQueryRecentPlayersCompleted(const FUniqueNetId &UserID, const FString &Namespace, bool bWasSuccessful, const FString& ErrorString);
// Handle to the registered OnFindSessionsComplete delegate // Handle to the registered OnFindSessionsComplete delegate
FDelegateHandle DelegateHandle; FDelegateHandle DelegateHandle;
// The player controller triggering things // The player controller triggering things
//TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr; //TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
// The UniqueNetID of the person to get recent players for // The UniqueNetID of the person to get recent players for
FBPUniqueNetId cUniqueNetId; FBPUniqueNetId cUniqueNetId;
// The delegate executed // The delegate executed
FOnQueryRecentPlayersCompleteDelegate QueryRecentPlayersCompleteDelegate; FOnQueryRecentPlayersCompleteDelegate QueryRecentPlayersCompleteDelegate;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; UObject* WorldContextObject;
}; };

View File

@@ -1,27 +1,27 @@
#pragma once #pragma once
//#include "EngineMinimal.h" //#include "EngineMinimal.h"
//#include "Core.h" //#include "Core.h"
//#include "OnlineSessionInterface.h" //#include "OnlineSessionInterface.h"
//#include "OnlineSessionSettings.h" //#include "OnlineSessionSettings.h"
//#include "OnlineDelegateMacros.h" //#include "OnlineDelegateMacros.h"
//#include "OnlineSubsystem.h" //#include "OnlineSubsystem.h"
//#include "OnlineSubsystemImpl.h" //#include "OnlineSubsystemImpl.h"
//#include "OnlineSubsystemUtils.h" //#include "OnlineSubsystemUtils.h"
//#include "OnlineSubsystemUtilsModule.h" //#include "OnlineSubsystemUtilsModule.h"
//#include "ModuleManager.h" //#include "ModuleManager.h"
//#include "OnlineSubsystemUtilsClasses.h" //#include "OnlineSubsystemUtilsClasses.h"
//#include "BlueprintDataDefinitions.h" //#include "BlueprintDataDefinitions.h"
/*#include "VoiceEngineImpl.h" /*#include "VoiceEngineImpl.h"
#include "VoiceInterfaceImpl.h" #include "VoiceInterfaceImpl.h"
#include "Voice.h"" #include "Voice.h""
*/ */
// Found this in the steam controller, seems like a nice thought since steam is throwing errors // Found this in the steam controller, seems like a nice thought since steam is throwing errors
// Disable crazy warnings that claim that standard C library is "deprecated". // Disable crazy warnings that claim that standard C library is "deprecated".
//#ifdef _MSC_VER //#ifdef _MSC_VER
//#pragma warning(push) //#pragma warning(push)
//#pragma warning(disable:4996) //#pragma warning(disable:4996)
//#endif //#endif

View File

@@ -1,49 +1,49 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "SendFriendInviteCallbackProxy.generated.h" #include "SendFriendInviteCallbackProxy.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSendFriendInviteLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedSendFriendInviteLog, Log, All);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBlueprintSendFriendInviteDelegate); DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBlueprintSendFriendInviteDelegate);
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class USendFriendInviteCallbackProxy : public UOnlineBlueprintCallProxyBase class USendFriendInviteCallbackProxy : public UOnlineBlueprintCallProxyBase
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
// Called when the friends list successfully was retrieved // Called when the friends list successfully was retrieved
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintSendFriendInviteDelegate OnSuccess; FBlueprintSendFriendInviteDelegate OnSuccess;
// Called when there was an error retrieving the friends list // Called when there was an error retrieving the friends list
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintSendFriendInviteDelegate OnFailure; FBlueprintSendFriendInviteDelegate OnFailure;
// Adds a friend who is using the defined UniqueNetId, some interfaces do now allow this function to be called (INCLUDING STEAM) // Adds a friend who is using the defined UniqueNetId, some interfaces do now allow this function to be called (INCLUDING STEAM)
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
static USendFriendInviteCallbackProxy* SendFriendInvite(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &UniqueNetIDInvited); static USendFriendInviteCallbackProxy* SendFriendInvite(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &UniqueNetIDInvited);
virtual void Activate() override; virtual void Activate() override;
private: private:
// Internal callback when the friends list is retrieved // Internal callback when the friends list is retrieved
void OnSendInviteComplete(int32 LocalPlayerNum, bool bWasSuccessful, const FUniqueNetId &InvitedPlayer, const FString &ListName, const FString &ErrorString); void OnSendInviteComplete(int32 LocalPlayerNum, bool bWasSuccessful, const FUniqueNetId &InvitedPlayer, const FString &ListName, const FString &ErrorString);
// The player controller triggering things // The player controller triggering things
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr; TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
// The UniqueNetID of the person to invite // The UniqueNetID of the person to invite
FBPUniqueNetId cUniqueNetId; FBPUniqueNetId cUniqueNetId;
// The delegate to call on completion // The delegate to call on completion
FOnSendInviteComplete OnSendInviteCompleteDelegate; FOnSendInviteComplete OnSendInviteCompleteDelegate;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; UObject* WorldContextObject;
}; };

View File

@@ -1,160 +1,160 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedExternalUILibrary.h" #include "AdvancedExternalUILibrary.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedExternalUILog); DEFINE_LOG_CATEGORY(AdvancedExternalUILog);
void UAdvancedExternalUILibrary::ShowAccountUpgradeUI(const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, EBlueprintResultSwitch &Result) void UAdvancedExternalUILibrary::ShowAccountUpgradeUI(const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, EBlueprintResultSwitch &Result)
{ {
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid()) if (!ExternalUIInterface.IsValid())
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowAccountUpgradeUI Failed to get External UI interface!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowAccountUpgradeUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ExternalUIInterface->ShowAccountUpgradeUI(*PlayerRequestingAccountUpgradeUI.GetUniqueNetId()); ExternalUIInterface->ShowAccountUpgradeUI(*PlayerRequestingAccountUpgradeUI.GetUniqueNetId());
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedExternalUILibrary::ShowProfileUI(const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, EBlueprintResultSwitch &Result) void UAdvancedExternalUILibrary::ShowProfileUI(const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, EBlueprintResultSwitch &Result)
{ {
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid()) if (!ExternalUIInterface.IsValid())
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowProfileUI Failed to get External UI interface!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowProfileUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ExternalUIInterface->ShowProfileUI(*PlayerViewingProfile.GetUniqueNetId(), *PlayerToViewProfileOf.GetUniqueNetId(), NULL); ExternalUIInterface->ShowProfileUI(*PlayerViewingProfile.GetUniqueNetId(), *PlayerToViewProfileOf.GetUniqueNetId(), NULL);
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedExternalUILibrary::ShowWebURLUI(FString URLToShow, EBlueprintResultSwitch &Result, TArray<FString>& AllowedDomains, bool bEmbedded, bool bShowBackground, bool bShowCloseButton, int32 OffsetX, int32 OffsetY, int32 SizeX, int32 SizeY) void UAdvancedExternalUILibrary::ShowWebURLUI(FString URLToShow, EBlueprintResultSwitch &Result, TArray<FString>& AllowedDomains, bool bEmbedded, bool bShowBackground, bool bShowCloseButton, int32 OffsetX, int32 OffsetY, int32 SizeX, int32 SizeY)
{ {
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid()) if (!ExternalUIInterface.IsValid())
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowWebURLUI Failed to get External UI interface!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowWebURLUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
URLToShow = URLToShow.Replace(TEXT("http://"), TEXT("")); URLToShow = URLToShow.Replace(TEXT("http://"), TEXT(""));
URLToShow = URLToShow.Replace(TEXT("https://"), TEXT("")); URLToShow = URLToShow.Replace(TEXT("https://"), TEXT(""));
FShowWebUrlParams Params; FShowWebUrlParams Params;
Params.AllowedDomains = AllowedDomains; Params.AllowedDomains = AllowedDomains;
Params.bEmbedded = bEmbedded; Params.bEmbedded = bEmbedded;
Params.bShowBackground = bShowBackground; Params.bShowBackground = bShowBackground;
Params.bShowCloseButton = bShowCloseButton; Params.bShowCloseButton = bShowCloseButton;
Params.OffsetX = OffsetX; Params.OffsetX = OffsetX;
Params.OffsetY = OffsetY; Params.OffsetY = OffsetY;
Params.SizeX = SizeX; Params.SizeX = SizeX;
Params.SizeY = SizeY; Params.SizeY = SizeY;
ExternalUIInterface->ShowWebURL(URLToShow, Params); ExternalUIInterface->ShowWebURL(URLToShow, Params);
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedExternalUILibrary::CloseWebURLUI() void UAdvancedExternalUILibrary::CloseWebURLUI()
{ {
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid()) if (!ExternalUIInterface.IsValid())
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("CloseWebURLUI Failed to get External UI interface!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("CloseWebURLUI Failed to get External UI interface!"));
return; return;
} }
ExternalUIInterface->CloseWebURL(); ExternalUIInterface->CloseWebURL();
} }
void UAdvancedExternalUILibrary::ShowLeaderBoardUI(FString LeaderboardName, EBlueprintResultSwitch &Result) void UAdvancedExternalUILibrary::ShowLeaderBoardUI(FString LeaderboardName, EBlueprintResultSwitch &Result)
{ {
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid()) if (!ExternalUIInterface.IsValid())
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowLeaderboardsUI Failed to get External UI interface!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowLeaderboardsUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ExternalUIInterface->ShowLeaderboardUI(LeaderboardName); ExternalUIInterface->ShowLeaderboardUI(LeaderboardName);
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedExternalUILibrary::ShowInviteUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result) void UAdvancedExternalUILibrary::ShowInviteUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Had a bad Player Controller!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Had a bad Player Controller!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid()) if (!ExternalUIInterface.IsValid())
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get External UI interface!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get ULocalPlayer for the given PlayerController!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get ULocalPlayer for the given PlayerController!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ExternalUIInterface->ShowInviteUI(Player->GetControllerId(), NAME_GameSession); ExternalUIInterface->ShowInviteUI(Player->GetControllerId(), NAME_GameSession);
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedExternalUILibrary::ShowFriendsUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result) void UAdvancedExternalUILibrary::ShowFriendsUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Had a bad Player Controller!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Had a bad Player Controller!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
if (!ExternalUIInterface.IsValid()) if (!ExternalUIInterface.IsValid())
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get External UI interface!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get ULocalPlayer for the given PlayerController!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get ULocalPlayer for the given PlayerController!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ExternalUIInterface->ShowFriendsUI(Player->GetControllerId()); ExternalUIInterface->ShowFriendsUI(Player->GetControllerId());
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }

View File

@@ -1,334 +1,334 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedFriendsGameInstance.h" #include "AdvancedFriendsGameInstance.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "GameFramework/PlayerController.h" #include "GameFramework/PlayerController.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedFriendsInterfaceLog); DEFINE_LOG_CATEGORY(AdvancedFriendsInterfaceLog);
UAdvancedFriendsGameInstance::UAdvancedFriendsGameInstance(const FObjectInitializer& ObjectInitializer) UAdvancedFriendsGameInstance::UAdvancedFriendsGameInstance(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
, bCallFriendInterfaceEventsOnPlayerControllers(true) , bCallFriendInterfaceEventsOnPlayerControllers(true)
, bCallIdentityInterfaceEventsOnPlayerControllers(true) , bCallIdentityInterfaceEventsOnPlayerControllers(true)
, bCallVoiceInterfaceEventsOnPlayerControllers(true) , bCallVoiceInterfaceEventsOnPlayerControllers(true)
, bEnableTalkingStatusDelegate(true) , bEnableTalkingStatusDelegate(true)
, SessionInviteReceivedDelegate(FOnSessionInviteReceivedDelegate::CreateUObject(this, &ThisClass::OnSessionInviteReceivedMaster)) , SessionInviteReceivedDelegate(FOnSessionInviteReceivedDelegate::CreateUObject(this, &ThisClass::OnSessionInviteReceivedMaster))
, SessionInviteAcceptedDelegate(FOnSessionUserInviteAcceptedDelegate::CreateUObject(this, &ThisClass::OnSessionInviteAcceptedMaster)) , SessionInviteAcceptedDelegate(FOnSessionUserInviteAcceptedDelegate::CreateUObject(this, &ThisClass::OnSessionInviteAcceptedMaster))
, PlayerTalkingStateChangedDelegate(FOnPlayerTalkingStateChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerTalkingStateChangedMaster)) , PlayerTalkingStateChangedDelegate(FOnPlayerTalkingStateChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerTalkingStateChangedMaster))
, PlayerLoginChangedDelegate(FOnLoginChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerLoginChangedMaster)) , PlayerLoginChangedDelegate(FOnLoginChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerLoginChangedMaster))
, PlayerLoginStatusChangedDelegate(FOnLoginStatusChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerLoginStatusChangedMaster)) , PlayerLoginStatusChangedDelegate(FOnLoginStatusChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerLoginStatusChangedMaster))
{ {
} }
void UAdvancedFriendsGameInstance::Shutdown() void UAdvancedFriendsGameInstance::Shutdown()
{ {
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(GetWorld()); IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(GetWorld());
if (!SessionInterface.IsValid()) if (!SessionInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsGameInstance Failed to get session system!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsGameInstance Failed to get session system!"));
//return; //return;
} }
else else
{ {
// Clear all of the delegate handles here // Clear all of the delegate handles here
SessionInterface->ClearOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegateHandle); SessionInterface->ClearOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegateHandle);
SessionInterface->ClearOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegateHandle); SessionInterface->ClearOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegateHandle);
} }
if (bEnableTalkingStatusDelegate) if (bEnableTalkingStatusDelegate)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(GetWorld()); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(GetWorld());
if (VoiceInterface.IsValid()) if (VoiceInterface.IsValid())
{ {
VoiceInterface->ClearOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegateHandle); VoiceInterface->ClearOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegateHandle);
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!"));
} }
} }
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(GetWorld()); IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(GetWorld());
if (IdentityInterface.IsValid()) if (IdentityInterface.IsValid())
{ {
IdentityInterface->ClearOnLoginChangedDelegate_Handle(PlayerLoginChangedDelegateHandle); IdentityInterface->ClearOnLoginChangedDelegate_Handle(PlayerLoginChangedDelegateHandle);
// I am just defaulting to player 1 // I am just defaulting to player 1
IdentityInterface->ClearOnLoginStatusChangedDelegate_Handle(0, PlayerLoginStatusChangedDelegateHandle); IdentityInterface->ClearOnLoginStatusChangedDelegate_Handle(0, PlayerLoginStatusChangedDelegateHandle);
} }
Super::Shutdown(); Super::Shutdown();
} }
void UAdvancedFriendsGameInstance::Init() void UAdvancedFriendsGameInstance::Init()
{ {
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(GetWorld());//OnlineSub->GetSessionInterface(); IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(GetWorld());//OnlineSub->GetSessionInterface();
if (SessionInterface.IsValid()) if (SessionInterface.IsValid())
{ {
// Currently doesn't store a handle or assign a delegate to any local player beyond the first.....should handle? // Currently doesn't store a handle or assign a delegate to any local player beyond the first.....should handle?
// Thought about directly handling it but friends for multiple players probably isn't required // Thought about directly handling it but friends for multiple players probably isn't required
// Iterating through the local player TArray only works if it has had players assigned to it, most of the online interfaces don't support // Iterating through the local player TArray only works if it has had players assigned to it, most of the online interfaces don't support
// Multiple logins either (IE: Steam) // Multiple logins either (IE: Steam)
SessionInviteAcceptedDelegateHandle = SessionInterface->AddOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegate); SessionInviteAcceptedDelegateHandle = SessionInterface->AddOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegate);
SessionInviteReceivedDelegateHandle = SessionInterface->AddOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegate); SessionInviteReceivedDelegateHandle = SessionInterface->AddOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegate);
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get session interface!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get session interface!"));
//return; //return;
} }
// Beginning work on the voice interface // Beginning work on the voice interface
if (bEnableTalkingStatusDelegate) if (bEnableTalkingStatusDelegate)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(GetWorld()); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(GetWorld());
if (VoiceInterface.IsValid()) if (VoiceInterface.IsValid())
{ {
PlayerTalkingStateChangedDelegateHandle = VoiceInterface->AddOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegate); PlayerTalkingStateChangedDelegateHandle = VoiceInterface->AddOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegate);
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!"));
} }
} }
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(GetWorld()); IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(GetWorld());
if (IdentityInterface.IsValid()) if (IdentityInterface.IsValid())
{ {
PlayerLoginChangedDelegateHandle = IdentityInterface->AddOnLoginChangedDelegate_Handle(PlayerLoginChangedDelegate); PlayerLoginChangedDelegateHandle = IdentityInterface->AddOnLoginChangedDelegate_Handle(PlayerLoginChangedDelegate);
// Just defaulting to player 1 // Just defaulting to player 1
PlayerLoginStatusChangedDelegateHandle = IdentityInterface->AddOnLoginStatusChangedDelegate_Handle(0, PlayerLoginStatusChangedDelegate); PlayerLoginStatusChangedDelegateHandle = IdentityInterface->AddOnLoginStatusChangedDelegate_Handle(0, PlayerLoginStatusChangedDelegate);
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get identity interface!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get identity interface!"));
} }
Super::Init(); Super::Init();
} }
/*void UAdvancedFriendsGameInstance::PostLoad() /*void UAdvancedFriendsGameInstance::PostLoad()
{ {
Super::PostLoad(); Super::PostLoad();
}*/ }*/
// Removed because it never gets called by the online subsystems // Removed because it never gets called by the online subsystems
/*void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId &InvitedPlayer, const FUniqueNetId &FriendInviting, const FOnlineSessionSearchResult& Session) /*void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId &InvitedPlayer, const FUniqueNetId &FriendInviting, const FOnlineSessionSearchResult& Session)
{ {
// Just call the blueprint event to let the user handle this // Just call the blueprint event to let the user handle this
FBPUniqueNetId IP, FI; FBPUniqueNetId IP, FI;
IP.SetUniqueNetId(&InvitedPlayer); IP.SetUniqueNetId(&InvitedPlayer);
FI.SetUniqueNetId(&FriendInviting); FI.SetUniqueNetId(&FriendInviting);
FBlueprintSessionResult BPS; FBlueprintSessionResult BPS;
BPS.OnlineResult = Session; BPS.OnlineResult = Session;
OnSessionInviteReceived(IP,FI,BPS); OnSessionInviteReceived(IP,FI,BPS);
TArray<class APlayerState*>& PlayerArray = GetWorld()->GetGameState()->PlayerArray; TArray<class APlayerState*>& PlayerArray = GetWorld()->GetGameState()->PlayerArray;
const TArray<class ULocalPlayer*>&ControllerArray = this->GetLocalPlayers(); const TArray<class ULocalPlayer*>&ControllerArray = this->GetLocalPlayers();
for (int i = 0; i < ControllerArray.Num(); i++) for (int i = 0; i < ControllerArray.Num(); i++)
{ {
if (*PlayerArray[ControllerArray[i]->PlayerController->NetPlayerIndex]->UniqueId.GetUniqueNetId().Get() == InvitedPlayer) if (*PlayerArray[ControllerArray[i]->PlayerController->NetPlayerIndex]->UniqueId.GetUniqueNetId().Get() == InvitedPlayer)
{ {
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
if (ControllerArray[i]->PlayerController->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) if (ControllerArray[i]->PlayerController->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
{ {
IAdvancedFriendsInterface::Execute_OnSessionInviteReceived(ControllerArray[i]->PlayerController, FI, BPS); IAdvancedFriendsInterface::Execute_OnSessionInviteReceived(ControllerArray[i]->PlayerController, FI, BPS);
} }
break; break;
} }
} }
}*/ }*/
void UAdvancedFriendsGameInstance::OnPlayerLoginStatusChangedMaster(int32 PlayerNum, ELoginStatus::Type PreviousStatus, ELoginStatus::Type NewStatus, const FUniqueNetId & NewPlayerUniqueNetID) void UAdvancedFriendsGameInstance::OnPlayerLoginStatusChangedMaster(int32 PlayerNum, ELoginStatus::Type PreviousStatus, ELoginStatus::Type NewStatus, const FUniqueNetId & NewPlayerUniqueNetID)
{ {
EBPLoginStatus OrigStatus = (EBPLoginStatus)PreviousStatus; EBPLoginStatus OrigStatus = (EBPLoginStatus)PreviousStatus;
EBPLoginStatus CurrentStatus = (EBPLoginStatus)NewStatus; EBPLoginStatus CurrentStatus = (EBPLoginStatus)NewStatus;
FBPUniqueNetId PlayerID; FBPUniqueNetId PlayerID;
PlayerID.SetUniqueNetId(&NewPlayerUniqueNetID); PlayerID.SetUniqueNetId(&NewPlayerUniqueNetID);
OnPlayerLoginStatusChanged(PlayerNum, OrigStatus,CurrentStatus,PlayerID); OnPlayerLoginStatusChanged(PlayerNum, OrigStatus,CurrentStatus,PlayerID);
if (bCallIdentityInterfaceEventsOnPlayerControllers) if (bCallIdentityInterfaceEventsOnPlayerControllers)
{ {
APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), PlayerNum); APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), PlayerNum);
if (Player != NULL) if (Player != NULL)
{ {
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
{ {
IAdvancedFriendsInterface::Execute_OnPlayerLoginStatusChanged(Player, OrigStatus, CurrentStatus, PlayerID); IAdvancedFriendsInterface::Execute_OnPlayerLoginStatusChanged(Player, OrigStatus, CurrentStatus, PlayerID);
} }
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnPlayerLoginStatusChangedMaster!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnPlayerLoginStatusChangedMaster!"));
} }
} }
} }
void UAdvancedFriendsGameInstance::OnPlayerLoginChangedMaster(int32 PlayerNum) void UAdvancedFriendsGameInstance::OnPlayerLoginChangedMaster(int32 PlayerNum)
{ {
OnPlayerLoginChanged(PlayerNum); OnPlayerLoginChanged(PlayerNum);
if (bCallIdentityInterfaceEventsOnPlayerControllers) if (bCallIdentityInterfaceEventsOnPlayerControllers)
{ {
APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), PlayerNum); APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), PlayerNum);
if (Player != NULL) if (Player != NULL)
{ {
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
{ {
IAdvancedFriendsInterface::Execute_OnPlayerLoginChanged(Player, PlayerNum); IAdvancedFriendsInterface::Execute_OnPlayerLoginChanged(Player, PlayerNum);
} }
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnPlayerLoginChanged!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnPlayerLoginChanged!"));
} }
} }
} }
void UAdvancedFriendsGameInstance::OnPlayerTalkingStateChangedMaster(TSharedRef<const FUniqueNetId> PlayerId, bool bIsTalking) void UAdvancedFriendsGameInstance::OnPlayerTalkingStateChangedMaster(TSharedRef<const FUniqueNetId> PlayerId, bool bIsTalking)
{ {
FBPUniqueNetId PlayerTalking; FBPUniqueNetId PlayerTalking;
PlayerTalking.SetUniqueNetId(PlayerId); PlayerTalking.SetUniqueNetId(PlayerId);
OnPlayerTalkingStateChanged(PlayerTalking, bIsTalking); OnPlayerTalkingStateChanged(PlayerTalking, bIsTalking);
if (bCallVoiceInterfaceEventsOnPlayerControllers) if (bCallVoiceInterfaceEventsOnPlayerControllers)
{ {
APlayerController* Player = NULL; APlayerController* Player = NULL;
for (const ULocalPlayer* LPlayer : LocalPlayers) for (const ULocalPlayer* LPlayer : LocalPlayers)
{ {
Player = UGameplayStatics::GetPlayerController(GetWorld(), LPlayer->GetControllerId()); Player = UGameplayStatics::GetPlayerController(GetWorld(), LPlayer->GetControllerId());
if (Player != NULL) if (Player != NULL)
{ {
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
{ {
IAdvancedFriendsInterface::Execute_OnPlayerVoiceStateChanged(Player, PlayerTalking, bIsTalking); IAdvancedFriendsInterface::Execute_OnPlayerVoiceStateChanged(Player, PlayerTalking, bIsTalking);
} }
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnVoiceStateChanged!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnVoiceStateChanged!"));
} }
} }
} }
} }
void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString& AppId, const FOnlineSessionSearchResult& SessionToJoin) void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString& AppId, const FOnlineSessionSearchResult& SessionToJoin)
{ {
if (SessionToJoin.IsValid()) if (SessionToJoin.IsValid())
{ {
FBlueprintSessionResult BluePrintResult; FBlueprintSessionResult BluePrintResult;
BluePrintResult.OnlineResult = SessionToJoin; BluePrintResult.OnlineResult = SessionToJoin;
FBPUniqueNetId PInvited; FBPUniqueNetId PInvited;
PInvited.SetUniqueNetId(&PersonInvited); PInvited.SetUniqueNetId(&PersonInvited);
FBPUniqueNetId PInviting; FBPUniqueNetId PInviting;
PInviting.SetUniqueNetId(&PersonInviting); PInviting.SetUniqueNetId(&PersonInviting);
TArray<APlayerController*> PlayerList; TArray<APlayerController*> PlayerList;
GEngine->GetAllLocalPlayerControllers(PlayerList); GEngine->GetAllLocalPlayerControllers(PlayerList);
APlayerController* Player = NULL; APlayerController* Player = NULL;
int32 LocalPlayer = 0; int32 LocalPlayer = 0;
for (int i = 0; i < PlayerList.Num(); i++) for (int i = 0; i < PlayerList.Num(); i++)
{ {
if (*PlayerList[i]->PlayerState->GetUniqueId().GetUniqueNetId() == PersonInvited) if (*PlayerList[i]->PlayerState->GetUniqueId().GetUniqueNetId() == PersonInvited)
{ {
LocalPlayer = i; LocalPlayer = i;
Player = PlayerList[i]; Player = PlayerList[i];
break; break;
} }
} }
OnSessionInviteReceived(LocalPlayer, PInviting, AppId, BluePrintResult); OnSessionInviteReceived(LocalPlayer, PInviting, AppId, BluePrintResult);
//IAdvancedFriendsInterface* TheInterface = NULL; //IAdvancedFriendsInterface* TheInterface = NULL;
if (Player != NULL) if (Player != NULL)
{ {
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
{ {
IAdvancedFriendsInterface::Execute_OnSessionInviteReceived(Player, PInviting, BluePrintResult); IAdvancedFriendsInterface::Execute_OnSessionInviteReceived(Player, PInviting, BluePrintResult);
} }
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnSessionInviteReceived!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnSessionInviteReceived!"));
} }
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Return a bad search result in OnSessionInviteReceived!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Return a bad search result in OnSessionInviteReceived!"));
} }
} }
void UAdvancedFriendsGameInstance::OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInvited, const FOnlineSessionSearchResult& SessionToJoin) void UAdvancedFriendsGameInstance::OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInvited, const FOnlineSessionSearchResult& SessionToJoin)
{ {
if (bWasSuccessful) if (bWasSuccessful)
{ {
if (SessionToJoin.IsValid()) if (SessionToJoin.IsValid())
{ {
FBlueprintSessionResult BluePrintResult; FBlueprintSessionResult BluePrintResult;
BluePrintResult.OnlineResult = SessionToJoin; BluePrintResult.OnlineResult = SessionToJoin;
FBPUniqueNetId PInvited; FBPUniqueNetId PInvited;
PInvited.SetUniqueNetId(PersonInvited); PInvited.SetUniqueNetId(PersonInvited);
OnSessionInviteAccepted(LocalPlayer,PInvited, BluePrintResult); OnSessionInviteAccepted(LocalPlayer,PInvited, BluePrintResult);
APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), LocalPlayer); APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), LocalPlayer);
//IAdvancedFriendsInterface* TheInterface = NULL; //IAdvancedFriendsInterface* TheInterface = NULL;
if (Player != NULL) if (Player != NULL)
{ {
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
{ {
IAdvancedFriendsInterface::Execute_OnSessionInviteAccepted(Player,PInvited, BluePrintResult); IAdvancedFriendsInterface::Execute_OnSessionInviteAccepted(Player,PInvited, BluePrintResult);
} }
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnSessionInviteAccepted!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnSessionInviteAccepted!"));
} }
} }
else else
{ {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Return a bad search result in OnSessionInviteAccepted!")); UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Return a bad search result in OnSessionInviteAccepted!"));
} }
} }
} }

View File

@@ -1,9 +1,9 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedFriendsInterface.h" #include "AdvancedFriendsInterface.h"
UAdvancedFriendsInterface::UAdvancedFriendsInterface(const class FObjectInitializer& ObjectInitializer) UAdvancedFriendsInterface::UAdvancedFriendsInterface(const class FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
{ {
} }

View File

@@ -1,274 +1,274 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedFriendsLibrary.h" #include "AdvancedFriendsLibrary.h"
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro // This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedFriendsLog); DEFINE_LOG_CATEGORY(AdvancedFriendsLog);
void UAdvancedFriendsLibrary::SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result) void UAdvancedFriendsLibrary::SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad Player Controller!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad Player Controller!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (Friends.Num() < 1) if (Friends.Num() < 1)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had no friends in invitation array!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had no friends in invitation array!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(); IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
if (!SessionInterface.IsValid()) if (!SessionInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Failed to get session interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Failed to get session interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend failed to get LocalPlayer!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend failed to get LocalPlayer!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
TArray<TSharedRef<const FUniqueNetId>> List; TArray<TSharedRef<const FUniqueNetId>> List;
for (int i = 0; i < Friends.Num(); i++) for (int i = 0; i < Friends.Num(); i++)
{ {
TSharedRef<const FUniqueNetId> val(Friends[i].UniqueNetId.ToSharedRef()); TSharedRef<const FUniqueNetId> val(Friends[i].UniqueNetId.ToSharedRef());
//TSharedRef<const FUniqueNetId> val(Friends[i].GetUniqueNetId()); //TSharedRef<const FUniqueNetId> val(Friends[i].GetUniqueNetId());
List.Add(val); List.Add(val);
} }
if (SessionInterface->SendSessionInviteToFriends(Player->GetControllerId(), NAME_GameSession, List)) if (SessionInterface->SendSessionInviteToFriends(Player->GetControllerId(), NAME_GameSession, List))
{ {
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
return; return;
} }
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
void UAdvancedFriendsLibrary::SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result) void UAdvancedFriendsLibrary::SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad Player Controller!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad Player Controller!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (!FriendUniqueNetId.IsValid()) if (!FriendUniqueNetId.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad UniqueNetId!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad UniqueNetId!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(); IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
if (!SessionInterface.IsValid()) if (!SessionInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Failed to get session interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Failed to get session interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend failed to get LocalPlayer!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend failed to get LocalPlayer!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (SessionInterface->SendSessionInviteToFriend(Player->GetControllerId(), NAME_GameSession, *FriendUniqueNetId.GetUniqueNetId())) if (SessionInterface->SendSessionInviteToFriend(Player->GetControllerId(), NAME_GameSession, *FriendUniqueNetId.GetUniqueNetId()))
{ {
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
return; return;
} }
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
void UAdvancedFriendsLibrary::GetFriend(APlayerController *PlayerController, const FBPUniqueNetId FriendUniqueNetId, FBPFriendInfo &Friend) void UAdvancedFriendsLibrary::GetFriend(APlayerController *PlayerController, const FBPUniqueNetId FriendUniqueNetId, FBPFriendInfo &Friend)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Had a bad Player Controller!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Had a bad Player Controller!"));
return; return;
} }
if (!FriendUniqueNetId.IsValid()) if (!FriendUniqueNetId.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Had a bad UniqueNetId!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Had a bad UniqueNetId!"));
return; return;
} }
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface(); IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
if (!FriendsInterface.IsValid()) if (!FriendsInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Failed to get friends interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Failed to get friends interface!"));
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend failed to get LocalPlayer!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend failed to get LocalPlayer!"));
return; return;
} }
TSharedPtr<FOnlineFriend> fr = FriendsInterface->GetFriend(Player->GetControllerId(), *FriendUniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Default)); TSharedPtr<FOnlineFriend> fr = FriendsInterface->GetFriend(Player->GetControllerId(), *FriendUniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Default));
if (fr.IsValid()) if (fr.IsValid())
{ {
FOnlineUserPresence pres = fr->GetPresence(); FOnlineUserPresence pres = fr->GetPresence();
Friend.DisplayName = fr->GetDisplayName(); Friend.DisplayName = fr->GetDisplayName();
Friend.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); Friend.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
Friend.RealName = fr->GetRealName(); Friend.RealName = fr->GetRealName();
Friend.UniqueNetId.SetUniqueNetId(fr->GetUserId()); Friend.UniqueNetId.SetUniqueNetId(fr->GetUserId());
Friend.bIsPlayingSameGame = pres.bIsPlayingThisGame; Friend.bIsPlayingSameGame = pres.bIsPlayingThisGame;
Friend.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport; Friend.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport;
Friend.PresenceInfo.bIsJoinable = pres.bIsJoinable; Friend.PresenceInfo.bIsJoinable = pres.bIsJoinable;
Friend.PresenceInfo.bIsOnline = pres.bIsOnline; Friend.PresenceInfo.bIsOnline = pres.bIsOnline;
Friend.PresenceInfo.bIsPlaying = pres.bIsPlaying; Friend.PresenceInfo.bIsPlaying = pres.bIsPlaying;
Friend.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame; Friend.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;
Friend.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); Friend.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
Friend.PresenceInfo.StatusString = pres.Status.StatusStr; Friend.PresenceInfo.StatusString = pres.Status.StatusStr;
} }
} }
void UAdvancedFriendsLibrary::IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend) void UAdvancedFriendsLibrary::IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad Player Controller!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad Player Controller!"));
return; return;
} }
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
return; return;
} }
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface(); IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
if (!FriendsInterface.IsValid()) if (!FriendsInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get friends interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get friends interface!"));
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get LocalPlayer!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get LocalPlayer!"));
return; return;
} }
IsFriend = FriendsInterface->IsFriend(Player->GetControllerId(), *UniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Default)); IsFriend = FriendsInterface->IsFriend(Player->GetControllerId(), *UniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Default));
} }
void UAdvancedFriendsLibrary::GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray<FBPOnlineRecentPlayer> &PlayersList) void UAdvancedFriendsLibrary::GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray<FBPOnlineRecentPlayer> &PlayersList)
{ {
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface(); IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
if (!FriendsInterface.IsValid()) if (!FriendsInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed to get friends interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed to get friends interface!"));
return; return;
} }
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed was given an invalid UniqueNetId!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed was given an invalid UniqueNetId!"));
return; return;
} }
TArray< TSharedRef<FOnlineRecentPlayer> > PlayerList; TArray< TSharedRef<FOnlineRecentPlayer> > PlayerList;
// For now getting all namespaces // For now getting all namespaces
FriendsInterface->GetRecentPlayers(*(UniqueNetId.GetUniqueNetId()),"", PlayerList); FriendsInterface->GetRecentPlayers(*(UniqueNetId.GetUniqueNetId()),"", PlayerList);
for (int32 i = 0; i < PlayerList.Num(); i++) for (int32 i = 0; i < PlayerList.Num(); i++)
{ {
TSharedRef<FOnlineRecentPlayer> Player = PlayerList[i]; TSharedRef<FOnlineRecentPlayer> Player = PlayerList[i];
FBPOnlineRecentPlayer BPF; FBPOnlineRecentPlayer BPF;
BPF.DisplayName = Player->GetDisplayName(); BPF.DisplayName = Player->GetDisplayName();
BPF.RealName = Player->GetRealName(); BPF.RealName = Player->GetRealName();
BPF.UniqueNetId.SetUniqueNetId(Player->GetUserId()); BPF.UniqueNetId.SetUniqueNetId(Player->GetUserId());
PlayersList.Add(BPF); PlayersList.Add(BPF);
} }
} }
void UAdvancedFriendsLibrary::GetStoredFriendsList(APlayerController *PlayerController, TArray<FBPFriendInfo> &FriendsList) void UAdvancedFriendsLibrary::GetStoredFriendsList(APlayerController *PlayerController, TArray<FBPFriendInfo> &FriendsList)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Had a bad Player Controller!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Had a bad Player Controller!"));
return; return;
} }
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface(); IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
if (!FriendsInterface.IsValid()) if (!FriendsInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get friends interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get friends interface!"));
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get LocalPlayer!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get LocalPlayer!"));
return; return;
} }
TArray< TSharedRef<FOnlineFriend> > FriendList; TArray< TSharedRef<FOnlineFriend> > FriendList;
FriendsInterface->GetFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendList); FriendsInterface->GetFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendList);
for (int32 i = 0; i < FriendList.Num(); i++) for (int32 i = 0; i < FriendList.Num(); i++)
{ {
TSharedRef<FOnlineFriend> Friend = FriendList[i]; TSharedRef<FOnlineFriend> Friend = FriendList[i];
FBPFriendInfo BPF; FBPFriendInfo BPF;
FOnlineUserPresence pres = Friend->GetPresence(); FOnlineUserPresence pres = Friend->GetPresence();
BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
BPF.DisplayName = Friend->GetDisplayName(); BPF.DisplayName = Friend->GetDisplayName();
BPF.RealName = Friend->GetRealName(); BPF.RealName = Friend->GetRealName();
BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId()); BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId());
BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame; BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame;
BPF.PresenceInfo.bIsOnline = pres.bIsOnline; BPF.PresenceInfo.bIsOnline = pres.bIsOnline;
BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport; BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport;
BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying; BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying;
BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
BPF.PresenceInfo.StatusString = pres.Status.StatusStr; BPF.PresenceInfo.StatusString = pres.Status.StatusStr;
BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable; BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable;
BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame; BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;
FriendsList.Add(BPF); FriendsList.Add(BPF);
} }
} }

View File

@@ -1,235 +1,235 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedIdentityLibrary.h" #include "AdvancedIdentityLibrary.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedIdentityLog); DEFINE_LOG_CATEGORY(AdvancedIdentityLog);
void UAdvancedIdentityLibrary::GetPlayerAuthToken(APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result) void UAdvancedIdentityLibrary::GetPlayerAuthToken(APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken was passed a bad player controller!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken was passed a bad player controller!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken failed to get LocalPlayer!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken failed to get LocalPlayer!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
if (!IdentityInterface.IsValid()) if (!IdentityInterface.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken Failed to get identity interface!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
AuthToken = IdentityInterface->GetAuthToken(Player->GetControllerId()); AuthToken = IdentityInterface->GetAuthToken(Player->GetControllerId());
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedIdentityLibrary::GetPlayerNickname(const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname) void UAdvancedIdentityLibrary::GetPlayerNickname(const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname)
{ {
if (!UniqueNetID.IsValid()) if (!UniqueNetID.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname was passed a bad player uniquenetid!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname was passed a bad player uniquenetid!"));
return; return;
} }
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
if (!IdentityInterface.IsValid()) if (!IdentityInterface.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname Failed to get identity interface!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname Failed to get identity interface!"));
return; return;
} }
PlayerNickname = IdentityInterface->GetPlayerNickname(*UniqueNetID.GetUniqueNetId()); PlayerNickname = IdentityInterface->GetPlayerNickname(*UniqueNetID.GetUniqueNetId());
} }
void UAdvancedIdentityLibrary::GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result) void UAdvancedIdentityLibrary::GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result)
{ {
if (!UniqueNetID.IsValid()) if (!UniqueNetID.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus was passed a bad player uniquenetid!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus was passed a bad player uniquenetid!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
if (!IdentityInterface.IsValid()) if (!IdentityInterface.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus Failed to get identity interface!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
LoginStatus = (EBPLoginStatus)IdentityInterface->GetLoginStatus(*UniqueNetID.GetUniqueNetId()); LoginStatus = (EBPLoginStatus)IdentityInterface->GetLoginStatus(*UniqueNetID.GetUniqueNetId());
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedIdentityLibrary::GetAllUserAccounts(TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result) void UAdvancedIdentityLibrary::GetAllUserAccounts(TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result)
{ {
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
if (!IdentityInterface.IsValid()) if (!IdentityInterface.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetAllUserAccounts Failed to get identity interface!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetAllUserAccounts Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
TArray<TSharedPtr<FUserOnlineAccount>> accountInfos = IdentityInterface->GetAllUserAccounts(); TArray<TSharedPtr<FUserOnlineAccount>> accountInfos = IdentityInterface->GetAllUserAccounts();
for (int i = 0; i < accountInfos.Num(); ++i) for (int i = 0; i < accountInfos.Num(); ++i)
{ {
AccountInfos.Add(FBPUserOnlineAccount(accountInfos[i])); AccountInfos.Add(FBPUserOnlineAccount(accountInfos[i]));
} }
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedIdentityLibrary::GetUserAccount(const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result) void UAdvancedIdentityLibrary::GetUserAccount(const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result)
{ {
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
if(!UniqueNetId.IsValid()) if(!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount was passed a bad unique net id!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount was passed a bad unique net id!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (!IdentityInterface.IsValid()) if (!IdentityInterface.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get identity interface!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
TSharedPtr<FUserOnlineAccount> accountInfo = IdentityInterface->GetUserAccount(*UniqueNetId.GetUniqueNetId()); TSharedPtr<FUserOnlineAccount> accountInfo = IdentityInterface->GetUserAccount(*UniqueNetId.GetUniqueNetId());
if (!accountInfo.IsValid()) if (!accountInfo.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get the account!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get the account!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
AccountInfo.UserAccountInfo = accountInfo; AccountInfo.UserAccountInfo = accountInfo;
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedIdentityLibrary::GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken) void UAdvancedIdentityLibrary::GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken)
{ {
if (!AccountInfo.UserAccountInfo.IsValid()) if (!AccountInfo.UserAccountInfo.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAccessToken was passed an invalid account!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAccessToken was passed an invalid account!"));
return; return;
} }
AccessToken = AccountInfo.UserAccountInfo->GetAccessToken(); AccessToken = AccountInfo.UserAccountInfo->GetAccessToken();
} }
void UAdvancedIdentityLibrary::GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result) void UAdvancedIdentityLibrary::GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result)
{ {
if (!AccountInfo.UserAccountInfo.IsValid()) if (!AccountInfo.UserAccountInfo.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute was passed an invalid account!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute was passed an invalid account!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (!AccountInfo.UserAccountInfo->GetAuthAttribute(AttributeName, AuthAttribute)) if (!AccountInfo.UserAccountInfo->GetAuthAttribute(AttributeName, AuthAttribute))
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute couldn't find the attribute!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute couldn't find the attribute!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedIdentityLibrary::SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result) void UAdvancedIdentityLibrary::SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result)
{ {
if (!AccountInfo.UserAccountInfo.IsValid()) if (!AccountInfo.UserAccountInfo.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was passed an invalid account!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was passed an invalid account!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (!AccountInfo.UserAccountInfo->SetUserAttribute(AttributeName, NewAttributeValue)) if (!AccountInfo.UserAccountInfo->SetUserAttribute(AttributeName, NewAttributeValue))
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was unable to set the attribute!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was unable to set the attribute!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedIdentityLibrary::GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID) void UAdvancedIdentityLibrary::GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID)
{ {
if (!AccountInfo.UserAccountInfo.IsValid()) if (!AccountInfo.UserAccountInfo.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserID was passed an invalid account!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserID was passed an invalid account!"));
return; return;
} }
UniqueNetID.SetUniqueNetId(AccountInfo.UserAccountInfo->GetUserId()); UniqueNetID.SetUniqueNetId(AccountInfo.UserAccountInfo->GetUserId());
} }
void UAdvancedIdentityLibrary::GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName) void UAdvancedIdentityLibrary::GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName)
{ {
if (!AccountInfo.UserAccountInfo.IsValid()) if (!AccountInfo.UserAccountInfo.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountRealName was passed an invalid account!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountRealName was passed an invalid account!"));
return; return;
} }
UserName = AccountInfo.UserAccountInfo->GetRealName(); UserName = AccountInfo.UserAccountInfo->GetRealName();
} }
void UAdvancedIdentityLibrary::GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName) void UAdvancedIdentityLibrary::GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName)
{ {
if (!AccountInfo.UserAccountInfo.IsValid()) if (!AccountInfo.UserAccountInfo.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountDisplayName was passed an invalid account!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountDisplayName was passed an invalid account!"));
return; return;
} }
DisplayName = AccountInfo.UserAccountInfo->GetDisplayName(); DisplayName = AccountInfo.UserAccountInfo->GetDisplayName();
} }
void UAdvancedIdentityLibrary::GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result) void UAdvancedIdentityLibrary::GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result)
{ {
if (!AccountInfo.UserAccountInfo.IsValid()) if (!AccountInfo.UserAccountInfo.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute was passed an invalid account!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute was passed an invalid account!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (!AccountInfo.UserAccountInfo->GetUserAttribute(AttributeName, AttributeValue)) if (!AccountInfo.UserAccountInfo->GetUserAttribute(AttributeName, AttributeValue))
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute failed to get user attribute!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute failed to get user attribute!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }

View File

@@ -1,12 +1,12 @@
//#include "StandAlonePrivatePCH.h" //#include "StandAlonePrivatePCH.h"
#include "AdvancedSessions.h" #include "AdvancedSessions.h"
void AdvancedSessions::StartupModule() void AdvancedSessions::StartupModule()
{ {
} }
void AdvancedSessions::ShutdownModule() void AdvancedSessions::ShutdownModule()
{ {
} }
IMPLEMENT_MODULE(AdvancedSessions, AdvancedSessions) IMPLEMENT_MODULE(AdvancedSessions, AdvancedSessions)

View File

@@ -1,254 +1,254 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedVoiceLibrary.h" #include "AdvancedVoiceLibrary.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedVoiceLog); DEFINE_LOG_CATEGORY(AdvancedVoiceLog);
void UAdvancedVoiceLibrary::IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum) void UAdvancedVoiceLibrary::IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
bHasHeadset = false; bHasHeadset = false;
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Check For Headset couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Check For Headset couldn't get the voice interface!"));
return; return;
} }
bHasHeadset = VoiceInterface->IsHeadsetPresent(LocalPlayerNum); bHasHeadset = VoiceInterface->IsHeadsetPresent(LocalPlayerNum);
} }
void UAdvancedVoiceLibrary::StartNetworkedVoice(uint8 LocalPlayerNum) void UAdvancedVoiceLibrary::StartNetworkedVoice(uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!"));
return; return;
} }
VoiceInterface->StartNetworkedVoice(LocalPlayerNum); VoiceInterface->StartNetworkedVoice(LocalPlayerNum);
} }
void UAdvancedVoiceLibrary::StopNetworkedVoice(uint8 LocalPlayerNum) void UAdvancedVoiceLibrary::StopNetworkedVoice(uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!"));
return; return;
} }
VoiceInterface->StopNetworkedVoice(LocalPlayerNum); VoiceInterface->StopNetworkedVoice(LocalPlayerNum);
} }
bool UAdvancedVoiceLibrary::RegisterLocalTalker(uint8 LocalPlayerNum) bool UAdvancedVoiceLibrary::RegisterLocalTalker(uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talker couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talker couldn't get the voice interface!"));
return false; return false;
} }
return VoiceInterface->RegisterLocalTalker(LocalPlayerNum); return VoiceInterface->RegisterLocalTalker(LocalPlayerNum);
} }
void UAdvancedVoiceLibrary::RegisterAllLocalTalkers() void UAdvancedVoiceLibrary::RegisterAllLocalTalkers()
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talkers couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talkers couldn't get the voice interface!"));
return; return;
} }
VoiceInterface->RegisterLocalTalkers(); VoiceInterface->RegisterLocalTalkers();
} }
void UAdvancedVoiceLibrary::UnRegisterLocalTalker(uint8 LocalPlayerNum) void UAdvancedVoiceLibrary::UnRegisterLocalTalker(uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unregister Local Talker couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unregister Local Talker couldn't get the voice interface!"));
return; return;
} }
VoiceInterface->UnregisterLocalTalker(LocalPlayerNum); VoiceInterface->UnregisterLocalTalker(LocalPlayerNum);
} }
void UAdvancedVoiceLibrary::UnRegisterAllLocalTalkers() void UAdvancedVoiceLibrary::UnRegisterAllLocalTalkers()
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister All Local Talkers couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister All Local Talkers couldn't get the voice interface!"));
return; return;
} }
VoiceInterface->UnregisterLocalTalkers(); VoiceInterface->UnregisterLocalTalkers();
} }
bool UAdvancedVoiceLibrary::RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId) bool UAdvancedVoiceLibrary::RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Remote Talker was passed an invalid unique net id!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Remote Talker was passed an invalid unique net id!"));
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Remote Talker couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Remote Talker couldn't get the voice interface!"));
return false; return false;
} }
return VoiceInterface->RegisterRemoteTalker(*UniqueNetId.GetUniqueNetId()); return VoiceInterface->RegisterRemoteTalker(*UniqueNetId.GetUniqueNetId());
} }
bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId) bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker was passed an invalid unique net id!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker was passed an invalid unique net id!"));
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker couldn't get the voice interface!"));
return false; return false;
} }
return VoiceInterface->UnregisterRemoteTalker(*UniqueNetId.GetUniqueNetId()); return VoiceInterface->UnregisterRemoteTalker(*UniqueNetId.GetUniqueNetId());
} }
void UAdvancedVoiceLibrary::RemoveAllRemoteTalkers() void UAdvancedVoiceLibrary::RemoveAllRemoteTalkers()
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Remove All Remote Talkers couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Remove All Remote Talkers couldn't get the voice interface!"));
return; return;
} }
VoiceInterface->RemoveAllRemoteTalkers(); VoiceInterface->RemoveAllRemoteTalkers();
} }
bool UAdvancedVoiceLibrary::IsLocalPlayerTalking(uint8 LocalPlayerNum) bool UAdvancedVoiceLibrary::IsLocalPlayerTalking(uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Local Player Talking couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Local Player Talking couldn't get the voice interface!"));
return false; return false;
} }
return VoiceInterface->IsLocalPlayerTalking(LocalPlayerNum); return VoiceInterface->IsLocalPlayerTalking(LocalPlayerNum);
} }
bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId) bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking was passed an invalid unique net id!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking was passed an invalid unique net id!"));
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking couldn't get the voice interface!"));
return false; return false;
} }
return VoiceInterface->IsRemotePlayerTalking(*UniqueNetId.GetUniqueNetId()); return VoiceInterface->IsRemotePlayerTalking(*UniqueNetId.GetUniqueNetId());
} }
bool UAdvancedVoiceLibrary::IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId) bool UAdvancedVoiceLibrary::IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted was passed an invalid unique net id!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted was passed an invalid unique net id!"));
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted couldn't get the voice interface!"));
return false; return false;
} }
return VoiceInterface->IsMuted(LocalUserNumChecking, *UniqueNetId.GetUniqueNetId()); return VoiceInterface->IsMuted(LocalUserNumChecking, *UniqueNetId.GetUniqueNetId());
} }
bool UAdvancedVoiceLibrary::MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide) bool UAdvancedVoiceLibrary::MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Mute Remote Talker was passed an invalid unique net id!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Mute Remote Talker was passed an invalid unique net id!"));
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Mute Remote Talker couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Mute Remote Talker couldn't get the voice interface!"));
return false; return false;
} }
return VoiceInterface->MuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide); return VoiceInterface->MuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide);
} }
bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide) bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker was passed an invalid unique net id!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker was passed an invalid unique net id!"));
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!"));
return false; return false;
} }
return VoiceInterface->UnmuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide); return VoiceInterface->UnmuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide);
} }
void UAdvancedVoiceLibrary::GetNumLocalTalkers(int32 & NumLocalTalkers) void UAdvancedVoiceLibrary::GetNumLocalTalkers(int32 & NumLocalTalkers)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
NumLocalTalkers = 0; NumLocalTalkers = 0;
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!"));
return; return;
} }
NumLocalTalkers = VoiceInterface->GetNumLocalTalkers(); NumLocalTalkers = VoiceInterface->GetNumLocalTalkers();
} }

View File

@@ -1,107 +1,107 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "FindFriendSessionCallbackProxy.h" #include "FindFriendSessionCallbackProxy.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// UGetRecentPlayersCallbackProxy // UGetRecentPlayersCallbackProxy
DEFINE_LOG_CATEGORY(AdvancedFindFriendSessionLog); DEFINE_LOG_CATEGORY(AdvancedFindFriendSessionLog);
UFindFriendSessionCallbackProxy::UFindFriendSessionCallbackProxy(const FObjectInitializer& ObjectInitializer) UFindFriendSessionCallbackProxy::UFindFriendSessionCallbackProxy(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
, OnFindFriendSessionCompleteDelegate(FOnFindFriendSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnFindFriendSessionCompleted)) , OnFindFriendSessionCompleteDelegate(FOnFindFriendSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnFindFriendSessionCompleted))
{ {
} }
UFindFriendSessionCallbackProxy* UFindFriendSessionCallbackProxy::FindFriendSession(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId) UFindFriendSessionCallbackProxy* UFindFriendSessionCallbackProxy::FindFriendSession(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId)
{ {
UFindFriendSessionCallbackProxy* Proxy = NewObject<UFindFriendSessionCallbackProxy>(); UFindFriendSessionCallbackProxy* Proxy = NewObject<UFindFriendSessionCallbackProxy>();
Proxy->PlayerControllerWeakPtr = PlayerController; Proxy->PlayerControllerWeakPtr = PlayerController;
Proxy->cUniqueNetId = FriendUniqueNetId; Proxy->cUniqueNetId = FriendUniqueNetId;
Proxy->WorldContextObject = WorldContextObject; Proxy->WorldContextObject = WorldContextObject;
return Proxy; return Proxy;
} }
void UFindFriendSessionCallbackProxy::Activate() void UFindFriendSessionCallbackProxy::Activate()
{ {
if (!cUniqueNetId.IsValid()) if (!cUniqueNetId.IsValid())
{ {
// Fail immediately // Fail immediately
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed received a bad UniqueNetId!")); UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed received a bad UniqueNetId!"));
TArray<FBlueprintSessionResult> EmptyResult; TArray<FBlueprintSessionResult> EmptyResult;
OnFailure.Broadcast(EmptyResult); OnFailure.Broadcast(EmptyResult);
return; return;
} }
if (!PlayerControllerWeakPtr.IsValid()) if (!PlayerControllerWeakPtr.IsValid())
{ {
// Fail immediately // Fail immediately
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed received a bad playercontroller!")); UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed received a bad playercontroller!"));
TArray<FBlueprintSessionResult> EmptyResult; TArray<FBlueprintSessionResult> EmptyResult;
OnFailure.Broadcast(EmptyResult); OnFailure.Broadcast(EmptyResult);
return; return;
} }
IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld()); IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld());
if (Sessions.IsValid()) if (Sessions.IsValid())
{ {
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
if (!Player) if (!Player)
{ {
// Fail immediately // Fail immediately
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed couldn't cast to ULocalPlayer!")); UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed couldn't cast to ULocalPlayer!"));
TArray<FBlueprintSessionResult> EmptyResult; TArray<FBlueprintSessionResult> EmptyResult;
OnFailure.Broadcast(EmptyResult); OnFailure.Broadcast(EmptyResult);
return; return;
} }
FindFriendSessionCompleteDelegateHandle = Sessions->AddOnFindFriendSessionCompleteDelegate_Handle(Player->GetControllerId(), OnFindFriendSessionCompleteDelegate); FindFriendSessionCompleteDelegateHandle = Sessions->AddOnFindFriendSessionCompleteDelegate_Handle(Player->GetControllerId(), OnFindFriendSessionCompleteDelegate);
Sessions->FindFriendSession(Player->GetControllerId(), *cUniqueNetId.GetUniqueNetId()); Sessions->FindFriendSession(Player->GetControllerId(), *cUniqueNetId.GetUniqueNetId());
return; return;
} }
// Fail immediately // Fail immediately
TArray<FBlueprintSessionResult> EmptyResult; TArray<FBlueprintSessionResult> EmptyResult;
OnFailure.Broadcast(EmptyResult); OnFailure.Broadcast(EmptyResult);
} }
void UFindFriendSessionCallbackProxy::OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const TArray<FOnlineSessionSearchResult>& SessionInfo) void UFindFriendSessionCallbackProxy::OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const TArray<FOnlineSessionSearchResult>& SessionInfo)
{ {
IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld()); IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld());
if (Sessions.IsValid()) if (Sessions.IsValid())
Sessions->ClearOnFindFriendSessionCompleteDelegate_Handle(LocalPlayer, FindFriendSessionCompleteDelegateHandle); Sessions->ClearOnFindFriendSessionCompleteDelegate_Handle(LocalPlayer, FindFriendSessionCompleteDelegateHandle);
if ( bWasSuccessful ) if ( bWasSuccessful )
{ {
TArray<FBlueprintSessionResult> Result; TArray<FBlueprintSessionResult> Result;
for (auto& Sesh : SessionInfo) for (auto& Sesh : SessionInfo)
{ {
if (Sesh.IsValid()) if (Sesh.IsValid())
{ {
FBlueprintSessionResult BSesh; FBlueprintSessionResult BSesh;
BSesh.OnlineResult = Sesh; BSesh.OnlineResult = Sesh;
Result.Add(BSesh); Result.Add(BSesh);
} }
} }
if(Result.Num() > 0) if(Result.Num() > 0)
OnSuccess.Broadcast(Result); OnSuccess.Broadcast(Result);
else else
{ {
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed, returned an invalid session.")); UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed, returned an invalid session."));
OnFailure.Broadcast(Result); OnFailure.Broadcast(Result);
} }
} }
else else
{ {
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed")); UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed"));
TArray<FBlueprintSessionResult> EmptyResult; TArray<FBlueprintSessionResult> EmptyResult;
OnFailure.Broadcast(EmptyResult); OnFailure.Broadcast(EmptyResult);
} }
} }

View File

@@ -1,433 +1,433 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "FindSessionsCallbackProxyAdvanced.h" #include "FindSessionsCallbackProxyAdvanced.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// UFindSessionsCallbackProxyAdvanced // UFindSessionsCallbackProxyAdvanced
UFindSessionsCallbackProxyAdvanced::UFindSessionsCallbackProxyAdvanced(const FObjectInitializer& ObjectInitializer) UFindSessionsCallbackProxyAdvanced::UFindSessionsCallbackProxyAdvanced(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
, Delegate(FOnFindSessionsCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted)) , Delegate(FOnFindSessionsCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted))
, bUseLAN(false) , bUseLAN(false)
{ {
bRunSecondSearch = false; bRunSecondSearch = false;
bIsOnSecondSearch = false; bIsOnSecondSearch = false;
} }
UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, bool bSearchLobbies, int MinSlotsAvailable) UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, bool bSearchLobbies, int MinSlotsAvailable)
{ {
UFindSessionsCallbackProxyAdvanced* Proxy = NewObject<UFindSessionsCallbackProxyAdvanced>(); UFindSessionsCallbackProxyAdvanced* Proxy = NewObject<UFindSessionsCallbackProxyAdvanced>();
Proxy->PlayerControllerWeakPtr = PlayerController; Proxy->PlayerControllerWeakPtr = PlayerController;
Proxy->bUseLAN = bUseLAN; Proxy->bUseLAN = bUseLAN;
Proxy->MaxResults = MaxResults; Proxy->MaxResults = MaxResults;
Proxy->WorldContextObject = WorldContextObject; Proxy->WorldContextObject = WorldContextObject;
Proxy->SearchSettings = Filters; Proxy->SearchSettings = Filters;
Proxy->ServerSearchType = ServerTypeToSearch; Proxy->ServerSearchType = ServerTypeToSearch;
Proxy->bEmptyServersOnly = bEmptyServersOnly, Proxy->bEmptyServersOnly = bEmptyServersOnly,
Proxy->bNonEmptyServersOnly = bNonEmptyServersOnly; Proxy->bNonEmptyServersOnly = bNonEmptyServersOnly;
Proxy->bSecureServersOnly = bSecureServersOnly; Proxy->bSecureServersOnly = bSecureServersOnly;
Proxy->bSearchLobbies = bSearchLobbies; Proxy->bSearchLobbies = bSearchLobbies;
Proxy->MinSlotsAvailable = MinSlotsAvailable; Proxy->MinSlotsAvailable = MinSlotsAvailable;
return Proxy; return Proxy;
} }
void UFindSessionsCallbackProxyAdvanced::Activate() void UFindSessionsCallbackProxyAdvanced::Activate()
{ {
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessions"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull)); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessions"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
if (Helper.IsValid()) if (Helper.IsValid())
{ {
auto Sessions = Helper.OnlineSub->GetSessionInterface(); auto Sessions = Helper.OnlineSub->GetSessionInterface();
if (Sessions.IsValid()) if (Sessions.IsValid())
{ {
// Re-initialize here, otherwise I think there might be issues with people re-calling search for some reason before it is destroyed // Re-initialize here, otherwise I think there might be issues with people re-calling search for some reason before it is destroyed
bRunSecondSearch = false; bRunSecondSearch = false;
bIsOnSecondSearch = false; bIsOnSecondSearch = false;
DelegateHandle = Sessions->AddOnFindSessionsCompleteDelegate_Handle(Delegate); DelegateHandle = Sessions->AddOnFindSessionsCompleteDelegate_Handle(Delegate);
SearchObject = MakeShareable(new FOnlineSessionSearch); SearchObject = MakeShareable(new FOnlineSessionSearch);
SearchObject->MaxSearchResults = MaxResults; SearchObject->MaxSearchResults = MaxResults;
SearchObject->bIsLanQuery = bUseLAN; SearchObject->bIsLanQuery = bUseLAN;
//SearchObject->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals); //SearchObject->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
// Create temp filter variable, because I had to re-define a blueprint version of this, it is required. // Create temp filter variable, because I had to re-define a blueprint version of this, it is required.
FOnlineSearchSettingsEx tem; FOnlineSearchSettingsEx tem;
/* // Search only for dedicated servers (value is true/false) /* // Search only for dedicated servers (value is true/false)
#define SEARCH_DEDICATED_ONLY FName(TEXT("DEDICATEDONLY")) #define SEARCH_DEDICATED_ONLY FName(TEXT("DEDICATEDONLY"))
// Search for empty servers only (value is true/false) // Search for empty servers only (value is true/false)
#define SEARCH_EMPTY_SERVERS_ONLY FName(TEXT("EMPTYONLY")) #define SEARCH_EMPTY_SERVERS_ONLY FName(TEXT("EMPTYONLY"))
// Search for non empty servers only (value is true/false) // Search for non empty servers only (value is true/false)
#define SEARCH_NONEMPTY_SERVERS_ONLY FName(TEXT("NONEMPTYONLY")) #define SEARCH_NONEMPTY_SERVERS_ONLY FName(TEXT("NONEMPTYONLY"))
// Search for secure servers only (value is true/false) // Search for secure servers only (value is true/false)
#define SEARCH_SECURE_SERVERS_ONLY FName(TEXT("SECUREONLY")) #define SEARCH_SECURE_SERVERS_ONLY FName(TEXT("SECUREONLY"))
// Search for presence sessions only (value is true/false) // Search for presence sessions only (value is true/false)
#define SEARCH_PRESENCE FName(TEXT("PRESENCESEARCH")) #define SEARCH_PRESENCE FName(TEXT("PRESENCESEARCH"))
// Search for a match with min player availability (value is int) // Search for a match with min player availability (value is int)
#define SEARCH_MINSLOTSAVAILABLE FName(TEXT("MINSLOTSAVAILABLE")) #define SEARCH_MINSLOTSAVAILABLE FName(TEXT("MINSLOTSAVAILABLE"))
// Exclude all matches where any unique ids in a given array are present (value is string of the form "uniqueid1;uniqueid2;uniqueid3") // Exclude all matches where any unique ids in a given array are present (value is string of the form "uniqueid1;uniqueid2;uniqueid3")
#define SEARCH_EXCLUDE_UNIQUEIDS FName(TEXT("EXCLUDEUNIQUEIDS")) #define SEARCH_EXCLUDE_UNIQUEIDS FName(TEXT("EXCLUDEUNIQUEIDS"))
// User ID to search for session of // User ID to search for session of
#define SEARCH_USER FName(TEXT("SEARCHUSER")) #define SEARCH_USER FName(TEXT("SEARCHUSER"))
// Keywords to match in session search // Keywords to match in session search
#define SEARCH_KEYWORDS FName(TEXT("SEARCHKEYWORDS"))*/ #define SEARCH_KEYWORDS FName(TEXT("SEARCHKEYWORDS"))*/
/** Keywords to match in session search */ /** Keywords to match in session search */
/** The matchmaking queue name to matchmake in, e.g. "TeamDeathmatch" (value is string) */ /** The matchmaking queue name to matchmake in, e.g. "TeamDeathmatch" (value is string) */
/** #define SEARCH_MATCHMAKING_QUEUE FName(TEXT("MATCHMAKINGQUEUE"))*/ /** #define SEARCH_MATCHMAKING_QUEUE FName(TEXT("MATCHMAKINGQUEUE"))*/
/** If set, use the named Xbox Live hopper to find a session via matchmaking (value is a string) */ /** If set, use the named Xbox Live hopper to find a session via matchmaking (value is a string) */
/** #define SEARCH_XBOX_LIVE_HOPPER_NAME FName(TEXT("LIVEHOPPERNAME"))*/ /** #define SEARCH_XBOX_LIVE_HOPPER_NAME FName(TEXT("LIVEHOPPERNAME"))*/
/** Which session template from the service configuration to use */ /** Which session template from the service configuration to use */
/** #define SEARCH_XBOX_LIVE_SESSION_TEMPLATE_NAME FName(TEXT("LIVESESSIONTEMPLATE"))*/ /** #define SEARCH_XBOX_LIVE_SESSION_TEMPLATE_NAME FName(TEXT("LIVESESSIONTEMPLATE"))*/
/** Selection method used to determine which match to join when multiple are returned (valid only on Switch) */ /** Selection method used to determine which match to join when multiple are returned (valid only on Switch) */
/** #define SEARCH_SWITCH_SELECTION_METHOD FName(TEXT("SWITCHSELECTIONMETHOD"))*/ /** #define SEARCH_SWITCH_SELECTION_METHOD FName(TEXT("SWITCHSELECTIONMETHOD"))*/
/** Whether to use lobbies vs sessions */ /** Whether to use lobbies vs sessions */
/** #define SEARCH_LOBBIES FName(TEXT("LOBBYSEARCH"))*/ /** #define SEARCH_LOBBIES FName(TEXT("LOBBYSEARCH"))*/
if (bEmptyServersOnly) if (bEmptyServersOnly)
tem.Set(SEARCH_EMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals); tem.Set(SEARCH_EMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
if (bNonEmptyServersOnly) if (bNonEmptyServersOnly)
tem.Set(SEARCH_NONEMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals); tem.Set(SEARCH_NONEMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
if (bSecureServersOnly) if (bSecureServersOnly)
tem.Set(SEARCH_SECURE_SERVERS_ONLY, true, EOnlineComparisonOp::Equals); tem.Set(SEARCH_SECURE_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
if (MinSlotsAvailable != 0) if (MinSlotsAvailable != 0)
tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals); tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals);
// Filter results // Filter results
if (SearchSettings.Num() > 0) if (SearchSettings.Num() > 0)
{ {
for (int i = 0; i < SearchSettings.Num(); i++) for (int i = 0; i < SearchSettings.Num(); i++)
{ {
// Function that was added to make directly adding a FVariant possible // Function that was added to make directly adding a FVariant possible
tem.HardSet(SearchSettings[i].PropertyKeyPair.Key, SearchSettings[i].PropertyKeyPair.Data, SearchSettings[i].ComparisonOp); tem.HardSet(SearchSettings[i].PropertyKeyPair.Key, SearchSettings[i].PropertyKeyPair.Data, SearchSettings[i].ComparisonOp);
} }
} }
switch (ServerSearchType) switch (ServerSearchType)
{ {
case EBPServerPresenceSearchType::ClientServersOnly: case EBPServerPresenceSearchType::ClientServersOnly:
{ {
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals); tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
if (bSearchLobbies) if (bSearchLobbies)
tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals); tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);
} }
break; break;
case EBPServerPresenceSearchType::DedicatedServersOnly: case EBPServerPresenceSearchType::DedicatedServersOnly:
{ {
//tem.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals); //tem.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
} }
break; break;
case EBPServerPresenceSearchType::AllServers: case EBPServerPresenceSearchType::AllServers:
default: default:
{ {
// Only steam uses the separate searching flags currently // Only steam uses the separate searching flags currently
if (IOnlineSubsystem::DoesInstanceExist("STEAM")) if (IOnlineSubsystem::DoesInstanceExist("STEAM"))
{ {
bRunSecondSearch = true; bRunSecondSearch = true;
SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch); SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch);
SearchObjectDedicated->MaxSearchResults = MaxResults; SearchObjectDedicated->MaxSearchResults = MaxResults;
SearchObjectDedicated->bIsLanQuery = bUseLAN; SearchObjectDedicated->bIsLanQuery = bUseLAN;
FOnlineSearchSettingsEx DedicatedOnly = tem; FOnlineSearchSettingsEx DedicatedOnly = tem;
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals); tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
//DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals); //DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
SearchObjectDedicated->QuerySettings = DedicatedOnly; SearchObjectDedicated->QuerySettings = DedicatedOnly;
} }
} }
break; break;
} }
// Copy the derived temp variable over to it's base class // Copy the derived temp variable over to it's base class
SearchObject->QuerySettings = tem; SearchObject->QuerySettings = tem;
Sessions->FindSessions(*Helper.UserID, SearchObject.ToSharedRef()); Sessions->FindSessions(*Helper.UserID, SearchObject.ToSharedRef());
// OnQueryCompleted will get called, nothing more to do now // OnQueryCompleted will get called, nothing more to do now
return; return;
} }
else else
{ {
FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning); FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
} }
} }
// Fail immediately // Fail immediately
OnFailure.Broadcast(SessionSearchResults); OnFailure.Broadcast(SessionSearchResults);
} }
void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess) void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
{ {
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessionsCallback"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull)); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessionsCallback"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
if (!bRunSecondSearch && Helper.IsValid()) if (!bRunSecondSearch && Helper.IsValid())
{ {
auto Sessions = Helper.OnlineSub->GetSessionInterface(); auto Sessions = Helper.OnlineSub->GetSessionInterface();
if (Sessions.IsValid()) if (Sessions.IsValid())
{ {
Sessions->ClearOnFindSessionsCompleteDelegate_Handle(DelegateHandle); Sessions->ClearOnFindSessionsCompleteDelegate_Handle(DelegateHandle);
} }
} }
if (bSuccess) if (bSuccess)
{ {
if (bIsOnSecondSearch) if (bIsOnSecondSearch)
{ {
if (SearchObjectDedicated.IsValid()) if (SearchObjectDedicated.IsValid())
{ {
// Just log the results for now, will need to add a blueprint-compatible search result struct // Just log the results for now, will need to add a blueprint-compatible search result struct
for (auto& Result : SearchObjectDedicated->SearchResults) for (auto& Result : SearchObjectDedicated->SearchResults)
{ {
FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs); FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs);
FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log); FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log);
FBlueprintSessionResult BPResult; FBlueprintSessionResult BPResult;
BPResult.OnlineResult = Result; BPResult.OnlineResult = Result;
SessionSearchResults.Add(BPResult); SessionSearchResults.Add(BPResult);
} }
OnSuccess.Broadcast(SessionSearchResults); OnSuccess.Broadcast(SessionSearchResults);
return; return;
} }
} }
else else
{ {
if (SearchObject.IsValid()) if (SearchObject.IsValid())
{ {
// Just log the results for now, will need to add a blueprint-compatible search result struct // Just log the results for now, will need to add a blueprint-compatible search result struct
for (auto& Result : SearchObject->SearchResults) for (auto& Result : SearchObject->SearchResults)
{ {
FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs); FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs);
FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log); FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log);
FBlueprintSessionResult BPResult; FBlueprintSessionResult BPResult;
BPResult.OnlineResult = Result; BPResult.OnlineResult = Result;
SessionSearchResults.Add(BPResult); SessionSearchResults.Add(BPResult);
} }
if (!bRunSecondSearch) if (!bRunSecondSearch)
{ {
OnSuccess.Broadcast(SessionSearchResults); OnSuccess.Broadcast(SessionSearchResults);
return; return;
} }
} }
} }
} }
else else
{ {
if (!bRunSecondSearch) if (!bRunSecondSearch)
{ {
// Need to account for only one of the searches failing // Need to account for only one of the searches failing
if (SessionSearchResults.Num() > 0) if (SessionSearchResults.Num() > 0)
OnSuccess.Broadcast(SessionSearchResults); OnSuccess.Broadcast(SessionSearchResults);
else else
OnFailure.Broadcast(SessionSearchResults); OnFailure.Broadcast(SessionSearchResults);
return; return;
} }
} }
if (Helper.IsValid() && bRunSecondSearch && ServerSearchType == EBPServerPresenceSearchType::AllServers) if (Helper.IsValid() && bRunSecondSearch && ServerSearchType == EBPServerPresenceSearchType::AllServers)
{ {
bRunSecondSearch = false; bRunSecondSearch = false;
bIsOnSecondSearch = true; bIsOnSecondSearch = true;
auto Sessions = Helper.OnlineSub->GetSessionInterface(); auto Sessions = Helper.OnlineSub->GetSessionInterface();
Sessions->FindSessions(*Helper.UserID, SearchObjectDedicated.ToSharedRef()); Sessions->FindSessions(*Helper.UserID, SearchObjectDedicated.ToSharedRef());
} }
else // We lost our player controller else // We lost our player controller
{ {
if (bSuccess && SessionSearchResults.Num() > 0) if (bSuccess && SessionSearchResults.Num() > 0)
OnSuccess.Broadcast(SessionSearchResults); OnSuccess.Broadcast(SessionSearchResults);
else else
OnFailure.Broadcast(SessionSearchResults); OnFailure.Broadcast(SessionSearchResults);
} }
} }
void UFindSessionsCallbackProxyAdvanced::FilterSessionResults(const TArray<FBlueprintSessionResult> &SessionResults, const TArray<FSessionsSearchSetting> &Filters, TArray<FBlueprintSessionResult> &FilteredResults) void UFindSessionsCallbackProxyAdvanced::FilterSessionResults(const TArray<FBlueprintSessionResult> &SessionResults, const TArray<FSessionsSearchSetting> &Filters, TArray<FBlueprintSessionResult> &FilteredResults)
{ {
for (int j = 0; j < SessionResults.Num(); j++) for (int j = 0; j < SessionResults.Num(); j++)
{ {
bool bAddResult = true; bool bAddResult = true;
// Filter results // Filter results
if (Filters.Num() > 0) if (Filters.Num() > 0)
{ {
const FOnlineSessionSetting * setting; const FOnlineSessionSetting * setting;
for (int i = 0; i < Filters.Num(); i++) for (int i = 0; i < Filters.Num(); i++)
{ {
setting = SessionResults[j].OnlineResult.Session.SessionSettings.Settings.Find(Filters[i].PropertyKeyPair.Key); setting = SessionResults[j].OnlineResult.Session.SessionSettings.Settings.Find(Filters[i].PropertyKeyPair.Key);
// Couldn't find this key // Couldn't find this key
if (!setting) if (!setting)
continue; continue;
if (!CompareVariants(setting->Data, Filters[i].PropertyKeyPair.Data, Filters[i].ComparisonOp)) if (!CompareVariants(setting->Data, Filters[i].PropertyKeyPair.Data, Filters[i].ComparisonOp))
{ {
bAddResult = false; bAddResult = false;
break; break;
} }
} }
} }
if (bAddResult) if (bAddResult)
FilteredResults.Add(SessionResults[j]); FilteredResults.Add(SessionResults[j]);
} }
return; return;
} }
bool UFindSessionsCallbackProxyAdvanced::CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator) bool UFindSessionsCallbackProxyAdvanced::CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator)
{ {
if (A.GetType() != B.GetType()) if (A.GetType() != B.GetType())
return false; return false;
switch (A.GetType()) switch (A.GetType())
{ {
case EOnlineKeyValuePairDataType::Bool: case EOnlineKeyValuePairDataType::Bool:
{ {
bool bA, bB; bool bA, bB;
A.GetValue(bA); A.GetValue(bA);
B.GetValue(bB); B.GetValue(bB);
switch (Comparator) switch (Comparator)
{ {
case EOnlineComparisonOpRedux::Equals: case EOnlineComparisonOpRedux::Equals:
return bA == bB; break; return bA == bB; break;
case EOnlineComparisonOpRedux::NotEquals: case EOnlineComparisonOpRedux::NotEquals:
return bA != bB; break; return bA != bB; break;
default: default:
return false;break; return false;break;
} }
} }
case EOnlineKeyValuePairDataType::Double: case EOnlineKeyValuePairDataType::Double:
{ {
double bA, bB; double bA, bB;
A.GetValue(bA); A.GetValue(bA);
B.GetValue(bB); B.GetValue(bB);
switch (Comparator) switch (Comparator)
{ {
case EOnlineComparisonOpRedux::Equals: case EOnlineComparisonOpRedux::Equals:
return bA == bB; break; return bA == bB; break;
case EOnlineComparisonOpRedux::NotEquals: case EOnlineComparisonOpRedux::NotEquals:
return bA != bB; break; return bA != bB; break;
case EOnlineComparisonOpRedux::GreaterThanEquals: case EOnlineComparisonOpRedux::GreaterThanEquals:
return (bA == bB || bA > bB); break; return (bA == bB || bA > bB); break;
case EOnlineComparisonOpRedux::LessThanEquals: case EOnlineComparisonOpRedux::LessThanEquals:
return (bA == bB || bA < bB); break; return (bA == bB || bA < bB); break;
case EOnlineComparisonOpRedux::GreaterThan: case EOnlineComparisonOpRedux::GreaterThan:
return bA > bB; break; return bA > bB; break;
case EOnlineComparisonOpRedux::LessThan: case EOnlineComparisonOpRedux::LessThan:
return bA < bB; break; return bA < bB; break;
default: default:
return false; break; return false; break;
} }
} }
case EOnlineKeyValuePairDataType::Float: case EOnlineKeyValuePairDataType::Float:
{ {
float tbA, tbB; float tbA, tbB;
double bA, bB; double bA, bB;
A.GetValue(tbA); A.GetValue(tbA);
B.GetValue(tbB); B.GetValue(tbB);
bA = (double)tbA; bA = (double)tbA;
bB = (double)tbB; bB = (double)tbB;
switch (Comparator) switch (Comparator)
{ {
case EOnlineComparisonOpRedux::Equals: case EOnlineComparisonOpRedux::Equals:
return bA == bB; break; return bA == bB; break;
case EOnlineComparisonOpRedux::NotEquals: case EOnlineComparisonOpRedux::NotEquals:
return bA != bB; break; return bA != bB; break;
case EOnlineComparisonOpRedux::GreaterThanEquals: case EOnlineComparisonOpRedux::GreaterThanEquals:
return (bA == bB || bA > bB); break; return (bA == bB || bA > bB); break;
case EOnlineComparisonOpRedux::LessThanEquals: case EOnlineComparisonOpRedux::LessThanEquals:
return (bA == bB || bA < bB); break; return (bA == bB || bA < bB); break;
case EOnlineComparisonOpRedux::GreaterThan: case EOnlineComparisonOpRedux::GreaterThan:
return bA > bB; break; return bA > bB; break;
case EOnlineComparisonOpRedux::LessThan: case EOnlineComparisonOpRedux::LessThan:
return bA < bB; break; return bA < bB; break;
default: default:
return false; break; return false; break;
} }
} }
case EOnlineKeyValuePairDataType::Int32: case EOnlineKeyValuePairDataType::Int32:
{ {
int32 bA, bB; int32 bA, bB;
A.GetValue(bA); A.GetValue(bA);
B.GetValue(bB); B.GetValue(bB);
switch (Comparator) switch (Comparator)
{ {
case EOnlineComparisonOpRedux::Equals: case EOnlineComparisonOpRedux::Equals:
return bA == bB; break; return bA == bB; break;
case EOnlineComparisonOpRedux::NotEquals: case EOnlineComparisonOpRedux::NotEquals:
return bA != bB; break; return bA != bB; break;
case EOnlineComparisonOpRedux::GreaterThanEquals: case EOnlineComparisonOpRedux::GreaterThanEquals:
return (bA == bB || bA > bB); break; return (bA == bB || bA > bB); break;
case EOnlineComparisonOpRedux::LessThanEquals: case EOnlineComparisonOpRedux::LessThanEquals:
return (bA == bB || bA < bB); break; return (bA == bB || bA < bB); break;
case EOnlineComparisonOpRedux::GreaterThan: case EOnlineComparisonOpRedux::GreaterThan:
return bA > bB; break; return bA > bB; break;
case EOnlineComparisonOpRedux::LessThan: case EOnlineComparisonOpRedux::LessThan:
return bA < bB; break; return bA < bB; break;
default: default:
return false; break; return false; break;
} }
} }
case EOnlineKeyValuePairDataType::Int64: case EOnlineKeyValuePairDataType::Int64:
{ {
uint64 bA, bB; uint64 bA, bB;
A.GetValue(bA); A.GetValue(bA);
B.GetValue(bB); B.GetValue(bB);
switch (Comparator) switch (Comparator)
{ {
case EOnlineComparisonOpRedux::Equals: case EOnlineComparisonOpRedux::Equals:
return bA == bB; break; return bA == bB; break;
case EOnlineComparisonOpRedux::NotEquals: case EOnlineComparisonOpRedux::NotEquals:
return bA != bB; break; return bA != bB; break;
case EOnlineComparisonOpRedux::GreaterThanEquals: case EOnlineComparisonOpRedux::GreaterThanEquals:
return (bA == bB || bA > bB); break; return (bA == bB || bA > bB); break;
case EOnlineComparisonOpRedux::LessThanEquals: case EOnlineComparisonOpRedux::LessThanEquals:
return (bA == bB || bA < bB); break; return (bA == bB || bA < bB); break;
case EOnlineComparisonOpRedux::GreaterThan: case EOnlineComparisonOpRedux::GreaterThan:
return bA > bB; break; return bA > bB; break;
case EOnlineComparisonOpRedux::LessThan: case EOnlineComparisonOpRedux::LessThan:
return bA < bB; break; return bA < bB; break;
default: default:
return false; break; return false; break;
} }
} }
case EOnlineKeyValuePairDataType::String: case EOnlineKeyValuePairDataType::String:
{ {
FString bA, bB; FString bA, bB;
A.GetValue(bA); A.GetValue(bA);
B.GetValue(bB); B.GetValue(bB);
switch (Comparator) switch (Comparator)
{ {
case EOnlineComparisonOpRedux::Equals: case EOnlineComparisonOpRedux::Equals:
return bA == bB; break; return bA == bB; break;
case EOnlineComparisonOpRedux::NotEquals: case EOnlineComparisonOpRedux::NotEquals:
return bA != bB; break; return bA != bB; break;
default: default:
return false; break; return false; break;
} }
} }
case EOnlineKeyValuePairDataType::Empty: case EOnlineKeyValuePairDataType::Empty:
case EOnlineKeyValuePairDataType::Blob: case EOnlineKeyValuePairDataType::Blob:
default: default:
return false; break; return false; break;
} }
} }

View File

@@ -1,94 +1,94 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "GetFriendsCallbackProxy.h" #include "GetFriendsCallbackProxy.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// UGetFriendsCallbackProxy // UGetFriendsCallbackProxy
DEFINE_LOG_CATEGORY(AdvancedGetFriendsLog); DEFINE_LOG_CATEGORY(AdvancedGetFriendsLog);
UGetFriendsCallbackProxy::UGetFriendsCallbackProxy(const FObjectInitializer& ObjectInitializer) UGetFriendsCallbackProxy::UGetFriendsCallbackProxy(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
, FriendListReadCompleteDelegate(FOnReadFriendsListComplete::CreateUObject(this, &ThisClass::OnReadFriendsListCompleted)) , FriendListReadCompleteDelegate(FOnReadFriendsListComplete::CreateUObject(this, &ThisClass::OnReadFriendsListCompleted))
{ {
} }
UGetFriendsCallbackProxy* UGetFriendsCallbackProxy::GetAndStoreFriendsList(UObject* WorldContextObject, class APlayerController* PlayerController) UGetFriendsCallbackProxy* UGetFriendsCallbackProxy::GetAndStoreFriendsList(UObject* WorldContextObject, class APlayerController* PlayerController)
{ {
UGetFriendsCallbackProxy* Proxy = NewObject<UGetFriendsCallbackProxy>(); UGetFriendsCallbackProxy* Proxy = NewObject<UGetFriendsCallbackProxy>();
Proxy->PlayerControllerWeakPtr = PlayerController; Proxy->PlayerControllerWeakPtr = PlayerController;
Proxy->WorldContextObject = WorldContextObject; Proxy->WorldContextObject = WorldContextObject;
return Proxy; return Proxy;
} }
void UGetFriendsCallbackProxy::Activate() void UGetFriendsCallbackProxy::Activate()
{ {
if (!PlayerControllerWeakPtr.IsValid()) if (!PlayerControllerWeakPtr.IsValid())
{ {
// Fail immediately // Fail immediately
UE_LOG(AdvancedGetFriendsLog, Warning, TEXT("GetFriends Failed received a bad player controller!")); UE_LOG(AdvancedGetFriendsLog, Warning, TEXT("GetFriends Failed received a bad player controller!"));
TArray<FBPFriendInfo> EmptyArray; TArray<FBPFriendInfo> EmptyArray;
OnFailure.Broadcast(EmptyArray); OnFailure.Broadcast(EmptyArray);
return; return;
} }
IOnlineFriendsPtr Friends = Online::GetFriendsInterface(); IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
if (Friends.IsValid()) if (Friends.IsValid())
{ {
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
Friends->ReadFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendListReadCompleteDelegate); Friends->ReadFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendListReadCompleteDelegate);
return; return;
} }
// Fail immediately // Fail immediately
TArray<FBPFriendInfo> EmptyArray; TArray<FBPFriendInfo> EmptyArray;
OnFailure.Broadcast(EmptyArray); OnFailure.Broadcast(EmptyArray);
} }
void UGetFriendsCallbackProxy::OnReadFriendsListCompleted(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorString) void UGetFriendsCallbackProxy::OnReadFriendsListCompleted(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorString)
{ {
if (bWasSuccessful) if (bWasSuccessful)
{ {
IOnlineFriendsPtr Friends = Online::GetFriendsInterface(); IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
if (Friends.IsValid()) if (Friends.IsValid())
{ {
// Not actually needed anymore, plus was not being validated and causing a crash // Not actually needed anymore, plus was not being validated and causing a crash
//ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player); //ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
TArray<FBPFriendInfo> FriendsListOut; TArray<FBPFriendInfo> FriendsListOut;
TArray< TSharedRef<FOnlineFriend> > FriendList; TArray< TSharedRef<FOnlineFriend> > FriendList;
Friends->GetFriendsList(LocalUserNum, ListName, FriendList); Friends->GetFriendsList(LocalUserNum, ListName, FriendList);
for (int32 i = 0; i < FriendList.Num(); i++) for (int32 i = 0; i < FriendList.Num(); i++)
{ {
TSharedRef<FOnlineFriend> Friend = FriendList[i]; TSharedRef<FOnlineFriend> Friend = FriendList[i];
FBPFriendInfo BPF; FBPFriendInfo BPF;
FOnlineUserPresence pres = Friend->GetPresence(); FOnlineUserPresence pres = Friend->GetPresence();
BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
BPF.DisplayName = Friend->GetDisplayName(); BPF.DisplayName = Friend->GetDisplayName();
BPF.RealName = Friend->GetRealName(); BPF.RealName = Friend->GetRealName();
BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId()); BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId());
BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame; BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame;
BPF.PresenceInfo.bIsOnline = pres.bIsOnline; BPF.PresenceInfo.bIsOnline = pres.bIsOnline;
BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport; BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport;
BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying; BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying;
BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
BPF.PresenceInfo.StatusString = pres.Status.StatusStr; BPF.PresenceInfo.StatusString = pres.Status.StatusStr;
BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable; BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable;
BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame; BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;
FriendsListOut.Add(BPF); FriendsListOut.Add(BPF);
} }
OnSuccess.Broadcast(FriendsListOut); OnSuccess.Broadcast(FriendsListOut);
} }
} }
else else
{ {
TArray<FBPFriendInfo> EmptyArray; TArray<FBPFriendInfo> EmptyArray;
OnFailure.Broadcast(EmptyArray); OnFailure.Broadcast(EmptyArray);
} }
} }

View File

@@ -1,85 +1,85 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "GetRecentPlayersCallbackProxy.h" #include "GetRecentPlayersCallbackProxy.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// UGetRecentPlayersCallbackProxy // UGetRecentPlayersCallbackProxy
DEFINE_LOG_CATEGORY(AdvancedGetRecentPlayersLog); DEFINE_LOG_CATEGORY(AdvancedGetRecentPlayersLog);
UGetRecentPlayersCallbackProxy::UGetRecentPlayersCallbackProxy(const FObjectInitializer& ObjectInitializer) UGetRecentPlayersCallbackProxy::UGetRecentPlayersCallbackProxy(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
, QueryRecentPlayersCompleteDelegate(FOnQueryRecentPlayersCompleteDelegate::CreateUObject(this, &ThisClass::OnQueryRecentPlayersCompleted)) , QueryRecentPlayersCompleteDelegate(FOnQueryRecentPlayersCompleteDelegate::CreateUObject(this, &ThisClass::OnQueryRecentPlayersCompleted))
{ {
} }
UGetRecentPlayersCallbackProxy* UGetRecentPlayersCallbackProxy::GetAndStoreRecentPlayersList(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId) UGetRecentPlayersCallbackProxy* UGetRecentPlayersCallbackProxy::GetAndStoreRecentPlayersList(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId)
{ {
UGetRecentPlayersCallbackProxy* Proxy = NewObject<UGetRecentPlayersCallbackProxy>(); UGetRecentPlayersCallbackProxy* Proxy = NewObject<UGetRecentPlayersCallbackProxy>();
Proxy->cUniqueNetId = UniqueNetId; Proxy->cUniqueNetId = UniqueNetId;
Proxy->WorldContextObject = WorldContextObject; Proxy->WorldContextObject = WorldContextObject;
return Proxy; return Proxy;
} }
void UGetRecentPlayersCallbackProxy::Activate() void UGetRecentPlayersCallbackProxy::Activate()
{ {
if (!cUniqueNetId.IsValid()) if (!cUniqueNetId.IsValid())
{ {
// Fail immediately // Fail immediately
UE_LOG(AdvancedGetRecentPlayersLog, Warning, TEXT("GetRecentPlayers Failed received a bad UniqueNetId!")); UE_LOG(AdvancedGetRecentPlayersLog, Warning, TEXT("GetRecentPlayers Failed received a bad UniqueNetId!"));
TArray<FBPOnlineRecentPlayer> EmptyArray; TArray<FBPOnlineRecentPlayer> EmptyArray;
OnFailure.Broadcast(EmptyArray); OnFailure.Broadcast(EmptyArray);
return; return;
} }
IOnlineFriendsPtr Friends = Online::GetFriendsInterface(); IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
if (Friends.IsValid()) if (Friends.IsValid())
{ {
DelegateHandle = Friends->AddOnQueryRecentPlayersCompleteDelegate_Handle(QueryRecentPlayersCompleteDelegate); DelegateHandle = Friends->AddOnQueryRecentPlayersCompleteDelegate_Handle(QueryRecentPlayersCompleteDelegate);
// Testing with null namespace // Testing with null namespace
Friends->QueryRecentPlayers(*(cUniqueNetId.GetUniqueNetId()), ""); Friends->QueryRecentPlayers(*(cUniqueNetId.GetUniqueNetId()), "");
return; return;
} }
// Fail immediately // Fail immediately
TArray<FBPOnlineRecentPlayer> EmptyArray; TArray<FBPOnlineRecentPlayer> EmptyArray;
OnFailure.Broadcast(EmptyArray); OnFailure.Broadcast(EmptyArray);
} }
void UGetRecentPlayersCallbackProxy::OnQueryRecentPlayersCompleted(const FUniqueNetId &UserID, const FString &Namespace, bool bWasSuccessful, const FString& ErrorString) void UGetRecentPlayersCallbackProxy::OnQueryRecentPlayersCompleted(const FUniqueNetId &UserID, const FString &Namespace, bool bWasSuccessful, const FString& ErrorString)
{ {
IOnlineFriendsPtr Friends = Online::GetFriendsInterface(); IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
if (Friends.IsValid()) if (Friends.IsValid())
Friends->ClearOnQueryRecentPlayersCompleteDelegate_Handle(DelegateHandle); Friends->ClearOnQueryRecentPlayersCompleteDelegate_Handle(DelegateHandle);
if (bWasSuccessful) if (bWasSuccessful)
{ {
// WHOOPS // WHOOPS
//IOnlineFriendsPtr Friends = Online::GetFriendsInterface(); //IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
if (Friends.IsValid()) if (Friends.IsValid())
{ {
TArray<FBPOnlineRecentPlayer> PlayersListOut; TArray<FBPOnlineRecentPlayer> PlayersListOut;
TArray< TSharedRef<FOnlineRecentPlayer> > PlayerList; TArray< TSharedRef<FOnlineRecentPlayer> > PlayerList;
Friends->GetRecentPlayers(*(cUniqueNetId.GetUniqueNetId()), "", PlayerList); Friends->GetRecentPlayers(*(cUniqueNetId.GetUniqueNetId()), "", PlayerList);
for (int32 i = 0; i < PlayerList.Num(); i++) for (int32 i = 0; i < PlayerList.Num(); i++)
{ {
TSharedRef<FOnlineRecentPlayer> Player = PlayerList[i]; TSharedRef<FOnlineRecentPlayer> Player = PlayerList[i];
FBPOnlineRecentPlayer BPF; FBPOnlineRecentPlayer BPF;
BPF.DisplayName = Player->GetDisplayName(); BPF.DisplayName = Player->GetDisplayName();
BPF.RealName = Player->GetRealName(); BPF.RealName = Player->GetRealName();
BPF.UniqueNetId.SetUniqueNetId(Player->GetUserId()); BPF.UniqueNetId.SetUniqueNetId(Player->GetUserId());
PlayersListOut.Add(BPF); PlayersListOut.Add(BPF);
} }
OnSuccess.Broadcast(PlayersListOut); OnSuccess.Broadcast(PlayersListOut);
} }
} }
else else
{ {
TArray<FBPOnlineRecentPlayer> EmptyArray; TArray<FBPOnlineRecentPlayer> EmptyArray;
OnFailure.Broadcast(EmptyArray); OnFailure.Broadcast(EmptyArray);
} }
} }

View File

@@ -1,73 +1,73 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "SendFriendInviteCallbackProxy.h" #include "SendFriendInviteCallbackProxy.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// UGetRecentPlayersCallbackProxy // UGetRecentPlayersCallbackProxy
DEFINE_LOG_CATEGORY(AdvancedSendFriendInviteLog); DEFINE_LOG_CATEGORY(AdvancedSendFriendInviteLog);
USendFriendInviteCallbackProxy::USendFriendInviteCallbackProxy(const FObjectInitializer& ObjectInitializer) USendFriendInviteCallbackProxy::USendFriendInviteCallbackProxy(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
, OnSendInviteCompleteDelegate(FOnSendInviteComplete::CreateUObject(this, &ThisClass::OnSendInviteComplete)) , OnSendInviteCompleteDelegate(FOnSendInviteComplete::CreateUObject(this, &ThisClass::OnSendInviteComplete))
{ {
} }
USendFriendInviteCallbackProxy* USendFriendInviteCallbackProxy::SendFriendInvite(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &UniqueNetIDInvited) USendFriendInviteCallbackProxy* USendFriendInviteCallbackProxy::SendFriendInvite(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &UniqueNetIDInvited)
{ {
USendFriendInviteCallbackProxy* Proxy = NewObject<USendFriendInviteCallbackProxy>(); USendFriendInviteCallbackProxy* Proxy = NewObject<USendFriendInviteCallbackProxy>();
Proxy->PlayerControllerWeakPtr = PlayerController; Proxy->PlayerControllerWeakPtr = PlayerController;
Proxy->cUniqueNetId = UniqueNetIDInvited; Proxy->cUniqueNetId = UniqueNetIDInvited;
Proxy->WorldContextObject = WorldContextObject; Proxy->WorldContextObject = WorldContextObject;
return Proxy; return Proxy;
} }
void USendFriendInviteCallbackProxy::Activate() void USendFriendInviteCallbackProxy::Activate()
{ {
if (!cUniqueNetId.IsValid()) if (!cUniqueNetId.IsValid())
{ {
// Fail immediately // Fail immediately
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed received a bad UniqueNetId!")); UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed received a bad UniqueNetId!"));
OnFailure.Broadcast(); OnFailure.Broadcast();
return; return;
} }
if (!PlayerControllerWeakPtr.IsValid()) if (!PlayerControllerWeakPtr.IsValid())
{ {
// Fail immediately // Fail immediately
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed received a bad playercontroller!")); UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed received a bad playercontroller!"));
OnFailure.Broadcast(); OnFailure.Broadcast();
return; return;
} }
IOnlineFriendsPtr Friends = Online::GetFriendsInterface(); IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
if (Friends.IsValid()) if (Friends.IsValid())
{ {
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
if (!Player) if (!Player)
{ {
// Fail immediately // Fail immediately
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed couldn't cast to ULocalPlayer!")); UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed couldn't cast to ULocalPlayer!"));
OnFailure.Broadcast(); OnFailure.Broadcast();
return; return;
} }
Friends->SendInvite(Player->GetControllerId(), *cUniqueNetId.GetUniqueNetId(), EFriendsLists::ToString((EFriendsLists::Default)), OnSendInviteCompleteDelegate); Friends->SendInvite(Player->GetControllerId(), *cUniqueNetId.GetUniqueNetId(), EFriendsLists::ToString((EFriendsLists::Default)), OnSendInviteCompleteDelegate);
return; return;
} }
// Fail immediately // Fail immediately
OnFailure.Broadcast(); OnFailure.Broadcast();
} }
void USendFriendInviteCallbackProxy::OnSendInviteComplete(int32 LocalPlayerNum, bool bWasSuccessful, const FUniqueNetId &InvitedPlayer, const FString &ListName, const FString &ErrorString) void USendFriendInviteCallbackProxy::OnSendInviteComplete(int32 LocalPlayerNum, bool bWasSuccessful, const FUniqueNetId &InvitedPlayer, const FString &ListName, const FString &ErrorString)
{ {
if ( bWasSuccessful ) if ( bWasSuccessful )
{ {
OnSuccess.Broadcast(); OnSuccess.Broadcast();
} }
else else
{ {
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed with error: %s"), *ErrorString); UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed with error: %s"), *ErrorString);
OnFailure.Broadcast(); OnFailure.Broadcast();
} }
} }

View File

@@ -1,38 +1,38 @@
{ {
"FileVersion" : 3, "FileVersion" : 3,
"FriendlyName" : "Advanced Steam Sessions", "FriendlyName" : "Advanced Steam Sessions",
"Version" : 5.0, "Version" : 5.0,
"VersionName": "5.0", "VersionName": "5.0",
"Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS", "Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS",
"Category" : "Advanced Sessions Plugin", "Category" : "Advanced Sessions Plugin",
"CreatedBy" : "Joshua Statzer", "CreatedBy" : "Joshua Statzer",
"CreatedByURL" : "N/A", "CreatedByURL" : "N/A",
"Modules" : "Modules" :
[ [
{ {
"Name" : "AdvancedSteamSessions", "Name" : "AdvancedSteamSessions",
"Type" : "RunTime", "Type" : "RunTime",
"LoadingPhase" : "PreDefault" "LoadingPhase" : "PreDefault"
} }
], ],
"Plugins": [ "Plugins": [
{ {
"Name": "AdvancedSessions", "Name": "AdvancedSessions",
"Enabled": true "Enabled": true
}, },
{ {
"Name": "OnlineSubsystem", "Name": "OnlineSubsystem",
"Enabled": true "Enabled": true
}, },
{ {
"Name": "OnlineSubsystemUtils", "Name": "OnlineSubsystemUtils",
"Enabled": true "Enabled": true
}, },
{ {
"Name": "OnlineSubsystemSteam", "Name": "OnlineSubsystemSteam",
"Enabled": true "Enabled": true
} }
] ]
} }

View File

@@ -1,22 +1,22 @@
using UnrealBuildTool; using UnrealBuildTool;
using System.IO; using System.IO;
public class AdvancedSteamSessions : ModuleRules public class AdvancedSteamSessions : ModuleRules
{ {
public AdvancedSteamSessions(ReadOnlyTargetRules Target) : base(Target) public AdvancedSteamSessions(ReadOnlyTargetRules Target) : base(Target)
{ {
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
//bEnforceIWYU = true; //bEnforceIWYU = true;
PublicDefinitions.Add("WITH_ADVANCED_STEAM_SESSIONS=1"); PublicDefinitions.Add("WITH_ADVANCED_STEAM_SESSIONS=1");
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets", "AdvancedSessions"/*"Voice", "OnlineSubsystemSteam"*/ }); PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets", "AdvancedSessions"/*"Voice", "OnlineSubsystemSteam"*/ });
PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/}); PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/});
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Linux) || (Target.Platform == UnrealTargetPlatform.Mac)) if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Linux) || (Target.Platform == UnrealTargetPlatform.Mac))
{ {
PublicDependencyModuleNames.AddRange(new string[] { "Steamworks",/*"Voice",*/ "OnlineSubsystemSteam" }); PublicDependencyModuleNames.AddRange(new string[] { "Steamworks",/*"Voice",*/ "OnlineSubsystemSteam" });
PublicIncludePaths.AddRange(new string[] { "../Plugins/Online/OnlineSubsystemSteam/Source/Private" });// This is dumb but it isn't very open PublicIncludePaths.AddRange(new string[] { "../Plugins/Online/OnlineSubsystemSteam/Source/Private" });// This is dumb but it isn't very open
} }
} }
} }

View File

@@ -1,387 +1,387 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "Interfaces/OnlineFriendsInterface.h" #include "Interfaces/OnlineFriendsInterface.h"
#include "Interfaces/OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "Interfaces/OnlineMessageInterface.h" #include "Interfaces/OnlineMessageInterface.h"
#include "Interfaces/OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "Interfaces/OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "UObject/UObjectIterator.h" #include "UObject/UObjectIterator.h"
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro // This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just // @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
// disable the warnings locally. Remove when this is fixed in the SDK // disable the warnings locally. Remove when this is fixed in the SDK
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4996) #pragma warning(disable:4996)
// #TODO check back on this at some point // #TODO check back on this at some point
#pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on.... #pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on....
#endif #endif
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
#pragma push_macro("ARRAY_COUNT") #pragma push_macro("ARRAY_COUNT")
#undef ARRAY_COUNT #undef ARRAY_COUNT
#if USING_CODE_ANALYSIS #if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(push)) MSVC_PRAGMA(warning(push))
MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS)) MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS))
#endif // USING_CODE_ANALYSIS #endif // USING_CODE_ANALYSIS
#include <steam/steam_api.h> #include <steam/steam_api.h>
#if USING_CODE_ANALYSIS #if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(pop)) MSVC_PRAGMA(warning(pop))
#endif // USING_CODE_ANALYSIS #endif // USING_CODE_ANALYSIS
#include <steam/isteamapps.h> #include <steam/isteamapps.h>
#include <steam/isteamapplist.h> #include <steam/isteamapplist.h>
//#include <OnlineSubsystemSteamTypes.h> //#include <OnlineSubsystemSteamTypes.h>
#pragma pop_macro("ARRAY_COUNT") #pragma pop_macro("ARRAY_COUNT")
// @todo Steam: See above // @todo Steam: See above
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif
// Making a copy of this here since the original is still in a private folder and is screwing with things // Making a copy of this here since the original is still in a private folder and is screwing with things
/** /**
* Steam specific implementation of the unique net id * Steam specific implementation of the unique net id
*/ */
class FUniqueNetIdSteam2 : class FUniqueNetIdSteam2 :
public FUniqueNetId public FUniqueNetId
{ {
PACKAGE_SCOPE: PACKAGE_SCOPE:
/** Holds the net id for a player */ /** Holds the net id for a player */
uint64 UniqueNetId; uint64 UniqueNetId;
/** Hidden on purpose */ /** Hidden on purpose */
FUniqueNetIdSteam2() : FUniqueNetIdSteam2() :
UniqueNetId(0) UniqueNetId(0)
{ {
} }
/** /**
* Copy Constructor * Copy Constructor
* *
* @param Src the id to copy * @param Src the id to copy
*/ */
explicit FUniqueNetIdSteam2(const FUniqueNetIdSteam2& Src) : explicit FUniqueNetIdSteam2(const FUniqueNetIdSteam2& Src) :
UniqueNetId(Src.UniqueNetId) UniqueNetId(Src.UniqueNetId)
{ {
} }
public: public:
/** /**
* Constructs this object with the specified net id * Constructs this object with the specified net id
* *
* @param InUniqueNetId the id to set ours to * @param InUniqueNetId the id to set ours to
*/ */
explicit FUniqueNetIdSteam2(uint64 InUniqueNetId) : explicit FUniqueNetIdSteam2(uint64 InUniqueNetId) :
UniqueNetId(InUniqueNetId) UniqueNetId(InUniqueNetId)
{ {
} }
/** /**
* Constructs this object with the steam id * Constructs this object with the steam id
* *
* @param InUniqueNetId the id to set ours to * @param InUniqueNetId the id to set ours to
*/ */
explicit FUniqueNetIdSteam2(CSteamID InSteamId) : explicit FUniqueNetIdSteam2(CSteamID InSteamId) :
UniqueNetId(InSteamId.ConvertToUint64()) UniqueNetId(InSteamId.ConvertToUint64())
{ {
} }
/** /**
* Constructs this object with the specified net id * Constructs this object with the specified net id
* *
* @param String textual representation of an id * @param String textual representation of an id
*/ */
explicit FUniqueNetIdSteam2(const FString& Str) : explicit FUniqueNetIdSteam2(const FString& Str) :
UniqueNetId(FCString::Atoi64(*Str)) UniqueNetId(FCString::Atoi64(*Str))
{ {
} }
/** /**
* Constructs this object with the specified net id * Constructs this object with the specified net id
* *
* @param InUniqueNetId the id to set ours to (assumed to be FUniqueNetIdSteam in fact) * @param InUniqueNetId the id to set ours to (assumed to be FUniqueNetIdSteam in fact)
*/ */
explicit FUniqueNetIdSteam2(const FUniqueNetId& InUniqueNetId) : explicit FUniqueNetIdSteam2(const FUniqueNetId& InUniqueNetId) :
UniqueNetId(*(uint64*)InUniqueNetId.GetBytes()) UniqueNetId(*(uint64*)InUniqueNetId.GetBytes())
{ {
} }
virtual FName GetType() const override virtual FName GetType() const override
{ {
return STEAM_SUBSYSTEM; return STEAM_SUBSYSTEM;
} }
/** /**
* Get the raw byte representation of this net id * Get the raw byte representation of this net id
* This data is platform dependent and shouldn't be manipulated directly * This data is platform dependent and shouldn't be manipulated directly
* *
* @return byte array of size GetSize() * @return byte array of size GetSize()
*/ */
virtual const uint8* GetBytes() const override virtual const uint8* GetBytes() const override
{ {
return (uint8*)&UniqueNetId; return (uint8*)&UniqueNetId;
} }
/** /**
* Get the size of the id * Get the size of the id
* *
* @return size in bytes of the id representation * @return size in bytes of the id representation
*/ */
virtual int32 GetSize() const override virtual int32 GetSize() const override
{ {
return sizeof(uint64); return sizeof(uint64);
} }
/** /**
* Check the validity of the id * Check the validity of the id
* *
* @return true if this is a well formed ID, false otherwise * @return true if this is a well formed ID, false otherwise
*/ */
virtual bool IsValid() const override virtual bool IsValid() const override
{ {
return UniqueNetId != 0 && CSteamID(UniqueNetId).IsValid(); return UniqueNetId != 0 && CSteamID(UniqueNetId).IsValid();
} }
/** /**
* Platform specific conversion to string representation of data * Platform specific conversion to string representation of data
* *
* @return data in string form * @return data in string form
*/ */
virtual FString ToString() const override virtual FString ToString() const override
{ {
return FString::Printf(TEXT("%llu"), UniqueNetId); return FString::Printf(TEXT("%llu"), UniqueNetId);
} }
/** /**
* Get a human readable representation of the net id * Get a human readable representation of the net id
* Shouldn't be used for anything other than logging/debugging * Shouldn't be used for anything other than logging/debugging
* *
* @return id in string form * @return id in string form
*/ */
virtual FString ToDebugString() const override virtual FString ToDebugString() const override
{ {
CSteamID SteamID(UniqueNetId); CSteamID SteamID(UniqueNetId);
if (SteamID.IsLobby()) if (SteamID.IsLobby())
{ {
return FString::Printf(TEXT("Lobby [0x%llX]"), UniqueNetId); return FString::Printf(TEXT("Lobby [0x%llX]"), UniqueNetId);
} }
else if (SteamID.BAnonGameServerAccount()) else if (SteamID.BAnonGameServerAccount())
{ {
return FString::Printf(TEXT("Server [0x%llX]"), UniqueNetId); return FString::Printf(TEXT("Server [0x%llX]"), UniqueNetId);
} }
else if (SteamID.IsValid()) else if (SteamID.IsValid())
{ {
const FString NickName(SteamFriends() ? UTF8_TO_TCHAR(SteamFriends()->GetFriendPersonaName(UniqueNetId)) : TEXT("UNKNOWN")); const FString NickName(SteamFriends() ? UTF8_TO_TCHAR(SteamFriends()->GetFriendPersonaName(UniqueNetId)) : TEXT("UNKNOWN"));
return FString::Printf(TEXT("%s [0x%llX]"), *NickName, UniqueNetId); return FString::Printf(TEXT("%s [0x%llX]"), *NickName, UniqueNetId);
} }
else else
{ {
return FString::Printf(TEXT("INVALID [0x%llX]"), UniqueNetId); return FString::Printf(TEXT("INVALID [0x%llX]"), UniqueNetId);
} }
} }
/** Needed for TMap::GetTypeHash() */ /** Needed for TMap::GetTypeHash() */
friend uint32 GetTypeHash(const FUniqueNetIdSteam2& A) friend uint32 GetTypeHash(const FUniqueNetIdSteam2& A)
{ {
return GetTypeHash(A.UniqueNetId); return GetTypeHash(A.UniqueNetId);
//return (uint32)(A.UniqueNetId) + ((uint32)((A.UniqueNetId) >> 32) * 23); //return (uint32)(A.UniqueNetId) + ((uint32)((A.UniqueNetId) >> 32) * 23);
} }
/** Convenience cast to CSteamID */ /** Convenience cast to CSteamID */
operator CSteamID() operator CSteamID()
{ {
return UniqueNetId; return UniqueNetId;
} }
/** Convenience cast to CSteamID */ /** Convenience cast to CSteamID */
operator const CSteamID() const operator const CSteamID() const
{ {
return UniqueNetId; return UniqueNetId;
} }
/** Convenience cast to CSteamID pointer */ /** Convenience cast to CSteamID pointer */
operator CSteamID*() operator CSteamID*()
{ {
return (CSteamID*)&UniqueNetId; return (CSteamID*)&UniqueNetId;
} }
/** Convenience cast to CSteamID pointer */ /** Convenience cast to CSteamID pointer */
operator const CSteamID*() const operator const CSteamID*() const
{ {
return (const CSteamID*)&UniqueNetId; return (const CSteamID*)&UniqueNetId;
} }
friend FArchive& operator<<(FArchive& Ar, FUniqueNetIdSteam2& UserId) friend FArchive& operator<<(FArchive& Ar, FUniqueNetIdSteam2& UserId)
{ {
return Ar << UserId.UniqueNetId; return Ar << UserId.UniqueNetId;
} }
}; };
#endif #endif
#include "AdvancedSteamFriendsLibrary.generated.h" #include "AdvancedSteamFriendsLibrary.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamFriendsLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamFriendsLog, Log, All);
UENUM(Blueprintable) UENUM(Blueprintable)
enum class SteamAvatarSize : uint8 enum class SteamAvatarSize : uint8
{ {
SteamAvatar_INVALID = 0, SteamAvatar_INVALID = 0,
SteamAvatar_Small = 1, SteamAvatar_Small = 1,
SteamAvatar_Medium = 2, SteamAvatar_Medium = 2,
SteamAvatar_Large = 3 SteamAvatar_Large = 3
}; };
UENUM(Blueprintable) UENUM(Blueprintable)
enum class ESteamUserOverlayType : uint8 enum class ESteamUserOverlayType : uint8
{ {
/*Opens the overlay web browser to the specified user or groups profile.*/ /*Opens the overlay web browser to the specified user or groups profile.*/
steamid, steamid,
/*Opens a chat window to the specified user, or joins the group chat.*/ /*Opens a chat window to the specified user, or joins the group chat.*/
chat, chat,
/*Opens a window to a Steam Trading session that was started with the ISteamEconomy / StartTrade Web API.*/ /*Opens a window to a Steam Trading session that was started with the ISteamEconomy / StartTrade Web API.*/
jointrade, jointrade,
/*Opens the overlay web browser to the specified user's stats.*/ /*Opens the overlay web browser to the specified user's stats.*/
stats, stats,
/*Opens the overlay web browser to the specified user's achievements.*/ /*Opens the overlay web browser to the specified user's achievements.*/
achievements, achievements,
/*Opens the overlay in minimal mode prompting the user to add the target user as a friend.*/ /*Opens the overlay in minimal mode prompting the user to add the target user as a friend.*/
friendadd, friendadd,
/*Opens the overlay in minimal mode prompting the user to remove the target friend.*/ /*Opens the overlay in minimal mode prompting the user to remove the target friend.*/
friendremove, friendremove,
/*Opens the overlay in minimal mode prompting the user to accept an incoming friend invite.*/ /*Opens the overlay in minimal mode prompting the user to accept an incoming friend invite.*/
friendrequestaccept, friendrequestaccept,
/*Opens the overlay in minimal mode prompting the user to ignore an incoming friend invite.*/ /*Opens the overlay in minimal mode prompting the user to ignore an incoming friend invite.*/
friendrequestignore friendrequestignore
}; };
static FString EnumToString(const FString& enumName, uint8 value) static FString EnumToString(const FString& enumName, uint8 value)
{ {
const UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, *enumName, true); const UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, *enumName, true);
if (!EnumPtr) if (!EnumPtr)
return FString(); return FString();
FString EnumName = EnumPtr->GetNameStringByIndex(value); FString EnumName = EnumPtr->GetNameStringByIndex(value);
return EnumName; return EnumName;
} }
USTRUCT(BlueprintType, Category = "Online|SteamAPI|SteamGroups") USTRUCT(BlueprintType, Category = "Online|SteamAPI|SteamGroups")
struct FBPSteamGroupInfo struct FBPSteamGroupInfo
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
public: public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
FBPUniqueNetId GroupID; // Uint64 representation FBPUniqueNetId GroupID; // Uint64 representation
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
FString GroupName; FString GroupName;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
FString GroupTag; FString GroupTag;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
int32 numOnline = 0; int32 numOnline = 0;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
int32 numInGame = 0; int32 numInGame = 0;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
int32 numChatting = 0; int32 numChatting = 0;
}; };
UENUM(Blueprintable) UENUM(Blueprintable)
enum class EBPTextFilteringContext : uint8 enum class EBPTextFilteringContext : uint8
{ {
/*Unknown context.*/ /*Unknown context.*/
FContext_Unknown = 0, FContext_Unknown = 0,
/*Game content, only legally required filtering is performed.*/ /*Game content, only legally required filtering is performed.*/
FContext_GameContent = 1, FContext_GameContent = 1,
/*Char from another player.*/ /*Char from another player.*/
FContext_Chat = 2, FContext_Chat = 2,
/*Character or item name.*/ /*Character or item name.*/
FContext_Name = 3 FContext_Name = 3
}; };
UCLASS() UCLASS()
class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* Friend List Functions *************// //********* Friend List Functions *************//
// Get a texture of a valid friends avatar, STEAM ONLY, Returns invalid texture if the subsystem hasn't loaded that size of avatar yet // Get a texture of a valid friends avatar, STEAM ONLY, Returns invalid texture if the subsystem hasn't loaded that size of avatar yet
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI", meta = (ExpandEnumAsExecs = "Result"))
static UTexture2D * GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize = SteamAvatarSize::SteamAvatar_Medium); static UTexture2D * GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize = SteamAvatarSize::SteamAvatar_Medium);
// Preloads the avatar and name of a steam friend, return whether it is already available or not, STEAM ONLY, Takes time to actually load everything after this is called. // Preloads the avatar and name of a steam friend, return whether it is already available or not, STEAM ONLY, Takes time to actually load everything after this is called.
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
static bool RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly = false); static bool RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly = false);
// Opens the steam overlay to go to the specified user dialog // Opens the steam overlay to go to the specified user dialog
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
static bool OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType); static bool OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType);
// Returns if the steam overlay is currently active (this can return false during initial overlay hooking) // Returns if the steam overlay is currently active (this can return false during initial overlay hooking)
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI") UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI")
static bool IsOverlayEnabled(); static bool IsOverlayEnabled();
// Gets the level of a friends steam account, STEAM ONLY, Returns -1 if the steam level is not known, might need RequestSteamFriendInfo called first. // Gets the level of a friends steam account, STEAM ONLY, Returns -1 if the steam level is not known, might need RequestSteamFriendInfo called first.
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
static int32 GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId); static int32 GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId);
// Gets the persona name of a steam ID, STEAM ONLY, Returns empty if no result, might need RequestSteamFriendInfo called first. // Gets the persona name of a steam ID, STEAM ONLY, Returns empty if no result, might need RequestSteamFriendInfo called first.
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
static FString GetSteamPersonaName(const FBPUniqueNetId UniqueNetId); static FString GetSteamPersonaName(const FBPUniqueNetId UniqueNetId);
// Creates a unique steam id directly from a string holding a uint64 value, useful for testing // Creates a unique steam id directly from a string holding a uint64 value, useful for testing
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI") UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI")
static FBPUniqueNetId CreateSteamIDFromString(const FString SteamID64); static FBPUniqueNetId CreateSteamIDFromString(const FString SteamID64);
// Retreives the local steam ID from steam // Retreives the local steam ID from steam
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI") UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI")
static FBPUniqueNetId GetLocalSteamIDFromSteam(); static FBPUniqueNetId GetLocalSteamIDFromSteam();
/* Gets the current game played by a friend - AppID is int32 even though steam ids are uint32, can't be helped in blueprint currently /* Gets the current game played by a friend - AppID is int32 even though steam ids are uint32, can't be helped in blueprint currently
* can use the AppID with the WebAPI GetAppList request. * can use the AppID with the WebAPI GetAppList request.
*/ */
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI", meta = (ExpandEnumAsExecs = "Result"))
static void GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result/*, FString & GameName*/, int32 & AppID); static void GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result/*, FString & GameName*/, int32 & AppID);
// Get a full list of steam groups // Get a full list of steam groups
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|SteamGroups") UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|SteamGroups")
static void GetSteamGroups(TArray<FBPSteamGroupInfo> & SteamGroups); static void GetSteamGroups(TArray<FBPSteamGroupInfo> & SteamGroups);
// Initializes text filtering (pre-loading dictonaries) // Initializes text filtering (pre-loading dictonaries)
// Returns if it succeeded, false if filtering is unavailable for the games language // Returns if it succeeded, false if filtering is unavailable for the games language
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering") UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering")
static bool InitTextFiltering(); static bool InitTextFiltering();
// Attempts to filter a string with the given filtering context // Attempts to filter a string with the given filtering context
// Returns true if the text has been filtered, false if it hasn't (no filtering required or operation failed) // Returns true if the text has been filtered, false if it hasn't (no filtering required or operation failed)
// If false it will still output the original text // If false it will still output the original text
// Textsource is the steam id that is the source of the text (player name / chat) // Textsource is the steam id that is the source of the text (player name / chat)
// Requires that InitTextFiltering be called first!! // Requires that InitTextFiltering be called first!!
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering") UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering")
static bool FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText); static bool FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText);
// Returns if steam is running in big picture mode // Returns if steam is running in big picture mode
UFUNCTION(BlueprintPure, Category = "Online|SteamAPI") UFUNCTION(BlueprintPure, Category = "Online|SteamAPI")
static bool IsSteamInBigPictureMode(); static bool IsSteamInBigPictureMode();
}; };

View File

@@ -1,12 +1,12 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Modules/ModuleManager.h" #include "Modules/ModuleManager.h"
class AdvancedSteamSessions : public IModuleInterface class AdvancedSteamSessions : public IModuleInterface
{ {
public: public:
/** IModuleInterface implementation */ /** IModuleInterface implementation */
void StartupModule(); void StartupModule();
void ShutdownModule(); void ShutdownModule();
}; };

View File

@@ -1,351 +1,351 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
#include "steam/isteamugc.h" #include "steam/isteamugc.h"
#include "steam/isteamremotestorage.h" #include "steam/isteamremotestorage.h"
#endif #endif
#include "Interfaces/OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just // @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
// disable the warnings locally. Remove when this is fixed in the SDK // disable the warnings locally. Remove when this is fixed in the SDK
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4996) #pragma warning(disable:4996)
// #TODO check back on this at some point // #TODO check back on this at some point
#pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on.... #pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on....
#endif #endif
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
#pragma push_macro("ARRAY_COUNT") #pragma push_macro("ARRAY_COUNT")
#undef ARRAY_COUNT #undef ARRAY_COUNT
#if USING_CODE_ANALYSIS #if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(push)) MSVC_PRAGMA(warning(push))
MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS)) MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS))
#endif // USING_CODE_ANALYSIS #endif // USING_CODE_ANALYSIS
#include <steam/steam_api.h> #include <steam/steam_api.h>
#if USING_CODE_ANALYSIS #if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(pop)) MSVC_PRAGMA(warning(pop))
#endif // USING_CODE_ANALYSIS #endif // USING_CODE_ANALYSIS
#pragma pop_macro("ARRAY_COUNT") #pragma pop_macro("ARRAY_COUNT")
#endif #endif
// @todo Steam: See above // @todo Steam: See above
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#include "AdvancedSteamWorkshopLibrary.generated.h" #include "AdvancedSteamWorkshopLibrary.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamWorkshopLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamWorkshopLog, Log, All);
// Using a custom struct because uint32 isn't blueprint supported and I don't want to cast to int32 // Using a custom struct because uint32 isn't blueprint supported and I don't want to cast to int32
// due to the size of the workshop it could end up overflowing? // due to the size of the workshop it could end up overflowing?
USTRUCT(BlueprintType) USTRUCT(BlueprintType)
struct FBPSteamWorkshopID struct FBPSteamWorkshopID
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
public: public:
uint64 SteamWorkshopID; uint64 SteamWorkshopID;
FBPSteamWorkshopID() FBPSteamWorkshopID()
{ {
} }
FBPSteamWorkshopID(uint64 ID) FBPSteamWorkshopID(uint64 ID)
{ {
SteamWorkshopID = ID; SteamWorkshopID = ID;
} }
}; };
// General result codes - Copying steams version over // General result codes - Copying steams version over
// Check these to future proof // Check these to future proof
UENUM(BlueprintType) UENUM(BlueprintType)
enum class FBPSteamResult : uint8 enum class FBPSteamResult : uint8
{ {
K_EResultInvalid = 0, K_EResultInvalid = 0,
k_EResultOK = 1, // success k_EResultOK = 1, // success
k_EResultFail = 2, // generic failure k_EResultFail = 2, // generic failure
k_EResultNoConnection = 3, // no/failed network connection k_EResultNoConnection = 3, // no/failed network connection
// k_EResultNoConnectionRetry = 4, // OBSOLETE - removed // k_EResultNoConnectionRetry = 4, // OBSOLETE - removed
k_EResultInvalidPassword = 5, // password/ticket is invalid k_EResultInvalidPassword = 5, // password/ticket is invalid
k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere
k_EResultInvalidProtocolVer = 7, // protocol version is incorrect k_EResultInvalidProtocolVer = 7, // protocol version is incorrect
k_EResultInvalidParam = 8, // a parameter is incorrect k_EResultInvalidParam = 8, // a parameter is incorrect
k_EResultFileNotFound = 9, // file was not found k_EResultFileNotFound = 9, // file was not found
k_EResultBusy = 10, // called method busy - action not taken k_EResultBusy = 10, // called method busy - action not taken
k_EResultInvalidState = 11, // called object was in an invalid state k_EResultInvalidState = 11, // called object was in an invalid state
k_EResultInvalidName = 12, // name is invalid k_EResultInvalidName = 12, // name is invalid
k_EResultInvalidEmail = 13, // email is invalid k_EResultInvalidEmail = 13, // email is invalid
k_EResultDuplicateName = 14, // name is not unique k_EResultDuplicateName = 14, // name is not unique
k_EResultAccessDenied = 15, // access is denied k_EResultAccessDenied = 15, // access is denied
k_EResultTimeout = 16, // operation timed out k_EResultTimeout = 16, // operation timed out
k_EResultBanned = 17, // VAC2 banned k_EResultBanned = 17, // VAC2 banned
k_EResultAccountNotFound = 18, // account not found k_EResultAccountNotFound = 18, // account not found
k_EResultInvalidSteamID = 19, // steamID is invalid k_EResultInvalidSteamID = 19, // steamID is invalid
k_EResultServiceUnavailable = 20, // The requested service is currently unavailable k_EResultServiceUnavailable = 20, // The requested service is currently unavailable
k_EResultNotLoggedOn = 21, // The user is not logged on k_EResultNotLoggedOn = 21, // The user is not logged on
k_EResultPending = 22, // Request is pending (may be in process, or waiting on third party) k_EResultPending = 22, // Request is pending (may be in process, or waiting on third party)
k_EResultEncryptionFailure = 23, // Encryption or Decryption failed k_EResultEncryptionFailure = 23, // Encryption or Decryption failed
k_EResultInsufficientPrivilege = 24, // Insufficient privilege k_EResultInsufficientPrivilege = 24, // Insufficient privilege
k_EResultLimitExceeded = 25, // Too much of a good thing k_EResultLimitExceeded = 25, // Too much of a good thing
k_EResultRevoked = 26, // Access has been revoked (used for revoked guest passes) k_EResultRevoked = 26, // Access has been revoked (used for revoked guest passes)
k_EResultExpired = 27, // License/Guest pass the user is trying to access is expired k_EResultExpired = 27, // License/Guest pass the user is trying to access is expired
k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by account, cannot be acked again k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by account, cannot be acked again
k_EResultDuplicateRequest = 29, // The request is a duplicate and the action has already occurred in the past, ignored this time k_EResultDuplicateRequest = 29, // The request is a duplicate and the action has already occurred in the past, ignored this time
k_EResultAlreadyOwned = 30, // All the games in this guest pass redemption request are already owned by the user k_EResultAlreadyOwned = 30, // All the games in this guest pass redemption request are already owned by the user
k_EResultIPNotFound = 31, // IP address not found k_EResultIPNotFound = 31, // IP address not found
k_EResultPersistFailed = 32, // failed to write change to the data store k_EResultPersistFailed = 32, // failed to write change to the data store
k_EResultLockingFailed = 33, // failed to acquire access lock for this operation k_EResultLockingFailed = 33, // failed to acquire access lock for this operation
k_EResultLogonSessionReplaced = 34, k_EResultLogonSessionReplaced = 34,
k_EResultConnectFailed = 35, k_EResultConnectFailed = 35,
k_EResultHandshakeFailed = 36, k_EResultHandshakeFailed = 36,
k_EResultIOFailure = 37, k_EResultIOFailure = 37,
k_EResultRemoteDisconnect = 38, k_EResultRemoteDisconnect = 38,
k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart requested k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart requested
k_EResultBlocked = 40, // a user didn't allow it k_EResultBlocked = 40, // a user didn't allow it
k_EResultIgnored = 41, // target is ignoring sender k_EResultIgnored = 41, // target is ignoring sender
k_EResultNoMatch = 42, // nothing matching the request found k_EResultNoMatch = 42, // nothing matching the request found
k_EResultAccountDisabled = 43, k_EResultAccountDisabled = 43,
k_EResultServiceReadOnly = 44, // this service is not accepting content changes right now k_EResultServiceReadOnly = 44, // this service is not accepting content changes right now
k_EResultAccountNotFeatured = 45, // account doesn't have value, so this feature isn't available k_EResultAccountNotFeatured = 45, // account doesn't have value, so this feature isn't available
k_EResultAdministratorOK = 46, // allowed to take this action, but only because requester is admin k_EResultAdministratorOK = 46, // allowed to take this action, but only because requester is admin
k_EResultContentVersion = 47, // A Version mismatch in content transmitted within the Steam protocol. k_EResultContentVersion = 47, // A Version mismatch in content transmitted within the Steam protocol.
k_EResultTryAnotherCM = 48, // The current CM can't service the user making a request, user should try another. k_EResultTryAnotherCM = 48, // The current CM can't service the user making a request, user should try another.
k_EResultPasswordRequiredToKickSession = 49,// You are already logged in elsewhere, this cached credential login has failed. k_EResultPasswordRequiredToKickSession = 49,// You are already logged in elsewhere, this cached credential login has failed.
k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in elsewhere, you must wait k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in elsewhere, you must wait
k_EResultSuspended = 51, // Long running operation (content download) suspended/paused k_EResultSuspended = 51, // Long running operation (content download) suspended/paused
k_EResultCancelled = 52, // Operation canceled (typically by user: content download) k_EResultCancelled = 52, // Operation canceled (typically by user: content download)
k_EResultDataCorruption = 53, // Operation canceled because data is ill formed or unrecoverable k_EResultDataCorruption = 53, // Operation canceled because data is ill formed or unrecoverable
k_EResultDiskFull = 54, // Operation canceled - not enough disk space. k_EResultDiskFull = 54, // Operation canceled - not enough disk space.
k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed
k_EResultPasswordUnset = 56, // Password could not be verified as it's unset server side k_EResultPasswordUnset = 56, // Password could not be verified as it's unset server side
k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...) is not linked to a Steam account k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...) is not linked to a Steam account
k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid
k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN, Facebook...) is already linked to some other account, must explicitly request to replace/delete the link first k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN, Facebook...) is already linked to some other account, must explicitly request to replace/delete the link first
k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict between the local and remote files k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict between the local and remote files
k_EResultIllegalPassword = 61, // The requested new password is not legal k_EResultIllegalPassword = 61, // The requested new password is not legal
k_EResultSameAsPreviousValue = 62, // new value is the same as the old one ( secret question and answer ) k_EResultSameAsPreviousValue = 62, // new value is the same as the old one ( secret question and answer )
k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor authentication failure k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor authentication failure
k_EResultCannotUseOldPassword = 64, // The requested new password is not legal k_EResultCannotUseOldPassword = 64, // The requested new password is not legal
k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid
k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent
k_EResultHardwareNotCapableOfIPT = 67, // k_EResultHardwareNotCapableOfIPT = 67, //
k_EResultIPTInitError = 68, // k_EResultIPTInitError = 68, //
k_EResultParentalControlRestricted = 69, // operation failed due to parental control restrictions for current user k_EResultParentalControlRestricted = 69, // operation failed due to parental control restrictions for current user
k_EResultFacebookQueryError = 70, // Facebook query returned an error k_EResultFacebookQueryError = 70, // Facebook query returned an error
k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth code expired k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth code expired
k_EResultIPLoginRestrictionFailed = 72, k_EResultIPLoginRestrictionFailed = 72,
k_EResultAccountLockedDown = 73, k_EResultAccountLockedDown = 73,
k_EResultAccountLogonDeniedVerifiedEmailRequired = 74, k_EResultAccountLogonDeniedVerifiedEmailRequired = 74,
k_EResultNoMatchingURL = 75, k_EResultNoMatchingURL = 75,
k_EResultBadResponse = 76, // parse failure, missing field, etc. k_EResultBadResponse = 76, // parse failure, missing field, etc.
k_EResultRequirePasswordReEntry = 77, // The user cannot complete the action until they re-enter their password k_EResultRequirePasswordReEntry = 77, // The user cannot complete the action until they re-enter their password
k_EResultValueOutOfRange = 78, // the value entered is outside the acceptable range k_EResultValueOutOfRange = 78, // the value entered is outside the acceptable range
k_EResultUnexpectedError = 79, // something happened that we didn't expect to ever happen k_EResultUnexpectedError = 79, // something happened that we didn't expect to ever happen
k_EResultDisabled = 80, // The requested service has been configured to be unavailable k_EResultDisabled = 80, // The requested service has been configured to be unavailable
k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG server are not valid ! k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG server are not valid !
k_EResultRestrictedDevice = 82, // The device being used is not allowed to perform this action k_EResultRestrictedDevice = 82, // The device being used is not allowed to perform this action
k_EResultRegionLocked = 83, // The action could not be complete because it is region restricted k_EResultRegionLocked = 83, // The action could not be complete because it is region restricted
k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try again later, different from k_EResultLimitExceeded which may be permanent k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try again later, different from k_EResultLimitExceeded which may be permanent
k_EResultAccountLoginDeniedNeedTwoFactor = 85, // Need two-factor code to login k_EResultAccountLoginDeniedNeedTwoFactor = 85, // Need two-factor code to login
k_EResultItemDeleted = 86, // The thing we're trying to access has been deleted k_EResultItemDeleted = 86, // The thing we're trying to access has been deleted
k_EResultAccountLoginDeniedThrottle = 87, // login attempt failed, try to throttle response to possible attacker k_EResultAccountLoginDeniedThrottle = 87, // login attempt failed, try to throttle response to possible attacker
k_EResultTwoFactorCodeMismatch = 88, // two factor code mismatch k_EResultTwoFactorCodeMismatch = 88, // two factor code mismatch
k_EResultTwoFactorActivationCodeMismatch = 89, // activation code for two-factor didn't match k_EResultTwoFactorActivationCodeMismatch = 89, // activation code for two-factor didn't match
k_EResultAccountAssociatedToMultiplePartners = 90, // account has been associated with multiple partners k_EResultAccountAssociatedToMultiplePartners = 90, // account has been associated with multiple partners
k_EResultNotModified = 91, // data not modified k_EResultNotModified = 91, // data not modified
}; };
// Check these to future proof // Check these to future proof
UENUM(BlueprintType) UENUM(BlueprintType)
enum class FBPWorkshopFileType : uint8 enum class FBPWorkshopFileType : uint8
{ {
k_EWorkshopFileTypeCommunity = 0, k_EWorkshopFileTypeCommunity = 0,
k_EWorkshopFileTypeMicrotransaction = 1, k_EWorkshopFileTypeMicrotransaction = 1,
k_EWorkshopFileTypeCollection = 2, k_EWorkshopFileTypeCollection = 2,
k_EWorkshopFileTypeArt = 3, k_EWorkshopFileTypeArt = 3,
k_EWorkshopFileTypeVideo = 4, k_EWorkshopFileTypeVideo = 4,
k_EWorkshopFileTypeScreenshot = 5, k_EWorkshopFileTypeScreenshot = 5,
k_EWorkshopFileTypeGame = 6, k_EWorkshopFileTypeGame = 6,
k_EWorkshopFileTypeSoftware = 7, k_EWorkshopFileTypeSoftware = 7,
k_EWorkshopFileTypeConcept = 8, k_EWorkshopFileTypeConcept = 8,
k_EWorkshopFileTypeWebGuide = 9, k_EWorkshopFileTypeWebGuide = 9,
k_EWorkshopFileTypeIntegratedGuide = 10, k_EWorkshopFileTypeIntegratedGuide = 10,
k_EWorkshopFileTypeMerch = 11, k_EWorkshopFileTypeMerch = 11,
k_EWorkshopFileTypeControllerBinding = 12, k_EWorkshopFileTypeControllerBinding = 12,
k_EWorkshopFileTypeSteamworksAccessInvite = 13, k_EWorkshopFileTypeSteamworksAccessInvite = 13,
k_EWorkshopFileTypeSteamVideo = 14, k_EWorkshopFileTypeSteamVideo = 14,
// Update k_EWorkshopFileTypeMax if you add values. // Update k_EWorkshopFileTypeMax if you add values.
k_EWorkshopFileTypeMax = 15 k_EWorkshopFileTypeMax = 15
}; };
// WorkshopItemDetails Struct // WorkshopItemDetails Struct
USTRUCT(BlueprintType) USTRUCT(BlueprintType)
struct FBPSteamWorkshopItemDetails struct FBPSteamWorkshopItemDetails
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
public: public:
FBPSteamWorkshopItemDetails() FBPSteamWorkshopItemDetails()
{ {
ResultOfRequest = FBPSteamResult::k_EResultOK; ResultOfRequest = FBPSteamResult::k_EResultOK;
FileType = FBPWorkshopFileType::k_EWorkshopFileTypeMax; FileType = FBPWorkshopFileType::k_EWorkshopFileTypeMax;
CreatorAppID = 0; CreatorAppID = 0;
ConsumerAppID = 0; ConsumerAppID = 0;
VotesUp = 0; VotesUp = 0;
VotesDown = 0; VotesDown = 0;
CalculatedScore = 0.f; CalculatedScore = 0.f;
bBanned = false; bBanned = false;
bAcceptedForUse = false; bAcceptedForUse = false;
bTagsTruncated = false; bTagsTruncated = false;
} }
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
FBPSteamWorkshopItemDetails(SteamUGCDetails_t &hUGCDetails) FBPSteamWorkshopItemDetails(SteamUGCDetails_t &hUGCDetails)
{ {
ResultOfRequest = (FBPSteamResult)hUGCDetails.m_eResult; ResultOfRequest = (FBPSteamResult)hUGCDetails.m_eResult;
FileType = (FBPWorkshopFileType)hUGCDetails.m_eFileType; FileType = (FBPWorkshopFileType)hUGCDetails.m_eFileType;
CreatorAppID = (int32)hUGCDetails.m_nCreatorAppID; CreatorAppID = (int32)hUGCDetails.m_nCreatorAppID;
ConsumerAppID = (int32)hUGCDetails.m_nConsumerAppID; ConsumerAppID = (int32)hUGCDetails.m_nConsumerAppID;
Title = FString(hUGCDetails.m_rgchTitle, k_cchPublishedDocumentTitleMax); Title = FString(hUGCDetails.m_rgchTitle, k_cchPublishedDocumentTitleMax);
Description = FString(hUGCDetails.m_rgchDescription, k_cchPublishedDocumentDescriptionMax); Description = FString(hUGCDetails.m_rgchDescription, k_cchPublishedDocumentDescriptionMax);
ItemUrl = FString(hUGCDetails.m_rgchURL, k_cchPublishedFileURLMax); ItemUrl = FString(hUGCDetails.m_rgchURL, k_cchPublishedFileURLMax);
VotesUp = (int32)hUGCDetails.m_unVotesUp; VotesUp = (int32)hUGCDetails.m_unVotesUp;
VotesDown = (int32)hUGCDetails.m_unVotesDown; VotesDown = (int32)hUGCDetails.m_unVotesDown;
CalculatedScore = hUGCDetails.m_flScore; CalculatedScore = hUGCDetails.m_flScore;
bBanned = hUGCDetails.m_bBanned; bBanned = hUGCDetails.m_bBanned;
bAcceptedForUse = hUGCDetails.m_bAcceptedForUse; bAcceptedForUse = hUGCDetails.m_bAcceptedForUse;
bTagsTruncated = hUGCDetails.m_bTagsTruncated; bTagsTruncated = hUGCDetails.m_bTagsTruncated;
CreatorSteamID = FString::Printf(TEXT("%llu"), hUGCDetails.m_ulSteamIDOwner); CreatorSteamID = FString::Printf(TEXT("%llu"), hUGCDetails.m_ulSteamIDOwner);
} }
FBPSteamWorkshopItemDetails(const SteamUGCDetails_t &hUGCDetails) FBPSteamWorkshopItemDetails(const SteamUGCDetails_t &hUGCDetails)
{ {
ResultOfRequest = (FBPSteamResult)hUGCDetails.m_eResult; ResultOfRequest = (FBPSteamResult)hUGCDetails.m_eResult;
FileType = (FBPWorkshopFileType)hUGCDetails.m_eFileType; FileType = (FBPWorkshopFileType)hUGCDetails.m_eFileType;
CreatorAppID = (int32)hUGCDetails.m_nCreatorAppID; CreatorAppID = (int32)hUGCDetails.m_nCreatorAppID;
ConsumerAppID = (int32)hUGCDetails.m_nConsumerAppID; ConsumerAppID = (int32)hUGCDetails.m_nConsumerAppID;
Title = FString(hUGCDetails.m_rgchTitle, k_cchPublishedDocumentTitleMax); Title = FString(hUGCDetails.m_rgchTitle, k_cchPublishedDocumentTitleMax);
Description = FString(hUGCDetails.m_rgchDescription, k_cchPublishedDocumentDescriptionMax); Description = FString(hUGCDetails.m_rgchDescription, k_cchPublishedDocumentDescriptionMax);
ItemUrl = FString(hUGCDetails.m_rgchURL, k_cchPublishedFileURLMax); ItemUrl = FString(hUGCDetails.m_rgchURL, k_cchPublishedFileURLMax);
VotesUp = (int32)hUGCDetails.m_unVotesUp; VotesUp = (int32)hUGCDetails.m_unVotesUp;
VotesDown = (int32)hUGCDetails.m_unVotesDown; VotesDown = (int32)hUGCDetails.m_unVotesDown;
CalculatedScore = hUGCDetails.m_flScore; CalculatedScore = hUGCDetails.m_flScore;
bBanned = hUGCDetails.m_bBanned; bBanned = hUGCDetails.m_bBanned;
bAcceptedForUse = hUGCDetails.m_bAcceptedForUse; bAcceptedForUse = hUGCDetails.m_bAcceptedForUse;
bTagsTruncated = hUGCDetails.m_bTagsTruncated; bTagsTruncated = hUGCDetails.m_bTagsTruncated;
CreatorSteamID = FString::Printf(TEXT("%llu"), hUGCDetails.m_ulSteamIDOwner); CreatorSteamID = FString::Printf(TEXT("%llu"), hUGCDetails.m_ulSteamIDOwner);
} }
#endif #endif
// Result of obtaining the details // Result of obtaining the details
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
FBPSteamResult ResultOfRequest; FBPSteamResult ResultOfRequest;
// Type of file // Type of file
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
FBPWorkshopFileType FileType; FBPWorkshopFileType FileType;
// These two are listed as baked to an int, but is stored as a uint, think its safe to keep int // These two are listed as baked to an int, but is stored as a uint, think its safe to keep int
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
int32 CreatorAppID; int32 CreatorAppID;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
int32 ConsumerAppID; int32 ConsumerAppID;
// Title of item // Title of item
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
FString Title; FString Title;
// Description of item // Description of item
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
FString Description; FString Description;
//Url for a video of website //Url for a video of website
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
FString ItemUrl; FString ItemUrl;
// Votes will be unlikely to go above signed limited // Votes will be unlikely to go above signed limited
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
int32 VotesUp; int32 VotesUp;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
int32 VotesDown; int32 VotesDown;
// Calculated score // Calculated score
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
float CalculatedScore; float CalculatedScore;
// whether the file was banned // whether the file was banned
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
bool bBanned; bool bBanned;
// developer has specifically flagged this item as accepted in the Workshop // developer has specifically flagged this item as accepted in the Workshop
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
bool bAcceptedForUse; bool bAcceptedForUse;
// whether the list of tags was too long to be returned in the provided buffer // whether the list of tags was too long to be returned in the provided buffer
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
bool bTagsTruncated; bool bTagsTruncated;
// Steam ID of the user who created this content. // Steam ID of the user who created this content.
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
FString CreatorSteamID; FString CreatorSteamID;
/* /*
PublishedFileId_t m_nPublishedFileId; PublishedFileId_t m_nPublishedFileId;
uint32 m_rtimeCreated; // time when the published file was created uint32 m_rtimeCreated; // time when the published file was created
uint32 m_rtimeUpdated; // time when the published file was last updated uint32 m_rtimeUpdated; // time when the published file was last updated
uint32 m_rtimeAddedToUserList; // time when the user added the published file to their list (not always applicable) uint32 m_rtimeAddedToUserList; // time when the user added the published file to their list (not always applicable)
ERemoteStoragePublishedFileVisibility m_eVisibility; // visibility ERemoteStoragePublishedFileVisibility m_eVisibility; // visibility
char m_rgchTags[k_cchTagListMax]; // comma separated list of all tags associated with this file char m_rgchTags[k_cchTagListMax]; // comma separated list of all tags associated with this file
// file/url information // file/url information
UGCHandle_t m_hFile; // The handle of the primary file UGCHandle_t m_hFile; // The handle of the primary file
UGCHandle_t m_hPreviewFile; // The handle of the preview file UGCHandle_t m_hPreviewFile; // The handle of the preview file
char m_pchFileName[k_cchFilenameMax]; // The cloud filename of the primary file char m_pchFileName[k_cchFilenameMax]; // The cloud filename of the primary file
int32 m_nFileSize; // Size of the primary file int32 m_nFileSize; // Size of the primary file
int32 m_nPreviewFileSize; // Size of the preview file int32 m_nPreviewFileSize; // Size of the preview file
uint32 m_unNumChildren; // if m_eFileType == k_EWorkshopFileTypeCollection, then this number will be the number of children contained within the collection uint32 m_unNumChildren; // if m_eFileType == k_EWorkshopFileTypeCollection, then this number will be the number of children contained within the collection
*/ */
}; };
UCLASS() UCLASS()
class UAdvancedSteamWorkshopLibrary : public UBlueprintFunctionLibrary class UAdvancedSteamWorkshopLibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* Steam Functions *************// //********* Steam Functions *************//
// Returns IDs for subscribed workshop items, TArray length dictates how many // Returns IDs for subscribed workshop items, TArray length dictates how many
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSteamWorkshop") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSteamWorkshop")
static TArray<FBPSteamWorkshopID> GetSubscribedWorkshopItems(int32 & NumberOfItems); static TArray<FBPSteamWorkshopID> GetSubscribedWorkshopItems(int32 & NumberOfItems);
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSteamWorkshop") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSteamWorkshop")
static void GetNumSubscribedWorkshopItems(int32 & NumberOfItems); static void GetNumSubscribedWorkshopItems(int32 & NumberOfItems);
}; };

View File

@@ -1,100 +1,100 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro // This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just // @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
// disable the warnings locally. Remove when this is fixed in the SDK // disable the warnings locally. Remove when this is fixed in the SDK
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4996) #pragma warning(disable:4996)
// #TODO check back on this at some point // #TODO check back on this at some point
#pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on.... #pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on....
#endif #endif
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
#include "OnlineSubsystemSteam.h" #include "OnlineSubsystemSteam.h"
#pragma push_macro("ARRAY_COUNT") #pragma push_macro("ARRAY_COUNT")
#undef ARRAY_COUNT #undef ARRAY_COUNT
#if USING_CODE_ANALYSIS #if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(push)) MSVC_PRAGMA(warning(push))
MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS)) MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS))
#endif // USING_CODE_ANALYSIS #endif // USING_CODE_ANALYSIS
#include <steam/steam_api.h> #include <steam/steam_api.h>
#if USING_CODE_ANALYSIS #if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(pop)) MSVC_PRAGMA(warning(pop))
#endif // USING_CODE_ANALYSIS #endif // USING_CODE_ANALYSIS
#pragma pop_macro("ARRAY_COUNT") #pragma pop_macro("ARRAY_COUNT")
#endif #endif
// @todo Steam: See above // @todo Steam: See above
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#include "SteamRequestGroupOfficersCallbackProxy.generated.h" #include "SteamRequestGroupOfficersCallbackProxy.generated.h"
USTRUCT(BlueprintType, Category = "Online|SteamAPI|SteamGroups") USTRUCT(BlueprintType, Category = "Online|SteamAPI|SteamGroups")
struct FBPSteamGroupOfficer struct FBPSteamGroupOfficer
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
public: public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
FBPUniqueNetId OfficerUniqueNetID; // Uint64 representation FBPUniqueNetId OfficerUniqueNetID; // Uint64 representation
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
bool bIsOwner = false; bool bIsOwner = false;
}; };
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGroupOfficerDetailsDelegate, const TArray<FBPSteamGroupOfficer> &, OfficerList); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGroupOfficerDetailsDelegate, const TArray<FBPSteamGroupOfficer> &, OfficerList);
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class USteamRequestGroupOfficersCallbackProxy : public UOnlineBlueprintCallProxyBase class USteamRequestGroupOfficersCallbackProxy : public UOnlineBlueprintCallProxyBase
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
virtual ~USteamRequestGroupOfficersCallbackProxy(); virtual ~USteamRequestGroupOfficersCallbackProxy();
// Called when there is a successful results return // Called when there is a successful results return
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGroupOfficerDetailsDelegate OnSuccess; FBlueprintGroupOfficerDetailsDelegate OnSuccess;
// Called when there is an unsuccessful results return // Called when there is an unsuccessful results return
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGroupOfficerDetailsDelegate OnFailure; FBlueprintGroupOfficerDetailsDelegate OnFailure;
// Returns a list of steam group officers // Returns a list of steam group officers
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|SteamAPI|SteamGroups") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|SteamAPI|SteamGroups")
static USteamRequestGroupOfficersCallbackProxy* GetSteamGroupOfficerList(UObject* WorldContextObject, FBPUniqueNetId GroupUniqueNetID); static USteamRequestGroupOfficersCallbackProxy* GetSteamGroupOfficerList(UObject* WorldContextObject, FBPUniqueNetId GroupUniqueNetID);
// UOnlineBlueprintCallProxyBase interface // UOnlineBlueprintCallProxyBase interface
virtual void Activate() override; virtual void Activate() override;
// End of UOnlineBlueprintCallProxyBase interface // End of UOnlineBlueprintCallProxyBase interface
private: private:
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
void OnRequestGroupOfficerDetails( ClanOfficerListResponse_t *pResult, bool bIOFailure); void OnRequestGroupOfficerDetails( ClanOfficerListResponse_t *pResult, bool bIOFailure);
CCallResult<USteamRequestGroupOfficersCallbackProxy, ClanOfficerListResponse_t> m_callResultGroupOfficerRequestDetails; CCallResult<USteamRequestGroupOfficersCallbackProxy, ClanOfficerListResponse_t> m_callResultGroupOfficerRequestDetails;
#endif #endif
private: private:
FBPUniqueNetId GroupUniqueID; FBPUniqueNetId GroupUniqueID;
UObject* WorldContextObject; UObject* WorldContextObject;
}; };

View File

@@ -5,43 +5,43 @@
#include "AdvancedSteamWorkshopLibrary.h" #include "AdvancedSteamWorkshopLibrary.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro // This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just // @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
// disable the warnings locally. Remove when this is fixed in the SDK // disable the warnings locally. Remove when this is fixed in the SDK
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4996) #pragma warning(disable:4996)
// #TODO check back on this at some point // #TODO check back on this at some point
#pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on.... #pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on....
#endif #endif
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
#include "OnlineSubsystemSteam.h" #include "OnlineSubsystemSteam.h"
#pragma push_macro("ARRAY_COUNT") #pragma push_macro("ARRAY_COUNT")
#undef ARRAY_COUNT #undef ARRAY_COUNT
#if USING_CODE_ANALYSIS #if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(push)) MSVC_PRAGMA(warning(push))
MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS)) MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS))
#endif // USING_CODE_ANALYSIS #endif // USING_CODE_ANALYSIS
#include <steam/steam_api.h> #include <steam/steam_api.h>
#if USING_CODE_ANALYSIS #if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(pop)) MSVC_PRAGMA(warning(pop))
#endif // USING_CODE_ANALYSIS #endif // USING_CODE_ANALYSIS
#pragma pop_macro("ARRAY_COUNT") #pragma pop_macro("ARRAY_COUNT")
#endif #endif
// @todo Steam: See above // @todo Steam: See above
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif
@@ -73,9 +73,9 @@ class USteamWSRequestUGCDetailsCallbackProxy : public UOnlineBlueprintCallProxyB
private: private:
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
// Internal callback when the operation completes, calls out to the public success/failure callbacks // Internal callback when the operation completes, calls out to the public success/failure callbacks
void OnUGCRequestUGCDetails(SteamUGCQueryCompleted_t *pResult, bool bIOFailure); void OnUGCRequestUGCDetails(SteamUGCQueryCompleted_t *pResult, bool bIOFailure);
CCallResult<USteamWSRequestUGCDetailsCallbackProxy, SteamUGCQueryCompleted_t> m_callResultUGCRequestDetails; CCallResult<USteamWSRequestUGCDetailsCallbackProxy, SteamUGCQueryCompleted_t> m_callResultUGCRequestDetails;
#endif #endif

View File

@@ -1,443 +1,443 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedSteamFriendsLibrary.h" #include "AdvancedSteamFriendsLibrary.h"
#include "OnlineSubSystemHeader.h" #include "OnlineSubSystemHeader.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedSteamFriendsLog); DEFINE_LOG_CATEGORY(AdvancedSteamFriendsLog);
// Clan functions, add in soon // Clan functions, add in soon
/*int32 UAdvancedSteamFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId) /*int32 UAdvancedSteamFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId)
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM) if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
{ {
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
return 0; return 0;
} }
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
// clan (group) iteration and access functions // clan (group) iteration and access functions
//virtual int GetClanCount() = 0; //virtual int GetClanCount() = 0;
//virtual CSteamID GetClanByIndex(int iClan) = 0; //virtual CSteamID GetClanByIndex(int iClan) = 0;
//virtual const char *GetClanName(CSteamID steamIDClan) = 0; //virtual const char *GetClanName(CSteamID steamIDClan) = 0;
//virtual const char *GetClanTag(CSteamID steamIDClan) = 0; //virtual const char *GetClanTag(CSteamID steamIDClan) = 0;
// returns the most recent information we have about what's happening in a clan // returns the most recent information we have about what's happening in a clan
//virtual bool GetClanActivityCounts(CSteamID steamIDClan, int *pnOnline, int *pnInGame, int *pnChatting) = 0; //virtual bool GetClanActivityCounts(CSteamID steamIDClan, int *pnOnline, int *pnInGame, int *pnChatting) = 0;
// for clans a user is a member of, they will have reasonably up-to-date information, but for others you'll have to download the info to have the latest // for clans a user is a member of, they will have reasonably up-to-date information, but for others you'll have to download the info to have the latest
//virtual SteamAPICall_t DownloadClanActivityCounts(ARRAY_COUNT(cClansToRequest) CSteamID *psteamIDClans, int cClansToRequest) = 0; //virtual SteamAPICall_t DownloadClanActivityCounts(ARRAY_COUNT(cClansToRequest) CSteamID *psteamIDClans, int cClansToRequest) = 0;
// requests information about a clan officer list // requests information about a clan officer list
// when complete, data is returned in ClanOfficerListResponse_t call result // when complete, data is returned in ClanOfficerListResponse_t call result
// this makes available the calls below // this makes available the calls below
// you can only ask about clans that a user is a member of // you can only ask about clans that a user is a member of
// note that this won't download avatars automatically; if you get an officer, // note that this won't download avatars automatically; if you get an officer,
// and no avatar image is available, call RequestUserInformation( steamID, false ) to download the avatar // and no avatar image is available, call RequestUserInformation( steamID, false ) to download the avatar
//virtual SteamAPICall_t RequestClanOfficerList(CSteamID steamIDClan) = 0; //virtual SteamAPICall_t RequestClanOfficerList(CSteamID steamIDClan) = 0;
// returns the steamID of the clan owner // returns the steamID of the clan owner
//virtual CSteamID GetClanOwner(CSteamID steamIDClan) = 0; //virtual CSteamID GetClanOwner(CSteamID steamIDClan) = 0;
// returns the number of officers in a clan (including the owner) // returns the number of officers in a clan (including the owner)
//virtual int GetClanOfficerCount(CSteamID steamIDClan) = 0; //virtual int GetClanOfficerCount(CSteamID steamIDClan) = 0;
// returns the steamID of a clan officer, by index, of range [0,GetClanOfficerCount) // returns the steamID of a clan officer, by index, of range [0,GetClanOfficerCount)
//virtual CSteamID GetClanOfficerByIndex(CSteamID steamIDClan, int iOfficer) = 0; //virtual CSteamID GetClanOfficerByIndex(CSteamID steamIDClan, int iOfficer) = 0;
return SteamFriends()->GetFriendSteamLevel(id); return SteamFriends()->GetFriendSteamLevel(id);
} }
#endif #endif
return 0; return 0;
}*/ }*/
void UAdvancedSteamFriendsLibrary::GetSteamGroups(TArray<FBPSteamGroupInfo> & SteamGroups) void UAdvancedSteamFriendsLibrary::GetSteamGroups(TArray<FBPSteamGroupInfo> & SteamGroups)
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
int numClans = SteamFriends()->GetClanCount(); int numClans = SteamFriends()->GetClanCount();
for (int i = 0; i < numClans; i++) for (int i = 0; i < numClans; i++)
{ {
CSteamID SteamGroupID = SteamFriends()->GetClanByIndex(i); CSteamID SteamGroupID = SteamFriends()->GetClanByIndex(i);
if(!SteamGroupID.IsValid()) if(!SteamGroupID.IsValid())
continue; continue;
FBPSteamGroupInfo GroupInfo; FBPSteamGroupInfo GroupInfo;
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(SteamGroupID)); TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(SteamGroupID));
GroupInfo.GroupID.SetUniqueNetId(ValueID); GroupInfo.GroupID.SetUniqueNetId(ValueID);
SteamFriends()->GetClanActivityCounts(SteamGroupID, &GroupInfo.numOnline, &GroupInfo.numInGame, &GroupInfo.numChatting); SteamFriends()->GetClanActivityCounts(SteamGroupID, &GroupInfo.numOnline, &GroupInfo.numInGame, &GroupInfo.numChatting);
GroupInfo.GroupName = FString(UTF8_TO_TCHAR(SteamFriends()->GetClanName(SteamGroupID))); GroupInfo.GroupName = FString(UTF8_TO_TCHAR(SteamFriends()->GetClanName(SteamGroupID)));
GroupInfo.GroupTag = FString(UTF8_TO_TCHAR(SteamFriends()->GetClanTag(SteamGroupID))); GroupInfo.GroupTag = FString(UTF8_TO_TCHAR(SteamFriends()->GetClanTag(SteamGroupID)));
SteamGroups.Add(GroupInfo); SteamGroups.Add(GroupInfo);
} }
} }
#endif #endif
} }
void UAdvancedSteamFriendsLibrary::GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result/*, FString & GameName*/, int32 & AppID) void UAdvancedSteamFriendsLibrary::GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result/*, FString & GameName*/, int32 & AppID)
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM) if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
{ {
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendGamePlayed Had a bad UniqueNetId!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendGamePlayed Had a bad UniqueNetId!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
FriendGameInfo_t GameInfo; FriendGameInfo_t GameInfo;
bool bIsInGame = SteamFriends()->GetFriendGamePlayed(id, &GameInfo); bool bIsInGame = SteamFriends()->GetFriendGamePlayed(id, &GameInfo);
if (bIsInGame && GameInfo.m_gameID.IsValid()) if (bIsInGame && GameInfo.m_gameID.IsValid())
{ {
AppID = GameInfo.m_gameID.AppID(); AppID = GameInfo.m_gameID.AppID();
// Forgot this test and left it in, it is incorrect, you would need restricted access // Forgot this test and left it in, it is incorrect, you would need restricted access
// And it would only find games in the local library anyway // And it would only find games in the local library anyway
/*char NameBuffer[512]; /*char NameBuffer[512];
int Len = SteamAppList()->GetAppName(GameInfo.m_gameID.AppID(), NameBuffer, 512); int Len = SteamAppList()->GetAppName(GameInfo.m_gameID.AppID(), NameBuffer, 512);
if (Len != -1) // Invalid if (Len != -1) // Invalid
{ {
GameName = FString(UTF8_TO_TCHAR(NameBuffer)); GameName = FString(UTF8_TO_TCHAR(NameBuffer));
}*/ }*/
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
return; return;
} }
} }
#endif #endif
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
} }
int32 UAdvancedSteamFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId) int32 UAdvancedSteamFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId)
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM) if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
{ {
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
return 0; return 0;
} }
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
return SteamFriends()->GetFriendSteamLevel(id); return SteamFriends()->GetFriendSteamLevel(id);
} }
#endif #endif
return 0; return 0;
} }
FString UAdvancedSteamFriendsLibrary::GetSteamPersonaName(const FBPUniqueNetId UniqueNetId) FString UAdvancedSteamFriendsLibrary::GetSteamPersonaName(const FBPUniqueNetId UniqueNetId)
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM) if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
{ {
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamPersonaName Had a bad UniqueNetId!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamPersonaName Had a bad UniqueNetId!"));
return FString(TEXT("")); return FString(TEXT(""));
} }
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
const char* PersonaName = SteamFriends()->GetFriendPersonaName(id); const char* PersonaName = SteamFriends()->GetFriendPersonaName(id);
return FString(UTF8_TO_TCHAR(PersonaName)); return FString(UTF8_TO_TCHAR(PersonaName));
} }
#endif #endif
return FString(TEXT("")); return FString(TEXT(""));
} }
FBPUniqueNetId UAdvancedSteamFriendsLibrary::CreateSteamIDFromString(const FString SteamID64) FBPUniqueNetId UAdvancedSteamFriendsLibrary::CreateSteamIDFromString(const FString SteamID64)
{ {
FBPUniqueNetId netId; FBPUniqueNetId netId;
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (!(SteamID64.Len() > 0)) if (!(SteamID64.Len() > 0))
{ {
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("CreateSteamIDFromString Had a bad UniqueNetId!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("CreateSteamIDFromString Had a bad UniqueNetId!"));
return netId; return netId;
} }
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
// Already does the conversion // Already does the conversion
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(SteamID64)); TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(SteamID64));
//FCString::Atoi64(*SteamID64)); //FCString::Atoi64(*SteamID64));
netId.SetUniqueNetId(ValueID); netId.SetUniqueNetId(ValueID);
return netId; return netId;
} }
#endif #endif
return netId; return netId;
} }
FBPUniqueNetId UAdvancedSteamFriendsLibrary::GetLocalSteamIDFromSteam() FBPUniqueNetId UAdvancedSteamFriendsLibrary::GetLocalSteamIDFromSteam()
{ {
FBPUniqueNetId netId; FBPUniqueNetId netId;
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
TSharedPtr<const FUniqueNetId> SteamID(new const FUniqueNetIdSteam2(SteamUser()->GetSteamID())); TSharedPtr<const FUniqueNetId> SteamID(new const FUniqueNetIdSteam2(SteamUser()->GetSteamID()));
netId.SetUniqueNetId(SteamID); netId.SetUniqueNetId(SteamID);
} }
#endif #endif
return netId; return netId;
} }
bool UAdvancedSteamFriendsLibrary::RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly) bool UAdvancedSteamFriendsLibrary::RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly)
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM) if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
{ {
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Had a bad UniqueNetId!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Had a bad UniqueNetId!"));
return false; return false;
} }
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
return !SteamFriends()->RequestUserInformation(id, bRequireNameOnly); return !SteamFriends()->RequestUserInformation(id, bRequireNameOnly);
} }
#endif #endif
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Couldn't init steamAPI!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Couldn't init steamAPI!"));
return false; return false;
} }
bool UAdvancedSteamFriendsLibrary::OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType) bool UAdvancedSteamFriendsLibrary::OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType)
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM) if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
{ {
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Had a bad UniqueNetId!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Had a bad UniqueNetId!"));
return false; return false;
} }
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
FString DialogName = EnumToString("ESteamUserOverlayType", (uint8)DialogType); FString DialogName = EnumToString("ESteamUserOverlayType", (uint8)DialogType);
SteamFriends()->ActivateGameOverlayToUser(TCHAR_TO_ANSI(*DialogName), id); SteamFriends()->ActivateGameOverlayToUser(TCHAR_TO_ANSI(*DialogName), id);
return true; return true;
} }
#endif #endif
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!"));
return false; return false;
} }
bool UAdvancedSteamFriendsLibrary::IsOverlayEnabled() bool UAdvancedSteamFriendsLibrary::IsOverlayEnabled()
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
return SteamUtils()->IsOverlayEnabled(); return SteamUtils()->IsOverlayEnabled();
} }
#endif #endif
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!"));
return false; return false;
} }
UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize) UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize)
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM) if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
{ {
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendAvatar Had a bad UniqueNetId!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendAvatar Had a bad UniqueNetId!"));
Result = EBlueprintAsyncResultSwitch::OnFailure; Result = EBlueprintAsyncResultSwitch::OnFailure;
return nullptr; return nullptr;
} }
uint32 Width = 0; uint32 Width = 0;
uint32 Height = 0; uint32 Height = 0;
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
//Getting the PictureID from the SteamAPI and getting the Size with the ID //Getting the PictureID from the SteamAPI and getting the Size with the ID
//virtual bool RequestUserInformation( CSteamID steamIDUser, bool bRequireNameOnly ) = 0; //virtual bool RequestUserInformation( CSteamID steamIDUser, bool bRequireNameOnly ) = 0;
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
int Picture = 0; int Picture = 0;
switch(AvatarSize) switch(AvatarSize)
{ {
case SteamAvatarSize::SteamAvatar_Small: Picture = SteamFriends()->GetSmallFriendAvatar(id); break; case SteamAvatarSize::SteamAvatar_Small: Picture = SteamFriends()->GetSmallFriendAvatar(id); break;
case SteamAvatarSize::SteamAvatar_Medium: Picture = SteamFriends()->GetMediumFriendAvatar(id); break; case SteamAvatarSize::SteamAvatar_Medium: Picture = SteamFriends()->GetMediumFriendAvatar(id); break;
case SteamAvatarSize::SteamAvatar_Large: Picture = SteamFriends()->GetLargeFriendAvatar(id); break; case SteamAvatarSize::SteamAvatar_Large: Picture = SteamFriends()->GetLargeFriendAvatar(id); break;
default: break; default: break;
} }
if (Picture == -1) if (Picture == -1)
{ {
Result = EBlueprintAsyncResultSwitch::AsyncLoading; Result = EBlueprintAsyncResultSwitch::AsyncLoading;
return NULL; return NULL;
} }
SteamUtils()->GetImageSize(Picture, &Width, &Height); SteamUtils()->GetImageSize(Picture, &Width, &Height);
// STOLEN FROM ANSWERHUB :p, then fixed because answerhub wasn't releasing the memory O.o // STOLEN FROM ANSWERHUB :p, then fixed because answerhub wasn't releasing the memory O.o
// Also fixed image pixel format and switched to a memcpy instead of manual iteration. // Also fixed image pixel format and switched to a memcpy instead of manual iteration.
// At some point I should probably reply to that answerhub post with these fixes to prevent people killing their games..... // At some point I should probably reply to that answerhub post with these fixes to prevent people killing their games.....
if (Width > 0 && Height > 0) if (Width > 0 && Height > 0)
{ {
//Creating the buffer "oAvatarRGBA" and then filling it with the RGBA Stream from the Steam Avatar //Creating the buffer "oAvatarRGBA" and then filling it with the RGBA Stream from the Steam Avatar
uint8 *oAvatarRGBA = new uint8[Width * Height * 4]; uint8 *oAvatarRGBA = new uint8[Width * Height * 4];
//Filling the buffer with the RGBA Stream from the Steam Avatar and creating a UTextur2D to parse the RGBA Steam in //Filling the buffer with the RGBA Stream from the Steam Avatar and creating a UTextur2D to parse the RGBA Steam in
SteamUtils()->GetImageRGBA(Picture, (uint8*)oAvatarRGBA, 4 * Height * Width * sizeof(char)); SteamUtils()->GetImageRGBA(Picture, (uint8*)oAvatarRGBA, 4 * Height * Width * sizeof(char));
// Removed as I changed the image bit code to be RGB, I think the original author was unaware that there were different pixel formats // Removed as I changed the image bit code to be RGB, I think the original author was unaware that there were different pixel formats
/* /*
//Swap R and B channels because for some reason the games whack //Swap R and B channels because for some reason the games whack
for (uint32 i = 0; i < (Width * Height * 4); i += 4) for (uint32 i = 0; i < (Width * Height * 4); i += 4)
{ {
uint8 Temp = oAvatarRGBA[i + 0]; uint8 Temp = oAvatarRGBA[i + 0];
oAvatarRGBA[i + 0] = oAvatarRGBA[i + 2]; oAvatarRGBA[i + 0] = oAvatarRGBA[i + 2];
oAvatarRGBA[i + 2] = Temp; oAvatarRGBA[i + 2] = Temp;
}*/ }*/
UTexture2D* Avatar = UTexture2D::CreateTransient(Width, Height, PF_R8G8B8A8); UTexture2D* Avatar = UTexture2D::CreateTransient(Width, Height, PF_R8G8B8A8);
// Switched to a Memcpy instead of byte by byte transer // Switched to a Memcpy instead of byte by byte transer
if (FTexturePlatformData* PlatformData = Avatar->GetPlatformData()) if (FTexturePlatformData* PlatformData = Avatar->GetPlatformData())
{ {
uint8* MipData = (uint8*)PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE); uint8* MipData = (uint8*)PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(MipData, (void*)oAvatarRGBA, Height * Width * 4); FMemory::Memcpy(MipData, (void*)oAvatarRGBA, Height * Width * 4);
PlatformData->Mips[0].BulkData.Unlock(); PlatformData->Mips[0].BulkData.Unlock();
// Original implementation was missing this!! // Original implementation was missing this!!
// the hell man...... // the hell man......
delete[] oAvatarRGBA; delete[] oAvatarRGBA;
//Setting some Parameters for the Texture and finally returning it //Setting some Parameters for the Texture and finally returning it
PlatformData->SetNumSlices(1); PlatformData->SetNumSlices(1);
Avatar->NeverStream = true; Avatar->NeverStream = true;
//Avatar->CompressionSettings = TC_EditorIcon; //Avatar->CompressionSettings = TC_EditorIcon;
} }
Avatar->UpdateResource(); Avatar->UpdateResource();
Result = EBlueprintAsyncResultSwitch::OnSuccess; Result = EBlueprintAsyncResultSwitch::OnSuccess;
return Avatar; return Avatar;
} }
else else
{ {
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("Bad Height / Width with steam avatar!")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("Bad Height / Width with steam avatar!"));
} }
Result = EBlueprintAsyncResultSwitch::OnFailure; Result = EBlueprintAsyncResultSwitch::OnFailure;
return nullptr; return nullptr;
} }
#endif #endif
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized")); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized"));
Result = EBlueprintAsyncResultSwitch::OnFailure; Result = EBlueprintAsyncResultSwitch::OnFailure;
return nullptr; return nullptr;
} }
bool UAdvancedSteamFriendsLibrary::InitTextFiltering() bool UAdvancedSteamFriendsLibrary::InitTextFiltering()
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
return SteamUtils()->InitFilterText(); return SteamUtils()->InitFilterText();
} }
#endif #endif
return false; return false;
} }
bool UAdvancedSteamFriendsLibrary::FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText) bool UAdvancedSteamFriendsLibrary::FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText)
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint32 BufferLen = TextToFilter.Len() + 10; // Docs say 1 byte excess min, going with 10 uint32 BufferLen = TextToFilter.Len() + 10; // Docs say 1 byte excess min, going with 10
char* OutText = new char[BufferLen]; char* OutText = new char[BufferLen];
uint64 id = 0; uint64 id = 0;
if (TextSourceID.IsValid()) if (TextSourceID.IsValid())
{ {
id = *((uint64*)TextSourceID.UniqueNetId->GetBytes()); id = *((uint64*)TextSourceID.UniqueNetId->GetBytes());
} }
// MAC is bugged with current steam version according to epic, they forced it to be the old steam ver // MAC is bugged with current steam version according to epic, they forced it to be the old steam ver
#if PLATFORM_MAC #if PLATFORM_MAC
// Filters the provided input message and places the filtered result into pchOutFilteredText. // Filters the provided input message and places the filtered result into pchOutFilteredText.
// pchOutFilteredText is where the output will be placed, even if no filtering or censoring is performed // pchOutFilteredText is where the output will be placed, even if no filtering or censoring is performed
// nByteSizeOutFilteredText is the size (in bytes) of pchOutFilteredText // nByteSizeOutFilteredText is the size (in bytes) of pchOutFilteredText
// pchInputText is the input string that should be filtered, which can be ASCII or UTF-8 // pchInputText is the input string that should be filtered, which can be ASCII or UTF-8
// bLegalOnly should be false if you want profanity and legally required filtering (where required) and true if you want legally required filtering only // bLegalOnly should be false if you want profanity and legally required filtering (where required) and true if you want legally required filtering only
// Returns the number of characters (not bytes) filtered. // Returns the number of characters (not bytes) filtered.
int FilterCount = SteamUtils()->FilterText(OutText, BufferLen, TCHAR_TO_ANSI(*TextToFilter), Context == EBPTextFilteringContext::FContext_GameContent); int FilterCount = SteamUtils()->FilterText(OutText, BufferLen, TCHAR_TO_ANSI(*TextToFilter), Context == EBPTextFilteringContext::FContext_GameContent);
#else #else
int FilterCount = SteamUtils()->FilterText((ETextFilteringContext)Context, id, TCHAR_TO_ANSI(*TextToFilter), OutText, BufferLen); int FilterCount = SteamUtils()->FilterText((ETextFilteringContext)Context, id, TCHAR_TO_ANSI(*TextToFilter), OutText, BufferLen);
#endif #endif
if (FilterCount > 0) if (FilterCount > 0)
{ {
FilteredText = FString(UTF8_TO_TCHAR(OutText)); FilteredText = FString(UTF8_TO_TCHAR(OutText));
delete[] OutText; delete[] OutText;
return true; return true;
} }
delete[] OutText; delete[] OutText;
} }
#endif #endif
FilteredText = TextToFilter; FilteredText = TextToFilter;
return false; return false;
} }
bool UAdvancedSteamFriendsLibrary::IsSteamInBigPictureMode() bool UAdvancedSteamFriendsLibrary::IsSteamInBigPictureMode()
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
return SteamUtils()->IsSteamInBigPictureMode(); return SteamUtils()->IsSteamInBigPictureMode();
} }
#endif #endif
return false; return false;
} }

View File

@@ -1,12 +1,12 @@
//#include "StandAlonePrivatePCH.h" //#include "StandAlonePrivatePCH.h"
#include "AdvancedSteamSessions.h" #include "AdvancedSteamSessions.h"
void AdvancedSteamSessions::StartupModule() void AdvancedSteamSessions::StartupModule()
{ {
} }
void AdvancedSteamSessions::ShutdownModule() void AdvancedSteamSessions::ShutdownModule()
{ {
} }
IMPLEMENT_MODULE(AdvancedSteamSessions, AdvancedSteamSessions) IMPLEMENT_MODULE(AdvancedSteamSessions, AdvancedSteamSessions)

View File

@@ -1,69 +1,69 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedSteamWorkshopLibrary.h" #include "AdvancedSteamWorkshopLibrary.h"
#include "OnlineSubSystemHeader.h" #include "OnlineSubSystemHeader.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedSteamWorkshopLog); DEFINE_LOG_CATEGORY(AdvancedSteamWorkshopLog);
void UAdvancedSteamWorkshopLibrary::GetNumSubscribedWorkshopItems(int32 & NumberOfItems) void UAdvancedSteamWorkshopLibrary::GetNumSubscribedWorkshopItems(int32 & NumberOfItems)
{ {
NumberOfItems = 0; NumberOfItems = 0;
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
NumberOfItems = SteamUGC()->GetNumSubscribedItems(); NumberOfItems = SteamUGC()->GetNumSubscribedItems();
return; return;
} }
else else
{ {
UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetNumSubscribedWorkshopItemCount : SteamAPI is not Inited!")); UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetNumSubscribedWorkshopItemCount : SteamAPI is not Inited!"));
return; return;
} }
#endif #endif
UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetNumSubscribedWorkshopItemCount : Called on an incompatible platform")); UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetNumSubscribedWorkshopItemCount : Called on an incompatible platform"));
return; return;
} }
TArray<FBPSteamWorkshopID> UAdvancedSteamWorkshopLibrary::GetSubscribedWorkshopItems(int32 & NumberOfItems) TArray<FBPSteamWorkshopID> UAdvancedSteamWorkshopLibrary::GetSubscribedWorkshopItems(int32 & NumberOfItems)
{ {
TArray<FBPSteamWorkshopID> outArray; TArray<FBPSteamWorkshopID> outArray;
NumberOfItems = 0; NumberOfItems = 0;
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint32 NumItems = SteamUGC()->GetNumSubscribedItems(); uint32 NumItems = SteamUGC()->GetNumSubscribedItems();
if (NumItems == 0) if (NumItems == 0)
return outArray; return outArray;
// Not using the actual variable above in case someone somehow goes past int32 limits // Not using the actual variable above in case someone somehow goes past int32 limits
// Don't want to go negative on the iteration. // Don't want to go negative on the iteration.
NumberOfItems = NumItems; NumberOfItems = NumItems;
PublishedFileId_t *fileIds = new PublishedFileId_t[NumItems]; PublishedFileId_t *fileIds = new PublishedFileId_t[NumItems];
uint32 subItems = SteamUGC()->GetSubscribedItems(fileIds, NumItems); uint32 subItems = SteamUGC()->GetSubscribedItems(fileIds, NumItems);
for (uint32 i = 0; i < subItems; ++i) for (uint32 i = 0; i < subItems; ++i)
{ {
outArray.Add(FBPSteamWorkshopID(fileIds[i])); outArray.Add(FBPSteamWorkshopID(fileIds[i]));
} }
delete[] fileIds; delete[] fileIds;
return outArray; return outArray;
} }
else else
{ {
UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetSubscribedWorkshopItemCount : SteamAPI is not Inited!")); UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetSubscribedWorkshopItemCount : SteamAPI is not Inited!"));
return outArray; return outArray;
} }
#endif #endif
UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetSubscribedWorkshopItemCount : Called on an incompatible platform")); UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetSubscribedWorkshopItemCount : Called on an incompatible platform"));
return outArray; return outArray;
} }

View File

@@ -30,13 +30,13 @@ USteamRequestGroupOfficersCallbackProxy* USteamRequestGroupOfficersCallbackProxy
} }
void USteamRequestGroupOfficersCallbackProxy::Activate() void USteamRequestGroupOfficersCallbackProxy::Activate()
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint64 id = *((uint64*)GroupUniqueID.UniqueNetId->GetBytes()); uint64 id = *((uint64*)GroupUniqueID.UniqueNetId->GetBytes());
SteamAPICall_t hSteamAPICall = SteamFriends()->RequestClanOfficerList(id); SteamAPICall_t hSteamAPICall = SteamFriends()->RequestClanOfficerList(id);
m_callResultGroupOfficerRequestDetails.Set(hSteamAPICall, this, &USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails); m_callResultGroupOfficerRequestDetails.Set(hSteamAPICall, this, &USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails);
return; return;
} }
@@ -46,76 +46,76 @@ void USteamRequestGroupOfficersCallbackProxy::Activate()
} }
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
void USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails(ClanOfficerListResponse_t *pResult, bool bIOFailure) void USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails(ClanOfficerListResponse_t *pResult, bool bIOFailure)
{ {
TArray<FBPSteamGroupOfficer> OfficerArray; TArray<FBPSteamGroupOfficer> OfficerArray;
FOnlineSubsystemSteam* SteamSubsystem = (FOnlineSubsystemSteam*)(IOnlineSubsystem::Get(STEAM_SUBSYSTEM)); FOnlineSubsystemSteam* SteamSubsystem = (FOnlineSubsystemSteam*)(IOnlineSubsystem::Get(STEAM_SUBSYSTEM));
if (bIOFailure || !pResult || !pResult->m_bSuccess) if (bIOFailure || !pResult || !pResult->m_bSuccess)
{ {
if (SteamSubsystem != nullptr) if (SteamSubsystem != nullptr)
{ {
SteamSubsystem->ExecuteNextTick([this]() SteamSubsystem->ExecuteNextTick([this]()
{ {
TArray<FBPSteamGroupOfficer> FailureArray; TArray<FBPSteamGroupOfficer> FailureArray;
OnFailure.Broadcast(FailureArray); OnFailure.Broadcast(FailureArray);
}); });
} }
//OnFailure.Broadcast(OfficerArray); //OnFailure.Broadcast(OfficerArray);
return; return;
} }
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint64 id = *((uint64*)GroupUniqueID.UniqueNetId->GetBytes()); uint64 id = *((uint64*)GroupUniqueID.UniqueNetId->GetBytes());
FBPSteamGroupOfficer Officer; FBPSteamGroupOfficer Officer;
CSteamID ClanOwner = SteamFriends()->GetClanOwner(id); CSteamID ClanOwner = SteamFriends()->GetClanOwner(id);
Officer.bIsOwner = true; Officer.bIsOwner = true;
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(ClanOwner)); TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(ClanOwner));
Officer.OfficerUniqueNetID.SetUniqueNetId(ValueID); Officer.OfficerUniqueNetID.SetUniqueNetId(ValueID);
OfficerArray.Add(Officer); OfficerArray.Add(Officer);
for (int i = 0; i < pResult->m_cOfficers; i++) for (int i = 0; i < pResult->m_cOfficers; i++)
{ {
CSteamID OfficerSteamID = SteamFriends()->GetClanOfficerByIndex(id, i); CSteamID OfficerSteamID = SteamFriends()->GetClanOfficerByIndex(id, i);
Officer.bIsOwner = false; Officer.bIsOwner = false;
TSharedPtr<const FUniqueNetId> newValueID(new const FUniqueNetIdSteam2(OfficerSteamID)); TSharedPtr<const FUniqueNetId> newValueID(new const FUniqueNetIdSteam2(OfficerSteamID));
Officer.OfficerUniqueNetID.SetUniqueNetId(newValueID); Officer.OfficerUniqueNetID.SetUniqueNetId(newValueID);
OfficerArray.Add(Officer); OfficerArray.Add(Officer);
} }
if (SteamSubsystem != nullptr) if (SteamSubsystem != nullptr)
{ {
SteamSubsystem->ExecuteNextTick([OfficerArray, this]() SteamSubsystem->ExecuteNextTick([OfficerArray, this]()
{ {
OnSuccess.Broadcast(OfficerArray); OnSuccess.Broadcast(OfficerArray);
}); });
} }
//OnSuccess.Broadcast(OfficerArray); //OnSuccess.Broadcast(OfficerArray);
return; return;
} }
else else
{ {
if (SteamSubsystem != nullptr) if (SteamSubsystem != nullptr)
{ {
SteamSubsystem->ExecuteNextTick([this]() SteamSubsystem->ExecuteNextTick([this]()
{ {
TArray<FBPSteamGroupOfficer> FailureArray; TArray<FBPSteamGroupOfficer> FailureArray;
OnFailure.Broadcast(FailureArray); OnFailure.Broadcast(FailureArray);
}); });
} }
} }
// Should never hit this anyway // Should never hit this anyway
//OnFailure.Broadcast(OfficerArray); //OnFailure.Broadcast(OfficerArray);
} }
#endif #endif

View File

@@ -24,13 +24,13 @@ USteamWSRequestUGCDetailsCallbackProxy* USteamWSRequestUGCDetailsCallbackProxy::
} }
void USteamWSRequestUGCDetailsCallbackProxy::Activate() void USteamWSRequestUGCDetailsCallbackProxy::Activate()
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
// #TODO: Support arrays instead in the future? // #TODO: Support arrays instead in the future?
UGCQueryHandle_t hQueryHandle = SteamUGC()->CreateQueryUGCDetailsRequest((PublishedFileId_t *)&WorkShopID.SteamWorkshopID, 1); UGCQueryHandle_t hQueryHandle = SteamUGC()->CreateQueryUGCDetailsRequest((PublishedFileId_t *)&WorkShopID.SteamWorkshopID, 1);
// #TODO: add search settings here by calling into the handle? // #TODO: add search settings here by calling into the handle?
SteamAPICall_t hSteamAPICall = SteamUGC()->SendQueryUGCRequest(hQueryHandle); SteamAPICall_t hSteamAPICall = SteamUGC()->SendQueryUGCRequest(hQueryHandle);
// Need to release the query // Need to release the query
@@ -50,52 +50,52 @@ void USteamWSRequestUGCDetailsCallbackProxy::Activate()
} }
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
void USteamWSRequestUGCDetailsCallbackProxy::OnUGCRequestUGCDetails(SteamUGCQueryCompleted_t *pResult, bool bIOFailure) void USteamWSRequestUGCDetailsCallbackProxy::OnUGCRequestUGCDetails(SteamUGCQueryCompleted_t *pResult, bool bIOFailure)
{ {
FOnlineSubsystemSteam* SteamSubsystem = (FOnlineSubsystemSteam*)(IOnlineSubsystem::Get(STEAM_SUBSYSTEM)); FOnlineSubsystemSteam* SteamSubsystem = (FOnlineSubsystemSteam*)(IOnlineSubsystem::Get(STEAM_SUBSYSTEM));
if (bIOFailure || !pResult || pResult->m_unNumResultsReturned <= 0) if (bIOFailure || !pResult || pResult->m_unNumResultsReturned <= 0)
{ {
if (SteamSubsystem != nullptr) if (SteamSubsystem != nullptr)
{ {
SteamSubsystem->ExecuteNextTick([this]() SteamSubsystem->ExecuteNextTick([this]()
{ {
OnFailure.Broadcast(FBPSteamWorkshopItemDetails()); OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
}); });
} }
//OnFailure.Broadcast(FBPSteamWorkshopItemDetails()); //OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
return; return;
} }
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
SteamUGCDetails_t Details; SteamUGCDetails_t Details;
if (SteamUGC()->GetQueryUGCResult(pResult->m_handle, 0, &Details)) if (SteamUGC()->GetQueryUGCResult(pResult->m_handle, 0, &Details))
{ {
if (SteamSubsystem != nullptr) if (SteamSubsystem != nullptr)
{ {
SteamSubsystem->ExecuteNextTick([Details, this]() SteamSubsystem->ExecuteNextTick([Details, this]()
{ {
OnSuccess.Broadcast(FBPSteamWorkshopItemDetails(Details)); OnSuccess.Broadcast(FBPSteamWorkshopItemDetails(Details));
}); });
} }
//OnSuccess.Broadcast(FBPSteamWorkshopItemDetails(Details)); //OnSuccess.Broadcast(FBPSteamWorkshopItemDetails(Details));
return; return;
} }
} }
else else
{ {
if (SteamSubsystem != nullptr) if (SteamSubsystem != nullptr)
{ {
SteamSubsystem->ExecuteNextTick([this]() SteamSubsystem->ExecuteNextTick([this]()
{ {
OnFailure.Broadcast(FBPSteamWorkshopItemDetails()); OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
}); });
} }
} }
// Not needed, should never hit here // Not needed, should never hit here
//OnFailure.Broadcast(FBPSteamWorkshopItemDetails()); //OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
} }
#endif #endif

View File

@@ -1,19 +1,19 @@
Copyright Joshua Statzer Copyright Joshua Statzer
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.