diff --git a/PCK-Studio/Forms/Additional-Popups/Animation/ChangeTile.cs b/PCK-Studio/Forms/Additional-Popups/Animation/ChangeTile.cs index 3cd495cf..04b57150 100644 --- a/PCK-Studio/Forms/Additional-Popups/Animation/ChangeTile.cs +++ b/PCK-Studio/Forms/Additional-Popups/Animation/ChangeTile.cs @@ -50,7 +50,7 @@ namespace PckStudio.Forms.Additional_Popups.Animation private void GetTileDataToView(string key, TreeNodeCollection collection, Action additinalAction) { - List textureInfos = key switch + List textureInfos = key switch { "blocks" => AnimationResources.BlockTileInfos, "items" => AnimationResources.ItemTileInfos, diff --git a/PCK-Studio/Forms/Editor/AnimationEditor.cs b/PCK-Studio/Forms/Editor/AnimationEditor.cs index fcfa9a50..24d234b7 100644 --- a/PCK-Studio/Forms/Editor/AnimationEditor.cs +++ b/PCK-Studio/Forms/Editor/AnimationEditor.cs @@ -415,7 +415,7 @@ namespace PckStudio.Forms.Editor _ => throw new ArgumentOutOfRangeException(currentAnimation.Category.ToString()) }; - if (textureInfos.FirstOrDefault(p => p.InternalName == TileName) is AnimationResources.TileInfo textureInfo) + if (textureInfos.FirstOrDefault(p => p.InternalName == TileName) is AnimationResources.JsonTileInfo textureInfo) { tileLabel.Text = textureInfo.DisplayName; return; diff --git a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs index 1a67f4ed..538ab744 100644 --- a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs +++ b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs @@ -52,9 +52,9 @@ namespace PckStudio internal readonly string Name; internal readonly string TextureName; internal readonly Rectangle Area; - internal readonly AnimationResources.TileInfo Tile; + internal readonly AnimationResources.JsonTileInfo Tile; - public SelectedTile(int index, string name, string textureName, Rectangle area, AnimationResources.TileInfo tile) + public SelectedTile(int index, string name, string textureName, Rectangle area, AnimationResources.JsonTileInfo tile) { Index = index; Name = name; @@ -70,7 +70,7 @@ namespace PckStudio private readonly int _columnCount; private readonly string _atlasType; private readonly List _textures; - private readonly List _textureInfos; + private readonly List _textureInfos; private SelectedTile _selectedItem = new SelectedTile(); private ColorContainer _colourTable; @@ -149,9 +149,10 @@ namespace PckStudio { var img = _textures[index]; if (_selectedItem.Tile.HasColourEntry && - !string.IsNullOrWhiteSpace(_selectedItem.Tile.ColourEntryName) && + _selectedItem.Tile.HasColourEntry && + !string.IsNullOrWhiteSpace(_selectedItem.Tile.ColourEntry.DefaultName) && _colourTable is not null && - _colourTable.Colors.FirstOrDefault(entry => entry.Name == _selectedItem.Tile.ColourEntryName) is ColorContainer.Color color) + _colourTable.Colors.FirstOrDefault(entry => entry.Name == _selectedItem.Tile.ColourEntry.DefaultName) is ColorContainer.Color color) { img = img.Blend(color.ColorPallette, BlendMode.Multiply); } @@ -333,16 +334,16 @@ namespace PckStudio AnimationEditor animationEditor; if (_selectedItem.Tile.HasColourEntry && - !string.IsNullOrWhiteSpace(_selectedItem.Tile.ColourEntryName) && + !string.IsNullOrWhiteSpace(_selectedItem.Tile.ColourEntry.DefaultName) && _colourTable is not null) { Color blenColor = Color.White; - if (_selectedItem.Tile.IsWaterColour && - _colourTable.WaterColors.FirstOrDefault(entry => entry.Name == _selectedItem.Tile.ColourEntryName) is ColorContainer.WaterColor waterColor) + if (_selectedItem.Tile.ColourEntry.IsWaterColour && + _colourTable.WaterColors.FirstOrDefault(entry => entry.Name == _selectedItem.Tile.ColourEntry.DefaultName) is ColorContainer.WaterColor waterColor) { blenColor = waterColor.SurfaceColor; } - else if (_colourTable.Colors.FirstOrDefault(entry => entry.Name == _selectedItem.Tile.ColourEntryName) is ColorContainer.Color color) + else if (_colourTable.Colors.FirstOrDefault(entry => entry.Name == _selectedItem.Tile.ColourEntry.DefaultName) is ColorContainer.Color color) { blenColor = color.ColorPallette; } diff --git a/PCK-Studio/Forms/Utilities/AnimationResources.cs b/PCK-Studio/Forms/Utilities/AnimationResources.cs index 62e45476..8f269b70 100644 --- a/PCK-Studio/Forms/Utilities/AnimationResources.cs +++ b/PCK-Studio/Forms/Utilities/AnimationResources.cs @@ -18,15 +18,15 @@ namespace PckStudio.Forms.Utilities internal class TileJson { [JsonProperty("blocks")] - public List Blocks { get; set; } + public List Blocks { get; set; } [JsonProperty("items")] - public List Items { get; set; } + public List Items { get; set; } } private static TileJson _jsonData; internal static TileJson JsonTileData => _jsonData ??= JsonConvert.DeserializeObject(Resources.tileData); - public class TileInfo + internal class JsonTileInfo { [JsonProperty("displayName")] public string DisplayName { get; set; } @@ -37,22 +37,31 @@ namespace PckStudio.Forms.Utilities [JsonProperty("hasColourEntry", DefaultValueHandling = DefaultValueHandling.Populate)] public bool HasColourEntry { get; set; } - [JsonProperty("isWaterColour", DefaultValueHandling = DefaultValueHandling.Populate)] - public bool IsWaterColour { get; set; } + [JsonProperty("colourEntry", DefaultValueHandling = DefaultValueHandling.Populate)] + public JsonColorEntry ColourEntry { get; set; } - [JsonProperty("colourEntryName", DefaultValueHandling = DefaultValueHandling.Populate)] - public string ColourEntryName { get; set; } - - public TileInfo(string displayName, string internalName) + public JsonTileInfo(string displayName, string internalName) { DisplayName = displayName; InternalName = internalName; } } - public static List ItemTileInfos => JsonTileData.Items; + internal class JsonColorEntry + { + [JsonProperty("defaultName", Required = Required.Always)] + public string DefaultName { get; set; } - public static List BlockTileInfos => JsonTileData.Blocks; + [JsonProperty("isWaterColour", DefaultValueHandling = DefaultValueHandling.Populate)] + public bool IsWaterColour { get; set; } + + [JsonProperty("variants", DefaultValueHandling = DefaultValueHandling.Populate)] + public string[] Variants { get; set; } + } + + internal static List ItemTileInfos => JsonTileData.Items; + + internal static List BlockTileInfos => JsonTileData.Blocks; private static Image[] _itemImages; public static Image[] ItemImages => _itemImages ??= Resources.items_sheet.CreateImageList(16).ToArray(); diff --git a/PCK-Studio/Resources/tileData.json b/PCK-Studio/Resources/tileData.json index 643df80b..e29d40c3 100644 --- a/PCK-Studio/Resources/tileData.json +++ b/PCK-Studio/Resources/tileData.json @@ -6,8 +6,16 @@ "internalName": "grass_top", "displayName": "Grass Block (Top)", "hasColourEntry": true, - "isWaterColour": false, - "colourEntryName": "Grass_Common" + "colourEntry": { + "isWaterColour": false, + "defaultName": "Grass_Common", + "variants": [ + "Grass_Common", + "Grass_Mesa", + "Grass_Swamp1", + "Grass_Swamp2" + ] + } }, { "internalName": "stone", @@ -161,8 +169,16 @@ "internalName": "grass_side_overlay", "displayName": "Grass Side (Overlay)", "hasColourEntry": true, - "isWaterColour": false, - "colourEntryName": "Grass_Common" + "colourEntry": { + "isWaterColour": false, + "defaultName": "Grass_Common", + "variants": [ + "Grass_Common", + "Grass_Mesa", + "Grass_Swamp1", + "Grass_Swamp2" + ] + } }, { "internalName": "tallgrass", @@ -314,7 +330,12 @@ }, { "internalName": "waterlily", - "displayName": "Lily Pad" + "displayName": "Lily Pad", + "hasColourEntry": true, + "colourEntry": { + "defaultName": "Tile_WaterLily", + "variants": [ "Tile_WaterLily" ] + } }, { "internalName": "mycel_side", @@ -832,15 +853,21 @@ "internalName": "water", "displayName": "Water", "hasColourEntry": true, - "isWaterColour": true, - "colourEntryName": "default" + "colourEntry": { + "isWaterColour": true, + "defaultName": "default", + "variants": [ "default" ] + } }, { "internalName": "water_flow", "displayName": "Flowing Water", "hasColourEntry": true, - "isWaterColour": true, - "colourEntryName": "default" + "colourEntry": { + "isWaterColour": true, + "defaultName": "default", + "variants": [ "default" ] + } }, { "internalName": "", @@ -2514,7 +2541,13 @@ "items": [ { "internalName": "helmetCloth", - "displayName": "Leather Cap" + "displayName": "Leather Cap", + "hasColourEntry": true, + "colourEntry": { + "isWaterColour": false, + "defaultName": "Armour_Default_Leather_Colour", + "variants": [ "Armour_Default_Leather_Colour" ] + } }, { "internalName": "helmetChain", @@ -2578,7 +2611,13 @@ }, { "internalName": "chestplateCloth", - "displayName": "Leather Tunic" + "displayName": "Leather Tunic", + "hasColourEntry": true, + "colourEntry": { + "isWaterColour": false, + "defaultName": "Armour_Default_Leather_Colour", + "variants": [ "Armour_Default_Leather_Colour" ] + } }, { "internalName": "chestplateChain", @@ -2642,7 +2681,13 @@ }, { "internalName": "leggingsCloth", - "displayName": "Leather Pants" + "displayName": "Leather Pants", + "hasColourEntry": true, + "colourEntry": { + "isWaterColour": false, + "defaultName": "Armour_Default_Leather_Colour", + "variants": [ "Armour_Default_Leather_Colour" ] + } }, { "internalName": "leggingsChain", @@ -2706,7 +2751,13 @@ }, { "internalName": "bootsCloth", - "displayName": "Leather Boots" + "displayName": "Leather Boots", + "hasColourEntry": true, + "colourEntry": { + "isWaterColour": false, + "defaultName": "Armour_Default_Leather_Colour", + "variants": [ "Armour_Default_Leather_Colour" ] + } }, { "internalName": "bootsChain", @@ -2729,8 +2780,8 @@ "displayName": "Stick" }, { - "internalName": "", - "displayName": "" + "internalName": "compass", + "displayName": "Compass" }, { "internalName": "diamond", @@ -2793,8 +2844,8 @@ "displayName": "Fishing Rod" }, { - "internalName": "", - "displayName": "" + "internalName": "clock", + "displayName": "Clock" }, { "internalName": "bowl",