Added atlas editor support for moon phases

This commit is contained in:
MattN-L
2024-03-13 07:01:31 -04:00
parent 513e73fa1a
commit f6e72b0e6e
8 changed files with 108 additions and 29 deletions

View File

@@ -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;

View File

@@ -17,6 +17,8 @@ namespace PckStudio.Internal.Json
public List<JsonTileInfo> Blocks { get; set; }
[JsonProperty("items")]
public List<JsonTileInfo> Items { get; set; }
[JsonProperty("moon_phases")]
public List<JsonTileInfo> MoonPhases { get; set; }
}
internal static class Tiles
@@ -27,6 +29,7 @@ namespace PckStudio.Internal.Json
internal static List<JsonTileInfo> ItemTileInfos => JsonTileData.Items;
internal static List<JsonTileInfo> BlockTileInfos => JsonTileData.Blocks;
internal static List<JsonTileInfo> 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;
}
}
}
}

View File

@@ -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)
{

View File

@@ -689,6 +689,7 @@
<None Include="Resources\icons\ranch.png" />
<Content Include="Resources\icons\Replace.png" />
<Content Include="Resources\icons\Save.png" />
<None Include="Resources\moon_phases.png" />
<Content Include="Resources\NoImageFound.png" />
</ItemGroup>
<ItemGroup>

View File

@@ -414,6 +414,16 @@ namespace PckStudio.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap moon_phases_sheet {
get {
object obj = ResourceManager.GetObject("moon_phases_sheet", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
@@ -617,30 +627,28 @@ namespace PckStudio.Properties {
/// <summary>
/// Looks up a localized string similar to {
/// &quot;COMMENT_1&quot;: &quot;Tile data research by MattNL&quot;,
/// &quot;COMMENT_2&quot;: &quot;JSON conversion by PhoenixARC&quot;,
/// &quot;COMMENT_2&quot;: &quot;JSON by PhoenixARC, MattNL, and NessieHax (Miku-666)&quot;,
/// &quot;blocks&quot;: [
/// {
/// &quot;internalName&quot;: &quot;grass_top&quot;,
/// &quot;displayName&quot;: &quot;Grass Block (Top)&quot;
/// &quot;displayName&quot;: &quot;Grass Block (Top)&quot;,
/// &quot;hasColourEntry&quot;: true,
/// &quot;colourEntry&quot;: {
/// &quot;defaultName&quot;: &quot;Grass_Common&quot;,
/// &quot;variants&quot;: [
/// &quot;Grass_Common&quot;,
/// &quot;Grass_Mesa&quot;,
/// &quot;Grass_Swamp1&quot;,
/// &quot;Grass_Swamp2&quot;
/// ]
/// }
/// },
/// {
/// &quot;internalName&quot;: &quot;stone&quot;,
/// &quot;displayName&quot;: &quot;Stone&quot;
/// },
/// {
/// &quot;internalName&quot;: &quot;dirt&quot;,
/// &quot;displayName&quot;: &quot;Dirt&quot;
/// },
/// {
/// &quot;internalName&quot;: &quot;grass_side&quot;,
/// &quot;displayName&quot;: &quot;Grass Block (Side)&quot;
/// },
/// {
/// &quot;internalName&quot;: &quot;planks_oak&quot;,
/// &quot;displayName&quot;: &quot;Oak Planks&quot;
/// },
/// {
/// &quot;internalName&quot;: [rest of string was truncated]&quot;;.
/// &quot;internalName&quot;: [rest of string was truncated]&quot;;.
/// </summary>
public static string tileData {
get {

View File

@@ -328,4 +328,7 @@
<data name="ProjectLogo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\ProjectLogo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="moon_phases_sheet" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\moon_phases.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

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