I actually did something like this a while ago, its pretty straight forward. What I achieved in my little project:
- Get count of subscribed items in the workshop
- Get the Workshop Item IDs
- Get the name of a subscribed item
If you take a look at the Steamworks API docs, you see its pretty easy to extend that stuff yourself. A bit of explaining:
For every thing I describe here, you’ll need the steamapi.h because the OnlineSubsystem wrappers don’t support Workshop (UGC - User Generated Content) yet, so you need to put
#include "ThirdParty/Steamworks/Steamv132/sdk/public/steam/steam_api.h"
in the piece of code where you trying to use the Steam things. I nearly done some of the functions inside a blueprint function library so I can use WOrkshop functions from Blueprints. I’m not putting the Headers here, because it should be self-explaining. Getting the subscribed item count is really easy:
int32 USteamBlueprintFunctions::GetSubscribedItemCount()
{
if (SteamAPI_Init())
{
return SteamUGC()->GetNumSubscribedItems();
}
else
{
return 0;
}
}
Notice that SteamUGC() is the object to interact with if you want Workshop things. if the SteamAPI_Init() is false, then Steam is not running, so its just a crash safe thing.
Getting the Steam workshop item ids of things you subcribed is pretty easy also:
TArray<int32> USteamBlueprintFunctions::GetSubscribedItemIDs()
{
TArray<int32> outArray;
if (SteamAPI_Init())
{
PublishedFileId_t fileIds[16];
int32 subItems = SteamUGC()->GetSubscribedItems(fileIds, 16);
for (int i = 0; i < subItems; i++)
{
PublishedFileId_t id = fileIds*;
outArray.Add(id);
}
}
else
{
outArray.Add(0);
}
return outArray;
}
You see, if the SteamAPI is valid, it uses SteamUGC()->GetSubscribedItems() and puts the output file ids into the PublishedFileID_t array. The 16 is a predefined number of a maximum amount of results you want to get. Then I just add every id into the Unreal compatible array and return it.
To get for example the name of an workshop item, you need to dig a bit deeper. This is not made in blueprints by me yet, so I just show what I made inside my GameInstance so it runs at game start.
Getting Information from UGC content requests, as Steamworks says, a Callback because this one is latent, which means, it sends the request to the server, and you can only proceed if that is done. The header contents for this:
void OnUGCRequestUGCDetails(SteamUGCRequestUGCDetailsResult_t *pResult, bool bIOFailure);
CCallResult<USteamGameInstance, SteamUGCRequestUGCDetailsResult_t> m_callResultUGCRequestDetails;
The source for that:
SteamAPICall_t hSteamAPICall = SteamUGC()->RequestUGCDetails(fileids[0], 20);
m_callResultUGCRequestDetails.Set(hSteamAPICall, this, &USteamGameInstance::OnUGCRequestUGCDetails);
Notice that fileids is an array with subscribed file ids as described above, and I am just doing this for the first subscribed item, thats why it only gets index 0. With a for each loop, you could do this for all. The 20 is the max Age in seconds, which is like a timeout. If you request data and do not get an answer for X seconds, it will just return nothing. It stores this Call inside a SteamAPICall_t type variable, and this is all well-documentated on the Steamworks API docs. So the void OnUGCRequestUGCDetails is just a method I define which will be executed once the result was received. Which arguments those things take is also documented at Steamworks. Then in the code the m_callResultUGCRequestDetails.Set is just a function to set up a callback, taking the API call, the class (this in this case :D) and the method we want to call when we received the answer, and thats the method we defined earlier. Code of this method:
void USteamGameInstance::OnUGCRequestUGCDetails(SteamUGCRequestUGCDetailsResult_t *pResult, bool bIOFailure)
{
if (bIOFailure)
{
return;
}
SteamUGCDetails_t hUGCDetails = pResult->m_details;
GEngine->AddOnScreenDebugMessage(-1, 10, FColor::Green, hUGCDetails.m_rgchTitle);
}
If we have an IO failure, we just return. If not, we store the details in the variable hUGCdetails, and then, you can pretty much do anything. I just did a debug message showing the title. Visual Studio will help you getting the variables out of hUGCDetails, because that contains a lot more than just the title. Hope i helped