From 8aae095cbc41e62ac1d9308861918d3e8422982d Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sun, 19 May 2024 14:01:42 +0200 Subject: [PATCH] ModelImporter - Only show bedrock model select dialog when more than 1 model is in the file --- PCK-Studio/Internal/ModelImporter.cs | 34 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/PCK-Studio/Internal/ModelImporter.cs b/PCK-Studio/Internal/ModelImporter.cs index 8e4ae6b3..dc5fc2b1 100644 --- a/PCK-Studio/Internal/ModelImporter.cs +++ b/PCK-Studio/Internal/ModelImporter.cs @@ -255,24 +255,40 @@ namespace PckStudio.Internal if (fileName.EndsWith(".geo.json")) { BedrockModel bedrockModel = JsonConvert.DeserializeObject(File.ReadAllText(fileName)); - ItemSelectionPopUp itemSelectionPopUp = new ItemSelectionPopUp(bedrockModel.Models.Select(m => m.Description.Identifier).ToArray()); - if (itemSelectionPopUp.ShowDialog() == DialogResult.OK && bedrockModel.Models.IndexInRange(itemSelectionPopUp.SelectedIndex)) + var availableModels = bedrockModel.Models.Select(m => m.Description.Identifier).ToArray(); + if (availableModels.Length > 1) { - selectedGeometry = bedrockModel.Models[itemSelectionPopUp.SelectedIndex]; + ItemSelectionPopUp itemSelectionPopUp = new ItemSelectionPopUp(availableModels); + if (itemSelectionPopUp.ShowDialog() == DialogResult.OK && bedrockModel.Models.IndexInRange(itemSelectionPopUp.SelectedIndex)) + { + selectedGeometry = bedrockModel.Models[itemSelectionPopUp.SelectedIndex]; + } + itemSelectionPopUp.Dispose(); + } + else + { + selectedGeometry = bedrockModel.Models[0]; } - itemSelectionPopUp.Dispose(); } // Bedrock Legacy Model else if (fileName.EndsWith(".json")) { BedrockLegacyModel bedrockModel = JsonConvert.DeserializeObject(File.ReadAllText(fileName)); - ItemSelectionPopUp itemSelectionPopUp = new ItemSelectionPopUp(bedrockModel.Select(m => m.Key).ToArray()); - if (itemSelectionPopUp.ShowDialog() == DialogResult.OK && itemSelectionPopUp.SelectedItem is not null) + var availableModels = bedrockModel.Select(m => m.Key).ToArray(); + if (availableModels.Length > 1) { - selectedGeometry = bedrockModel[itemSelectionPopUp.SelectedItem]; + ItemSelectionPopUp itemSelectionPopUp = new ItemSelectionPopUp(availableModels); + if (itemSelectionPopUp.ShowDialog() == DialogResult.OK && itemSelectionPopUp.SelectedItem is not null) + { + selectedGeometry = bedrockModel[itemSelectionPopUp.SelectedItem]; + } + itemSelectionPopUp.Dispose(); + } + else + { + selectedGeometry = bedrockModel[availableModels[0]]; } - itemSelectionPopUp.Dispose(); } SkinModelInfo modelInfo = null; @@ -356,7 +372,7 @@ namespace PckStudio.Internal foreach (External.Format.Cube cube in bone.Cubes) { Vector3 pos = TranslateToInternalPosition(boxType, cube.Origin, cube.Size, Vector3.UnitY); - var skinBox = new SkinBOX(boxType, pos, cube.Size, cube.Uv); + var skinBox = new SkinBOX(boxType, pos, cube.Size, cube.Uv, mirror: cube.Mirror); if (bone.Name == "helmet") { skinBox.HideWithArmor = true;