From 0fc300f2891c55ee00f2e391ce720c1d1b013691 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 14 Aug 2024 08:41:23 +0200 Subject: [PATCH] GameModelImporter - Add options to create root outline --- PCK-Studio/Internal/GameModelImporter.cs | 13 +++++++++++-- PCK-Studio/MainForm.cs | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/PCK-Studio/Internal/GameModelImporter.cs b/PCK-Studio/Internal/GameModelImporter.cs index 174c33f7..3643cba6 100644 --- a/PCK-Studio/Internal/GameModelImporter.cs +++ b/PCK-Studio/Internal/GameModelImporter.cs @@ -34,6 +34,8 @@ namespace PckStudio.Internal { public static GameModelImporter Default { get; } = new GameModelImporter(); + public bool CreateModelOutline { get; set; } = true; + internal static ReadOnlyDictionary ModelMetaData { get; } = JsonConvert.DeserializeObject>(Resources.modelMetaData); private GameModelImporter() @@ -42,7 +44,7 @@ namespace PckStudio.Internal InternalAddProvider(new FileDialogFilter("Block bench model(*.bbmodel)", "*.bbmodel"), null, ExportBlockBenchModel); } - private static void ExportBlockBenchModel(string fileName, GameModelInfo modelInfo) + private void ExportBlockBenchModel(string fileName, GameModelInfo modelInfo) { BlockBenchModel blockBenchModel = BlockBenchModel.Create(modelInfo.Model.Name, modelInfo.Model.TextureSize, modelInfo.Textures.Select(nt => (Texture)nt)); @@ -81,7 +83,14 @@ namespace PckStudio.Internal TraverseChildren(modelMetaData.RootParts, ref outliners); blockBenchModel.Elements = elements.ToArray(); - blockBenchModel.Outliner = JArray.FromObject(outliners.Values.Where(value => modelMetaData.RootParts.Count == 0 || modelMetaData.RootParts.ContainsKey(value.Name))); + IEnumerable outlines = outliners.Values.Where(value => modelMetaData.RootParts.Count == 0 || modelMetaData.RootParts.ContainsKey(value.Name)); + if (CreateModelOutline) + outlines = new Outline[1] + { + new Outline(modelInfo.Model.Name) { Children = JArray.FromObject(outlines) } + }; + + blockBenchModel.Outliner = JArray.FromObject(outlines); string content = JsonConvert.SerializeObject(blockBenchModel, Formatting.Indented); File.WriteAllText(fileName, content); diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index f355b371..963fbae4 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -626,6 +626,11 @@ namespace PckStudio Debug.WriteLine(model.Name + "; "); Debug.WriteLine(model.TextureSize + "; "); + GameModelImporter.Default.CreateModelOutline = + MessageBox.Show( + $"Do you wish to have all model parts contained in a group called '{model.Name}'?", + "Group model parts", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; + using SaveFileDialog openFileDialog = new SaveFileDialog(); openFileDialog.FileName = model.Name; openFileDialog.Filter = GameModelImporter.Default.SupportedModelFileFormatsFilter;