mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 13:45:37 +03:00
Added Workshop.Editor.OnChangesSubmitted event
This commit is contained in:
parent
46f56c24f3
commit
2e8fe41040
@ -4,6 +4,7 @@
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using Facepunch.Steamworks.Callbacks;
|
||||||
|
|
||||||
namespace Facepunch.Steamworks.Test
|
namespace Facepunch.Steamworks.Test
|
||||||
{
|
{
|
||||||
@ -452,6 +453,12 @@ public void CreatePublish()
|
|||||||
|
|
||||||
Console.WriteLine(item.Folder);
|
Console.WriteLine(item.Folder);
|
||||||
|
|
||||||
|
item.OnChangesSubmitted += result =>
|
||||||
|
{
|
||||||
|
Console.WriteLine( "OnChangesSubmitted called: " + result );
|
||||||
|
Assert.AreEqual( Result.OK, result );
|
||||||
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
item.Publish();
|
item.Publish();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SteamNative;
|
using SteamNative;
|
||||||
|
using Result = Facepunch.Steamworks.Callbacks.Result;
|
||||||
|
|
||||||
namespace Facepunch.Steamworks
|
namespace Facepunch.Steamworks
|
||||||
{
|
{
|
||||||
@ -37,7 +38,10 @@ public enum VisibilityType : int
|
|||||||
|
|
||||||
public bool NeedToAgreeToWorkshopLegal { get; internal set; }
|
public bool NeedToAgreeToWorkshopLegal { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when published changes have finished being submitted.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<Result> OnChangesSubmitted;
|
||||||
|
|
||||||
public double Progress
|
public double Progress
|
||||||
{
|
{
|
||||||
@ -119,13 +123,16 @@ private void OnItemCreated( SteamNative.CreateItemResult_t obj, bool Failed )
|
|||||||
|
|
||||||
if ( obj.Result == SteamNative.Result.OK && !Failed )
|
if ( obj.Result == SteamNative.Result.OK && !Failed )
|
||||||
{
|
{
|
||||||
|
Error = null;
|
||||||
Id = obj.PublishedFileId;
|
Id = obj.PublishedFileId;
|
||||||
PublishChanges();
|
PublishChanges();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error = "Error creating new file: " + obj.Result.ToString() + "("+ obj.PublishedFileId+ ")";
|
Error = $"Error creating new file: {obj.Result} ({obj.PublishedFileId})";
|
||||||
Publishing = false;
|
Publishing = false;
|
||||||
|
|
||||||
|
OnChangesSubmitted?.Invoke( (Result) obj.Result );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PublishChanges()
|
private void PublishChanges()
|
||||||
@ -179,10 +186,10 @@ private void PublishChanges()
|
|||||||
workshop.ugc.RemoveItemPreview( UpdateId, uint32 index ) = 0; // remove a preview by index starting at 0 (previews are sorted)
|
workshop.ugc.RemoveItemPreview( UpdateId, uint32 index ) = 0; // remove a preview by index starting at 0 (previews are sorted)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SubmitItemUpdate = workshop.ugc.SubmitItemUpdate( UpdateHandle, ChangeNote, OnChangesSubmitted );
|
SubmitItemUpdate = workshop.ugc.SubmitItemUpdate( UpdateHandle, ChangeNote, OnChangesSubmittedInternal );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnChangesSubmitted( SteamNative.SubmitItemUpdateResult_t obj, bool Failed )
|
private void OnChangesSubmittedInternal( SteamNative.SubmitItemUpdateResult_t obj, bool Failed )
|
||||||
{
|
{
|
||||||
if ( Failed )
|
if ( Failed )
|
||||||
throw new System.Exception( "CreateItemResult_t Failed" );
|
throw new System.Exception( "CreateItemResult_t Failed" );
|
||||||
@ -192,12 +199,11 @@ private void OnChangesSubmitted( SteamNative.SubmitItemUpdateResult_t obj, bool
|
|||||||
NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement;
|
NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement;
|
||||||
Publishing = false;
|
Publishing = false;
|
||||||
|
|
||||||
if ( obj.Result == SteamNative.Result.OK )
|
Error = obj.Result != SteamNative.Result.OK
|
||||||
{
|
? $"Error publishing changes: {obj.Result} ({NeedToAgreeToWorkshopLegal})"
|
||||||
return;
|
: null;
|
||||||
}
|
|
||||||
|
|
||||||
Error = "Error publishing changes: " + obj.Result.ToString() + " ("+ NeedToAgreeToWorkshopLegal + ")";
|
OnChangesSubmitted?.Invoke( (Result) obj.Result );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete()
|
public void Delete()
|
||||||
|
Loading…
Reference in New Issue
Block a user