mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-23 23:16:49 +00:00
SkinModelImporter - Move 'ModelTextureLocations' to GameModelImporter
This commit is contained in:
@@ -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<GameModelInfo>
|
||||
{
|
||||
public static GameModelImporter Default { get; } = new GameModelImporter();
|
||||
|
||||
|
||||
internal static ReadOnlyDictionary<string, JsonModelMetaData> ModelTextureLocations { get; } = JsonConvert.DeserializeObject<ReadOnlyDictionary<string, JsonModelMetaData>>(Resources.modelTextureLocations);
|
||||
|
||||
private GameModelImporter()
|
||||
{
|
||||
// TODO: add import functionality -miku
|
||||
|
||||
@@ -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<string, JsonModelMetaData> ModelTextureLocations { get; private set; }
|
||||
|
||||
internal SkinModelImporter()
|
||||
private SkinModelImporter()
|
||||
{
|
||||
ModelTextureLocations = JsonConvert.DeserializeObject<ReadOnlyDictionary<string, JsonModelMetaData>>(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);
|
||||
|
||||
@@ -632,10 +632,10 @@ namespace PckStudio
|
||||
|
||||
IEnumerable<NamedTexture> GetModelTextures(string modelName)
|
||||
{
|
||||
if (!SkinModelImporter.ModelTextureLocations.ContainsKey(modelName) || SkinModelImporter.ModelTextureLocations[modelName]?.TextureLocations?.Length <= 0)
|
||||
return Array.Empty<NamedTexture>();
|
||||
if (!GameModelImporter.ModelTextureLocations.ContainsKey(modelName) || GameModelImporter.ModelTextureLocations[modelName]?.TextureLocations?.Length <= 0)
|
||||
return Enumerable.Empty<NamedTexture>();
|
||||
|
||||
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<NamedTexture> textures = GetModelTextures(model.Name);
|
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
GameModelImporter.Default.Export(openFileDialog.FileName, new GameModelInfo(model, textures));
|
||||
IEnumerable<NamedTexture> textures = GetModelTextures(model.Name);
|
||||
var modelInfo = new GameModelInfo(model, textures);
|
||||
GameModelImporter.Default.Export(openFileDialog.FileName, modelInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user