2019-11-24 20:49:53 +00:00
|
|
|
|
using RecrownedAthenaeum.Types;
|
2019-01-20 07:07:52 +00:00
|
|
|
|
namespace RecrownedAthenaeum.Data
|
2018-12-05 01:19:31 +00:00
|
|
|
|
{
|
2019-01-15 23:03:17 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Data transfer object for a texture atlas.
|
|
|
|
|
/// </summary>
|
2018-12-05 08:28:09 +00:00
|
|
|
|
public class TextureAtlasData
|
2018-12-05 01:19:31 +00:00
|
|
|
|
{
|
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>
|
2018-12-05 08:28:09 +00:00
|
|
|
|
public string textureName;
|
2018-12-05 01:19:31 +00:00
|
|
|
|
|
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)
|
2018-12-08 23:04:33 +00:00
|
|
|
|
{
|
|
|
|
|
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-03-21 00:28:16 +00:00
|
|
|
|
public struct AtlasRegionData
|
2018-12-05 01:19:31 +00:00
|
|
|
|
{
|
2019-01-15 23:03:17 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Name of the region for referencial purposes.
|
|
|
|
|
/// </summary>
|
2018-12-05 01:19:31 +00:00
|
|
|
|
public string name;
|
2019-01-15 23:03:17 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The location of the patch is designated by this rectangle.
|
|
|
|
|
/// </summary>
|
2019-01-22 01:56:51 +00:00
|
|
|
|
public Rectangle bounds;
|
2019-01-15 23:03:17 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The ninepatch information.
|
|
|
|
|
/// </summary>
|
2018-12-05 08:28:09 +00:00
|
|
|
|
public NinePatchData ninePatchData;
|
2018-12-07 23:58:59 +00:00
|
|
|
|
|
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>
|
2018-12-07 23:58:59 +00:00
|
|
|
|
public void SetPosition(int x, int y)
|
|
|
|
|
{
|
2019-01-22 01:56:51 +00:00
|
|
|
|
bounds.X = x;
|
|
|
|
|
bounds.Y = y;
|
2018-12-07 23:58:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
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>
|
2018-12-07 23:58:59 +00:00
|
|
|
|
public void SetSize(int width, int height)
|
|
|
|
|
{
|
2019-01-22 01:56:51 +00:00
|
|
|
|
bounds.Width = width;
|
|
|
|
|
bounds.Height = height;
|
2018-12-07 23:58:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
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>
|
2018-12-07 23:58:59 +00:00
|
|
|
|
public void SetBounds(int x, int y, int width, int height)
|
|
|
|
|
{
|
|
|
|
|
SetPosition(x, y);
|
|
|
|
|
SetSize(width, height);
|
|
|
|
|
}
|
2018-12-05 01:19:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|