mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
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:
parent
bf21cb9df3
commit
2108dc3b76
@ -63,6 +63,19 @@ public void Download( bool highPriority = true )
|
|||||||
workshop.OnItemInstalled += OnItemInstalled;
|
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 )
|
private void OnFileDownloaded( ulong fileid, Callbacks.Result result )
|
||||||
{
|
{
|
||||||
if ( fileid != Id ) return;
|
if ( fileid != Id ) return;
|
||||||
|
@ -123,6 +123,37 @@ public Item GetItem( ulong itemid )
|
|||||||
return new Item( itemid, this );
|
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>
|
/// <summary>
|
||||||
/// How a query should be ordered.
|
/// How a query should be ordered.
|
||||||
|
@ -284,9 +284,12 @@ public bool GetQueryUGCStatistic( UGCQueryHandle_t handle /*UGCQueryHandle_t*/,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// uint
|
// 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
|
// SteamAPICall_t
|
||||||
|
Loading…
Reference in New Issue
Block a user