diff --git a/Facepunch.Steamworks.Test/UgcTest.cs b/Facepunch.Steamworks.Test/UgcTest.cs
index b8fffc2..e5e55e0 100644
--- a/Facepunch.Steamworks.Test/UgcTest.cs
+++ b/Facepunch.Steamworks.Test/UgcTest.cs
@@ -24,6 +24,28 @@ namespace Steamworks
Console.WriteLine( $"TotalCount: {result?.TotalCount}" );
}
+ [TestMethod]
+ public async Task QueryWithTags()
+ {
+ var q = UgcQuery.All()
+ .WithTag( "Fun" )
+ .WithTag( "Movie" )
+ .MatchAllTags();
+
+ var result = await q.GetPageAsync( 1 );
+ Assert.IsNotNull( result );
+
+ Console.WriteLine( $"ResultCount: {result?.ResultCount}" );
+ Console.WriteLine( $"TotalCount: {result?.TotalCount}" );
+
+ foreach ( var entry in result.Value.Entries )
+ {
+ Assert.IsTrue( entry.HasTag( "Fun" ) );
+ Assert.IsTrue( entry.HasTag( "Movie" ) );
+
+ }
+ }
+
[TestMethod]
public async Task QueryAllFromFriends()
{
diff --git a/Facepunch.Steamworks/Structs/UgcQuery.cs b/Facepunch.Steamworks/Structs/UgcQuery.cs
index 7d9932c..337bb37 100644
--- a/Facepunch.Steamworks/Structs/UgcQuery.cs
+++ b/Facepunch.Steamworks/Structs/UgcQuery.cs
@@ -71,18 +71,27 @@ namespace Steamworks.Data
public UgcQuery RankedByPlaytimeSessionsTrend() { queryType = UGCQuery.RankedByPlaytimeSessionsTrend; return this; }
public UgcQuery RankedByLifetimePlaytimeSessions() { queryType = UGCQuery.RankedByLifetimePlaytimeSessions; return this; }
- public UgcQuery ReturnOnlyIDs( bool b) { WantsReturnOnlyIDs = b; return this; }
- public UgcQuery ReturnKeyValueTag( bool b ) { WantsReturnKeyValueTags = b; return this; }
- public UgcQuery ReturnLongDescription( bool b ) { WantsReturnLongDescription = b; return this; }
- public UgcQuery ReturnMetadata( bool b ) { WantsReturnMetadata = b; return this; }
- public UgcQuery ReturnChildren( bool b ) { WantsReturnChildren = b; return this; }
- public UgcQuery ReturnAdditionalPreviews( bool b ) { WantsReturnAdditionalPreviews = b; return this; }
- public UgcQuery ReturnTotalOnly( bool b ) { WantsReturnTotalOnly = b; return this; }
- public UgcQuery ReturnPlaytimeStats( bool b ) { WantsReturnPlaytimeStats = b; return this; }
+ public UgcQuery WithOnlyIDs( bool b) { WantsReturnOnlyIDs = b; return this; }
+ public UgcQuery WithKeyValueTag( bool b ) { WantsReturnKeyValueTags = b; return this; }
+ public UgcQuery WithLongDescription( bool b ) { WantsReturnLongDescription = b; return this; }
+ public UgcQuery WithMetadata( bool b ) { WantsReturnMetadata = b; return this; }
+ public UgcQuery WithChildren( bool b ) { WantsReturnChildren = b; return this; }
+ public UgcQuery WithAdditionalPreviews( bool b ) { WantsReturnAdditionalPreviews = b; return this; }
+ public UgcQuery WithTotalOnly( bool b ) { WantsReturnTotalOnly = b; return this; }
+ public UgcQuery WithPlaytimeStats( bool b ) { WantsReturnPlaytimeStats = b; return this; }
public UgcQuery AllowCachedResponse( int maxSecondsAge ) { maxCacheAge = maxSecondsAge; return this; }
public UgcQuery InLanguage( string lang ) { language = lang; return this; }
- public UgcQuery MatchAnyTag( bool b ) { matchAnyTag = b; return this; }
+
+ ///
+ /// Found items must have at least one of the defined tags
+ ///
+ public UgcQuery MatchAnyTag() { matchAnyTag = true; return this; }
+
+ ///
+ /// Found items must have all defined tags
+ ///
+ public UgcQuery MatchAllTags() { matchAnyTag = false; return this; }
public UgcQuery WithTag( string tag )
{
@@ -129,6 +138,11 @@ namespace Steamworks.Data
SteamUGC.Internal.AddRequiredKeyValueTag( handle, tag.Key, tag.Value );
}
+ if ( matchAnyTag .HasValue )
+ {
+ SteamUGC.Internal.SetMatchAnyTag( handle, matchAnyTag.Value );
+ }
+
//
// TODO - add more
//
@@ -193,6 +207,7 @@ namespace Steamworks.Data
public string Title;
public string Description;
+ public string[] Tags;
//
@@ -211,7 +226,6 @@ namespace Steamworks.Data
internal bool Banned; // m_bBanned _Bool
internal bool AcceptedForUse; // m_bAcceptedForUse _Bool
internal bool TagsTruncated; // m_bTagsTruncated _Bool
- internal string Tags; // m_rgchTags char [1025]
internal ulong File; // m_hFile UGCHandle_t
internal ulong PreviewFile; // m_hPreviewFile UGCHandle_t
internal string PchFileName; // m_pchFileName char [260]
@@ -232,10 +246,21 @@ namespace Steamworks.Data
Title = details.Title,
Description = details.Description,
+ Tags = details.Tags.Split( new[] { ',' }, StringSplitOptions.RemoveEmptyEntries )
};
return d;
}
+
+ ///
+ /// A case insensitive check for tag
+ ///
+ public bool HasTag( string find )
+ {
+ if ( Tags.Length == 0 ) return false;
+
+ return Tags.Contains( find, StringComparer.OrdinalIgnoreCase );
+ }
}
}
\ No newline at end of file