diff --git a/Source/AdvancedSessions/AdvancedSessions.Build.cs b/Source/AdvancedSessions/AdvancedSessions.Build.cs index 78d9e03..23377b1 100644 --- a/Source/AdvancedSessions/AdvancedSessions.Build.cs +++ b/Source/AdvancedSessions/AdvancedSessions.Build.cs @@ -12,7 +12,9 @@ public class AdvancedSessions : ModuleRules if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32) || (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 } } } \ No newline at end of file diff --git a/Source/AdvancedSessions/Classes/AdvancedFriendsLibrary.h b/Source/AdvancedSessions/Classes/AdvancedFriendsLibrary.h index 1118a44..e8409d2 100644 --- a/Source/AdvancedSessions/Classes/AdvancedFriendsLibrary.h +++ b/Source/AdvancedSessions/Classes/AdvancedFriendsLibrary.h @@ -67,10 +67,17 @@ public: // 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") - static bool RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId); + static bool RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly = false); // 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") 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. + UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") + static FString GetSteamPersonaName(const FBPUniqueNetId UniqueNetId); + + // Creates a unique steam id directly from a string holding a uint64 value, useful for testing + UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI") + static FBPUniqueNetId CreateSteamIDFromString(const FString SteamID64); }; diff --git a/Source/AdvancedSessions/Classes/SteamFuncs/AdvancedSteamWorkshopLibrary.h b/Source/AdvancedSessions/Classes/SteamFuncs/AdvancedSteamWorkshopLibrary.h index 635d223..89e572f 100644 --- a/Source/AdvancedSessions/Classes/SteamFuncs/AdvancedSteamWorkshopLibrary.h +++ b/Source/AdvancedSessions/Classes/SteamFuncs/AdvancedSteamWorkshopLibrary.h @@ -210,6 +210,8 @@ public: bBanned = hUGCDetails.m_bBanned; bAcceptedForUse = hUGCDetails.m_bAcceptedForUse; bTagsTruncated = hUGCDetails.m_bTagsTruncated; + + CreatorSteamID = FString::Printf(TEXT("%llu"), hUGCDetails.m_ulSteamIDOwner); } // Result of obtaining the details @@ -260,9 +262,12 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") bool bTagsTruncated; + // Steam ID of the user who created this content. + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") + FString CreatorSteamID; + /* PublishedFileId_t m_nPublishedFileId; - uint64 m_ulSteamIDOwner; // Steam ID of the user who created this content. uint32 m_rtimeCreated; // time when the published file was created 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) diff --git a/Source/AdvancedSessions/Private/AdvancedFriendsLibrary.cpp b/Source/AdvancedSessions/Private/AdvancedFriendsLibrary.cpp index 7c2ca94..9f0cb99 100644 --- a/Source/AdvancedSessions/Private/AdvancedFriendsLibrary.cpp +++ b/Source/AdvancedSessions/Private/AdvancedFriendsLibrary.cpp @@ -18,6 +18,7 @@ #undef ARRAY_COUNT #include +#include #pragma pop_macro("ARRAY_COUNT") @@ -55,7 +56,53 @@ int32 UAdvancedFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNe } -bool UAdvancedFriendsLibrary::RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId) +FString UAdvancedFriendsLibrary::GetSteamPersonaName(const FBPUniqueNetId UniqueNetId) +{ + +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid()) + { + UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetSteamPersonaName Had a bad UniqueNetId!")); + return FString(TEXT("")); + } + + if (SteamAPI_Init()) + { + uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); + const char* PersonaName = SteamFriends()->GetFriendPersonaName(id); + return FString(UTF8_TO_TCHAR(PersonaName)); + } +#endif + + return FString(TEXT("")); +} + +FBPUniqueNetId UAdvancedFriendsLibrary::CreateSteamIDFromString(const FString SteamID64) +{ + FBPUniqueNetId netId; + +#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX + if (!(SteamID64.Len() > 0)) + { + UE_LOG(AdvancedFriendsLog, Warning, TEXT("CreateSteamIDFromString Had a bad UniqueNetId!")); + return netId; + } + + if (SteamAPI_Init()) + { + // Already does the conversion + TSharedPtr ValueID(new const FUniqueNetIdSteam(SteamID64)); + //FCString::Atoi64(*SteamID64)); + + netId.SetUniqueNetId(ValueID); + return netId; + } +#endif + + return netId; +} + +bool UAdvancedFriendsLibrary::RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly) { #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid()) @@ -68,7 +115,7 @@ bool UAdvancedFriendsLibrary::RequestSteamFriendInfo(const FBPUniqueNetId Unique { uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); - return !SteamFriends()->RequestUserInformation(id, false); + return !SteamFriends()->RequestUserInformation(id, bRequireNameOnly); } #endif @@ -357,7 +404,7 @@ void UAdvancedFriendsLibrary::IsAFriend(APlayerController *PlayerController, con void UAdvancedFriendsLibrary::GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray &PlayersList) { IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface(); - + if (!FriendsInterface.IsValid()) { UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed to get friends interface!"));