(9d0bc3391) Fixed console error when attempting to publish a sub with no preview image in the workshop
This commit is contained in:
@@ -740,25 +740,28 @@ namespace Barotrauma
|
|||||||
itemEditor.Tags.Add("Submarine");
|
itemEditor.Tags.Add("Submarine");
|
||||||
itemEditor.Description = sub.Description;
|
itemEditor.Description = sub.Description;
|
||||||
|
|
||||||
string previewImagePath = Path.GetFullPath(Path.Combine(SteamManager.WorkshopItemStagingFolder, SteamManager.PreviewImageName));
|
if (sub.PreviewImage != null)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
using (Stream s = File.Create(previewImagePath))
|
string previewImagePath = Path.GetFullPath(Path.Combine(SteamManager.WorkshopItemStagingFolder, SteamManager.PreviewImageName));
|
||||||
|
try
|
||||||
{
|
{
|
||||||
sub.PreviewImage.Texture.SaveAsPng(s, (int)sub.PreviewImage.size.X, (int)sub.PreviewImage.size.Y);
|
using (Stream s = File.Create(previewImagePath))
|
||||||
itemEditor.PreviewImage = previewImagePath;
|
{
|
||||||
|
sub.PreviewImage.Texture.SaveAsPng(s, (int)sub.PreviewImage.size.X, (int)sub.PreviewImage.size.Y);
|
||||||
|
itemEditor.PreviewImage = previewImagePath;
|
||||||
|
}
|
||||||
|
if (new FileInfo(previewImagePath).Length > 1024 * 1024)
|
||||||
|
{
|
||||||
|
new GUIMessageBox(TextManager.Get("Error"), TextManager.Get("WorkshopItemPreviewImageTooLarge"));
|
||||||
|
itemEditor.PreviewImage = SteamManager.DefaultPreviewImagePath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (new FileInfo(previewImagePath).Length > 1024 * 1024)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
new GUIMessageBox(TextManager.Get("Error"), TextManager.Get("WorkshopItemPreviewImageTooLarge"));
|
DebugConsole.ThrowError("Saving submarine preview image failed.", e);
|
||||||
itemEditor.PreviewImage = SteamManager.DefaultPreviewImagePath;
|
itemEditor.PreviewImage = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
DebugConsole.ThrowError("Saving submarine preview image failed.", e);
|
|
||||||
itemEditor.PreviewImage = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void CreateWorkshopItem(ContentPackage contentPackage)
|
private void CreateWorkshopItem(ContentPackage contentPackage)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user