From 2b4c62bd286746b15131e46c613765f41d1ae5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20M=C3=B6ller?= Date: Wed, 30 Aug 2017 23:35:47 +0200 Subject: [PATCH] Added support for publishing workshop items to the main app from another app. --- .../Interfaces/Workshop.Editor.cs | 5 +++-- Facepunch.Steamworks/Interfaces/Workshop.cs | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs b/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs index 761cb64..e57d2fa 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs @@ -24,6 +24,7 @@ namespace Facepunch.Steamworks public ItemType? Type { get; set; } public string Error { get; internal set; } = null; public string ChangeNote { get; set; } = ""; + public uint WorkshopUploadAppId { get; set; } public enum VisibilityType : int { @@ -109,7 +110,7 @@ namespace Facepunch.Steamworks if ( !Type.HasValue ) throw new System.Exception( "Editor.Type must be set when creating a new item!" ); - CreateItem = workshop.ugc.CreateItem( workshop.steamworks.AppId, (SteamNative.WorkshopFileType)(uint)Type, OnItemCreated ); + CreateItem = workshop.ugc.CreateItem( WorkshopUploadAppId, (SteamNative.WorkshopFileType)(uint)Type, OnItemCreated ); } private void OnItemCreated( SteamNative.CreateItemResult_t obj, bool Failed ) @@ -130,7 +131,7 @@ namespace Facepunch.Steamworks private void PublishChanges() { - UpdateHandle = workshop.ugc.StartItemUpdate( workshop.steamworks.AppId, Id ); + UpdateHandle = workshop.ugc.StartItemUpdate(WorkshopUploadAppId, Id ); if ( Title != null ) workshop.ugc.SetItemTitle( UpdateHandle, Title ); diff --git a/Facepunch.Steamworks/Interfaces/Workshop.cs b/Facepunch.Steamworks/Interfaces/Workshop.cs index e35bc4b..c32713a 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.cs @@ -98,9 +98,20 @@ namespace Facepunch.Steamworks /// public Editor CreateItem( ItemType type ) { - return new Editor() { workshop = this, Type = type }; + return CreateItem(this.steamworks.AppId, type); } - + + /// + /// Create a new Editor object with the intention of creating a new item. + /// Your item won't actually be created until you call Publish() on the object. + /// Your item will be published to the provided appId. + /// + /// You need to add app publish permissions for cross app uploading to work. + public Editor CreateItem( uint workshopUploadAppId, ItemType type ) + { + return new Editor() { workshop = this, WorkshopUploadAppId = workshopUploadAppId, Type = type }; + } + /// /// Returns a class representing this ItemId. We don't query /// item name, description etc. We don't verify that item exists.