(965c31410a) Unstable v0.10.4.0
This commit is contained in:
@@ -14,29 +14,36 @@ namespace Steamworks.Ugc
|
||||
public PublishedFileId FileId { get; private set; }
|
||||
|
||||
bool creatingNew;
|
||||
WorkshopFileType creatingType;
|
||||
AppId consumerAppId;
|
||||
|
||||
internal Editor(WorkshopFileType filetype) : this()
|
||||
{
|
||||
this.creatingNew = true;
|
||||
this.creatingType = filetype;
|
||||
}
|
||||
WorkshopFileType creatingType;
|
||||
AppId consumerAppId;
|
||||
|
||||
public Editor(PublishedFileId fileId) : this()
|
||||
{
|
||||
this.FileId = fileId;
|
||||
}
|
||||
internal Editor( WorkshopFileType filetype ) : this()
|
||||
{
|
||||
this.creatingNew = true;
|
||||
this.creatingType = filetype;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a Normal Workshop item that can be subscribed to
|
||||
/// </summary>
|
||||
public static Editor CreateCommunityFile() { return new Editor(WorkshopFileType.Community); }
|
||||
public Editor( PublishedFileId fileId ) : this()
|
||||
{
|
||||
this.FileId = fileId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Workshop item that is meant to be voted on for the purpose of selling in-game
|
||||
/// </summary>
|
||||
public static Editor CreateMicrotransactionFile() { return new Editor(WorkshopFileType.Microtransaction ); }
|
||||
/// <summary>
|
||||
/// Create a Normal Workshop item that can be subscribed to
|
||||
/// </summary>
|
||||
public static Editor NewCommunityFile => new Editor( WorkshopFileType.Community );
|
||||
|
||||
/// <summary>
|
||||
/// Create a Collection
|
||||
/// Add items using Item.AddDependency()
|
||||
/// </summary>
|
||||
public static Editor NewCollection => new Editor( WorkshopFileType.Collection );
|
||||
|
||||
/// <summary>
|
||||
/// Workshop item that is meant to be voted on for the purpose of selling in-game
|
||||
/// </summary>
|
||||
public static Editor NewMicrotransactionFile => new Editor( WorkshopFileType.Microtransaction );
|
||||
|
||||
public Editor ForAppId( AppId id ) { this.consumerAppId = id; return this; }
|
||||
|
||||
@@ -68,11 +75,14 @@ namespace Steamworks.Ugc
|
||||
public Editor WithFriendsOnlyVisibility() { Visibility = RemoteStoragePublishedFileVisibility.FriendsOnly; return this; }
|
||||
public Editor WithPrivateVisibility() { Visibility = RemoteStoragePublishedFileVisibility.Private; return this; }
|
||||
|
||||
public List<string> Tags { get; private set; }
|
||||
Dictionary<string, List<string>> KeyValueTags;
|
||||
HashSet<string> KeyValueTagsToRemove;
|
||||
|
||||
public bool IsPublic => Visibility == RemoteStoragePublishedFileVisibility.Public;
|
||||
public bool IsFriendsOnly => Visibility == RemoteStoragePublishedFileVisibility.FriendsOnly;
|
||||
public bool IsPrivate => Visibility == RemoteStoragePublishedFileVisibility.Private;
|
||||
|
||||
public List<string> Tags { get; private set; }
|
||||
public Editor WithTag( string tag )
|
||||
{
|
||||
if ( Tags == null ) Tags = new List<string>();
|
||||
@@ -82,22 +92,56 @@ namespace Steamworks.Ugc
|
||||
return this;
|
||||
}
|
||||
|
||||
public Editor WithTags( IEnumerable<string> tags )
|
||||
{
|
||||
if (Tags == null) Tags = new List<string>();
|
||||
public Editor WithTags(IEnumerable<string> tags)
|
||||
{
|
||||
if (Tags == null) Tags = new List<string>();
|
||||
|
||||
Tags.AddRange(tags);
|
||||
Tags.AddRange(tags);
|
||||
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Editor WithoutTag( string tag )
|
||||
public Editor WithoutTag(string tag)
|
||||
{
|
||||
if (Tags != null && Tags.Contains(tag)) Tags.Remove(tag);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a key-value tag pair to an item.
|
||||
/// Keys can map to multiple different values (1-to-many relationship).
|
||||
/// Key names are restricted to alpha-numeric characters and the '_' character.
|
||||
/// Both keys and values cannot exceed 255 characters in length. Key-value tags are searchable by exact match only.
|
||||
/// To replace all values associated to one key use RemoveKeyValueTags then AddKeyValueTag.
|
||||
/// </summary>
|
||||
public Editor AddKeyValueTag(string key, string value)
|
||||
{
|
||||
if (KeyValueTags == null)
|
||||
KeyValueTags = new Dictionary<string, List<string>>();
|
||||
|
||||
if ( KeyValueTags.TryGetValue( key, out var list ) )
|
||||
list.Add( value );
|
||||
else
|
||||
KeyValueTags[key] = new List<string>() { value };
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a key and all values associated to it.
|
||||
/// You can remove up to 100 keys per item update.
|
||||
/// If you need remove more tags than that you'll need to make subsequent item updates.
|
||||
/// </summary>
|
||||
public Editor RemoveKeyValueTags(string key)
|
||||
{
|
||||
if (KeyValueTagsToRemove == null)
|
||||
KeyValueTagsToRemove = new HashSet<string>();
|
||||
|
||||
KeyValueTagsToRemove.Add(key);
|
||||
return this;
|
||||
}
|
||||
|
||||
public bool HasTag( string tag )
|
||||
{
|
||||
if (Tags != null && Tags.Contains(tag)) { return true; }
|
||||
@@ -114,6 +158,19 @@ namespace Steamworks.Ugc
|
||||
if ( consumerAppId == 0 )
|
||||
consumerAppId = SteamClient.AppId;
|
||||
|
||||
//
|
||||
// Checks
|
||||
//
|
||||
if ( ContentFolder != null )
|
||||
{
|
||||
if ( !System.IO.Directory.Exists( ContentFolder.FullName ) )
|
||||
throw new System.Exception( $"UgcEditor - Content Folder doesn't exist ({ContentFolder.FullName})" );
|
||||
|
||||
if ( !ContentFolder.EnumerateFiles( "*", System.IO.SearchOption.AllDirectories ).Any() )
|
||||
throw new System.Exception( $"UgcEditor - Content Folder is empty" );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Item Create
|
||||
//
|
||||
@@ -160,6 +217,22 @@ namespace Steamworks.Ugc
|
||||
}
|
||||
}
|
||||
|
||||
if ( KeyValueTagsToRemove != null)
|
||||
{
|
||||
foreach ( var key in KeyValueTagsToRemove )
|
||||
SteamUGC.Internal.RemoveItemKeyValueTags( handle, key );
|
||||
}
|
||||
|
||||
if ( KeyValueTags != null )
|
||||
{
|
||||
foreach ( var keyWithValues in KeyValueTags )
|
||||
{
|
||||
var key = keyWithValues.Key;
|
||||
foreach ( var value in keyWithValues.Value )
|
||||
SteamUGC.Internal.AddItemKeyValueTag( handle, key, value );
|
||||
}
|
||||
}
|
||||
|
||||
result.Result = Steamworks.Result.Fail;
|
||||
|
||||
if ( ChangeLog == null )
|
||||
@@ -197,7 +270,7 @@ namespace Steamworks.Ugc
|
||||
}
|
||||
case ItemUpdateStatus.UploadingPreviewFile:
|
||||
{
|
||||
progress?.Report( 8f );
|
||||
progress?.Report( 0.8f );
|
||||
break;
|
||||
}
|
||||
case ItemUpdateStatus.CommittingChanges:
|
||||
@@ -213,7 +286,7 @@ namespace Steamworks.Ugc
|
||||
|
||||
progress?.Report( 1 );
|
||||
|
||||
var updated = updating.Result;
|
||||
var updated = updating.GetResult();
|
||||
|
||||
if ( !updated.HasValue ) return result;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user