mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 14:48:02 +03:00
Workshop.Item to its own file
This commit is contained in:
parent
e2cf8c0b80
commit
1a61766b2b
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -137,6 +137,7 @@
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="Callbacks\Networking.cs" />
|
||||
<Compile Include="Interfaces\Workshop.cs" />
|
||||
<Compile Include="Interfaces\Workshop.Item.cs" />
|
||||
<Compile Include="Interop\Callback.cs" />
|
||||
<Compile Include="Interop\CallResult.cs" />
|
||||
<Compile Include="Interop\Native.cs" />
|
||||
|
52
Facepunch.Steamworks/Interfaces/Workshop.Item.cs
Normal file
52
Facepunch.Steamworks/Interfaces/Workshop.Item.cs
Normal file
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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<WorkshopItem>();
|
||||
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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user