mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 22:58:01 +03:00
Progress - will do for now
This commit is contained in:
parent
e275b209b3
commit
39705d5a2a
@ -30,10 +30,23 @@ namespace Steamworks
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ProgressBar : IProgress<float>
|
||||||
|
{
|
||||||
|
float Value = 0;
|
||||||
|
|
||||||
|
public void Report( float value )
|
||||||
|
{
|
||||||
|
if ( Value >= value ) return;
|
||||||
|
|
||||||
|
Value = value;
|
||||||
|
|
||||||
|
Console.WriteLine( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task UploadBigFile()
|
public async Task UploadBigFile()
|
||||||
{
|
{
|
||||||
|
|
||||||
var created = Ugc.Editor.NewCommunityFile
|
var created = Ugc.Editor.NewCommunityFile
|
||||||
.WithTitle( "Unit Test Upload Item" )
|
.WithTitle( "Unit Test Upload Item" )
|
||||||
.WithDescription( "This item was created by Facepunch Steamworks unit tests.\n\n" +
|
.WithDescription( "This item was created by Facepunch Steamworks unit tests.\n\n" +
|
||||||
@ -60,9 +73,7 @@ namespace Steamworks
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var done = await created.SubmitAsync();
|
var done = await created.SubmitAsync( new ProgressBar() );
|
||||||
|
|
||||||
// TODO - Upload Progress
|
|
||||||
|
|
||||||
Assert.IsTrue( done.Success );
|
Assert.IsTrue( done.Success );
|
||||||
Console.WriteLine( "item.Id: {0}", done.FileId );
|
Console.WriteLine( "item.Id: {0}", done.FileId );
|
||||||
|
@ -52,10 +52,12 @@ namespace Steamworks.Ugc
|
|||||||
public Editor WithContent( string folderName ) { return WithContent( new System.IO.DirectoryInfo( folderName ) ); }
|
public Editor WithContent( string folderName ) { return WithContent( new System.IO.DirectoryInfo( folderName ) ); }
|
||||||
|
|
||||||
|
|
||||||
public async Task<PublishResult> SubmitAsync()
|
public async Task<PublishResult> SubmitAsync( IProgress<float> progress = null )
|
||||||
{
|
{
|
||||||
var result = default( PublishResult );
|
var result = default( PublishResult );
|
||||||
|
|
||||||
|
progress?.Report( 0 );
|
||||||
|
|
||||||
//
|
//
|
||||||
// Item Create
|
// Item Create
|
||||||
//
|
//
|
||||||
@ -77,10 +79,9 @@ namespace Steamworks.Ugc
|
|||||||
fileId = created.Value.PublishedFileId;
|
fileId = created.Value.PublishedFileId;
|
||||||
result.NeedsWorkshopAgreement = created.Value.UserNeedsToAcceptWorkshopLegalAgreement;
|
result.NeedsWorkshopAgreement = created.Value.UserNeedsToAcceptWorkshopLegalAgreement;
|
||||||
result.FileId = fileId;
|
result.FileId = fileId;
|
||||||
|
|
||||||
await Task.Delay( 500 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
result.FileId = fileId;
|
result.FileId = fileId;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -99,7 +100,56 @@ namespace Steamworks.Ugc
|
|||||||
|
|
||||||
result.Result = Steamworks.Result.Fail;
|
result.Result = Steamworks.Result.Fail;
|
||||||
|
|
||||||
var updated = await SteamUGC.Internal.SubmitItemUpdate( handle, "" );
|
var updating = SteamUGC.Internal.SubmitItemUpdate( handle, "" );
|
||||||
|
|
||||||
|
while ( !updating.IsCompleted )
|
||||||
|
{
|
||||||
|
if ( progress != null )
|
||||||
|
{
|
||||||
|
ulong total = 0;
|
||||||
|
ulong processed = 0;
|
||||||
|
|
||||||
|
var r = SteamUGC.Internal.GetItemUpdateProgress( handle, ref processed, ref total );
|
||||||
|
|
||||||
|
switch ( r )
|
||||||
|
{
|
||||||
|
case ItemUpdateStatus.PreparingConfig:
|
||||||
|
{
|
||||||
|
progress?.Report( 0.1f );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ItemUpdateStatus.PreparingContent:
|
||||||
|
{
|
||||||
|
progress?.Report( 0.2f );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ItemUpdateStatus.UploadingContent:
|
||||||
|
{
|
||||||
|
var uploaded = total > 0 ? ((float)processed / (float)total) : 0.0f;
|
||||||
|
progress?.Report( 0.2f + uploaded * 0.7f );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ItemUpdateStatus.UploadingPreviewFile:
|
||||||
|
{
|
||||||
|
progress?.Report( 8f );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ItemUpdateStatus.CommittingChanges:
|
||||||
|
{
|
||||||
|
progress?.Report( 1 );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.Delay( 1000 / 60 );
|
||||||
|
}
|
||||||
|
|
||||||
|
progress?.Report( 1 );
|
||||||
|
|
||||||
|
var updated = updating.Result;
|
||||||
|
|
||||||
if ( !updated.HasValue ) return result;
|
if ( !updated.HasValue ) return result;
|
||||||
|
|
||||||
result.Result = updated.Value.Result;
|
result.Result = updated.Value.Result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user