PckAssetBrowserEditor - Add armor resoucre handling

This commit is contained in:
miku-666
2025-11-26 08:56:22 +01:00
parent 0cec1a9f31
commit 87fd010ee0
3 changed files with 56 additions and 23 deletions

View File

@@ -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<string, Image> tryGet = TryGet<string, Image>.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;

View File

@@ -15,12 +15,20 @@ namespace PckStudio.Core
private static readonly Dictionary<string, ArmorSetDescription> _pathLookUp = new Dictionary<string, ArmorSetDescription>();
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; }

View File

@@ -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,
}
}