mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-22 16:04:18 +00:00
Split plugin into two modules
One is for the general AdvancedSessions The second is for Steam specific implementations This makes it easier to package without steam included, as the default setup always packaged steam out on PC platforms. Unchecking the AdvancedSteamSessions plugin should allow for totally removing any steam reliance from the plugin. You would also have to remove steam specific nodes from your blueprints as well however as they will no longer exist. Former-commit-id: 0bf1fc80dff7be0cc2b9cebaf5affed4918cea49
This commit is contained in:
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
@@ -9,11 +9,5 @@ public class AdvancedSessions : ModuleRules
|
||||
PublicIncludePaths.AddRange(new string[] { "AdvancedSessions/Public" });
|
||||
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"*/});
|
||||
|
||||
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Linux) || (Target.Platform == UnrealTargetPlatform.Mac))
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,15 +20,6 @@
|
||||
//General Advanced Sessions Log
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsLog, Log, All);
|
||||
|
||||
UENUM(Blueprintable)
|
||||
enum class SteamAvatarSize : uint8
|
||||
{
|
||||
SteamAvatar_Small = 1,
|
||||
SteamAvatar_Medium = 2,
|
||||
SteamAvatar_Large = 3
|
||||
};
|
||||
|
||||
|
||||
UCLASS()
|
||||
class UAdvancedFriendsLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
@@ -60,24 +51,4 @@ public:
|
||||
// Check if a UniqueNetId is a friend
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|FriendsList")
|
||||
static void IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend);
|
||||
|
||||
// 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"))
|
||||
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.
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
|
||||
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);
|
||||
};
|
@@ -5,222 +5,9 @@
|
||||
|
||||
// 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
|
||||
// disable the warnings locally. Remove when this is fixed in the SDK
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
|
||||
#pragma push_macro("ARRAY_COUNT")
|
||||
#undef ARRAY_COUNT
|
||||
|
||||
#include <steam/steam_api.h>
|
||||
#include <OnlineSubsystemSteamTypes.h>
|
||||
|
||||
#pragma pop_macro("ARRAY_COUNT")
|
||||
|
||||
#endif
|
||||
|
||||
// @todo Steam: See above
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedFriendsLog);
|
||||
|
||||
|
||||
int32 UAdvancedFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId)
|
||||
{
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
|
||||
|
||||
return SteamFriends()->GetFriendSteamLevel(id);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
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<const FUniqueNetId> 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())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("RequestSteamFriendInfo Had a bad UniqueNetId!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
|
||||
|
||||
return !SteamFriends()->RequestUserInformation(id, bRequireNameOnly);
|
||||
}
|
||||
#endif
|
||||
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("RequestSteamFriendInfo Couldn't init steamAPI!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
UTexture2D * UAdvancedFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize)
|
||||
{
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetSteamFriendAvatar Had a bad UniqueNetId!"));
|
||||
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32 Width = 0;
|
||||
uint32 Height = 0;
|
||||
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
//Getting the PictureID from the SteamAPI and getting the Size with the ID
|
||||
//virtual bool RequestUserInformation( CSteamID steamIDUser, bool bRequireNameOnly ) = 0;
|
||||
|
||||
|
||||
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
|
||||
int Picture = 0;
|
||||
|
||||
switch(AvatarSize)
|
||||
{
|
||||
case SteamAvatarSize::SteamAvatar_Small: Picture = SteamFriends()->GetSmallFriendAvatar(id); break;
|
||||
case SteamAvatarSize::SteamAvatar_Medium: Picture = SteamFriends()->GetMediumFriendAvatar(id); break;
|
||||
case SteamAvatarSize::SteamAvatar_Large: Picture = SteamFriends()->GetLargeFriendAvatar(id); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (Picture == -1)
|
||||
{
|
||||
Result = EBlueprintAsyncResultSwitch::AsyncLoading;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SteamUtils()->GetImageSize(Picture, &Width, &Height);
|
||||
|
||||
// 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.
|
||||
// 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)
|
||||
{
|
||||
//Creating the buffer "oAvatarRGBA" and then filling it with the RGBA Stream from the Steam Avatar
|
||||
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
|
||||
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
|
||||
/*
|
||||
//Swap R and B channels because for some reason the games whack
|
||||
for (uint32 i = 0; i < (Width * Height * 4); i += 4)
|
||||
{
|
||||
uint8 Temp = oAvatarRGBA[i + 0];
|
||||
oAvatarRGBA[i + 0] = oAvatarRGBA[i + 2];
|
||||
oAvatarRGBA[i + 2] = Temp;
|
||||
}*/
|
||||
|
||||
UTexture2D* Avatar = UTexture2D::CreateTransient(Width, Height, PF_R8G8B8A8);
|
||||
|
||||
// Switched to a Memcpy instead of byte by byte transer
|
||||
uint8* MipData = (uint8*)Avatar->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
|
||||
FMemory::Memcpy(MipData, (void*)oAvatarRGBA, Height * Width * 4);
|
||||
Avatar->PlatformData->Mips[0].BulkData.Unlock();
|
||||
|
||||
// Original implementation was missing this!!
|
||||
// the hell man......
|
||||
delete[] oAvatarRGBA;
|
||||
|
||||
//Setting some Parameters for the Texture and finally returning it
|
||||
Avatar->PlatformData->NumSlices = 1;
|
||||
Avatar->NeverStream = true;
|
||||
//Avatar->CompressionSettings = TC_EditorIcon;
|
||||
|
||||
Avatar->UpdateResource();
|
||||
|
||||
Result = EBlueprintAsyncResultSwitch::OnSuccess;
|
||||
return Avatar;
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("Bad Height / Width with steam avatar!"));
|
||||
}
|
||||
|
||||
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
UE_LOG(AdvancedFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized"));
|
||||
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UAdvancedFriendsLibrary::SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
if (!PlayerController)
|
21
AdvancedSteamSessions/AdvancedSteamSessions.uplugin
Normal file
21
AdvancedSteamSessions/AdvancedSteamSessions.uplugin
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"FileVersion" : 3,
|
||||
|
||||
"FriendlyName" : "Advanced Steam Sessions",
|
||||
"Version" : 1.9,
|
||||
"VersionName": "1.9",
|
||||
"EngineVersion" : 1579795,
|
||||
"Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS",
|
||||
"Category" : "Advanced Sessions Plugin",
|
||||
"CreatedBy" : "Joshua Statzer",
|
||||
"CreatedByURL" : "N/A",
|
||||
|
||||
"Modules" :
|
||||
[
|
||||
{
|
||||
"Name" : "AdvancedSteamSessions",
|
||||
"Type" : "RunTime",
|
||||
"LoadingPhase" : "PreDefault"
|
||||
}
|
||||
]
|
||||
}
|
BIN
AdvancedSteamSessions/Resources/Icon128.png
Normal file
BIN
AdvancedSteamSessions/Resources/Icon128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
@@ -0,0 +1,17 @@
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
|
||||
public class AdvancedSteamSessions : ModuleRules
|
||||
{
|
||||
public AdvancedSteamSessions(TargetInfo Target)
|
||||
{
|
||||
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"*/});
|
||||
|
||||
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Linux) || (Target.Platform == UnrealTargetPlatform.Mac))
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineFriendsInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlineMessageInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
|
||||
#include "UObjectIterator.h"
|
||||
|
||||
#include "AdvancedSteamFriendsLibrary.generated.h"
|
||||
|
||||
|
||||
//General Advanced Sessions Log
|
||||
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamFriendsLog, Log, All);
|
||||
|
||||
UENUM(Blueprintable)
|
||||
enum class SteamAvatarSize : uint8
|
||||
{
|
||||
SteamAvatar_Small = 1,
|
||||
SteamAvatar_Medium = 2,
|
||||
SteamAvatar_Large = 3
|
||||
};
|
||||
|
||||
|
||||
UCLASS()
|
||||
class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
//********* 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
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI", meta = (ExpandEnumAsExecs = "Result"))
|
||||
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.
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
|
||||
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);
|
||||
};
|
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "ModuleManager.h"
|
||||
|
||||
class AdvancedSteamSessions : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
/** IModuleInterface implementation */
|
||||
void StartupModule();
|
||||
void ShutdownModule();
|
||||
};
|
@@ -0,0 +1,221 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "AdvancedSteamFriendsLibrary.h"
|
||||
|
||||
|
||||
// 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
|
||||
// disable the warnings locally. Remove when this is fixed in the SDK
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
|
||||
#pragma push_macro("ARRAY_COUNT")
|
||||
#undef ARRAY_COUNT
|
||||
|
||||
#include <steam/steam_api.h>
|
||||
#include <OnlineSubsystemSteamTypes.h>
|
||||
#pragma pop_macro("ARRAY_COUNT")
|
||||
|
||||
#endif
|
||||
|
||||
// @todo Steam: See above
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedSteamFriendsLog);
|
||||
|
||||
|
||||
int32 UAdvancedSteamFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId)
|
||||
{
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
|
||||
|
||||
return SteamFriends()->GetFriendSteamLevel(id);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
FString UAdvancedSteamFriendsLibrary::GetSteamPersonaName(const FBPUniqueNetId UniqueNetId)
|
||||
{
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, 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 UAdvancedSteamFriendsLibrary::CreateSteamIDFromString(const FString SteamID64)
|
||||
{
|
||||
FBPUniqueNetId netId;
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!(SteamID64.Len() > 0))
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("CreateSteamIDFromString Had a bad UniqueNetId!"));
|
||||
return netId;
|
||||
}
|
||||
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
// Already does the conversion
|
||||
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam(SteamID64));
|
||||
//FCString::Atoi64(*SteamID64));
|
||||
|
||||
netId.SetUniqueNetId(ValueID);
|
||||
return netId;
|
||||
}
|
||||
#endif
|
||||
|
||||
return netId;
|
||||
}
|
||||
|
||||
bool UAdvancedSteamFriendsLibrary::RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly)
|
||||
{
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Had a bad UniqueNetId!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
|
||||
|
||||
return !SteamFriends()->RequestUserInformation(id, bRequireNameOnly);
|
||||
}
|
||||
#endif
|
||||
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Couldn't init steamAPI!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize)
|
||||
{
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendAvatar Had a bad UniqueNetId!"));
|
||||
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32 Width = 0;
|
||||
uint32 Height = 0;
|
||||
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
//Getting the PictureID from the SteamAPI and getting the Size with the ID
|
||||
//virtual bool RequestUserInformation( CSteamID steamIDUser, bool bRequireNameOnly ) = 0;
|
||||
|
||||
|
||||
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
|
||||
int Picture = 0;
|
||||
|
||||
switch(AvatarSize)
|
||||
{
|
||||
case SteamAvatarSize::SteamAvatar_Small: Picture = SteamFriends()->GetSmallFriendAvatar(id); break;
|
||||
case SteamAvatarSize::SteamAvatar_Medium: Picture = SteamFriends()->GetMediumFriendAvatar(id); break;
|
||||
case SteamAvatarSize::SteamAvatar_Large: Picture = SteamFriends()->GetLargeFriendAvatar(id); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (Picture == -1)
|
||||
{
|
||||
Result = EBlueprintAsyncResultSwitch::AsyncLoading;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SteamUtils()->GetImageSize(Picture, &Width, &Height);
|
||||
|
||||
// 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.
|
||||
// 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)
|
||||
{
|
||||
//Creating the buffer "oAvatarRGBA" and then filling it with the RGBA Stream from the Steam Avatar
|
||||
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
|
||||
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
|
||||
/*
|
||||
//Swap R and B channels because for some reason the games whack
|
||||
for (uint32 i = 0; i < (Width * Height * 4); i += 4)
|
||||
{
|
||||
uint8 Temp = oAvatarRGBA[i + 0];
|
||||
oAvatarRGBA[i + 0] = oAvatarRGBA[i + 2];
|
||||
oAvatarRGBA[i + 2] = Temp;
|
||||
}*/
|
||||
|
||||
UTexture2D* Avatar = UTexture2D::CreateTransient(Width, Height, PF_R8G8B8A8);
|
||||
|
||||
// Switched to a Memcpy instead of byte by byte transer
|
||||
uint8* MipData = (uint8*)Avatar->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
|
||||
FMemory::Memcpy(MipData, (void*)oAvatarRGBA, Height * Width * 4);
|
||||
Avatar->PlatformData->Mips[0].BulkData.Unlock();
|
||||
|
||||
// Original implementation was missing this!!
|
||||
// the hell man......
|
||||
delete[] oAvatarRGBA;
|
||||
|
||||
//Setting some Parameters for the Texture and finally returning it
|
||||
Avatar->PlatformData->NumSlices = 1;
|
||||
Avatar->NeverStream = true;
|
||||
//Avatar->CompressionSettings = TC_EditorIcon;
|
||||
|
||||
Avatar->UpdateResource();
|
||||
|
||||
Result = EBlueprintAsyncResultSwitch::OnSuccess;
|
||||
return Avatar;
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("Bad Height / Width with steam avatar!"));
|
||||
}
|
||||
|
||||
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized"));
|
||||
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
||||
return nullptr;
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
//#include "StandAlonePrivatePCH.h"
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "AdvancedSteamSessions.h"
|
||||
|
||||
void AdvancedSteamSessions::StartupModule()
|
||||
{
|
||||
}
|
||||
|
||||
void AdvancedSteamSessions::ShutdownModule()
|
||||
{
|
||||
}
|
||||
|
||||
IMPLEMENT_MODULE(AdvancedSteamSessions, AdvancedSteamSessions)
|
@@ -1,6 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "SteamFuncs/AdvancedSteamWorkshopLibrary.h"
|
||||
#include "AdvancedSteamWorkshopLibrary.h"
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedSteamWorkshopLog);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "SteamFuncs/SteamWSRequestUGCDetailsCallbackProxy.h"
|
||||
#include "SteamWSRequestUGCDetailsCallbackProxy.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UEndSessionCallbackProxy
|
Reference in New Issue
Block a user