recrownedgtk/RecrownedAthenaeum/Data/TextureAtlasData.cs

85 lines
2.9 KiB
C#

using Microsoft.Xna.Framework;
namespace RecrownedAthenaeum.Data
{
/// <summary>
/// Data transfer object for a texture atlas.
/// </summary>
public class TextureAtlasData
{
/// <summary>
/// Contains the regions of the texture atlas.
/// </summary>
public AtlasRegionData[] regions;
/// <summary>
/// The name of the file.
/// </summary>
public string textureName;
/// <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>
public TextureAtlasData(string textureName, AtlasRegionData[] regions)
{
this.regions = regions;
this.textureName = textureName;
}
/// <summary>
/// Data object that contains information about the region ninepatch situation of a given region in an atlas.
/// </summary>
public struct AtlasRegionData
{
/// <summary>
/// Name of the region for referencial purposes.
/// </summary>
public string name;
/// <summary>
/// The location of the patch is designated by this rectangle.
/// </summary>
public Rectangle bounds;
/// <summary>
/// The ninepatch information.
/// </summary>
public NinePatchData ninePatchData;
/// <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)
{
bounds.X = x;
bounds.Y = y;
}
/// <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)
{
bounds.Width = width;
bounds.Height = height;
}
/// <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);
}
}
}
}