Implemented Workshop Item Subscription

Added subscribing to items as well as the UGC interfaces
GetNumSubscribedItems and GetSubscribedItems. Edited SteamUGC Method
GetSubscribedItems to accept array instead of a ptr to allow c# calling
This commit is contained in:
Matthew Oldfield 2017-07-10 15:15:53 +01:00
parent bf21cb9df3
commit 2108dc3b76
3 changed files with 49 additions and 2 deletions

View File

@ -63,6 +63,19 @@ public void Download( bool highPriority = true )
workshop.OnItemInstalled += OnItemInstalled;
}
public void Subscribe()
{
workshop.ugc.SubscribeItem(Id);
SubscriptionCount++;
}
public void UnSubscribe()
{
workshop.ugc.UnsubscribeItem(Id);
SubscriptionCount--;
}
private void OnFileDownloaded( ulong fileid, Callbacks.Result result )
{
if ( fileid != Id ) return;

View File

@ -123,6 +123,37 @@ public Item GetItem( ulong itemid )
return new Item( itemid, this );
}
/// <summary>
/// The amount of item's the user is subscribed to for this App
/// </summary>
public uint GetAmountSubsribed()
{
return ugc.GetNumSubscribedItems();
}
/// <summary>
/// Creates a list of all item's that the user is currently subscribed
/// to for this App. This does not query titles or descriptions but
/// allows you to get the directories, state and ID of any subscribed Item.
/// This is mostly useful for getting all subscribed items install location.
/// </summary>
public Item[] GetSubscribedItems(uint amount)
{
Item[] items;
PublishedFileId_t[] vecSubscribedItems = new PublishedFileId_t[amount];
uint subAmount = ugc.GetSubscribedItems(vecSubscribedItems, amount);
if (subAmount < amount)
items = new Item[subAmount];
else
items = new Item[amount];
for(int i =0, length = items.Length; i<length; i++)
{
items[i] = new Item(vecSubscribedItems[i].Value, this);
}
return items;
}
/// <summary>
/// How a query should be ordered.

View File

@ -284,9 +284,12 @@ public bool GetQueryUGCStatistic( UGCQueryHandle_t handle /*UGCQueryHandle_t*/,
}
// uint
public uint GetSubscribedItems( PublishedFileId_t* pvecPublishedFileID /*PublishedFileId_t **/, uint cMaxEntries /*uint32*/ )
public uint GetSubscribedItems( PublishedFileId_t[] pvecPublishedFileID /*PublishedFileId_t **/, uint cMaxEntries /*uint32*/ )
{
return platform.ISteamUGC_GetSubscribedItems( (IntPtr) pvecPublishedFileID, cMaxEntries );
fixed (PublishedFileId_t* pvecPublishedFileID_ptr = pvecPublishedFileID)
{
return platform.ISteamUGC_GetSubscribedItems((IntPtr)pvecPublishedFileID_ptr, cMaxEntries);
}
}
// SteamAPICall_t