From f6e72b0e6ede61cb86f2f7c7416a6d954f73c796 Mon Sep 17 00:00:00 2001 From: MattN-L Date: Wed, 13 Mar 2024 07:01:31 -0400 Subject: [PATCH] Added atlas editor support for moon phases --- PCK-Studio/Forms/Editor/TextureAtlasEditor.cs | 26 +++++++----- PCK-Studio/Internal/Json/Tiles.cs | 21 ++++++++++ PCK-Studio/MainForm.cs | 14 +++++-- PCK-Studio/PckStudio.csproj | 1 + PCK-Studio/Properties/Resources.Designer.cs | 38 +++++++++++------- PCK-Studio/Properties/Resources.resx | 3 ++ PCK-Studio/Resources/moon_phases.png | Bin 0 -> 1569 bytes PCK-Studio/Resources/tileData.json | 34 ++++++++++++++++ 8 files changed, 108 insertions(+), 29 deletions(-) create mode 100644 PCK-Studio/Resources/moon_phases.png diff --git a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs index 09403f6f..12ed5b6e 100644 --- a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs +++ b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs @@ -94,6 +94,7 @@ namespace PckStudio.Forms.Editor { "terrain" => (Tiles.BlockTileInfos, "blocks"), "items" => (Tiles.ItemTileInfos, "items"), + "moon_phases" => (Tiles.MoonPhasesTileInfos, "moon_phases"), _ => (null, null), }; originalPictureBox.Image = atlas; @@ -151,17 +152,20 @@ namespace PckStudio.Forms.Editor selectTilePictureBox.BlendColor = GetBlendColor(); selectTilePictureBox.UseBlendColor = applyColorMaskToolStripMenuItem.Checked; - bool hasAnimation = - _pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.png", PckFileType.TextureFile, out var animationFile); - animationButton.Text = hasAnimation ? "Edit Animation" : "Create Animation"; - replaceButton.Enabled = !hasAnimation; - - if (playAnimationsToolStripMenuItem.Checked && - hasAnimation && - animationFile.Size > 0) + if (animationButton.Enabled = _atlasType == "blocks" || _atlasType == "items") { - var animation = AnimationHelper.GetAnimationFromFile(animationFile); - selectTilePictureBox.Start(animation); + bool hasAnimation = + _pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.png", PckFileType.TextureFile, out var animationFile); + animationButton.Text = hasAnimation ? "Edit Animation" : "Create Animation"; + replaceButton.Enabled = !hasAnimation; + + if (playAnimationsToolStripMenuItem.Checked && + hasAnimation && + animationFile.Size > 0) + { + var animation = AnimationHelper.GetAnimationFromFile(animationFile); + selectTilePictureBox.Start(animation); + } } if (setColorButton.Enabled = clearColorButton.Enabled = dataTile.Tile.HasColourEntry) @@ -504,7 +508,7 @@ namespace PckStudio.Forms.Editor 0x211D1D, // Black 0x325483 // Brown }; - + if (colorPick.ShowDialog() != DialogResult.OK) return; selectTilePictureBox.BlendColor = colorPick.Color; diff --git a/PCK-Studio/Internal/Json/Tiles.cs b/PCK-Studio/Internal/Json/Tiles.cs index b6e7942c..924e51bc 100644 --- a/PCK-Studio/Internal/Json/Tiles.cs +++ b/PCK-Studio/Internal/Json/Tiles.cs @@ -17,6 +17,8 @@ namespace PckStudio.Internal.Json public List Blocks { get; set; } [JsonProperty("items")] public List Items { get; set; } + [JsonProperty("moon_phases")] + public List MoonPhases { get; set; } } internal static class Tiles @@ -27,6 +29,7 @@ namespace PckStudio.Internal.Json internal static List ItemTileInfos => JsonTileData.Items; internal static List BlockTileInfos => JsonTileData.Blocks; + internal static List MoonPhasesTileInfos => JsonTileData.MoonPhases; private static Image[] _itemImages; public static Image[] ItemImages => _itemImages ??= Resources.items_sheet.SplitHorizontal(16).ToArray(); @@ -34,6 +37,9 @@ namespace PckStudio.Internal.Json private static Image[] _blockImages; public static Image[] BlockImages => _blockImages ??= Resources.terrain_sheet.SplitHorizontal(16).ToArray(); + private static Image[] _moonPhasesImages; + public static Image[] MoonPhasesImages => _moonPhasesImages ??= Resources.moon_phases_sheet.SplitHorizontal(8).ToArray(); + private static ImageList _itemImageList; public static ImageList ItemImageList { @@ -63,5 +69,20 @@ namespace PckStudio.Internal.Json return _blockImageList; } } + + private static ImageList _moonPhasesImageList; + public static ImageList MoonPhasesImageList + { + get + { + if (_moonPhasesImageList is null) + { + _moonPhasesImageList = new ImageList(); + _moonPhasesImageList.ColorDepth = ColorDepth.Depth32Bit; + _moonPhasesImageList.Images.AddRange(MoonPhasesImages); + } + return _moonPhasesImageList; + } + } } } diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index d9c7cb3d..ce1f4237 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -375,11 +375,19 @@ namespace PckStudio return; } - if (file.Filename == "res/terrain.png" || file.Filename == "res/items.png") + bool isTerrainOrItems = file.Filename == "res/terrain.png" || file.Filename == "res/items.png"; + bool isMoon = file.Filename == "res/terrain/moon_phases.png"; + + if (isTerrainOrItems || isMoon) { var img = file.GetTexture(); - var res = img.Width / 16; // texture count on X axes - var size = new Size(res, res); + + var columnCount = 0; + if (isTerrainOrItems) columnCount = 16; + else if (isMoon) columnCount = 4; + + var resolution = img.Width / columnCount; + var size = new Size(resolution, resolution); var viewer = new TextureAtlasEditor(currentPCK, file.Filename, img, size); if (viewer.ShowDialog() == DialogResult.OK) { diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 3013435f..5dfbced4 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -689,6 +689,7 @@ + diff --git a/PCK-Studio/Properties/Resources.Designer.cs b/PCK-Studio/Properties/Resources.Designer.cs index 88909123..aedf0101 100644 --- a/PCK-Studio/Properties/Resources.Designer.cs +++ b/PCK-Studio/Properties/Resources.Designer.cs @@ -414,6 +414,16 @@ namespace PckStudio.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap moon_phases_sheet { + get { + object obj = ResourceManager.GetObject("moon_phases_sheet", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// @@ -617,30 +627,28 @@ namespace PckStudio.Properties { /// /// Looks up a localized string similar to { /// "COMMENT_1": "Tile data research by MattNL", - /// "COMMENT_2": "JSON conversion by PhoenixARC", + /// "COMMENT_2": "JSON by PhoenixARC, MattNL, and NessieHax (Miku-666)", /// "blocks": [ /// { /// "internalName": "grass_top", - /// "displayName": "Grass Block (Top)" + /// "displayName": "Grass Block (Top)", + /// "hasColourEntry": true, + /// "colourEntry": { + /// "defaultName": "Grass_Common", + /// "variants": [ + /// "Grass_Common", + /// "Grass_Mesa", + /// "Grass_Swamp1", + /// "Grass_Swamp2" + /// ] + /// } /// }, /// { /// "internalName": "stone", /// "displayName": "Stone" /// }, /// { - /// "internalName": "dirt", - /// "displayName": "Dirt" - /// }, - /// { - /// "internalName": "grass_side", - /// "displayName": "Grass Block (Side)" - /// }, - /// { - /// "internalName": "planks_oak", - /// "displayName": "Oak Planks" - /// }, - /// { - /// "internalName": [rest of string was truncated]";. + /// "internalName": [rest of string was truncated]";. /// public static string tileData { get { diff --git a/PCK-Studio/Properties/Resources.resx b/PCK-Studio/Properties/Resources.resx index 58f5451c..e4d8ab0b 100644 --- a/PCK-Studio/Properties/Resources.resx +++ b/PCK-Studio/Properties/Resources.resx @@ -328,4 +328,7 @@ ..\..\ProjectLogo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\moon_phases.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/PCK-Studio/Resources/moon_phases.png b/PCK-Studio/Resources/moon_phases.png new file mode 100644 index 0000000000000000000000000000000000000000..ce239ea7b40a685b1d74de6d8feca11ad580cd68 GIT binary patch literal 1569 zcmV++2HyFJP)N2bPDNB8 zb~7$DE-^4L^m3s900o^%L_t(|UhP~2Nz&P z6?dSD1t(z5mP2p>_S^&BbZbUqjU z=0}G=(T7;>A+&Akd&7A@Iah6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iYb00000NkvXXu0mjfYU}K5 literal 0 HcmV?d00001 diff --git a/PCK-Studio/Resources/tileData.json b/PCK-Studio/Resources/tileData.json index 39076f79..456dfe04 100644 --- a/PCK-Studio/Resources/tileData.json +++ b/PCK-Studio/Resources/tileData.json @@ -4134,5 +4134,39 @@ "internalName": "", "displayName": "" } + ], + "moon_phases": [ + { + "internalName": "moon_phase_0", + "displayName": "Full Moon" + }, + { + "internalName": "moon_phase_1", + "displayName": "Waning Gibbous" + }, + { + "internalName": "moon_phase_2", + "displayName": "Last Quarter" + }, + { + "internalName": "moon_phase_3", + "displayName": "Waning Crescent" + }, + { + "internalName": "moon_phase_4", + "displayName": "New Moon" + }, + { + "internalName": "moon_phase_5", + "displayName": "Waxing Crescent" + }, + { + "internalName": "moon_phase_6", + "displayName": "First Quarter" + }, + { + "internalName": "moon_phase_7", + "displayName": "Waxing Gibbous" + }, ] }