From 65fc0aa371a8bf562a10efd45f72924cdab26598 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Tue, 20 Aug 2024 20:21:12 +0200 Subject: [PATCH] SkinModelImporter - Small code clean up inside 'ImportBedrockJson' --- PCK-Studio/Internal/SkinModelImporter.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/PCK-Studio/Internal/SkinModelImporter.cs b/PCK-Studio/Internal/SkinModelImporter.cs index 824aaaed..dd30a9ce 100644 --- a/PCK-Studio/Internal/SkinModelImporter.cs +++ b/PCK-Studio/Internal/SkinModelImporter.cs @@ -232,12 +232,11 @@ namespace PckStudio.Internal var availableModels = bedrockModel.Models.Select(m => m.Description.Identifier).ToArray(); if (availableModels.Length > 1) { - ItemSelectionPopUp itemSelectionPopUp = new ItemSelectionPopUp(availableModels); + using ItemSelectionPopUp itemSelectionPopUp = new ItemSelectionPopUp(availableModels); if (itemSelectionPopUp.ShowDialog() == DialogResult.OK && bedrockModel.Models.IndexInRange(itemSelectionPopUp.SelectedIndex)) { selectedGeometry = bedrockModel.Models[itemSelectionPopUp.SelectedIndex]; } - itemSelectionPopUp.Dispose(); } else { @@ -252,12 +251,11 @@ namespace PckStudio.Internal var availableModels = bedrockModel.Select(m => m.Key).ToArray(); if (availableModels.Length > 1) { - ItemSelectionPopUp itemSelectionPopUp = new ItemSelectionPopUp(availableModels); - if (itemSelectionPopUp.ShowDialog() == DialogResult.OK && itemSelectionPopUp.SelectedItem is not null) + using ItemSelectionPopUp itemSelectionPopUp = new ItemSelectionPopUp(availableModels); + if (itemSelectionPopUp.ShowDialog() == DialogResult.OK && bedrockModel.ContainsKey(itemSelectionPopUp.SelectedItem)) { selectedGeometry = bedrockModel[itemSelectionPopUp.SelectedItem]; } - itemSelectionPopUp.Dispose(); } else { @@ -269,8 +267,8 @@ namespace PckStudio.Internal if (selectedGeometry is not null) { modelInfo = LoadGeometry(selectedGeometry); - } modelInfo.Texture = SwapBoxBottomTexture(modelInfo); + } return modelInfo; }