mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
Added Workshop.UserQuery Test
This commit is contained in:
parent
029cad5514
commit
b304b8ce64
@ -306,5 +306,38 @@ public void CreatePublish()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[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<ulong>( item.OwnerId, 76561197960279927 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,10 @@ public class Query : IDisposable
|
|||||||
|
|
||||||
public int TotalResults { get; set; }
|
public int TotalResults { get; set; }
|
||||||
|
|
||||||
|
public ulong? UserId { get; set; }
|
||||||
|
|
||||||
|
public UserQueryType UserQueryType { get; set; } = UserQueryType.Published;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Page starts at 1 !!
|
/// Page starts at 1 !!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -61,6 +65,11 @@ public unsafe void Run()
|
|||||||
Handle = workshop.ugc.CreateQueryUGCDetailsRequest( (IntPtr)array, (uint)fileArray.Length );
|
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
|
else
|
||||||
{
|
{
|
||||||
Handle = workshop.ugc.CreateQueryAllUGCRequest( (uint)Order, (uint)QueryType, UploaderAppId, AppId, (uint)Page );
|
Handle = workshop.ugc.CreateQueryAllUGCRequest( (uint)Order, (uint)QueryType, UploaderAppId, AppId, (uint)Page );
|
||||||
|
@ -125,6 +125,18 @@ public enum ItemType
|
|||||||
GameManagedItem = 15, // managed completely by the game, not the user, and not shown on the web
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user