From 392b57e18d349ce9a099f16b3288e50c092e7de7 Mon Sep 17 00:00:00 2001 From: kamyker Date: Fri, 8 May 2020 01:20:50 +0200 Subject: [PATCH] Ugc item key value tags (cherry picked from commit a5386b358fec87911d2c4cd221d53b90f470bcf4) --- Facepunch.Steamworks/Structs/UgcItem.cs | 5 +++++ Facepunch.Steamworks/Structs/UgcQuery.cs | 5 ++++- Facepunch.Steamworks/Structs/UgcResultPage.cs | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Facepunch.Steamworks/Structs/UgcItem.cs b/Facepunch.Steamworks/Structs/UgcItem.cs index 640a0a4..87457e6 100644 --- a/Facepunch.Steamworks/Structs/UgcItem.cs +++ b/Facepunch.Steamworks/Structs/UgcItem.cs @@ -39,6 +39,11 @@ public Item( PublishedFileId id ) : this() /// public string[] Tags { get; internal set; } + /// + /// A dictionary of key value tags for this item, only available from queries WithKeyValueTags(true) + /// + public Dictionary KeyValueTags { get; internal set; } + /// /// App Id of the app that created this item /// diff --git a/Facepunch.Steamworks/Structs/UgcQuery.cs b/Facepunch.Steamworks/Structs/UgcQuery.cs index d448224..8d6c467 100644 --- a/Facepunch.Steamworks/Structs/UgcQuery.cs +++ b/Facepunch.Steamworks/Structs/UgcQuery.cs @@ -149,6 +149,7 @@ public Query WithFileId( params PublishedFileId[] files ) ResultCount = (int) result.Value.NumResultsReturned, TotalCount = (int)result.Value.TotalMatchingResults, CachedData = result.Value.CachedData + ReturnsKeyValueTags = WantsReturnKeyValueTags ?? false, }; } @@ -241,7 +242,9 @@ void ApplyConstraints( UGCQueryHandle_t handle ) bool? WantsReturnOnlyIDs; public QueryType WithOnlyIDs(bool b) { WantsReturnOnlyIDs = b; return this; } bool? WantsReturnKeyValueTags; - public QueryType WithKeyValueTag(bool b) { WantsReturnKeyValueTags = b; return this; } + public QueryType WithKeyValueTags(bool b) { WantsReturnKeyValueTags = b; return this; } + [Obsolete( "Renamed to WithKeyValueTags" )] + public QueryType WithKeyValueTag(bool b) { WantsReturnKeyValueTags = b; return this; } bool? WantsReturnLongDescription; public QueryType WithLongDescription(bool b) { WantsReturnLongDescription = b; return this; } bool? WantsReturnMetadata; diff --git a/Facepunch.Steamworks/Structs/UgcResultPage.cs b/Facepunch.Steamworks/Structs/UgcResultPage.cs index 77044af..f2c45c3 100644 --- a/Facepunch.Steamworks/Structs/UgcResultPage.cs +++ b/Facepunch.Steamworks/Structs/UgcResultPage.cs @@ -12,6 +12,7 @@ public struct ResultPage : System.IDisposable public bool CachedData; + internal bool ReturnsKeyValueTags; public IEnumerable Entries { get @@ -43,9 +44,21 @@ public IEnumerable Entries item.PreviewImageUrl = preview; } + if ( ReturnsKeyValueTags ) + { + var keyValueTagsCount = SteamUGC.Internal.GetQueryUGCNumKeyValueTags( Handle, i ); + + item.KeyValueTags = new Dictionary( (int)keyValueTagsCount ); + for ( uint j = 0; j < keyValueTagsCount; j++ ) + { + string key, value; + if ( SteamUGC.Internal.GetQueryUGCKeyValueTag( Handle, i, j, out key, out value ) ) + item.KeyValueTags[key] = value; + } + } + // TODO GetQueryUGCAdditionalPreview // TODO GetQueryUGCChildren - // TODO GetQueryUGCKeyValueTag // TODO GetQueryUGCMetadata