From 87fd010ee084cb2cbdbdfc3e7aa183f11fb89351 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 26 Nov 2025 08:56:22 +0100 Subject: [PATCH] PckAssetBrowserEditor - Add armor resoucre handling --- PCK-Studio/Controls/PckAssetBrowserEditor.cs | 17 ++++++++ PckStudio.Core/ArmorSetDescription.cs | 20 +++++++--- PckStudio.Core/ResourceCategory.cs | 42 ++++++++++++-------- 3 files changed, 56 insertions(+), 23 deletions(-) diff --git a/PCK-Studio/Controls/PckAssetBrowserEditor.cs b/PCK-Studio/Controls/PckAssetBrowserEditor.cs index 47a51432..ed18fb84 100644 --- a/PCK-Studio/Controls/PckAssetBrowserEditor.cs +++ b/PCK-Studio/Controls/PckAssetBrowserEditor.cs @@ -365,6 +365,23 @@ namespace PckStudio.Controls BuildMainTreeView(); } break; + case ResourceCategory.ArmorTextures: + string assetName = Path.GetFileNameWithoutExtension(asset.Filename); + ArmorSetDescription armorSetDescription = ArmorSetDescription.GetFromAssetName(assetName); + Debug.WriteLineIf(!armorSetDescription.IsEmpty, armorSetDescription.Name); + ITryGet tryGet = TryGet.FromDelegate((string path, out Image img) => + { + img = null; + if (EditorValue.File.TryGetAsset(path + ".png", PckAssetType.TextureFile, out PckAsset armorAsset)) + { + img = armorAsset.GetTexture(); + Debug.WriteLine($"Got texture for: {path}"); + return true; + } + return false; + }); + ArmorSet armorSet = armorSetDescription.GetArmorSet(tryGetTexture: tryGet); + break; default: Debug.WriteLine($"Unhandled Resource Category: {resourceLocation.Category}"); break; diff --git a/PckStudio.Core/ArmorSetDescription.cs b/PckStudio.Core/ArmorSetDescription.cs index fe73727e..5f63c6b7 100644 --- a/PckStudio.Core/ArmorSetDescription.cs +++ b/PckStudio.Core/ArmorSetDescription.cs @@ -15,12 +15,20 @@ namespace PckStudio.Core private static readonly Dictionary _pathLookUp = new Dictionary(); private static readonly string _resourcePath = ResourceLocations.GetFromCategory(ResourceCategory.ArmorTextures).FullPath; public static ArmorSetDescription Empty = new ArmorSetDescription(string.Empty, 0, 0); - public static ArmorSetDescription Leather = new ArmorSetDescription("cloth", layerCount: 1); - public static ArmorSetDescription Chain = new ArmorSetDescription("chain"); - public static ArmorSetDescription Iron = new ArmorSetDescription("iron"); - public static ArmorSetDescription Gold = new ArmorSetDescription("gold"); - public static ArmorSetDescription Diamond = new ArmorSetDescription("diamond"); - public static ArmorSetDescription Turtle = new ArmorSetDescription("turtle", textureCount: 1); + + public const string CLOTH = "cloth"; + public const string CHAIN = "chain"; + public const string IRON = "iron"; + public const string GOLD = "gold"; + public const string DIAMOND = "diamond"; + public const string TURTLE = "turtle"; + + public static ArmorSetDescription Leather = new ArmorSetDescription(CLOTH, layerCount: 1); + public static ArmorSetDescription Chain = new ArmorSetDescription(CHAIN); + public static ArmorSetDescription Iron = new ArmorSetDescription(IRON); + public static ArmorSetDescription Gold = new ArmorSetDescription(GOLD); + public static ArmorSetDescription Diamond = new ArmorSetDescription(DIAMOND); + public static ArmorSetDescription Turtle = new ArmorSetDescription(TURTLE, textureCount: 1); public string Name { get; } diff --git a/PckStudio.Core/ResourceCategory.cs b/PckStudio.Core/ResourceCategory.cs index 64c33179..5d0bba4d 100644 --- a/PckStudio.Core/ResourceCategory.cs +++ b/PckStudio.Core/ResourceCategory.cs @@ -16,25 +16,33 @@ * 3. This notice may not be removed or altered from any source distribution. **/ +using System; + namespace PckStudio.Core { - public enum ResourceCategory + [Flags] + public enum ResourceCategory : int { - Unknown = -1, - ItemAnimation, - BlockAnimation, - MobEntityTextures, - ItemEntityTextures, - ArmorTextures, - ItemAtlas, - BlockAtlas, - ParticleAtlas, - BannerAtlas, - PaintingAtlas, - ExplosionAtlas, - ExperienceOrbAtlas, - MoonPhaseAtlas, - MapIconAtlas, - AdditionalMapIconsAtlas, + Unknown = -1, + Animation = 0x01, + ItemAnimation = 0x02 | Animation, + BlockAnimation = 0x04 | Animation, + + Atlas = 0x08, + ItemAtlas = 0x10 | Atlas, + BlockAtlas = 0x20 | Atlas, + ParticleAtlas = 0x40 | Atlas, + BannerAtlas = 0x80 | Atlas, + PaintingAtlas = 0x100 | Atlas, + ExplosionAtlas = 0x200 | Atlas, + ExperienceOrbAtlas = 0x400 | Atlas, + MoonPhaseAtlas = 0x800 | Atlas, + MapIconAtlas = 0x1000 | Atlas, + AdditionalMapIconsAtlas = 0x2000 | Atlas, + + Textures = 0x4000, + MobEntityTextures = 0x8000 | Textures, + ItemEntityTextures = 0x10000 | Textures, + ArmorTextures = 0x20000 | Textures, } }