From c4eff7f61a12f0cf33a3b568979e91e0e34ed6b7 Mon Sep 17 00:00:00 2001 From: Jannik Nickel Date: Sun, 23 Jun 2019 20:22:28 +0200 Subject: [PATCH 1/2] Added missing methods to UgcItem and UgcQuery Added Steamworks.Ugc.Query.WhereSearchText Added Steamworks.Ugc.Item.VotesUp Added Steamworks.Ugc.Item.VotesDown Added Steamworks.Ugc.Item.Subscribe Added Steamworks.Ugc.Item.Unsubscribe --- Facepunch.Steamworks/Structs/UgcItem.cs | 46 ++++++++++++++++++------ Facepunch.Steamworks/Structs/UgcQuery.cs | 8 +++++ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/Facepunch.Steamworks/Structs/UgcItem.cs b/Facepunch.Steamworks/Structs/UgcItem.cs index cb89ee8..aa28967 100644 --- a/Facepunch.Steamworks/Structs/UgcItem.cs +++ b/Facepunch.Steamworks/Structs/UgcItem.cs @@ -93,7 +93,17 @@ namespace Steamworks.Ugc /// public bool IsAcceptedForUse => details.AcceptedForUse; - public bool IsInstalled => (State & ItemState.Installed) == ItemState.Installed; + /// + /// The number of upvotes of this item + /// + public uint VotesUp => details.VotesUp; + + /// + /// The number of downvotes of this item + /// + public uint VotesDown => details.VotesDown; + + public bool IsInstalled => (State & ItemState.Installed) == ItemState.Installed; public bool IsDownloading => (State & ItemState.Downloading) == ItemState.Downloading; public bool IsDownloadPending => (State & ItemState.DownloadPending) == ItemState.DownloadPending; public bool IsSubscribed => (State & ItemState.Subscribed) == ItemState.Subscribed; @@ -122,7 +132,7 @@ namespace Steamworks.Ugc return SteamUGC.Internal.DownloadItem( Id, highPriority ); } - private ItemState State => (ItemState) SteamUGC.Internal.GetItemState( Id ); + private ItemState State => (ItemState) SteamUGC.Internal.GetItemState( Id ); public static async Task GetAsync( PublishedFileId id, int maxageseconds = 60 * 30 ) { @@ -156,10 +166,26 @@ namespace Steamworks.Ugc return Tags.Contains( find, StringComparer.OrdinalIgnoreCase ); } - /// - /// Allows the user to rate a workshop item up or down. - /// - public async Task Vote( bool up ) + /// + /// Allows the user to subscribe to this item + /// + public async Task Subscribe () + { + var result = await SteamUGC.Internal.SubscribeItem( _id ); + return result?.Result == Result.OK; + } + + /// + /// Allows the user to unsubscribe from this item + /// + public async Task Unsubscribe () + { + } + + /// + /// Allows the user to rate a workshop item up or down. + /// + public async Task Vote( bool up ) { var r = await SteamUGC.Internal.SetUserItemVote( Id, up ); return r?.Result == Result.OK; @@ -204,10 +230,10 @@ namespace Steamworks.Ugc public ulong NumSecondsPlayedDuringTimePeriod { get; internal set; } public ulong NumPlaytimeSessionsDuringTimePeriod { get; internal set; } - /// - /// The URL to the preview image for this item - /// - public string PreviewImageUrl { get; internal set; } + /// + /// The URL to the preview image for this item + /// + public string PreviewImageUrl { get; internal set; } /// /// Edit this item diff --git a/Facepunch.Steamworks/Structs/UgcQuery.cs b/Facepunch.Steamworks/Structs/UgcQuery.cs index 4302b55..e69ef1c 100644 --- a/Facepunch.Steamworks/Structs/UgcQuery.cs +++ b/Facepunch.Steamworks/Structs/UgcQuery.cs @@ -14,6 +14,7 @@ namespace Steamworks.Ugc UGCQuery queryType; AppId consumerApp; AppId creatorApp; + string searchText; public Query( UgcType type ) : this() { @@ -90,6 +91,8 @@ namespace Steamworks.Ugc public Query SortByVoteScore() { userSort = UserUGCListSortOrder.VoteScoreDesc; return this; } public Query SortByModeration() { userSort = UserUGCListSortOrder.ForModeration; return this; } + public Query WhereSearchText(string searchText) { this.searchText = searchText; return this; } + #endregion #region Files @@ -227,6 +230,11 @@ namespace Steamworks.Ugc { SteamUGC.Internal.SetRankedByTrendDays( handle, (uint)trendDays.Value ); } + + if ( !string.IsNullOrEmpty( searchText ) ) + { + SteamUGC.Internal.SetSearchText( handle, searchText ); + } } #endregion From 97b85172e222f43ab67a5b7bf5d08cf5c745a2aa Mon Sep 17 00:00:00 2001 From: Jannik Nickel Date: Sun, 23 Jun 2019 20:22:37 +0200 Subject: [PATCH 2/2] Update UgcItem.cs --- Facepunch.Steamworks/Structs/UgcItem.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Facepunch.Steamworks/Structs/UgcItem.cs b/Facepunch.Steamworks/Structs/UgcItem.cs index aa28967..58ac730 100644 --- a/Facepunch.Steamworks/Structs/UgcItem.cs +++ b/Facepunch.Steamworks/Structs/UgcItem.cs @@ -180,6 +180,8 @@ namespace Steamworks.Ugc /// public async Task Unsubscribe () { + var result = await SteamUGC.Internal.UnsubscribeItem( _id ); + return result?.Result == Result.OK; } ///