Added missing public methods for various functions in ISteamUGC. Fixed UGC Submit process reporting invalid progress value.

This commit is contained in:
Alex Mein 2019-10-16 14:41:57 +01:00
parent 06169693d0
commit 455a9f8956
4 changed files with 79 additions and 5 deletions

View File

@ -69,6 +69,8 @@ namespace Steamworks.Ugc
public Editor WithPrivateVisibility() { Visibility = RemoteStoragePublishedFileVisibility.Private; return this; } public Editor WithPrivateVisibility() { Visibility = RemoteStoragePublishedFileVisibility.Private; return this; }
List<string> Tags; List<string> Tags;
Dictionary<string, string> KeyValueTags;
public Editor WithTag( string tag ) public Editor WithTag( string tag )
{ {
if ( Tags == null ) Tags = new List<string>(); if ( Tags == null ) Tags = new List<string>();
@ -78,6 +80,13 @@ namespace Steamworks.Ugc
return this; return this;
} }
public Editor AddKeyValueTag(string key, string value)
{
if (KeyValueTags == null) KeyValueTags = new Dictionary<string, string>();
KeyValueTags.Add(key, value);
return this;
}
public async Task<PublishResult> SubmitAsync( IProgress<float> progress = null ) public async Task<PublishResult> SubmitAsync( IProgress<float> progress = null )
{ {
var result = default( PublishResult ); var result = default( PublishResult );
@ -134,6 +143,14 @@ namespace Steamworks.Ugc
} }
} }
if (KeyValueTags != null && KeyValueTags.Count > 0)
{
foreach (var keyValueTag in KeyValueTags)
{
SteamUGC.Internal.AddItemKeyValueTag(handle, keyValueTag.Key, keyValueTag.Value);
}
}
result.Result = Steamworks.Result.Fail; result.Result = Steamworks.Result.Fail;
if ( ChangeLog == null ) if ( ChangeLog == null )
@ -171,7 +188,7 @@ namespace Steamworks.Ugc
} }
case ItemUpdateStatus.UploadingPreviewFile: case ItemUpdateStatus.UploadingPreviewFile:
{ {
progress?.Report( 8f ); progress?.Report( 0.8f );
break; break;
} }
case ItemUpdateStatus.CommittingChanges: case ItemUpdateStatus.CommittingChanges:

View File

@ -263,6 +263,24 @@ namespace Steamworks.Ugc
return result?.Result == Result.OK; return result?.Result == Result.OK;
} }
/// <summary>
/// Adds item to user favorite list
/// </summary>
public async Task<bool> AddFavorite()
{
var result = await SteamUGC.Internal.AddItemToFavorites(details.ConsumerAppID, _id);
return result?.Result == Result.OK;
}
/// <summary>
/// Removes item from user favorite list
/// </summary>
public async Task<bool> RemoveFavorite()
{
var result = await SteamUGC.Internal.RemoveItemFromFavorites(details.ConsumerAppID, _id);
return result?.Result == Result.OK;
}
/// <summary> /// <summary>
/// Allows the user to rate a workshop item up or down. /// Allows the user to rate a workshop item up or down.
/// </summary> /// </summary>
@ -272,6 +290,17 @@ namespace Steamworks.Ugc
return r?.Result == Result.OK; return r?.Result == Result.OK;
} }
/// <summary>
/// Gets the current users vote on the item
/// </summary>
public async Task<UserItemVote?> GetUserVote()
{
var result = await SteamUGC.Internal.GetUserItemVote(_id);
if (!result.HasValue)
return null;
return UserItemVote.From(result.Value);
}
/// <summary> /// <summary>
/// Return a URL to view this item online /// Return a URL to view this item online
/// </summary> /// </summary>

View File

@ -194,6 +194,13 @@ namespace Steamworks.Ugc
return this; return this;
} }
public QueryType AddRequiredKeyValueTag(string key, string value)
{
if (requiredKv == null) requiredKv = new Dictionary<string, string>();
requiredKv.Add(key, value);
return this;
}
public QueryType WithoutTag( string tag ) public QueryType WithoutTag( string tag )
{ {
if ( excludedTags == null ) excludedTags = new List<string>(); if ( excludedTags == null ) excludedTags = new List<string>();

View File

@ -0,0 +1,21 @@
using Steamworks.Data;
namespace Steamworks.Ugc
{
public struct UserItemVote
{
public bool VotedUp;
public bool VotedDown;
public bool VoteSkipped;
internal static UserItemVote? From(GetUserItemVoteResult_t result)
{
return new UserItemVote
{
VotedUp = result.VotedUp,
VotedDown = result.VotedDown,
VoteSkipped = result.VoteSkipped
};
}
}
}