Rename class 'Meta' ->'BlockBenchFormatInfo' and update BlockBenchModel.Create function signature

This commit is contained in:
miku-666
2024-08-14 09:59:47 +02:00
parent c930c59524
commit 1f4cd087a9
3 changed files with 24 additions and 14 deletions

View File

@@ -16,16 +16,31 @@ using PckStudio.Internal;
namespace PckStudio.External.Format
{
internal class Meta
internal static class BlockBenchFormatInfos
{
internal static readonly string FormatVersion = "4.5";
internal static BlockBenchFormatInfo Free { get; } = new BlockBenchFormatInfo(FormatVersion, "free", true);
internal static BlockBenchFormatInfo BedrockEntity { get; } = new BlockBenchFormatInfo(FormatVersion, "bedrock", true);
}
internal sealed class BlockBenchFormatInfo
{
[JsonProperty("format_version")]
internal string FormatVersion;
internal string FormatVersion { get; }
[JsonProperty("model_format")]
internal string ModelFormat;
internal string ModelFormat { get; }
[JsonProperty("box_uv")]
internal bool UseBoxUv;
internal bool UseBoxUv { get; }
internal BlockBenchFormatInfo(string formatVersion, string modelFormat, bool useBoxUv)
{
FormatVersion = formatVersion;
ModelFormat = modelFormat;
UseBoxUv = useBoxUv;
}
}
internal class Element
@@ -309,7 +324,7 @@ namespace PckStudio.External.Format
internal string Name;
[JsonProperty("meta")]
internal Meta Metadata;
internal BlockBenchFormatInfo Format;
[JsonProperty("model_identifier")]
internal string ModelIdentifier { get; set; } = "";
@@ -329,7 +344,7 @@ namespace PckStudio.External.Format
[JsonProperty("textures")]
internal Texture[] Textures;
internal static BlockBenchModel Create(string name, Size textureResolution, IEnumerable<Texture> textures)
internal static BlockBenchModel Create(BlockBenchFormatInfo formatInfo, string name, Size textureResolution, IEnumerable<Texture> textures)
{
return new BlockBenchModel()
{
@@ -337,12 +352,7 @@ namespace PckStudio.External.Format
Textures = textures.ToArray(),
TextureResolution = textureResolution,
ModelIdentifier = "",
Metadata = new Meta()
{
FormatVersion = "4.5",
ModelFormat = "free",
UseBoxUv = true,
}
Format = formatInfo,
};
}
}

View File

@@ -46,7 +46,7 @@ namespace PckStudio.Internal
private void ExportBlockBenchModel(string fileName, GameModelInfo modelInfo)
{
BlockBenchModel blockBenchModel = BlockBenchModel.Create(modelInfo.Model.Name, modelInfo.Model.TextureSize, modelInfo.Textures.Select(nt => (Texture)nt));
BlockBenchModel blockBenchModel = BlockBenchModel.Create(BlockBenchFormatInfos.BedrockEntity, modelInfo.Model.Name, modelInfo.Model.TextureSize, modelInfo.Textures.Select(nt => (Texture)nt));
Dictionary<string, Outline> outliners = new Dictionary<string, Outline>(5);
List<Element> elements = new List<Element>(modelInfo.Model.Parts.Count);

View File

@@ -162,7 +162,7 @@ namespace PckStudio.Internal
internal static void ExportBlockBenchModel(string fileName, SkinModelInfo modelInfo)
{
Image exportTexture = FixTexture(modelInfo);
BlockBenchModel blockBenchModel = BlockBenchModel.Create(Path.GetFileNameWithoutExtension(fileName), new Size(64, exportTexture.Width == exportTexture.Height ? 64 : 32), [exportTexture]);
BlockBenchModel blockBenchModel = BlockBenchModel.Create(BlockBenchFormatInfos.Free, Path.GetFileNameWithoutExtension(fileName), new Size(64, exportTexture.Width == exportTexture.Height ? 64 : 32), [exportTexture]);
Dictionary<string, Outline> outliners = new Dictionary<string, Outline>(5);
List<Element> elements = new List<Element>(modelInfo.AdditionalBoxes.Count);