Merge pull request #66 from MollerVictor/master

Added support for publishing workshop items to the main app from anot…
This commit is contained in:
Garry Newman 2017-08-30 22:45:46 +01:00 committed by GitHub
commit 13c8b543cc
2 changed files with 16 additions and 4 deletions

View File

@ -24,6 +24,7 @@ public class Editor
public ItemType? Type { get; set; } public ItemType? Type { get; set; }
public string Error { get; internal set; } = null; public string Error { get; internal set; } = null;
public string ChangeNote { get; set; } = ""; public string ChangeNote { get; set; } = "";
public uint WorkshopUploadAppId { get; set; }
public enum VisibilityType : int public enum VisibilityType : int
{ {
@ -109,7 +110,7 @@ private void StartCreatingItem()
if ( !Type.HasValue ) if ( !Type.HasValue )
throw new System.Exception( "Editor.Type must be set when creating a new item!" ); 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 ) private void OnItemCreated( SteamNative.CreateItemResult_t obj, bool Failed )
@ -130,7 +131,7 @@ private void OnItemCreated( SteamNative.CreateItemResult_t obj, bool Failed )
private void PublishChanges() private void PublishChanges()
{ {
UpdateHandle = workshop.ugc.StartItemUpdate( workshop.steamworks.AppId, Id ); UpdateHandle = workshop.ugc.StartItemUpdate(WorkshopUploadAppId, Id );
if ( Title != null ) if ( Title != null )
workshop.ugc.SetItemTitle( UpdateHandle, Title ); workshop.ugc.SetItemTitle( UpdateHandle, Title );

View File

@ -98,9 +98,20 @@ public Query CreateQuery()
/// </summary> /// </summary>
public Editor CreateItem( ItemType type ) public Editor CreateItem( ItemType type )
{ {
return new Editor() { workshop = this, Type = type }; return CreateItem(this.steamworks.AppId, type);
} }
/// <summary>
/// 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.
/// </summary>
/// <remarks>You need to add app publish permissions for cross app uploading to work.</remarks>
public Editor CreateItem( uint workshopUploadAppId, ItemType type )
{
return new Editor() { workshop = this, WorkshopUploadAppId = workshopUploadAppId, Type = type };
}
/// <summary> /// <summary>
/// Returns a class representing this ItemId. We don't query /// Returns a class representing this ItemId. We don't query
/// item name, description etc. We don't verify that item exists. /// item name, description etc. We don't verify that item exists.