From 6f7eb8fa5e1ce2349d14d186415d4b892276f519 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Thu, 23 May 2024 18:53:02 +0200 Subject: [PATCH] CustomSkinEditor - Add trace warning when 'GenerateUV' or exoprt texture fails due to missing texture --- PCK-Studio/Forms/Editor/CustomSkinEditor.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs index 9dc7afd7..1be6c12e 100644 --- a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs +++ b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs @@ -9,6 +9,7 @@ using MetroFramework.Forms; using PckStudio.Internal; using PckStudio.Extensions; using PckStudio.Forms.Additional_Popups; +using System.Diagnostics; namespace PckStudio.Forms.Editor { @@ -101,6 +102,11 @@ namespace PckStudio.Forms.Editor private void GenerateUVTextureMap(SkinBOX skinBox) { + if (_skin?.Model?.Texture is null) + { + Trace.TraceWarning($"[{nameof(CustomSkinEditor)}@{nameof(GenerateUVTextureMap)}] Failed to generate uv for {skinBox}. Reason: Model.Texture was null"); + return; + } using (Graphics graphics = Graphics.FromImage(_skin.Model.Texture)) { graphics.ApplyConfig(_graphicsConfig); @@ -128,6 +134,11 @@ namespace PckStudio.Forms.Editor private void exportTextureButton_Click(object sender, EventArgs e) { + if (_skin?.Model?.Texture is null) + { + Trace.TraceWarning($"[{nameof(CustomSkinEditor)}@{nameof(exportTextureButton_Click)}] Failed to export texture. Reason: skin.Model.Texture was null"); + return; + } using SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "PNG Image Files | *.png"; if (saveFileDialog.ShowDialog() == DialogResult.OK)