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