Cache age / metadata for workshop queries

This commit is contained in:
James King 2019-09-14 14:21:35 +02:00
parent 79b73ff576
commit 55f98f6350
3 changed files with 17 additions and 4 deletions

View File

@ -26,7 +26,7 @@ public class Editor
public string Error { get; internal set; } = null;
public string ChangeNote { get; set; } = "";
public uint WorkshopUploadAppId { get; set; }
public string MetaData { get; set; } = null;
public string Metadata { get; set; } = null;
public Dictionary<string, string[]> KeyValues { get; set; } = new Dictionary<string, string[]>();
public enum VisibilityType : int
@ -182,9 +182,9 @@ private void PublishChanges()
workshop.ugc.SetItemPreview( UpdateHandle, PreviewImage );
}
if ( MetaData != null )
if ( Metadata != null )
{
workshop.ugc.SetItemMetadata( UpdateHandle, MetaData );
workshop.ugc.SetItemMetadata( UpdateHandle, Metadata );
}
if ( KeyValues != null )

View File

@ -229,6 +229,7 @@ public Editor Edit()
public int WebsiteViews { get; internal set; }
public int ReportScore { get; internal set; }
public string PreviewImageUrl { get; internal set; }
public string Metadata { get; internal set; }
string _ownerName = null;

View File

@ -35,8 +35,12 @@ public class Query : IDisposable
public ulong? UserId { get; set; }
public TimeSpan? MaxCacheAge { get; set; }
public bool ReturnKeyValueTags { get; set; }
public bool ReturnMetadata { get; set; }
/// <summary>
/// If order is RankedByTrend, this value represents how many days to take
/// into account.
@ -123,6 +127,10 @@ void RunInternal()
workshop.ugc.AddExcludedTag( Handle, tag );
workshop.ugc.SetReturnKeyValueTags( Handle, ReturnKeyValueTags );
workshop.ugc.SetReturnMetadata( Handle, ReturnMetadata );
if ( MaxCacheAge.HasValue )
workshop.ugc.SetAllowCachedResponse( Handle, (uint) MaxCacheAge.Value.TotalSeconds );
Callback = workshop.ugc.SendQueryUGCRequest( Handle, ResultCallback );
}
@ -160,10 +168,14 @@ void ResultCallback( SteamNative.SteamUGCQueryCompleted_t data, bool bFailed )
if ( ReturnKeyValueTags )
item.ReadKeyValueTags( data, (uint)i );
string url = null;
string url;
if ( workshop.ugc.GetQueryUGCPreviewURL( data.Handle, (uint)i, out url ) )
item.PreviewImageUrl = url;
string metadata;
if ( workshop.ugc.GetQueryUGCMetadata( data.Handle, (uint)i, out metadata ) )
item.Metadata = metadata;
_results.Add( item );
_resultsRemain--;