TexturePackerFileContent.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections.Generic;
  2. using System.Text.Json.Serialization;
  3. using MonoGame.Extended.Serialization.Json;
  4. namespace MonoGame.Extended.Content.TexturePacker;
  5. public record TexturePackerFileContent([property: JsonPropertyName("frames")] List<TexturePackerFrame> Regions,
  6. [property: JsonPropertyName("textures")] List<TexturePackerTexture> Textures,
  7. [property: JsonPropertyName("meta")] TexturePackerMeta Meta);
  8. public record TexturePackerTexture([property: JsonPropertyName("filename")] string FileName,
  9. [property: JsonPropertyName("format")] string? Format = null,
  10. [property: JsonPropertyName("size")] TexturePackerSize Size = default,
  11. [property: JsonPropertyName("scale")] string? Scale = null,
  12. [property: JsonPropertyName("premultiplied")] bool Premultiplied = false,
  13. [property: JsonPropertyName("frames")] Dictionary<string, TexturePackerTextureFrame>? Frames = null
  14. );
  15. public record TexturePackerTextureFrame([property: JsonPropertyName("frame")] TexturePackerRectangle Frame,
  16. [property: JsonPropertyName("rotated")] int Rotated = 0,
  17. [property: JsonPropertyName("size")] TexturePackerSize? Size = null,
  18. [property: JsonPropertyName("offset")] TexturePackerPoint? Offset = null,
  19. [property: JsonPropertyName("pivot")] TexturePackerPointF? Pivot = null,
  20. [property: JsonPropertyName("scale9")] TexturePackerRectangle? Scale9 = null
  21. );
  22. public record TexturePackerPoint([property: JsonPropertyName("x")] int X,
  23. [property: JsonPropertyName("y")] int Y);
  24. public record TexturePackerPointF([property: JsonPropertyName("x")] double X,
  25. [property: JsonPropertyName("y")] double Y);
  26. public record TexturePackerSize([property: JsonPropertyName("w")] int Width,
  27. [property: JsonPropertyName("h")] int Height);
  28. public record TexturePackerRectangle([property: JsonPropertyName("x")] int X,
  29. [property: JsonPropertyName("y")] int Y,
  30. [property: JsonPropertyName("w")] int Width,
  31. [property: JsonPropertyName("h")] int Height);
  32. public record TexturePackerFrame([property: JsonPropertyName("filename")] string FileName,
  33. [property: JsonPropertyName("frame")] TexturePackerRectangle Frame,
  34. [property: JsonPropertyName("rotated")] bool Rotated,
  35. [property: JsonPropertyName("trimmed")] bool Trimmed,
  36. [property: JsonPropertyName("spriteSourceSize")] TexturePackerRectangle SpriteSourceSize,
  37. [property: JsonPropertyName("sourceSize")] TexturePackerSize SourceSize,
  38. [property: JsonPropertyName("pivot")] TexturePackerPointF PivotPoint);
  39. public record TexturePackerMeta([property: JsonPropertyName("app")] string App,
  40. [property: JsonPropertyName("version")] string Version,
  41. [property: JsonPropertyName("image")] string Image,
  42. [property: JsonPropertyName("dataformat")] string DataFormat,
  43. [property: JsonPropertyName("smartupdate")] string SmartUpdate);