mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-13 23:28:11 +03:00
Added Ugc.Item.Edit()
This commit is contained in:
parent
1980a2106a
commit
586f4ee6f2
@ -90,6 +90,59 @@ namespace Steamworks
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[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 );
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ namespace Steamworks
|
|||||||
Console.WriteLine( $"IsSubscribed: {itemInfo?.IsSubscribed}" );
|
Console.WriteLine( $"IsSubscribed: {itemInfo?.IsSubscribed}" );
|
||||||
Console.WriteLine( $"NeedsUpdate: {itemInfo?.NeedsUpdate}" );
|
Console.WriteLine( $"NeedsUpdate: {itemInfo?.NeedsUpdate}" );
|
||||||
Console.WriteLine( $"Description: {itemInfo?.Description}" );
|
Console.WriteLine( $"Description: {itemInfo?.Description}" );
|
||||||
|
Console.WriteLine( $"Owner: {itemInfo?.Owner}" );
|
||||||
|
Console.WriteLine( $"Score: {itemInfo?.Score}" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
public struct Socket
|
public struct Socket
|
||||||
{
|
{
|
||||||
internal uint Id;
|
internal uint Id;
|
||||||
|
|
||||||
public override string ToString() => Id.ToString();
|
public override string ToString() => Id.ToString();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -19,8 +19,13 @@ namespace Steamworks.Ugc
|
|||||||
|
|
||||||
internal Editor( WorkshopFileType filetype ) : this()
|
internal Editor( WorkshopFileType filetype ) : this()
|
||||||
{
|
{
|
||||||
creatingNew = true;
|
this.creatingNew = true;
|
||||||
creatingType = filetype;
|
this.creatingType = filetype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Editor( PublishedFileId fileId ) : this()
|
||||||
|
{
|
||||||
|
this.fileId = fileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -35,7 +40,6 @@ namespace Steamworks.Ugc
|
|||||||
|
|
||||||
public Editor ForAppId( AppId id ) { this.consumerAppId = id; return this; }
|
public Editor ForAppId( AppId id ) { this.consumerAppId = id; return this; }
|
||||||
|
|
||||||
|
|
||||||
string Title;
|
string Title;
|
||||||
public Editor WithTitle( string t ) { this.Title = t; return this; }
|
public Editor WithTitle( string t ) { this.Title = t; return this; }
|
||||||
|
|
||||||
@ -80,14 +84,14 @@ namespace Steamworks.Ugc
|
|||||||
|
|
||||||
progress?.Report( 0 );
|
progress?.Report( 0 );
|
||||||
|
|
||||||
|
if ( consumerAppId == 0 )
|
||||||
|
consumerAppId = SteamClient.AppId;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Item Create
|
// Item Create
|
||||||
//
|
//
|
||||||
if ( creatingNew )
|
if ( creatingNew )
|
||||||
{
|
{
|
||||||
if ( consumerAppId == 0 )
|
|
||||||
consumerAppId = SteamClient.AppId;
|
|
||||||
|
|
||||||
result.Result = Steamworks.Result.Fail;
|
result.Result = Steamworks.Result.Fail;
|
||||||
|
|
||||||
var created = await SteamUGC.Internal.CreateItem( consumerAppId, creatingType );
|
var created = await SteamUGC.Internal.CreateItem( consumerAppId, creatingType );
|
||||||
|
@ -18,7 +18,6 @@ namespace Steamworks.Ugc
|
|||||||
_id = id;
|
_id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The actual ID of this file
|
/// The actual ID of this file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -206,6 +205,14 @@ namespace Steamworks.Ugc
|
|||||||
/// The URL to the preview image for this item
|
/// The URL to the preview image for this item
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PreviewImageUrl { get; internal set; }
|
public string PreviewImageUrl { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Edit this item
|
||||||
|
/// </summary>
|
||||||
|
public Ugc.Editor Edit()
|
||||||
|
{
|
||||||
|
return new Ugc.Editor( Id );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user