From 6e2ab8b735cd14f9488784d1080d8627f1b4b659 Mon Sep 17 00:00:00 2001 From: kamyker Date: Tue, 9 Jun 2020 00:22:54 +0200 Subject: [PATCH 1/3] Add/Remove ws item dependency --- Facepunch.Steamworks/Structs/UgcItem.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Facepunch.Steamworks/Structs/UgcItem.cs b/Facepunch.Steamworks/Structs/UgcItem.cs index a386486..b272267 100644 --- a/Facepunch.Steamworks/Structs/UgcItem.cs +++ b/Facepunch.Steamworks/Structs/UgcItem.cs @@ -382,7 +382,19 @@ namespace Steamworks.Ugc { return new Ugc.Editor( Id ); } - + + public async Task AddDependency( PublishedFileId child ) + { + var r = await SteamUGC.Internal.AddDependency( Id, child ); + return r?.Result == Result.OK; + } + + public async Task RemoveDependency( PublishedFileId child ) + { + var r = await SteamUGC.Internal.RemoveDependency( Id, child ); + return r?.Result == Result.OK; + } + public Result Result => details.Result; } } From 75dc868064091fa2e08b7e91271a8882b96a1f8f Mon Sep 17 00:00:00 2001 From: kamyker Date: Fri, 19 Jun 2020 10:02:36 +0200 Subject: [PATCH 2/3] getting dependencies/children --- Facepunch.Steamworks/Structs/UgcItem.cs | 4 ++++ Facepunch.Steamworks/Structs/UgcQuery.cs | 1 + Facepunch.Steamworks/Structs/UgcResultPage.cs | 11 ++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Facepunch.Steamworks/Structs/UgcItem.cs b/Facepunch.Steamworks/Structs/UgcItem.cs index b272267..08617ba 100644 --- a/Facepunch.Steamworks/Structs/UgcItem.cs +++ b/Facepunch.Steamworks/Structs/UgcItem.cs @@ -108,6 +108,10 @@ namespace Steamworks.Ugc /// The number of downvotes of this item /// public uint VotesDown => details.VotesDown; + /// + /// Dependencies/children of this item or collection, available only from WithDependencies(true) queries + /// + public PublishedFileId[] Children; public bool IsInstalled => (State & ItemState.Installed) == ItemState.Installed; public bool IsDownloading => (State & ItemState.Downloading) == ItemState.Downloading; diff --git a/Facepunch.Steamworks/Structs/UgcQuery.cs b/Facepunch.Steamworks/Structs/UgcQuery.cs index 7401225..eb8901a 100644 --- a/Facepunch.Steamworks/Structs/UgcQuery.cs +++ b/Facepunch.Steamworks/Structs/UgcQuery.cs @@ -152,6 +152,7 @@ namespace Steamworks.Ugc ReturnsKeyValueTags = WantsReturnKeyValueTags ?? false, ReturnsDefaultStats = WantsDefaultStats ?? true, //true by default ReturnsMetadata = WantsReturnMetadata ?? false, + ReturnsChildren = WantsReturnChildren ?? false, }; } diff --git a/Facepunch.Steamworks/Structs/UgcResultPage.cs b/Facepunch.Steamworks/Structs/UgcResultPage.cs index 86a6e2b..352f98a 100644 --- a/Facepunch.Steamworks/Structs/UgcResultPage.cs +++ b/Facepunch.Steamworks/Structs/UgcResultPage.cs @@ -15,6 +15,7 @@ namespace Steamworks.Ugc internal bool ReturnsKeyValueTags; internal bool ReturnsDefaultStats; internal bool ReturnsMetadata; + internal bool ReturnsChildren; public IEnumerable Entries { @@ -73,8 +74,16 @@ namespace Steamworks.Ugc } } + uint numChildren = item.details.NumChildren; + if ( ReturnsChildren && numChildren > 0 ) + { + var children = new PublishedFileId[numChildren]; + if ( SteamUGC.Internal.GetQueryUGCChildren( Handle, i, children, numChildren ) ) + { + item.Children = children; + } + } // TODO GetQueryUGCAdditionalPreview - // TODO GetQueryUGCChildren yield return item; } From 0d9db585f5ede77c68971b86b0db41fae7c14d50 Mon Sep 17 00:00:00 2001 From: kamyker Date: Fri, 28 Aug 2020 13:10:57 +0200 Subject: [PATCH 3/3] Added ugc addtional previews --- .../Structs/UgcAdditionalPreview.cs | 33 +++++++++++++++++++ .../Structs/UgcAdditionalPreview.cs.meta | 11 +++++++ Facepunch.Steamworks/Structs/UgcItem.cs | 5 +++ Facepunch.Steamworks/Structs/UgcQuery.cs | 1 + Facepunch.Steamworks/Structs/UgcResultPage.cs | 23 ++++++++++++- 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 Facepunch.Steamworks/Structs/UgcAdditionalPreview.cs create mode 100644 Facepunch.Steamworks/Structs/UgcAdditionalPreview.cs.meta diff --git a/Facepunch.Steamworks/Structs/UgcAdditionalPreview.cs b/Facepunch.Steamworks/Structs/UgcAdditionalPreview.cs new file mode 100644 index 0000000..49e6e34 --- /dev/null +++ b/Facepunch.Steamworks/Structs/UgcAdditionalPreview.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Steamworks.Data +{ + public struct UgcAdditionalPreview + { + internal UgcAdditionalPreview( string urlOrVideoID, string originalFileName, ItemPreviewType itemPreviewType ) + { + this.UrlOrVideoID = urlOrVideoID; + this.OriginalFileName = originalFileName; + this.ItemPreviewType = itemPreviewType; + } + + public string UrlOrVideoID { get; private set; } + public string OriginalFileName { get; private set; } + internal ItemPreviewType ItemPreviewType { get; private set; } + + /// + /// Flags that specify the type of preview an item has: + /// Image = 0, + /// YouTubeVideo = 1, + /// Sketchfab = 2, + /// EnvironmentMap_HorizontalCross = 3, + /// EnvironmentMap_LatLong = 4, + /// ReservedMax = 255 + /// + public int GetItemPreviewType() => (int)ItemPreviewType; + } +} diff --git a/Facepunch.Steamworks/Structs/UgcAdditionalPreview.cs.meta b/Facepunch.Steamworks/Structs/UgcAdditionalPreview.cs.meta new file mode 100644 index 0000000..511f7d5 --- /dev/null +++ b/Facepunch.Steamworks/Structs/UgcAdditionalPreview.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 48f086235d5dbeb44bccbb40802e30fb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facepunch.Steamworks/Structs/UgcItem.cs b/Facepunch.Steamworks/Structs/UgcItem.cs index 08617ba..fb63898 100644 --- a/Facepunch.Steamworks/Structs/UgcItem.cs +++ b/Facepunch.Steamworks/Structs/UgcItem.cs @@ -113,6 +113,11 @@ namespace Steamworks.Ugc /// public PublishedFileId[] Children; + /// + /// Additional previews of this item or collection, available only from WithAdditionalPreviews(true) queries + /// + public UgcAdditionalPreview[] AdditionalPreviews { get; internal set; } + public bool IsInstalled => (State & ItemState.Installed) == ItemState.Installed; public bool IsDownloading => (State & ItemState.Downloading) == ItemState.Downloading; public bool IsDownloadPending => (State & ItemState.DownloadPending) == ItemState.DownloadPending; diff --git a/Facepunch.Steamworks/Structs/UgcQuery.cs b/Facepunch.Steamworks/Structs/UgcQuery.cs index eb8901a..79893bb 100644 --- a/Facepunch.Steamworks/Structs/UgcQuery.cs +++ b/Facepunch.Steamworks/Structs/UgcQuery.cs @@ -153,6 +153,7 @@ namespace Steamworks.Ugc ReturnsDefaultStats = WantsDefaultStats ?? true, //true by default ReturnsMetadata = WantsReturnMetadata ?? false, ReturnsChildren = WantsReturnChildren ?? false, + ReturnsAdditionalPreviews = WantsReturnAdditionalPreviews ?? false, }; } diff --git a/Facepunch.Steamworks/Structs/UgcResultPage.cs b/Facepunch.Steamworks/Structs/UgcResultPage.cs index 352f98a..03399b5 100644 --- a/Facepunch.Steamworks/Structs/UgcResultPage.cs +++ b/Facepunch.Steamworks/Structs/UgcResultPage.cs @@ -16,6 +16,7 @@ namespace Steamworks.Ugc internal bool ReturnsDefaultStats; internal bool ReturnsMetadata; internal bool ReturnsChildren; + internal bool ReturnsAdditionalPreviews; public IEnumerable Entries { @@ -83,7 +84,27 @@ namespace Steamworks.Ugc item.Children = children; } } - // TODO GetQueryUGCAdditionalPreview + + if ( ReturnsAdditionalPreviews ) + { + var previewsCount = SteamUGC.Internal.GetQueryUGCNumAdditionalPreviews( Handle, i ); + if ( previewsCount > 0 ) + { + item.AdditionalPreviews = new UgcAdditionalPreview[previewsCount]; + for ( uint j = 0; j < previewsCount; j++ ) + { + string previewUrlOrVideo; + string originalFileName; //what is this??? + ItemPreviewType previewType = default; + if ( SteamUGC.Internal.GetQueryUGCAdditionalPreview( + Handle, i, j, out previewUrlOrVideo, out originalFileName, ref previewType ) ) + { + item.AdditionalPreviews[j] = new UgcAdditionalPreview( + previewUrlOrVideo, originalFileName, previewType ); + } + } + } + } yield return item; }