refactors.

This commit is contained in:
Harrison Deng 2019-01-15 19:34:47 -06:00
parent 203f251df6
commit a27df5a287

View File

@ -13,24 +13,24 @@ namespace RecrownedAthenaeum.SpecialTypes
{
private Texture2D texture;
private bool disposed;
private Dictionary<string, TextureAtlasRegion> dictionaryOfRegions = new Dictionary<string, TextureAtlasRegion>();
private Dictionary<string, Region> dictionaryOfRegions = new Dictionary<string, Region>();
/// <summary>
/// Given a name, can return a <see cref="TextureAtlasRegion"/>.
/// Given a name, can return a <see cref="Region"/>.
/// </summary>
/// <param name="name">Name of <see cref="TextureAtlasRegion"/> to obtain.</param>
/// <returns><see cref="TextureAtlasRegion"/> based off name.</returns>
public TextureAtlasRegion this[string name] { get { if (name != null && dictionaryOfRegions.ContainsKey(name)) return dictionaryOfRegions[name]; else return null; } }
/// <param name="name">Name of <see cref="Region"/> to obtain.</param>
/// <returns><see cref="Region"/> based off name.</returns>
public Region this[string name] { get { if (name != null && dictionaryOfRegions.ContainsKey(name)) return dictionaryOfRegions[name]; else return null; } }
/// <summary>
/// Creates a texture atlas with given main texture as well as an array of <see cref="TextureAtlasRegion"/> to represent locations of which textures reside within the atlas. Region names will be used to refer to the regions within the dictionary.
/// Creates a texture atlas with given main texture as well as an array of <see cref="Region"/> to represent locations of which textures reside within the atlas. Region names will be used to refer to the regions within the dictionary.
/// </summary>
/// <param name="texture">The texture representing the overall atlas.</param>
/// <param name="regions">The sub regions that represent the individual textures.</param>
public TextureAtlas(Texture2D texture, TextureAtlasRegion[] regions)
public TextureAtlas(Texture2D texture, Region[] regions)
{
this.texture = texture;
foreach (TextureAtlasRegion region in regions)
foreach (Region region in regions)
{
dictionaryOfRegions.Add(region.name, region);
}
@ -41,7 +41,7 @@ namespace RecrownedAthenaeum.SpecialTypes
/// </summary>
/// <param name="texture">The texture representing the overall atlas.</param>
/// <param name="dictionaryOfRegions"></param>
public TextureAtlas(Texture2D texture, Dictionary<string, TextureAtlasRegion> dictionaryOfRegions)
public TextureAtlas(Texture2D texture, Dictionary<string, Region> dictionaryOfRegions)
{
this.texture = texture;
this.dictionaryOfRegions = dictionaryOfRegions;
@ -109,7 +109,7 @@ namespace RecrownedAthenaeum.SpecialTypes
/// <summary>
/// A region of a <see cref="TextureAtlas"/>.
/// </summary>
public class TextureAtlasRegion : IComparable<TextureAtlasRegion>, ISpecialDrawable, IDisposable
public class Region : IComparable<Region>, ISpecialDrawable, IDisposable
{
/// <summary>
/// The name of the region. Mostly used to be refered to within the context of a <see cref="TextureAtlas"/>.
@ -132,7 +132,7 @@ namespace RecrownedAthenaeum.SpecialTypes
/// <param name="sourceRegion">The location of the region on the atlas.</param>
/// <param name="ninePatch">A <see cref="NinePatch"/> definition for the region.</param>
/// <param name="atlasTexture">The texture that holds the image data for the atlas.</param>
public TextureAtlasRegion(string name, Rectangle sourceRegion, NinePatch ninePatch, Texture2D atlasTexture)
public Region(string name, Rectangle sourceRegion, NinePatch ninePatch, Texture2D atlasTexture)
{
this.atlasTexture = atlasTexture ?? throw new ArgumentNullException("Name parameters can be null.");
this.name = name ?? throw new ArgumentNullException("Name parameters can be null.");
@ -185,7 +185,7 @@ namespace RecrownedAthenaeum.SpecialTypes
/// </summary>
/// <param name="other">The other region to compare to in terms of name.</param>
/// <returns>Less than one if precedes, greater than one if after, 0 if same.</returns>
public int CompareTo(TextureAtlasRegion other)
public int CompareTo(Region other)
{
return name.CompareTo(other);
}
@ -216,7 +216,7 @@ namespace RecrownedAthenaeum.SpecialTypes
/// <summary>
/// Destructor.
/// </summary>
~TextureAtlasRegion()
~Region()
{
Dispose(false);
}