Added Ugc.Item.Edit()

This commit is contained in:
Garry Newman 2019-05-10 10:43:03 +01:00
parent 1980a2106a
commit 586f4ee6f2
5 changed files with 73 additions and 8 deletions

View File

@ -90,6 +90,59 @@ public async Task UploadBigishFile()
}
}
[TestMethod]
public async Task CreateAndThenEditFile()
{
PublishedFileId fileid = default;
//
// Make a file
//
{
var result = await Ugc.Editor.NewCommunityFile
.WithTitle( "Unedited File" )
.SubmitAsync();
Assert.IsTrue( result.Success );
Assert.AreNotEqual( result.FileId.Value, 0 );
fileid = result.FileId;
}
await Task.Delay( 1000 );
//
// Edit it
//
{
var editor = new Ugc.Editor( fileid );
editor = editor.WithTitle( "An Edited File" );
var result = await editor.SubmitAsync();
Assert.IsTrue( result.Success );
Assert.AreEqual( result.FileId, fileid );
}
await Task.Delay( 1000 );
//
// Make sure the edited file matches
//
{
var details = await SteamUGC.QueryFileAsync( fileid ) ?? throw new Exception( "Somethign went wrong" );
Assert.AreEqual( details.Id, fileid );
Assert.AreEqual( details.Title, "An Edited File" );
}
//
// Clean up
//
var deleted = await SteamUGC.DeleteFileAsync( fileid );
Assert.IsTrue( deleted );
}
}
}

View File

@ -32,6 +32,8 @@ public async Task GetInformation()
Console.WriteLine( $"IsSubscribed: {itemInfo?.IsSubscribed}" );
Console.WriteLine( $"NeedsUpdate: {itemInfo?.NeedsUpdate}" );
Console.WriteLine( $"Description: {itemInfo?.Description}" );
Console.WriteLine( $"Owner: {itemInfo?.Owner}" );
Console.WriteLine( $"Score: {itemInfo?.Score}" );
}
}
}

View File

@ -3,7 +3,6 @@
public struct Socket
{
internal uint Id;
public override string ToString() => Id.ToString();
/// <summary>

View File

@ -19,8 +19,13 @@ public struct Editor
internal Editor( WorkshopFileType filetype ) : this()
{
creatingNew = true;
creatingType = filetype;
this.creatingNew = true;
this.creatingType = filetype;
}
public Editor( PublishedFileId fileId ) : this()
{
this.fileId = fileId;
}
/// <summary>
@ -35,7 +40,6 @@ internal Editor( WorkshopFileType filetype ) : this()
public Editor ForAppId( AppId id ) { this.consumerAppId = id; return this; }
string Title;
public Editor WithTitle( string t ) { this.Title = t; return this; }
@ -80,14 +84,14 @@ public async Task<PublishResult> SubmitAsync( IProgress<float> progress = null )
progress?.Report( 0 );
if ( consumerAppId == 0 )
consumerAppId = SteamClient.AppId;
//
// Item Create
//
if ( creatingNew )
{
if ( consumerAppId == 0 )
consumerAppId = SteamClient.AppId;
result.Result = Steamworks.Result.Fail;
var created = await SteamUGC.Internal.CreateItem( consumerAppId, creatingType );

View File

@ -18,7 +18,6 @@ public Item( PublishedFileId id ) : this()
_id = id;
}
/// <summary>
/// The actual ID of this file
/// </summary>
@ -206,6 +205,14 @@ public async Task<bool> Vote( bool up )
/// The URL to the preview image for this item
/// </summary>
public string PreviewImageUrl { get; internal set; }
/// <summary>
/// Edit this item
/// </summary>
public Ugc.Editor Edit()
{
return new Ugc.Editor( Id );
}
}
}