From b304b8ce64a0a4bab70ea0b6f70d9849ad813eff Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Wed, 12 Oct 2016 10:20:02 +0100 Subject: [PATCH] Added Workshop.UserQuery Test --- Facepunch.Steamworks.Test/Client/Workshop.cs | 33 +++++++++++++++++++ .../Interfaces/Workshop.Query.cs | 9 +++++ Facepunch.Steamworks/Interfaces/Workshop.cs | 12 +++++++ 3 files changed, 54 insertions(+) diff --git a/Facepunch.Steamworks.Test/Client/Workshop.cs b/Facepunch.Steamworks.Test/Client/Workshop.cs index ec9aeb6..1e4c891 100644 --- a/Facepunch.Steamworks.Test/Client/Workshop.cs +++ b/Facepunch.Steamworks.Test/Client/Workshop.cs @@ -306,5 +306,38 @@ namespace Facepunch.Steamworks.Test } } + [TestMethod] + public void UserQuery() + { + using ( var client = new Facepunch.Steamworks.Client( 252490 ) ) + { + Assert.IsTrue( client.IsValid ); + + var Query = client.Workshop.CreateQuery(); + + Query.UserId = 76561197960279927; + Query.UserQueryType = Workshop.UserQueryType.Published; + + Query.Run(); + + // Block, wait for result + // (don't do this in realtime) + Query.Block(); + + Assert.IsFalse( Query.IsRunning ); + Assert.IsTrue( Query.TotalResults > 0 ); + Assert.IsTrue( Query.Items.Length > 0 ); + + Console.WriteLine( "Query.TotalResults: {0}", Query.TotalResults ); + Console.WriteLine( "Query.Items.Length: {0}", Query.Items.Length ); + + foreach ( var item in Query.Items ) + { + Console.WriteLine( "{0}", item.Title ); + Assert.AreEqual( item.OwnerId, 76561197960279927 ); + } + } + } + } } diff --git a/Facepunch.Steamworks/Interfaces/Workshop.Query.cs b/Facepunch.Steamworks/Interfaces/Workshop.Query.cs index c0bdb37..11d40da 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.Query.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.Query.cs @@ -38,6 +38,10 @@ namespace Facepunch.Steamworks public int TotalResults { get; set; } + public ulong? UserId { get; set; } + + public UserQueryType UserQueryType { get; set; } = UserQueryType.Published; + /// /// Page starts at 1 !! /// @@ -61,6 +65,11 @@ namespace Facepunch.Steamworks Handle = workshop.ugc.CreateQueryUGCDetailsRequest( (IntPtr)array, (uint)fileArray.Length ); } } + else if ( UserId.HasValue ) + { + uint accountId = (uint)( UserId.Value & 0xFFFFFFFFul ); + Handle = workshop.ugc.CreateQueryUserUGCRequest( accountId, (uint) UserQueryType, (uint)QueryType, (uint)Order, UploaderAppId, AppId, (uint)Page ); + } else { Handle = workshop.ugc.CreateQueryAllUGCRequest( (uint)Order, (uint)QueryType, UploaderAppId, AppId, (uint)Page ); diff --git a/Facepunch.Steamworks/Interfaces/Workshop.cs b/Facepunch.Steamworks/Interfaces/Workshop.cs index a99dc61..7f0f53c 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.cs @@ -125,6 +125,18 @@ namespace Facepunch.Steamworks GameManagedItem = 15, // managed completely by the game, not the user, and not shown on the web }; + public enum UserQueryType : uint + { + Published = 0, + VotedOn, + VotedUp, + VotedDown, + WillVoteLater, + Favorited, + Subscribed, + UsedOrPlayed, + Followed, + } }