diff --git a/PCK-Studio/Internal/GameModelImporter.cs b/PCK-Studio/Internal/GameModelImporter.cs index e522c493..14dc1a2b 100644 --- a/PCK-Studio/Internal/GameModelImporter.cs +++ b/PCK-Studio/Internal/GameModelImporter.cs @@ -9,13 +9,18 @@ using OMI.Formats.Model; using PckStudio.External.Format; using System.Numerics; using System.IO; +using PckStudio.Internal.Json; +using System.Collections.ObjectModel; +using PckStudio.Properties; namespace PckStudio.Internal { internal sealed class GameModelImporter : ModelImporter { public static GameModelImporter Default { get; } = new GameModelImporter(); - + + internal static ReadOnlyDictionary ModelTextureLocations { get; } = JsonConvert.DeserializeObject>(Resources.modelTextureLocations); + private GameModelImporter() { // TODO: add import functionality -miku diff --git a/PCK-Studio/Internal/SkinModelImporter.cs b/PCK-Studio/Internal/SkinModelImporter.cs index ff9e2ccc..9255901b 100644 --- a/PCK-Studio/Internal/SkinModelImporter.cs +++ b/PCK-Studio/Internal/SkinModelImporter.cs @@ -20,19 +20,14 @@ using System.IO; using System.Linq; using System.Drawing; using System.Numerics; -using System.Diagnostics; using System.Windows.Forms; using System.Drawing.Imaging; using System.Collections.Generic; -using System.Collections.ObjectModel; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PckStudio.Extensions; -using PckStudio.Interfaces; -using PckStudio.Properties; using PckStudio.Internal.Skin; -using PckStudio.Internal.Json; using PckStudio.Internal.IO.PSM; using PckStudio.External.Format; using PckStudio.Internal.FileFormats; @@ -44,11 +39,9 @@ namespace PckStudio.Internal { public static SkinModelImporter Default { get; } = new SkinModelImporter(); - internal static ReadOnlyDictionary ModelTextureLocations { get; private set; } - - internal SkinModelImporter() + private SkinModelImporter() { - ModelTextureLocations = JsonConvert.DeserializeObject>(Resources.modelTextureLocations); + InternalAddProvider(new("Pck skin model(*.psm)", "*.psm"), ImportPsm, ExportPsm); InternalAddProvider(new("Block bench model(*.bbmodel)", "*.bbmodel"), ImportBlockBenchModel, ExportBlockBenchModel); InternalAddProvider(new("Bedrock (Legacy) Model(*.geo.json;*.json)", "*.geo.json;*.json"), ImportBedrockJson, ExportBedrockJson); diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 05356465..20822e9e 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -632,10 +632,10 @@ namespace PckStudio IEnumerable GetModelTextures(string modelName) { - if (!SkinModelImporter.ModelTextureLocations.ContainsKey(modelName) || SkinModelImporter.ModelTextureLocations[modelName]?.TextureLocations?.Length <= 0) - return Array.Empty(); + if (!GameModelImporter.ModelTextureLocations.ContainsKey(modelName) || GameModelImporter.ModelTextureLocations[modelName]?.TextureLocations?.Length <= 0) + return Enumerable.Empty(); - return SkinModelImporter.ModelTextureLocations[modelName].TextureLocations.Select(texturePath => + return GameModelImporter.ModelTextureLocations[modelName].TextureLocations.Select(texturePath => { if (currentPCK.TryGetAsset(texturePath + ".png", PckAssetType.TextureFile, out PckAsset modelTextureAsset) || currentPCK.TryGetAsset(texturePath + ".tga", PckAssetType.TextureFile, out modelTextureAsset)) @@ -644,11 +644,11 @@ namespace PckStudio }); } - IEnumerable textures = GetModelTextures(model.Name); - if (openFileDialog.ShowDialog() == DialogResult.OK) { - GameModelImporter.Default.Export(openFileDialog.FileName, new GameModelInfo(model, textures)); + IEnumerable textures = GetModelTextures(model.Name); + var modelInfo = new GameModelInfo(model, textures); + GameModelImporter.Default.Export(openFileDialog.FileName, modelInfo); } } }