From 8afce3665f53a1f1120c3a4cf04f2e4f8672527c Mon Sep 17 00:00:00 2001 From: Lothsahn Date: Sun, 13 Aug 2023 23:20:47 -0400 Subject: [PATCH] Add support for 1:many KeyValueTags --- Facepunch.Steamworks/Structs/UgcItem.cs | 2 +- Facepunch.Steamworks/Structs/UgcResultPage.cs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Facepunch.Steamworks/Structs/UgcItem.cs b/Facepunch.Steamworks/Structs/UgcItem.cs index fb63898..66a1f6e 100644 --- a/Facepunch.Steamworks/Structs/UgcItem.cs +++ b/Facepunch.Steamworks/Structs/UgcItem.cs @@ -42,7 +42,7 @@ public Item( PublishedFileId id ) : this() /// /// A dictionary of key value tags for this item, only available from queries WithKeyValueTags(true) /// - public Dictionary KeyValueTags { get; internal set; } + public Dictionary> KeyValueTags { get; internal set; } /// /// App Id of the app that created this item diff --git a/Facepunch.Steamworks/Structs/UgcResultPage.cs b/Facepunch.Steamworks/Structs/UgcResultPage.cs index 03399b5..c3a7636 100644 --- a/Facepunch.Steamworks/Structs/UgcResultPage.cs +++ b/Facepunch.Steamworks/Structs/UgcResultPage.cs @@ -57,12 +57,20 @@ public IEnumerable Entries { var keyValueTagsCount = SteamUGC.Internal.GetQueryUGCNumKeyValueTags( Handle, i ); - item.KeyValueTags = new Dictionary( (int)keyValueTagsCount ); + 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; + { + if ( !item.KeyValueTags.TryGetValue( key, out List list ) ) + { + list = new List(); + item.KeyValueTags[key] = list; + } + + list.Add(value); + } } } @@ -131,4 +139,4 @@ public void Dispose() } } } -} \ No newline at end of file +}