Skip to content

Commit

Permalink
Add skipped methods from previous commits
Browse files Browse the repository at this point in the history
  • Loading branch information
trdwll committed Dec 14, 2020
1 parent 3e15aa8 commit 070fed3
Show file tree
Hide file tree
Showing 14 changed files with 302 additions and 28 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Interface | Completed | Notes |
ISteamApps | :heavy_check_mark: |
ISteamFriends | :heavy_check_mark: | [1] (1) |
ISteamGameServer | :heavy_check_mark: | [1] (4) |
ISteamGameServerStats | :heavy_check_mark: | [1] (1) |
ISteamGameServerStats | :heavy_check_mark: | [1] (2) |
ISteamHTMLSurface | :heavy_check_mark: |
ISteamHTTP | :heavy_check_mark: |
ISteamInput | :heavy_check_mark: |
ISteamInventory | :heavy_check_mark: | [1] (5)
ISteamInventory | :heavy_check_mark: | [1] (2)
ISteamMatchmaking | :heavy_check_mark: |
ISteamMatchmakingServers | :heavy_check_mark: | [1] (10)
ISteamMusic | :heavy_check_mark: |
Expand All @@ -27,8 +27,8 @@ ISteamRemoteStorage | :heavy_check_mark: | [1] (5)
ISteamScreenshots | :heavy_check_mark: |
ISteamUGC | :heavy_check_mark: | [1][3] (3/3)
ISteamUser | :heavy_check_mark: |
ISteamUserStats | :heavy_check_mark: | [1] (4)
ISteamUtils | :heavy_check_mark: | [1] (5)
ISteamUserStats | :heavy_check_mark: | [1] (1)
ISteamUtils | :heavy_check_mark: | [1] (3)
ISteamVideo | :heavy_check_mark: |
SteamWeb | :x: | [2] |

Expand Down
39 changes: 38 additions & 1 deletion Source/SteamBridge/Private/Core/SteamFriends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,42 @@ FSteamAPICall USteamFriends::DownloadClanActivityCounts(TArray<FSteamID>& SteamC
return res;
}

// #NOTE: This should work, but the reason of failure is k_ESteamAPICallFailureSteamGone so I'm assuming it's where this method isn't async
//TArray<FSteamID> USteamFriends::EnumerateFollowingList() const
//{
// int32 ResultCount = 0;
// FriendsEnumerateFollowingList_t Result;
// TArray<FSteamID> SteamIDs;
//
// do
// {
// if (SteamAPICall_t ResultHandle = SteamFriends()->EnumerateFollowingList(ResultCount))
// {
// if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Orange, "LOL");
// bool bTmpResult;
// if (SteamUtils()->GetAPICallResult(ResultHandle, &Result, sizeof(Result), Result.k_iCallback, &bTmpResult))
// {
// if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Orange, "LOL2");
// ResultCount += Result.m_nResultsReturned;
// for (const auto& id : Result.m_rgSteamID)
// {
// if (id.IsValid())
// {
// SteamIDs.Add(id.ConvertToUint64());
// }
// }
// }
//
// ESteamAPICallFailure_ reason = (ESteamAPICallFailure_)((uint8)SteamUtils()->GetAPICallFailureReason(ResultHandle) - 1);
//
// if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Orange, USteamBridgeUtils::GetEnumValueAsString<ESteamAPICallFailure_>("ESteamAPICallFailure_", reason));
//
// }
// } while (ResultCount < Result.m_nTotalResultCount);
//
// return SteamIDs;
//}

int32 USteamFriends::GetClanChatMessage(FSteamID SteamIDClanChat, int32 MessageID, FString& Message, ESteamChatEntryType& ChatEntryType, FSteamID& SteamIDChatter)
{
EChatEntryType TmpEntryType;
Expand Down Expand Up @@ -167,7 +203,7 @@ void USteamFriends::GetFriendsGroupMembersList(FSteamFriendsGroupID FriendsGroup
}
}

UTexture2D* USteamFriends::GetFriendAvatar(FSteamID SteamIDFriend, ESteamAvatarSize AvatarSize) const
UTexture2D* USteamFriends::GetFriendAvatar(FSteamID SteamIDFriend, ESteamAvatarSize AvatarSize, int32& ImageHandle) const
{
int32 Avatar = 0;
switch (AvatarSize)
Expand All @@ -183,6 +219,7 @@ UTexture2D* USteamFriends::GetFriendAvatar(FSteamID SteamIDFriend, ESteamAvatarS
break;
}

ImageHandle = Avatar;
uint32 Width = 0, Height = 0;
SteamUtils()->GetImageSize(Avatar, &Width, &Height);
if (Width > 0 && Height > 0)
Expand Down
12 changes: 10 additions & 2 deletions Source/SteamBridge/Private/Core/SteamGameServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ USteamGameServer::~USteamGameServer()
OnGSPolicyResponseCallback.Unregister();
}

ESteamBeginAuthSessionResult USteamGameServer::BeginAuthSession(TArray<uint8> AuthTicket, FSteamID SteamID)
ESteamBeginAuthSessionResult USteamGameServer::BeginAuthSession(TArray<uint8> AuthTicket, FSteamID SteamID) const
{
AuthTicket.SetNum(8192);
return (ESteamBeginAuthSessionResult)SteamGameServer()->BeginAuthSession(AuthTicket.GetData(), 8192, SteamID);
}

FHAuthTicket USteamGameServer::GetAuthSessionTicket(TArray<uint8> &AuthTicket)
FHAuthTicket USteamGameServer::GetAuthSessionTicket(TArray<uint8> &AuthTicket) const
{
uint32 length = 0;
AuthTicket.SetNum(8192);
Expand All @@ -43,6 +43,14 @@ FHAuthTicket USteamGameServer::GetAuthSessionTicket(TArray<uint8> &AuthTicket)
return result;
}

FString USteamGameServer::GetPublicIP() const
{
FString TmpIP;
USteamBridgeUtils::ConvertIPToString(SteamGameServer()->GetPublicIP().m_unIPv4);

return TmpIP;
}

void USteamGameServer::OnAssociateWithClanResult(AssociateWithClanResult_t *pParam)
{
m_OnAssociateWithClanResult.Broadcast((ESteamResult)pParam->m_eResult);
Expand Down
50 changes: 50 additions & 0 deletions Source/SteamBridge/Private/Core/SteamInventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,56 @@ bool USteamInventory::GetItemDefinitionIDs(TArray<FSteamItemDef>& Items) const
return false;
}

bool USteamInventory::GetItemDefinitionProperty(FSteamItemDef Definition, const FString& PropertyName, FString& Value) const
{
uint32 Size = 0;
if (SteamInventory()->GetItemDefinitionProperty(Definition, TCHAR_TO_UTF8(*PropertyName), nullptr, &Size))
{
TArray<char> TmpStr;
TmpStr.SetNum(Size);
bool bResult = SteamInventory()->GetItemDefinitionProperty(Definition, TCHAR_TO_UTF8(*PropertyName), TmpStr.GetData(), &Size);
Value = UTF8_TO_TCHAR(TmpStr.GetData());
return bResult;
}
return false;
}

bool USteamInventory::GetItemsByID(FSteamInventoryResult& ResultHandle, const TArray<FSteamItemInstanceID>& InstanceIDs) const
{
const int32 Size = InstanceIDs.Num();
TArray<SteamItemInstanceID_t> TmpIDs;
TmpIDs.SetNum(Size);

for (int32 i = 0; i < Size; i++)
{
TmpIDs.Add(InstanceIDs[i]);
}

return SteamInventory()->GetItemsByID((SteamInventoryResult_t*)&ResultHandle, TmpIDs.GetData(), Size);
}

bool USteamInventory::GetItemsWithPrices(TArray<FSteamItemPriceData>& ItemData) const
{
const int32 Size = SteamInventory()->GetNumItemsWithPrices();

TArray<SteamItemDef_t> TmpItems;
TArray<uint64> TmpCurrentPrices;
TArray<uint64> TmpBasePrices;
TmpItems.SetNum(Size);
TmpCurrentPrices.SetNum(Size);
TmpBasePrices.SetNum(Size);

if (bool bResult = SteamInventory()->GetItemsWithPrices(TmpItems.GetData(), TmpCurrentPrices.GetData(), TmpBasePrices.GetData(), Size))
{
for (int32 i = 0; i < Size; i++)
{
ItemData.Add({TmpItems[i], (int64)TmpCurrentPrices[i], (int64)TmpBasePrices[i] });
}
return bResult;
}
return false;
}

bool USteamInventory::GetResultItemProperty(FSteamInventoryResult ResultHandle, int32 ItemIndex, const FString& PropertyName, FString& Value) const
{
TArray<char> TmpStr;
Expand Down
25 changes: 25 additions & 0 deletions Source/SteamBridge/Private/Core/SteamUserStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ FSteamAPICall USteamUserStats::FindOrCreateLeaderboard(const FString& Leaderboar
return SteamUserStats()->FindOrCreateLeaderboard(TCHAR_TO_UTF8(*LeaderboardName), (ELeaderboardSortMethod)LeaderboardSortMethod, (ELeaderboardDisplayType)LeaderboardDisplayType);
}

bool USteamUserStats::GetDownloadedLeaderboardEntry(FSteamLeaderboardEntries SteamLeaderboardEntries, int32 index, FSteamLeaderboardEntry& LeaderboardEntry, TArray<int32>& Details, int32 DetailsMax) const
{
Details.SetNum(DetailsMax);
LeaderboardEntry_t TmpEntry;
bool bResult = SteamUserStats()->GetDownloadedLeaderboardEntry(SteamLeaderboardEntries, index, &TmpEntry, Details.GetData(), DetailsMax);
LeaderboardEntry = TmpEntry;
return bResult;
}

int32 USteamUserStats::GetGlobalStatHistoryFloat(const FString& StatName, TArray<float>& Data, int32 Size) const
{
TArray<double> TmpData;
Expand All @@ -57,6 +66,22 @@ int32 USteamUserStats::GetGlobalStatHistoryFloat(const FString& StatName, TArray
return result;
}

int32 USteamUserStats::GetMostAchievedAchievementInfo(FString& Name, float& Percent, bool& bAchieved) const
{
TArray<char> TmpName;
int32 result = SteamUserStats()->GetMostAchievedAchievementInfo(TmpName.GetData(), 1024, &Percent, &bAchieved);
Name = UTF8_TO_TCHAR(TmpName.GetData());
return result;
}

int32 USteamUserStats::GetNextMostAchievedAchievementInfo(int32 IteratorPrevious, FString& Name, float& Percent, bool& bAchieved) const
{
TArray<char> TmpName;
int32 result = SteamUserStats()->GetNextMostAchievedAchievementInfo(IteratorPrevious, TmpName.GetData(), 1024, &Percent, &bAchieved);
Name = UTF8_TO_TCHAR(TmpName.GetData());
return result;
}

FSteamAPICall USteamUserStats::UploadLeaderboardScore(FSteamLeaderboard SteamLeaderboard, ESteamLeaderboardUploadScoreMethod LeaderboardUploadScoreMethod, int32 Score, const TArray<int32>& ScoreDetails) const
{
return SteamUserStats()->UploadLeaderboardScore(SteamLeaderboard, (ELeaderboardUploadScoreMethod)LeaderboardUploadScoreMethod, Score, ScoreDetails.GetData(), ScoreDetails.Num());
Expand Down
28 changes: 28 additions & 0 deletions Source/SteamBridge/Private/Core/SteamUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@ bool USteamUtils::GetEnteredGamepadTextInput(FString& Text) const
return bResult;
}

bool USteamUtils::GetImageRGBA(int32 Image, TArray<uint8>& Buffer) const
{
uint32 Width, Height;
if (SteamUtils()->GetImageSize(Image, &Width, &Height))
{
const int32 ImageSize = Width * Height * 4;
TArray<uint8> TmpBuffer;
TmpBuffer.SetNum(ImageSize);
bool bResult = SteamUtils()->GetImageRGBA(Image, TmpBuffer.GetData(), ImageSize);

for (int32 i = 0; i < ImageSize; i++)
{
Buffer.Add(TmpBuffer[i]);
}

return bResult;
}
return false;
}

bool USteamUtils::GetImageSize(int32 Image, FIntPoint& Size) const
{
uint32 Width, Height;
bool bResult = SteamUtils()->GetImageSize(Image, &Width, &Height);
Size = { (int32)Width, (int32)Height };
return bResult;
}

bool USteamUtils::ShowGamepadTextInput(ESteamGamepadTextInputMode InputMode, ESteamGamepadTextInputLineMode LineInputMode, const FString& Description, const FString& ExistingText, int32 CharMax) const
{
return SteamUtils()->ShowGamepadTextInput((EGamepadTextInputMode)InputMode, (EGamepadTextInputLineMode)LineInputMode, TCHAR_TO_UTF8(*Description), CharMax, TCHAR_TO_UTF8(*ExistingText));
Expand Down
2 changes: 1 addition & 1 deletion Source/SteamBridge/Private/SteamBridgeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FString USteamBridgeUtils::ConvertIPToString(uint32 IP)
return FString::FromInt(IP >> 24) + "." + FString::FromInt((IP >> 16) % 256) + "." + FString::FromInt((IP >> 8) % 256) + "." + FString::FromInt(IP % 256);
}

FString USteamBridgeUtils::GetSteamIDAsString(const FSteamID& SteamID) const
FString USteamBridgeUtils::GetSteamIDAsString(const FSteamID& SteamID)
{
return FString::Printf(TEXT("%llu"), SteamID.Value);
}
6 changes: 4 additions & 2 deletions Source/SteamBridge/Public/Core/SteamFriends.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ class STEAMBRIDGE_API USteamFriends final : public UObject
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|Friends")
FSteamAPICall DownloadClanActivityCounts(TArray<FSteamID>& SteamClanIDs, int32 ClansToRequest = 1) const;

// #TODO EnumerateFollowingList
/*UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "SteamBridgeCore|Friends")
TArray<FSteamID> EnumerateFollowingList() const;*/

/**
* Gets the Steam ID at the given index in a Steam group chat.
Expand Down Expand Up @@ -509,10 +510,11 @@ class STEAMBRIDGE_API USteamFriends final : public UObject
*
* @param FSteamID SteamIDFriend
* @param ESteamAvatarSize AvatarSize
* @param int32& ImageHandle
* @return UTexture2D*
*/
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|Friends")
UTexture2D* GetFriendAvatar(FSteamID SteamIDFriend, ESteamAvatarSize AvatarSize) const;
UTexture2D* GetFriendAvatar(FSteamID SteamIDFriend, ESteamAvatarSize AvatarSize, int32& ImageHandle) const;

/**
* Gets the current users persona (display) name.
Expand Down
18 changes: 14 additions & 4 deletions Source/SteamBridge/Public/Core/SteamGameServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class STEAMBRIDGE_API USteamGameServer final : public UObject
* @return ESteamBeginAuthSessionResult
*/
UFUNCTION(BlueprintCallable, Category = "SteamBridgeCore|GameServer")
ESteamBeginAuthSessionResult BeginAuthSession(TArray<uint8> AuthTicket, FSteamID SteamID);
ESteamBeginAuthSessionResult BeginAuthSession(TArray<uint8> AuthTicket, FSteamID SteamID) const;

/**
* Checks if the game server is logged on.
Expand Down Expand Up @@ -132,10 +132,20 @@ class STEAMBRIDGE_API USteamGameServer final : public UObject
* @return FHAuthTicket - A handle to the auth ticket. When you're done interacting with the entity you must call CancelAuthTicket on the handle.
*/
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|GameServer")
FHAuthTicket GetAuthSessionTicket(TArray<uint8>& AuthTicket);
FHAuthTicket GetAuthSessionTicket(TArray<uint8>& AuthTicket) const;

// #TODO GetNextOutgoingPacket
// #TODO GetPublicIP


// #NOTE This method only returns IPv4 for now, will eventually return a struct of the IPs (to support IPv6)
/**
* Gets the public IP of the server according to Steam.
* This is useful when the server is behind NAT and you want to advertise its IP in a lobby for other clients to directly connect to.
*
* @return FString - Returns the IP address (IPv4) as an FString
*/
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|GameServer")
FString GetPublicIP() const;

/**
* Gets the Steam ID of the game server.
Expand Down Expand Up @@ -359,7 +369,7 @@ class STEAMBRIDGE_API USteamGameServer final : public UObject
* @return ESteamUserHasLicenseForAppResult
*/
UFUNCTION(BlueprintCallable, Category = "SteamBridgeCore|GameServer")
ESteamUserHasLicenseForAppResult UserHasLicenseForApp(FSteamID SteamID, int32 AppID) { return (ESteamUserHasLicenseForAppResult)SteamGameServer()->UserHasLicenseForApp(SteamID, AppID); }
ESteamUserHasLicenseForAppResult UserHasLicenseForApp(FSteamID SteamID, int32 AppID) const { return (ESteamUserHasLicenseForAppResult)SteamGameServer()->UserHasLicenseForApp(SteamID, AppID); }

/**
* Checks if the master server has alerted us that we are out of date.
Expand Down
43 changes: 39 additions & 4 deletions Source/SteamBridge/Public/Core/SteamInventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,44 @@ class STEAMBRIDGE_API USteamInventory final : public UObject
/**
* Returns the set of all item definition IDs which are defined in the App Admin panel of the Steamworks website.
* These item definitions may not necessarily be contiguous integers.
* This should be called in response to a SteamInventoryDefinitionUpdate_t callback. There is no reason to call this function if your game hardcodes the numeric definition IDs (eg, purple face mask = 20, blue weapon mod = 55) and does not allow for adding new item types without a client patch.
* This should be called in response to a SteamInventoryDefinitionUpdate_t callback. There is no reason to call this function if your game hardcodes the numeric definition IDs (eg, purple face mask = 20, blue weapon mod = 55)
* and does not allow for adding new item types without a client patch.
*
* @param TArray<FSteamItemDef> & Items - Returns the item definitions by copying them into this array.
* @return bool - This call returns true upon success. It only returns false if item definitions have not been loaded from the server, or no item defintions exist for the current application.
*/
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "SteamBridgeCore|Inventory")
bool GetItemDefinitionIDs(TArray<FSteamItemDef>& Items) const;

// #TODO GetItemDefinitionProperty
// #TODO GetItemsByID
/**
* Gets a string property from the specified item definition.
* Gets a property value for a specific item definition.
* Note that some properties (for example, "name") may be localized and will depend on the current Steam language settings (see ISteamApps::GetCurrentGameLanguage). Property names are always ASCII alphanumeric and underscores.
* Pass in NULL for pchPropertyName to get a comma-separated list of available property names. In this mode, punValueBufferSizeOut will contain the suggested buffer size. Otherwise it will be the number of bytes actually copied to pchValueBuffer.
*
* @param FSteamItemDef Definition - The item definition to get the properties for.
* @param const FString & PropertyName - The property name to get the value for. If you pass in NULL then pchValueBuffer will contain a comma-separated list of all the available names.
* @param FString & Value - Returns the value associated with pchPropertyName.
* @return bool - This returns true upon success; otherwise, false indicating that the item definitions have not been loaded from the server, or no item definitions exist for the current application, or the property name was not found in the item definition.
* The associated value is returned via pchValueBuffer, and the total number of bytes required to hold the value is available from punValueBufferSizeOut. It's recommended to call this function twice, the first time with pchValueBuffer
* set to NULL and punValueBufferSizeOut set to zero to get the size required for the buffer for the subsequent call.
*/
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "SteamBridgeCore|Inventory")
bool GetItemDefinitionProperty(FSteamItemDef Definition, const FString& PropertyName, FString& Value) const;

/**
* Gets the state of a subset of the current user's inventory.
* The subset is specified by an array of item instance IDs.
* The results from this call can be serialized using SerializeResult and passed to other players to "prove" that the current user owns specific items, without exposing the user's entire inventory.
* For example, you could call this with the IDs of the user's currently equipped items and serialize this to a buffer, and then transmit this buffer to other players upon joining a game.
* NOTE: You must call DestroyResult on the provided inventory result when you are done with it.
*
* @param FSteamInventoryResult & ResultHandle - Returns a new inventory result handle.
* @param const TArray<FSteamItemInstanceID> & InstanceIDs - A list of the item instance ids to update the state of.
* @return bool - This function always returns true when called by a regular user, and always returns false when called from SteamGameServer. Returns a new result handle via pResultHandle.
*/
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "SteamBridgeCore|Inventory")
bool GetItemsByID(FSteamInventoryResult& ResultHandle, const TArray<FSteamItemInstanceID>& InstanceIDs) const;

/**
* After a successful call to RequestPrices, you can call this method to get the pricing for a specific item definition.
Expand All @@ -206,7 +234,14 @@ class STEAMBRIDGE_API USteamInventory final : public UObject
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|Inventory")
bool GetItemPrice(FSteamItemDef ItemDef, int64& CurrentPrice, int64& BasePrice) const { return SteamInventory()->GetItemPrice(ItemDef, (uint64*)&CurrentPrice, (uint64*)&BasePrice); }

// #TODO GetItemsWithPrices
/**
* After a successful call to RequestPrices, you can call this method to get all the pricing for applicable item definitions. Use the result of GetNumItemsWithPrices as the the size of the arrays that you pass in.
*
* @param TArray<FSteamItemPriceData> & ItemData - The array of item definition ids to populate
* @return bool - true upon success, indicating that pArrayItemDefs and pPrices have been successfully filled with the item definition ids and prices of items that are for sale. false if the parameters are invalid
*/
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|Inventory")
bool GetItemsWithPrices(TArray<FSteamItemPriceData>& ItemData) const;

/**
* After a successful call to RequestPrices, this will return the number of item definitions with valid pricing.
Expand Down
Loading

0 comments on commit 070fed3

Please sign in to comment.