From f549a69bc00509865e8aa7d4714a9a3c621db126 Mon Sep 17 00:00:00 2001 From: Alex Mein Date: Fri, 18 Oct 2019 10:07:18 +0100 Subject: [PATCH] Added proper implementation of the various 'setreturn...' methods which previously did nothing --- Facepunch.Steamworks/Structs/UgcQuery.cs | 93 +++++++++++++++++++----- 1 file changed, 73 insertions(+), 20 deletions(-) diff --git a/Facepunch.Steamworks/Structs/UgcQuery.cs b/Facepunch.Steamworks/Structs/UgcQuery.cs index 6bfd5ce..986bdcd 100644 --- a/Facepunch.Steamworks/Structs/UgcQuery.cs +++ b/Facepunch.Steamworks/Structs/UgcQuery.cs @@ -127,6 +127,13 @@ public Query WithFileId( params PublishedFileId[] files ) handle = SteamUGC.Internal.CreateQueryAllUGCRequest1( queryType, matchingType, creatorApp.Value, consumerApp.Value, (uint)page ); } + ApplyReturns(handle); + + if (maxCacheAge.HasValue) + { + SteamUGC.Internal.SetAllowCachedResponse(handle, (uint)maxCacheAge.Value); + } + ApplyConstraints( handle ); var result = await SteamUGC.Internal.SendQueryUGCRequest( handle ); @@ -145,25 +152,8 @@ public Query WithFileId( params PublishedFileId[] files ) }; } - - #region SharedConstraints + #region SharedConstraints public QueryType WithType( UgcType type ) { matchingType = type; return this; } - bool? WantsReturnOnlyIDs; - public QueryType WithOnlyIDs( bool b ) { WantsReturnOnlyIDs = b; return this; } - bool? WantsReturnKeyValueTags; - public QueryType WithKeyValueTag( bool b ) { WantsReturnKeyValueTags = b; return this; } - bool? WantsReturnLongDescription; - public QueryType WithLongDescription( bool b ) { WantsReturnLongDescription = b; return this; } - bool? WantsReturnMetadata; - public QueryType WithMetadata( bool b ) { WantsReturnMetadata = b; return this; } - bool? WantsReturnChildren; - public QueryType WithChildren( bool b ) { WantsReturnChildren = b; return this; } - bool? WantsReturnAdditionalPreviews; - public QueryType WithAdditionalPreviews( bool b ) { WantsReturnAdditionalPreviews = b; return this; } - bool? WantsReturnTotalOnly; - public QueryType WithTotalOnly( bool b ) { WantsReturnTotalOnly = b; return this; } - bool? WantsReturnPlaytimeStats; - public QueryType WithPlaytimeStats( bool b ) { WantsReturnPlaytimeStats = b; return this; } int? maxCacheAge; public QueryType AllowCachedResponse( int maxSecondsAge ) { maxCacheAge = maxSecondsAge; return this; } string language; @@ -244,7 +234,70 @@ void ApplyConstraints( UGCQueryHandle_t handle ) } } - #endregion + #endregion - } + #region ReturnValues + + bool? WantsReturnOnlyIDs; + public QueryType WithOnlyIDs(bool b) { WantsReturnOnlyIDs = b; return this; } + bool? WantsReturnKeyValueTags; + public QueryType WithKeyValueTag(bool b) { WantsReturnKeyValueTags = b; return this; } + bool? WantsReturnLongDescription; + public QueryType WithLongDescription(bool b) { WantsReturnLongDescription = b; return this; } + bool? WantsReturnMetadata; + public QueryType WithMetadata(bool b) { WantsReturnMetadata = b; return this; } + bool? WantsReturnChildren; + public QueryType WithChildren(bool b) { WantsReturnChildren = b; return this; } + bool? WantsReturnAdditionalPreviews; + public QueryType WithAdditionalPreviews(bool b) { WantsReturnAdditionalPreviews = b; return this; } + bool? WantsReturnTotalOnly; + public QueryType WithTotalOnly(bool b) { WantsReturnTotalOnly = b; return this; } + uint? WantsReturnPlaytimeStats; + public QueryType WithPlaytimeStats(uint unDays) { WantsReturnPlaytimeStats = unDays; return this; } + + private void ApplyReturns(UGCQueryHandle_t handle) + { + if (WantsReturnOnlyIDs.HasValue) + { + SteamUGC.Internal.SetReturnOnlyIDs(handle, WantsReturnOnlyIDs.Value); + } + + if (WantsReturnKeyValueTags.HasValue) + { + SteamUGC.Internal.SetReturnKeyValueTags(handle, WantsReturnKeyValueTags.Value); + } + + if (WantsReturnLongDescription.HasValue) + { + SteamUGC.Internal.SetReturnLongDescription(handle, WantsReturnLongDescription.Value); + } + + if (WantsReturnMetadata.HasValue) + { + SteamUGC.Internal.SetReturnMetadata(handle, WantsReturnMetadata.Value); + } + + if (WantsReturnChildren.HasValue) + { + SteamUGC.Internal.SetReturnChildren(handle, WantsReturnChildren.Value); + } + + if (WantsReturnAdditionalPreviews.HasValue) + { + SteamUGC.Internal.SetReturnAdditionalPreviews(handle, WantsReturnAdditionalPreviews.Value); + } + + if (WantsReturnTotalOnly.HasValue) + { + SteamUGC.Internal.SetReturnTotalOnly(handle, WantsReturnTotalOnly.Value); + } + + if (WantsReturnPlaytimeStats.HasValue) + { + SteamUGC.Internal.SetReturnPlaytimeStats(handle, WantsReturnPlaytimeStats.Value); + } + } + + #endregion + } } \ No newline at end of file