From 627cb01bf63dc2181a17f91712f89ef2d4cf8d45 Mon Sep 17 00:00:00 2001 From: MattN-L Date: Thu, 14 Mar 2024 16:52:07 -0400 Subject: [PATCH] Added Atlas Editor support for Experience Orbs --- PCK-Studio/Forms/Editor/TextureAtlasEditor.cs | 23 +++- PCK-Studio/Internal/Json/Tiles.cs | 43 ++++++- PCK-Studio/MainForm.cs | 8 +- PCK-Studio/PckStudio.csproj | 1 + PCK-Studio/Properties/Resources.Designer.cs | 10 ++ PCK-Studio/Properties/Resources.resx | 3 + .../Resources/atlases/experience_orbs.png | Bin 0 -> 583 bytes PCK-Studio/Resources/atlases/tileData.json | 121 ++++++++++++++++++ 8 files changed, 204 insertions(+), 5 deletions(-) create mode 100644 PCK-Studio/Resources/atlases/experience_orbs.png diff --git a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs index ae0609e2..21b9eb4e 100644 --- a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs +++ b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs @@ -1,4 +1,4 @@ -/* Copyright (c) 2023-present miku-666 +/* Copyright (c) 2023-present miku-666, MattNL * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. @@ -111,9 +111,11 @@ namespace PckStudio.Forms.Editor "mapicons" => (Tiles.MapIconTileInfos, "map_icons"), "additionalmapicons" => (Tiles.AdditionalMapIconTileInfos, "additional_map_icons"), "moon_phases" => (Tiles.MoonPhaseTileInfos, "moon_phases"), + "xporb" => (Tiles.ExperienceOrbTileInfos, "experience_orbs"), _ => (null, null), }; + // there's got to be a better way to get around this clone exception originalPictureBox.Image = (Image)((Bitmap)atlas).Clone(new Rectangle(new Point(0, 0), new Size(atlas.Width - 1, atlas.Height - 1)), PixelFormat.Format32bppArgb); var images = atlas.Split(_areaSize, _imageLayout); @@ -368,9 +370,12 @@ namespace PckStudio.Forms.Editor var col = FindBlendColorByKey(dataTile.Tile.ColourEntry.DefaultName); return col; } + return Color.White; } + int xp_orb_red = 0x0; + bool xp_orb_reverse = false; private Color FindBlendColorByKey(string colorKey) { if (_colourTable is not null && @@ -390,6 +395,18 @@ namespace PckStudio.Forms.Editor return waterColor.SurfaceColor; } } + + // Experience Orbs are hardcoded within a range and do not have color table entries + if (colorKey == "experience_orb") + { + if (xp_orb_red == 0) xp_orb_reverse = false; + if (xp_orb_red == 0xFF) xp_orb_reverse = true; + + xp_orb_red += xp_orb_reverse ? -0x05 : 0x05; + + return Color.FromArgb(xp_orb_red, 255, 0); + } + return Color.White; } @@ -397,6 +414,10 @@ namespace PckStudio.Forms.Editor { switch (keyData) { + case Keys.R: + // Reselects the specific tile. Can be held to for cycling through colors for XP orbs + SelectedIndex = _selectedTile.Index; + return true; case Keys.Left: SelectedIndex = _selectedTile.Index - 1; return true; diff --git a/PCK-Studio/Internal/Json/Tiles.cs b/PCK-Studio/Internal/Json/Tiles.cs index a7e95c9a..68691564 100644 --- a/PCK-Studio/Internal/Json/Tiles.cs +++ b/PCK-Studio/Internal/Json/Tiles.cs @@ -15,14 +15,21 @@ namespace PckStudio.Internal.Json { [JsonProperty("blocks")] public List Blocks { get; set; } + [JsonProperty("items")] public List Items { get; set; } + [JsonProperty("moon_phases")] public List MoonPhases { get; set; } + [JsonProperty("map_icons")] public List MapIcons { get; set; } + [JsonProperty("additional_map_icons")] public List AdditionalMapIcons { get; set; } + + [JsonProperty("experience_orbs")] + public List ExperienceOrbs { get; set; } } internal static class Tiles @@ -36,6 +43,7 @@ namespace PckStudio.Internal.Json internal static List MoonPhaseTileInfos => JsonTileData.MoonPhases; internal static List MapIconTileInfos => JsonTileData.MapIcons; internal static List AdditionalMapIconTileInfos => JsonTileData.AdditionalMapIcons; + internal static List ExperienceOrbTileInfos => JsonTileData.ExperienceOrbs; private static Image[] _itemImages; public static Image[] ItemImages => _itemImages ??= Resources.items_sheet.SplitHorizontal(16).ToArray(); @@ -50,7 +58,10 @@ namespace PckStudio.Internal.Json public static Image[] MapIconImages => _mapIconImages ??= Resources.map_icons_sheet.SplitHorizontal(4).ToArray(); private static Image[] _additionalMapIconImages; - public static Image[] AdditionalMapIconImages => _mapIconImages ??= Resources.additional_map_icons_sheet.SplitHorizontal(4).ToArray(); + public static Image[] AdditionalMapIconImages => _additionalMapIconImages ??= Resources.additional_map_icons_sheet.SplitHorizontal(4).ToArray(); + + private static Image[] _experienceOrbIconImages; + public static Image[] ExperienceOrbIconImages => _experienceOrbIconImages ??= Resources.experience_orbs_sheet.SplitHorizontal(4).ToArray(); private static ImageList _itemImageList; public static ImageList ItemImageList @@ -111,5 +122,35 @@ namespace PckStudio.Internal.Json return _mapIconImageList; } } + + private static ImageList _additionalMapIconImageList; + public static ImageList AdditionalMapIconImageList + { + get + { + if (_additionalMapIconImageList is null) + { + _additionalMapIconImageList = new ImageList(); + _additionalMapIconImageList.ColorDepth = ColorDepth.Depth32Bit; + _additionalMapIconImageList.Images.AddRange(AdditionalMapIconImages); + } + return _additionalMapIconImageList; + } + } + + private static ImageList _experienceOrbsImageList; + public static ImageList ExperienceOrbsImageList + { + get + { + if (_experienceOrbsImageList is null) + { + _experienceOrbsImageList = new ImageList(); + _experienceOrbsImageList.ColorDepth = ColorDepth.Depth32Bit; + _experienceOrbsImageList.Images.AddRange(ExperienceOrbIconImages); + } + return _experienceOrbsImageList; + } + } } } diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index fc50240c..9439a115 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -379,14 +379,16 @@ namespace PckStudio bool isMoonPhases = file.Filename == "res/terrain/moon_phases.png"; bool isMapIcons = file.Filename == "res/misc/mapicons.png"; bool isAdditionalMapIcons = file.Filename == "res/misc/additionalmapicons.png"; + bool isXPOrbs = file.Filename == "res/item/xporb.png"; - if (isTerrainOrItems || isMoonPhases || isMapIcons || isAdditionalMapIcons) + if (isTerrainOrItems || isMoonPhases || isMapIcons || isAdditionalMapIcons || isXPOrbs) { var img = file.GetTexture(); - var columnCount = 0; + // all of the other atlases so far use 4 + var columnCount = 4; + if (isTerrainOrItems) columnCount = 16; - else if (isMoonPhases || isMapIcons || isAdditionalMapIcons) columnCount = 4; var resolution = img.Width / columnCount; var size = new Size(resolution, resolution); diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 3d6c6f18..35eeeb95 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -680,6 +680,7 @@ + diff --git a/PCK-Studio/Properties/Resources.Designer.cs b/PCK-Studio/Properties/Resources.Designer.cs index a3b953f4..9a8e5b0d 100644 --- a/PCK-Studio/Properties/Resources.Designer.cs +++ b/PCK-Studio/Properties/Resources.Designer.cs @@ -294,6 +294,16 @@ namespace PckStudio.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap experience_orbs_sheet { + get { + object obj = ResourceManager.GetObject("experience_orbs_sheet", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/PCK-Studio/Properties/Resources.resx b/PCK-Studio/Properties/Resources.resx index 5cfa8456..9c8afa9a 100644 --- a/PCK-Studio/Properties/Resources.resx +++ b/PCK-Studio/Properties/Resources.resx @@ -337,4 +337,7 @@ ..\Resources\atlases\map_icons.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\atlases\experience_orbs.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/atlases/experience_orbs.png b/PCK-Studio/Resources/atlases/experience_orbs.png new file mode 100644 index 0000000000000000000000000000000000000000..1a2d58a36c8a49b5c5c86ae387325467fb74e82a GIT binary patch literal 583 zcmV-N0=WH&P)Px#1ZP1_K>z@;j|==^1poj57*I@9MR0I%prD|^!NLFk|Np?i|B#UXY-|7k0D?BJ z)c^nh2y{|TQ~&?}|NsC00N#VWSpWb432;bRa{vGi!vFvd!vV){sAK>D0i;PpK~z{r z-Ia@O!ypVrNhs|9|9J8f0}hP2lcri~rQ_H)30#Nt6^t|{PUB|+3BzSyU}#7eh9)et z%(5X}H-;oSCKc>Zg>+$sC`i310Oy=DF{iFpFBN*nz5y99XDa{=RzR;m3A|o!7Kpw= zbP>bbIK^7fG14vu!M&9a;=c+k-g#vH?+ct&w?^ZAG`lc4u``nAgJyO7jougboTuf@ z%6&rnMM3)2yLcIf2^%mY2^PR%YvYDoiZb>i=bHptK@+eIch05O0*|2OwQ|E-1j4Tn zUBvJ*F2Dtv{z@SD3c*E;Ze!R;o^?lFTiG9;kr%_Hg6;B-ZMeykc$2{R zga=G(V7BFy;jc5sDNois