mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-23 08:24:18 +00:00
Added new steam sessions functions
IsOverlay Enabled InitTextFiltering FilterText IsSteamInBigPictureMode
This commit is contained in:
@@ -305,6 +305,19 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UENUM(Blueprintable)
|
||||||
|
enum class EBPTextFilteringContext : uint8
|
||||||
|
{
|
||||||
|
/*Unknown context.*/
|
||||||
|
FContext_Unknown = 0,
|
||||||
|
/*Game content, only legally required filtering is performed.*/
|
||||||
|
FContext_GameContent = 1,
|
||||||
|
/*Char from another player.*/
|
||||||
|
FContext_Chat = 2,
|
||||||
|
/*Character or item name.*/
|
||||||
|
FContext_Name = 3
|
||||||
|
};
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary
|
class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary
|
||||||
{
|
{
|
||||||
@@ -325,6 +338,10 @@ public:
|
|||||||
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)
|
||||||
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI")
|
||||||
|
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);
|
||||||
@@ -350,4 +367,21 @@ public:
|
|||||||
// 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)
|
||||||
|
// Returns if it succeeded, false if filtering is unavailable for the games language
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering")
|
||||||
|
static bool InitTextFiltering();
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
// If false it will still output the original text
|
||||||
|
// Textsource is the steam id that is the source of the text (player name / chat)
|
||||||
|
// Requires that InitTextFiltering be called first!!
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering")
|
||||||
|
static bool FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText);
|
||||||
|
|
||||||
|
// Returns if steam is running in big picture mode
|
||||||
|
UFUNCTION(BlueprintPure, Category = "Online|SteamAPI")
|
||||||
|
static bool IsSteamInBigPictureMode();
|
||||||
};
|
};
|
||||||
|
@@ -255,6 +255,19 @@ bool UAdvancedSteamFriendsLibrary::OpenSteamUserOverlay(const FBPUniqueNetId Uni
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UAdvancedSteamFriendsLibrary::IsOverlayEnabled()
|
||||||
|
{
|
||||||
|
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||||
|
if (SteamAPI_Init())
|
||||||
|
{
|
||||||
|
return SteamUtils()->IsOverlayEnabled();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!"));
|
||||||
|
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
|
||||||
@@ -351,3 +364,65 @@ UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueN
|
|||||||
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UAdvancedSteamFriendsLibrary::InitTextFiltering()
|
||||||
|
{
|
||||||
|
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||||
|
|
||||||
|
if (SteamAPI_Init())
|
||||||
|
{
|
||||||
|
return SteamUtils()->InitFilterText();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UAdvancedSteamFriendsLibrary::FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText)
|
||||||
|
{
|
||||||
|
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||||
|
|
||||||
|
if (SteamAPI_Init())
|
||||||
|
{
|
||||||
|
uint32 BufferLen = TextToFilter.Len() + 10; // Docs say 1 byte excess min, going with 10
|
||||||
|
char* OutText = new char[BufferLen];
|
||||||
|
|
||||||
|
uint64 id = 0;
|
||||||
|
|
||||||
|
if (TextSourceID.IsValid())
|
||||||
|
{
|
||||||
|
id = *((uint64*)TextSourceID.UniqueNetId->GetBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
int FilterCount = SteamUtils()->FilterText((ETextFilteringContext)Context, id, TCHAR_TO_ANSI(*TextToFilter), OutText, BufferLen);
|
||||||
|
|
||||||
|
if (FilterCount > 0)
|
||||||
|
{
|
||||||
|
FilteredText = FString(UTF8_TO_TCHAR(OutText));
|
||||||
|
delete[] OutText;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] OutText;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FilteredText = TextToFilter;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UAdvancedSteamFriendsLibrary::IsSteamInBigPictureMode()
|
||||||
|
{
|
||||||
|
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||||
|
|
||||||
|
if (SteamAPI_Init())
|
||||||
|
{
|
||||||
|
return SteamUtils()->IsSteamInBigPictureMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
Reference in New Issue
Block a user