diff --git a/RecrownedAthenaeum.ConsoleTools/TextureAtlasTools/TexturePacker.cs b/RecrownedAthenaeum.ConsoleTools/TextureAtlasTools/TexturePacker.cs index 353c3a4..a745e0f 100644 --- a/RecrownedAthenaeum.ConsoleTools/TextureAtlasTools/TexturePacker.cs +++ b/RecrownedAthenaeum.ConsoleTools/TextureAtlasTools/TexturePacker.cs @@ -8,6 +8,7 @@ using RecrownedAthenaeum.Pipeline.NinePatch; using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using System.Linq; +using Newtonsoft.Json; namespace RecrownedAthenaeum.Tools.TextureAtlas { @@ -85,8 +86,9 @@ namespace RecrownedAthenaeum.Tools.TextureAtlas /// /// Renders the build into a PNG file and generates the respective meant for serialization and later to be loaded. /// - /// - public void Save(string output) + /// directory to output to. + /// name of atlas. + public void Save(string output, string atlasName) { GraphicsOptions gOptions = new GraphicsOptions(); @@ -104,13 +106,17 @@ namespace RecrownedAthenaeum.Tools.TextureAtlas regions[i].ninePatchData = imageH.ninePatchData; atlasTexture.Mutate(img => img.DrawImage(gOptions, imageH.image, new Point(imageH.x, imageH.y))); } - using (FileStream stream = new FileStream(output, FileMode.Create)) + using (FileStream stream = new FileStream(output + atlasName + ".png", FileMode.Create)) { atlasTexture.SaveAsPng(stream); } } + string serialized = JsonConvert.SerializeObject(new TextureAtlasData(atlasName + ".png", regions)); - + using (StreamWriter stream = new StreamWriter(output + atlasName + ".tatlas")) + { + stream.WriteLine(serialized); + } } public void SetNinePatch(string fileName, int a, int b, int c, int d)