From 2ec739d4c0eef807327873a40a78ee350851144d Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 13 Mar 2024 18:04:48 +0100 Subject: [PATCH] MainForm - Fix unable to create skin when no loc file is found --- .../Forms/Skins-And-Textures/AddNewSkin.cs | 18 +++++++++++++----- PCK-Studio/MainForm.cs | 9 +++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs index 3f34cb3d..7c80ab59 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs @@ -242,15 +242,23 @@ namespace PckStudio.Popups } string skinId = _skinId.ToString("d08"); skin.Filename = $"dlcskin{skinId}.png"; - string skinDisplayNameLocKey = $"IDS_dlcskin{skinId}_DISPLAYNAME"; - currentLoc.AddLocKey(skinDisplayNameLocKey, textSkinName.Text); skin.Properties.Add("DISPLAYNAME", textSkinName.Text); - skin.Properties.Add("DISPLAYNAMEID", skinDisplayNameLocKey); + + if (currentLoc is not null) + { + string skinDisplayNameLocKey = $"IDS_dlcskin{skinId}_DISPLAYNAME"; + skin.Properties.Add("DISPLAYNAMEID", skinDisplayNameLocKey); + currentLoc.AddLocKey(skinDisplayNameLocKey, textSkinName.Text); + } + if (!string.IsNullOrEmpty(textThemeName.Text)) { skin.Properties.Add("THEMENAME", textThemeName.Text); - skin.Properties.Add("THEMENAMEID", $"IDS_dlcskin{skinId}_THEMENAME"); - currentLoc.AddLocKey($"IDS_dlcskin{skinId}_THEMENAME", textThemeName.Text); + if (currentLoc is not null) + { + skin.Properties.Add("THEMENAMEID", $"IDS_dlcskin{skinId}_THEMENAME"); + currentLoc.AddLocKey($"IDS_dlcskin{skinId}_THEMENAME", textThemeName.Text); + } } skin.Properties.Add("ANIM", anim); skin.Properties.Add("GAME_FLAGS", "0x18"); diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index d9c7cb3d..dd4f1c8b 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -801,12 +801,9 @@ namespace PckStudio private void createSkinToolStripMenuItem_Click(object sender, EventArgs e) { - if (!TryGetLocFile(out LOCFile locFile)) - { - MessageBox.Show("No .loc file found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - using (AddNewSkin add = new AddNewSkin(locFile)) + LOCFile locFile = null; + TryGetLocFile(out locFile); + using AddNewSkin add = new AddNewSkin(locFile); if (add.ShowDialog() == DialogResult.OK) {