mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-24 04:28:00 +03:00
File queries
This commit is contained in:
parent
668a682173
commit
e2cf8c0b80
@ -129,5 +129,63 @@ namespace Facepunch.Steamworks.Test
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void QueryFile()
|
||||||
|
{
|
||||||
|
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 );
|
||||||
|
|
||||||
|
Console.WriteLine( "Query.TotalResults: {0}", Query.TotalResults );
|
||||||
|
Console.WriteLine( "Query.Items.Length: {0}", Query.Items.Length );
|
||||||
|
|
||||||
|
Assert.AreEqual<ulong>( Query.Items[0].Id, 751993251 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void QueryFiles()
|
||||||
|
{
|
||||||
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
||||||
|
{
|
||||||
|
Assert.IsTrue( client.IsValid );
|
||||||
|
|
||||||
|
using ( var Query = client.Workshop.CreateQuery() )
|
||||||
|
{
|
||||||
|
Query.FileId.Add( 751993251 );
|
||||||
|
Query.FileId.Add( 747266909 );
|
||||||
|
Query.Run();
|
||||||
|
|
||||||
|
Assert.IsTrue( Query.IsRunning );
|
||||||
|
|
||||||
|
Query.Block();
|
||||||
|
|
||||||
|
Assert.IsFalse( Query.IsRunning );
|
||||||
|
Assert.AreEqual( Query.TotalResults, 2 );
|
||||||
|
Assert.AreEqual( Query.Items.Length, 2 );
|
||||||
|
|
||||||
|
Console.WriteLine( "Query.TotalResults: {0}", Query.TotalResults );
|
||||||
|
Console.WriteLine( "Query.Items.Length: {0}", Query.Items.Length );
|
||||||
|
|
||||||
|
Assert.IsTrue( Query.Items.Any( x => x.Id == 751993251 ) );
|
||||||
|
Assert.IsTrue( Query.Items.Any( x => x.Id == 747266909 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ namespace Facepunch.Steamworks
|
|||||||
public int Page { get; set; } = 1;
|
public int Page { get; set; } = 1;
|
||||||
internal Workshop workshop;
|
internal Workshop workshop;
|
||||||
|
|
||||||
public void Run()
|
public unsafe void Run()
|
||||||
{
|
{
|
||||||
if ( Callback != null )
|
if ( Callback != null )
|
||||||
return;
|
return;
|
||||||
@ -136,7 +136,21 @@ namespace Facepunch.Steamworks
|
|||||||
if ( Page <= 0 )
|
if ( Page <= 0 )
|
||||||
throw new System.Exception( "Page should be 1 or above" );
|
throw new System.Exception( "Page should be 1 or above" );
|
||||||
|
|
||||||
Handle = workshop.ugc.CreateQueryAllUGCRequest( (uint)Order, (uint)QueryType, UploaderAppId, AppId,( uint)Page );
|
if ( FileId.Count != 0 )
|
||||||
|
{
|
||||||
|
var fileArray = FileId.ToArray();
|
||||||
|
|
||||||
|
fixed ( ulong* array = fileArray )
|
||||||
|
{
|
||||||
|
Handle = workshop.ugc.CreateQueryUGCDetailsRequest( (IntPtr) array, (uint)fileArray.Length );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Handle = workshop.ugc.CreateQueryAllUGCRequest( (uint)Order, (uint)QueryType, UploaderAppId, AppId, (uint)Page );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ( !string.IsNullOrEmpty( SearchText ) )
|
if ( !string.IsNullOrEmpty( SearchText ) )
|
||||||
workshop.ugc.SetSearchText( Handle, SearchText );
|
workshop.ugc.SetSearchText( Handle, SearchText );
|
||||||
@ -195,6 +209,11 @@ namespace Facepunch.Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> ExcludeTags { get; set; } = new List<string>();
|
public List<string> ExcludeTags { get; set; } = new List<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If you're querying for a particular file or files, add them to this.
|
||||||
|
/// </summary>
|
||||||
|
public List<ulong> FileId { get; set; } = new List<ulong>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Don't call this in production!
|
/// Don't call this in production!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -976,7 +976,7 @@ namespace Valve.Interop
|
|||||||
[DllImportAttribute( Config.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamUGC_CreateQueryAllUGCRequest" )]
|
[DllImportAttribute( Config.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamUGC_CreateQueryAllUGCRequest" )]
|
||||||
internal static extern ulong SteamAPI_ISteamUGC_CreateQueryAllUGCRequest( IntPtr instancePtr, uint eQueryType, uint eMatchingeMatchingUGCTypeFileType, uint nCreatorAppID, uint nConsumerAppID, uint unPage );
|
internal static extern ulong SteamAPI_ISteamUGC_CreateQueryAllUGCRequest( IntPtr instancePtr, uint eQueryType, uint eMatchingeMatchingUGCTypeFileType, uint nCreatorAppID, uint nConsumerAppID, uint unPage );
|
||||||
[DllImportAttribute( Config.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamUGC_CreateQueryUGCDetailsRequest" )]
|
[DllImportAttribute( Config.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamUGC_CreateQueryUGCDetailsRequest" )]
|
||||||
internal static extern ulong SteamAPI_ISteamUGC_CreateQueryUGCDetailsRequest( IntPtr instancePtr, ref ulong pvecPublishedFileID, uint unNumPublishedFileIDs );
|
internal static unsafe extern ulong SteamAPI_ISteamUGC_CreateQueryUGCDetailsRequest( IntPtr instancePtr, IntPtr pvecPublishedFileID, uint unNumPublishedFileIDs );
|
||||||
[DllImportAttribute( Config.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamUGC_SendQueryUGCRequest" )]
|
[DllImportAttribute( Config.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamUGC_SendQueryUGCRequest" )]
|
||||||
internal static extern ulong SteamAPI_ISteamUGC_SendQueryUGCRequest( IntPtr instancePtr, ulong handle );
|
internal static extern ulong SteamAPI_ISteamUGC_SendQueryUGCRequest( IntPtr instancePtr, ulong handle );
|
||||||
[DllImportAttribute( Config.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamUGC_GetQueryUGCResult" )]
|
[DllImportAttribute( Config.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamUGC_GetQueryUGCResult" )]
|
||||||
@ -2173,7 +2173,7 @@ namespace Valve.Steamworks
|
|||||||
internal abstract IntPtr GetIntPtr();
|
internal abstract IntPtr GetIntPtr();
|
||||||
internal abstract ulong CreateQueryUserUGCRequest( uint unAccountID, uint eListType, uint eMatchingUGCType, uint eSortOrder, uint nCreatorAppID, uint nConsumerAppID, uint unPage );
|
internal abstract ulong CreateQueryUserUGCRequest( uint unAccountID, uint eListType, uint eMatchingUGCType, uint eSortOrder, uint nCreatorAppID, uint nConsumerAppID, uint unPage );
|
||||||
internal abstract ulong CreateQueryAllUGCRequest( uint eQueryType, uint eMatchingeMatchingUGCTypeFileType, uint nCreatorAppID, uint nConsumerAppID, uint unPage );
|
internal abstract ulong CreateQueryAllUGCRequest( uint eQueryType, uint eMatchingeMatchingUGCTypeFileType, uint nCreatorAppID, uint nConsumerAppID, uint unPage );
|
||||||
internal abstract ulong CreateQueryUGCDetailsRequest( ref ulong pvecPublishedFileID, uint unNumPublishedFileIDs );
|
internal abstract ulong CreateQueryUGCDetailsRequest( IntPtr pvecPublishedFileID, uint unNumPublishedFileIDs );
|
||||||
internal abstract ulong SendQueryUGCRequest( ulong handle );
|
internal abstract ulong SendQueryUGCRequest( ulong handle );
|
||||||
internal abstract bool GetQueryUGCResult( ulong handle, uint index, ref SteamUGCDetails_t pDetails );
|
internal abstract bool GetQueryUGCResult( ulong handle, uint index, ref SteamUGCDetails_t pDetails );
|
||||||
internal abstract bool GetQueryUGCPreviewURL( ulong handle, uint index, out string pchURL );
|
internal abstract bool GetQueryUGCPreviewURL( ulong handle, uint index, out string pchURL );
|
||||||
@ -5631,11 +5631,10 @@ namespace Valve.Steamworks
|
|||||||
ulong result = NativeEntrypoints.SteamAPI_ISteamUGC_CreateQueryAllUGCRequest(m_pSteamUGC,eQueryType,eMatchingeMatchingUGCTypeFileType,nCreatorAppID,nConsumerAppID,unPage);
|
ulong result = NativeEntrypoints.SteamAPI_ISteamUGC_CreateQueryAllUGCRequest(m_pSteamUGC,eQueryType,eMatchingeMatchingUGCTypeFileType,nCreatorAppID,nConsumerAppID,unPage);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
internal override ulong CreateQueryUGCDetailsRequest( ref ulong pvecPublishedFileID, uint unNumPublishedFileIDs )
|
internal override ulong CreateQueryUGCDetailsRequest( IntPtr pvecPublishedFileID, uint unNumPublishedFileIDs )
|
||||||
{
|
{
|
||||||
CheckIfUsable();
|
CheckIfUsable();
|
||||||
pvecPublishedFileID = 0;
|
ulong result = NativeEntrypoints.SteamAPI_ISteamUGC_CreateQueryUGCDetailsRequest(m_pSteamUGC, pvecPublishedFileID,unNumPublishedFileIDs);
|
||||||
ulong result = NativeEntrypoints.SteamAPI_ISteamUGC_CreateQueryUGCDetailsRequest(m_pSteamUGC,ref pvecPublishedFileID,unNumPublishedFileIDs);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
internal override ulong SendQueryUGCRequest( ulong handle )
|
internal override ulong SendQueryUGCRequest( ulong handle )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user