From 3490d05b403c607debaf0b26b77a0f33462fd85f Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 8 Nov 2016 10:14:49 +0000 Subject: [PATCH] On publish validate that folder exists, preview image is under 1mb --- .../Interfaces/Workshop.Editor.cs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs b/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs index 32e2f8b..761cb64 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.Editor.cs @@ -139,7 +139,14 @@ private void PublishChanges() workshop.ugc.SetItemDescription( UpdateHandle, Description ); if ( Folder != null ) + { + var info = new System.IO.DirectoryInfo( Folder ); + + if ( !info.Exists ) + throw new System.Exception( $"Folder doesn't exist ({Folder})" ); + workshop.ugc.SetItemContent( UpdateHandle, Folder ); + } if ( Tags != null && Tags.Count > 0 ) workshop.ugc.SetItemTags( UpdateHandle, Tags.ToArray() ); @@ -148,7 +155,17 @@ private void PublishChanges() workshop.ugc.SetItemVisibility( UpdateHandle, (SteamNative.RemoteStoragePublishedFileVisibility)(uint)Visibility.Value ); if ( PreviewImage != null ) - workshop.ugc.SetItemPreview( UpdateHandle, PreviewImage ); // change preview image file for this item. pszPreviewFile points to local image file, which must be under 1MB in size + { + var info = new System.IO.FileInfo( PreviewImage ); + + if ( !info.Exists ) + throw new System.Exception( $"PreviewImage doesn't exist ({PreviewImage})" ); + + if ( info.Length >= 1024 * 1024 ) + throw new System.Exception( $"PreviewImage should be under 1MB ({info.Length})" ); + + workshop.ugc.SetItemPreview( UpdateHandle, PreviewImage ); + } /* workshop.ugc.SetItemUpdateLanguage( UpdateId, const char *pchLanguage ) = 0; // specify the language of the title or description that will be set @@ -179,7 +196,7 @@ private void OnChangesSubmitted( SteamNative.SubmitItemUpdateResult_t obj, bool return; } - Error = "Error publishing changes: " + obj.Result.ToString(); + Error = "Error publishing changes: " + obj.Result.ToString() + " ("+ NeedToAgreeToWorkshopLegal + ")"; } public void Delete()