recrownedathenaeum/RecrownedAthenaeum/Serializable/TextureAtlasData.cs

85 lines
3.0 KiB
C#
Raw Normal View History

using Microsoft.Xna.Framework;
2019-01-15 23:44:15 +00:00
namespace RecrownedAthenaeum.Serializable
{
2019-01-15 23:03:17 +00:00
/// <summary>
/// Data transfer object for a texture atlas.
/// </summary>
public class TextureAtlasData
{
2019-01-15 23:03:17 +00:00
/// <summary>
/// Contains the regions of the texture atlas.
/// </summary>
2019-01-15 05:38:50 +00:00
public AtlasRegionData[] regions;
2019-01-15 23:03:17 +00:00
/// <summary>
/// The name of the file.
/// </summary>
public string textureName;
2019-01-15 23:03:17 +00:00
/// <summary>
/// Creates the atlas given the regions and the file name of the texture file to be used.
/// </summary>
/// <param name="textureName"></param>
/// <param name="regions"></param>
2019-01-15 05:38:50 +00:00
public TextureAtlasData(string textureName, AtlasRegionData[] regions)
{
this.regions = regions;
this.textureName = textureName;
}
2019-01-15 23:03:17 +00:00
/// <summary>
/// Data object that contains information about the region ninepatch situation of a given region in an atlas.
/// </summary>
2019-01-15 05:38:50 +00:00
public class AtlasRegionData
{
2019-01-15 23:03:17 +00:00
/// <summary>
/// Name of the region for referencial purposes.
/// </summary>
public string name;
2019-01-15 23:03:17 +00:00
/// <summary>
/// The location of the patch is designated by this rectangle.
/// </summary>
public Rectangle location;
2019-01-15 23:03:17 +00:00
/// <summary>
/// The ninepatch information.
/// </summary>
public NinePatchData ninePatchData;
2019-01-15 23:03:17 +00:00
/// <summary>
/// Sets position in atlas for convenience.
/// </summary>
/// <param name="x">X coordinate of the position in the patch.</param>
/// <param name="y">Y coordinate of the position in the patch.</param>
public void SetPosition(int x, int y)
{
location.X = x;
location.Y = y;
}
2019-01-15 23:03:17 +00:00
/// <summary>
/// Sets the dimensions of the region on the atlas for convenience.
/// </summary>
/// <param name="width">Width of the region.</param>
/// <param name="height">Height of the region.</param>
public void SetSize(int width, int height)
{
location.Width = width;
location.Height = height;
}
2019-01-15 23:03:17 +00:00
/// <summary>
/// Sets both the coordinates and dimensions of the region on the atlas for convenience.
/// </summary>
/// <param name="x">X coordinate of the position in the patch.</param>
/// <param name="y">Y coordinate of the position in the patch.</param>
/// <param name="width">Width of the region.</param>
/// <param name="height">Height of the region.</param>
public void SetBounds(int x, int y, int width, int height)
{
SetPosition(x, y);
SetSize(width, height);
}
}
}
}