diff --git a/Facepunch.Steamworks.Test/Client/Workshop.cs b/Facepunch.Steamworks.Test/Client/Workshop.cs
index b1b6eb4..84b1aa2 100644
--- a/Facepunch.Steamworks.Test/Client/Workshop.cs
+++ b/Facepunch.Steamworks.Test/Client/Workshop.cs
@@ -187,5 +187,33 @@ namespace Facepunch.Steamworks.Test
}
}
+ [TestMethod]
+ public void DownloadFile()
+ {
+ using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
+ {
+ Assert.IsTrue( client.IsValid );
+
+ using ( var Query = client.Workshop.CreateQuery() )
+ {
+ Query.FileId.Add( 751993251 );
+ Query.Run();
+
+ Assert.IsTrue( Query.IsRunning );
+
+ Query.Block();
+
+ Assert.IsFalse( Query.IsRunning );
+ Assert.AreEqual( Query.TotalResults, 1 );
+ Assert.AreEqual( Query.Items.Length, 1 );
+
+ var item = Query.Items[0];
+
+ item.Download();
+
+ }
+ }
+ }
+
}
}
diff --git a/Facepunch.Steamworks/Facepunch.Steamworks.csproj b/Facepunch.Steamworks/Facepunch.Steamworks.csproj
index 1bdff4c..2c6bfb4 100644
--- a/Facepunch.Steamworks/Facepunch.Steamworks.csproj
+++ b/Facepunch.Steamworks/Facepunch.Steamworks.csproj
@@ -137,6 +137,7 @@
+
diff --git a/Facepunch.Steamworks/Interfaces/Workshop.Item.cs b/Facepunch.Steamworks/Interfaces/Workshop.Item.cs
new file mode 100644
index 0000000..7309ca6
--- /dev/null
+++ b/Facepunch.Steamworks/Interfaces/Workshop.Item.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using Facepunch.Steamworks.Callbacks.Networking;
+using Facepunch.Steamworks.Callbacks.Workshop;
+using Facepunch.Steamworks.Interop;
+using Valve.Steamworks;
+
+namespace Facepunch.Steamworks
+{
+ public partial class Workshop
+ {
+ public class Item
+ {
+ internal ISteamUGC ugc;
+
+ public string Description { get; private set; }
+ public ulong Id { get; private set; }
+ public ulong OwnerId { get; private set; }
+ public float Score { get; private set; }
+ public string[] Tags { get; private set; }
+ public string Title { get; private set; }
+ public uint VotesDown { get; private set; }
+ public uint VotesUp { get; private set; }
+
+ internal static Item From( SteamUGCDetails_t details, ISteamUGC ugc )
+ {
+ var item = new Item();
+
+ item.ugc = ugc;
+ item.Id = details.m_nPublishedFileId;
+ item.Title = details.m_rgchTitle;
+ item.Description = details.m_rgchDescription;
+ item.OwnerId = details.m_ulSteamIDOwner;
+ item.Tags = details.m_rgchTags.Split( ',' );
+ item.Score = details.m_flScore;
+ item.VotesUp = details.m_unVotesUp;
+ item.VotesDown = details.m_unVotesDown;
+
+ return item;
+ }
+
+ public void Download()
+ {
+
+ }
+ }
+ }
+}
diff --git a/Facepunch.Steamworks/Interfaces/Workshop.cs b/Facepunch.Steamworks/Interfaces/Workshop.cs
index 753ddbd..fe032e2 100644
--- a/Facepunch.Steamworks/Interfaces/Workshop.cs
+++ b/Facepunch.Steamworks/Interfaces/Workshop.cs
@@ -11,7 +11,7 @@ using Valve.Steamworks;
namespace Facepunch.Steamworks
{
- public class Workshop
+ public partial class Workshop
{
internal const ulong InvalidHandle = 0xffffffffffffffff;
@@ -69,34 +69,6 @@ namespace Facepunch.Steamworks
return q;
}
- public class WorkshopItem
- {
- public string Description { get; private set; }
- public ulong Id { get; private set; }
- public ulong OwnerId { get; private set; }
- public float Score { get; private set; }
- public string[] Tags { get; private set; }
- public string Title { get; private set; }
- public uint VotesDown { get; private set; }
- public uint VotesUp { get; private set; }
-
- internal static WorkshopItem From( SteamUGCDetails_t details )
- {
- var item = new WorkshopItem();
-
- item.Id = details.m_nPublishedFileId;
- item.Title = details.m_rgchTitle;
- item.Description = details.m_rgchDescription;
- item.OwnerId = details.m_ulSteamIDOwner;
- item.Tags = details.m_rgchTags.Split( ',' );
- item.Score = details.m_flScore;
- item.VotesUp = details.m_unVotesUp;
- item.VotesDown = details.m_unVotesDown;
-
- return item;
- }
- }
-
public class WorkshopQuery : IDisposable
{
internal ulong Handle;
@@ -118,7 +90,7 @@ namespace Facepunch.Steamworks
public string SearchText { get; set; }
- public WorkshopItem[] Items { get; set; }
+ public Item[] Items { get; set; }
public int TotalResults { get; set; }
@@ -150,8 +122,6 @@ namespace Facepunch.Steamworks
Handle = workshop.ugc.CreateQueryAllUGCRequest( (uint)Order, (uint)QueryType, UploaderAppId, AppId, (uint)Page );
}
-
-
if ( !string.IsNullOrEmpty( SearchText ) )
workshop.ugc.SetSearchText( Handle, SearchText );
@@ -172,16 +142,15 @@ namespace Facepunch.Steamworks
void OnResult( QueryCompleted.Data data )
{
- List< WorkshopItem > items = new List();
+ Items = new Item[data.m_unNumResultsReturned];
for ( int i = 0; i < data.m_unNumResultsReturned; i++ )
{
SteamUGCDetails_t details = new SteamUGCDetails_t();
workshop.ugc.GetQueryUGCResult( data.Handle, (uint) i, ref details );
- items.Add( WorkshopItem.From( details ) );
+ Items[i] = Item.From( details, workshop.ugc );
}
- Items = items.ToArray();
TotalResults = (int) data.m_unTotalMatchingResults;
Callback.Dispose();