Ugc item key value tags

(cherry picked from commit a5386b358fec87911d2c4cd221d53b90f470bcf4)
This commit is contained in:
kamyker 2020-05-08 01:20:50 +02:00
parent 9b487aae0e
commit 392b57e18d
3 changed files with 23 additions and 2 deletions

View File

@ -39,6 +39,11 @@ public Item( PublishedFileId id ) : this()
/// </summary>
public string[] Tags { get; internal set; }
/// <summary>
/// A dictionary of key value tags for this item, only available from queries WithKeyValueTags(true)
/// </summary>
public Dictionary<string,string> KeyValueTags { get; internal set; }
/// <summary>
/// App Id of the app that created this item
/// </summary>

View File

@ -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;

View File

@ -12,6 +12,7 @@ public struct ResultPage : System.IDisposable
public bool CachedData;
internal bool ReturnsKeyValueTags;
public IEnumerable<Item> Entries
{
get
@ -43,9 +44,21 @@ public IEnumerable<Item> Entries
item.PreviewImageUrl = preview;
}
if ( ReturnsKeyValueTags )
{
var keyValueTagsCount = SteamUGC.Internal.GetQueryUGCNumKeyValueTags( Handle, i );
item.KeyValueTags = new Dictionary<string, string>( (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