diff --git a/RecrownedAthenaeum/DataTypes/TextureAtlas.cs b/RecrownedAthenaeum/DataTypes/TextureAtlas.cs
index a184d96..4076d68 100644
--- a/RecrownedAthenaeum/DataTypes/TextureAtlas.cs
+++ b/RecrownedAthenaeum/DataTypes/TextureAtlas.cs
@@ -5,12 +5,27 @@ using System.Collections.Generic;
namespace RecrownedAthenaeum.DataTypes
{
+ ///
+ /// Holds information about an image file that contains various textures in various regions in the file.
+ ///
public class TextureAtlas
{
private Texture2D texture;
private Dictionary dictionaryOfRegions = new Dictionary();
+
+ ///
+ /// Given a name, can return a .
+ ///
+ /// Name of to obtain.
+ /// based off name.
public TextureAtlasRegion this[string name] { get { if (name != null && dictionaryOfRegions.ContainsKey(name)) return dictionaryOfRegions[name]; else return null; } }
+
+ ///
+ /// Creates a texture atlas with given main texture as well as an array of to represent locations of which textures reside within the atlas. Region names will be used to refer to the regions within the dictionary.
+ ///
+ /// The texture representing the overall atlas.
+ /// The sub regions that represent the individual textures.
public TextureAtlas(Texture2D texture, TextureAtlasRegion[] regions)
{
this.texture = texture;
@@ -20,6 +35,11 @@ namespace RecrownedAthenaeum.DataTypes
}
}
+ ///
+ /// Creates a texture region given a dictionary of regions keyed to strings that can be used to refer to them.
+ ///
+ /// The texture representing the overall atlas.
+ ///
public TextureAtlas(Texture2D texture, Dictionary dictionaryOfRegions)
{
this.texture = texture;
@@ -51,13 +71,23 @@ namespace RecrownedAthenaeum.DataTypes
return dictionaryOfRegions[name].AsTexture2D(graphicsDevice);
}
+ ///
+ /// A region of a .
+ ///
public class TextureAtlasRegion : IComparable, ISpecialDrawable, IDisposable
{
+ ///
+ /// The name of the region. Mostly used to be refered to within the context of a .
+ ///
public readonly string name;
+ ///
+ /// The location and dimensions of where the original texture resides on the texture representing the atlas.
+ ///
public readonly Rectangle sourceRectangle;
readonly NinePatch ninepatch;
Texture2D atlasTexture;
Texture2D regionTexture;
+ private bool disposed;
///
/// A specified region in a texture atlas.
@@ -74,8 +104,18 @@ namespace RecrownedAthenaeum.DataTypes
this.ninepatch = ninePatch;
}
- public void Draw(SpriteBatch batch, Rectangle destination, Color color, float rotation, Vector2 origin)
+ ///
+ /// Draws the region. If ninepatch, rotation and origin are ignored.
+ ///
+ /// The batch to use. Should be began.
+ /// The destination rectangle to draw to.
+ /// The color to use.
+ /// Rotation of the final drawing. Ignored if is a 9patch.
+ /// The origin of the drawing. Ignored if is a 9patch.
+ public void Draw(SpriteBatch batch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
{
+ if (disposed) throw new ObjectDisposedException(GetType().Name);
+
if (ninepatch != null)
{
ninepatch.Draw(batch, destination);
@@ -92,6 +132,8 @@ namespace RecrownedAthenaeum.DataTypes
/// The texture of the region.
public Texture2D AsTexture2D(GraphicsDevice graphicsDevice)
{
+ if (disposed) throw new ObjectDisposedException(GetType().Name);
+
if (regionTexture == null)
{
Color[] data = new Color[sourceRectangle.Width * sourceRectangle.Height];
@@ -102,14 +144,45 @@ namespace RecrownedAthenaeum.DataTypes
return regionTexture;
}
+ ///
+ /// Compares this region to another in terms of name.
+ ///
+ /// The other region to compare to in terms of name.
+ /// Less than one if precedes, greater than one if after, 0 if same.
public int CompareTo(TextureAtlasRegion other)
{
return name.CompareTo(other);
}
+ ///
+ /// Call this to dispose.
+ ///
public void Dispose()
{
- regionTexture?.Dispose();
+ if (disposed) throw new ObjectDisposedException(GetType().Name);
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Overridable dispose.
+ ///
+ /// Whether or not this was a user made call.
+ public virtual void Dispose(bool disposing)
+ {
+ if (disposing && !disposed)
+ {
+ regionTexture?.Dispose();
+ }
+ disposed = true;
+ }
+
+ ///
+ /// Destructor.
+ ///
+ ~TextureAtlasRegion()
+ {
+ Dispose(false);
}
}
}
diff --git a/RecrownedAthenaeum/ScreenSystem/Screen.cs b/RecrownedAthenaeum/ScreenSystem/Screen.cs
index c2df13c..c8493c3 100644
--- a/RecrownedAthenaeum/ScreenSystem/Screen.cs
+++ b/RecrownedAthenaeum/ScreenSystem/Screen.cs
@@ -32,6 +32,7 @@ namespace RecrownedAthenaeum.ScreenSystem
/// Transitions to apply.
///
public readonly List Transitions;
+
///
/// Whether or not to continue rendering this screen onto a buffer for the benifit of the next screen to use as a transition.
///
@@ -113,7 +114,6 @@ namespace RecrownedAthenaeum.ScreenSystem
///
/// Time passed since last frame in seconds.
/// If the this transition should wait.
- /// The previous screen's frame. May be null.
/// Only returns true if exit transition is complete. Returns false otherwise.
public bool UpdateTransition(double delta, bool waiting)
{
diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs
index a1a30e3..4504e2d 100644
--- a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs
+++ b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs
@@ -5,11 +5,27 @@ using RecrownedAthenaeum.UI.Skin.Definitions;
namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
{
+ ///
+ /// Button that holds a string.
+ ///
public class TextButton : Button
{
private Text text;
+
+ ///
+ /// The color the font should be rendered in.
+ ///
public Color FontColor { get { return text.color; } set { text.color = value; } }
+ ///
+ /// Constructs text button with the positions represented by
+ ///
+ /// The string representing the text to be displayed.
+ /// The font to be used to display the text.
+ /// What to draw as button is pushed down.
+ /// What to draw as button is not pushed.
+ /// What to draw as button is disabled.
+ /// What to draw as button is selected.
public TextButton(string text, SpriteFont font, ISpecialDrawable down, ISpecialDrawable up, ISpecialDrawable disabled = null, ISpecialDrawable selected = null) : base(down, up, disabled, selected)
{
this.text = new Text(font, text)
@@ -18,6 +34,12 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
};
}
+ ///
+ /// Constructs a text button using a skin and definition.
+ ///
+ /// The text to display.
+ /// The skin to use.
+ /// Name of the definition for this type in the skin given.
public TextButton(string text, Skin.Skin skin, string definitionName = null) : base(skin, definitionName)
{
TextButtonSkinDefinition skinDefinition = skin.ObtainDefinition(definitionName, GetType());
@@ -25,6 +47,10 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
FontColor = skin.colors[skinDefinition.fontColor];
}
+ ///
+ /// Updates the text button.
+ ///
+ /// Snapshot of information about time for game.
public override void Update(GameTime gameTime)
{
text.bounds = bounds;
@@ -32,6 +58,10 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
base.Update(gameTime);
}
+ ///
+ /// Called whenever game wants to render this button.
+ ///
+ /// Batch to use. Batch should already be started.
public override void Draw(SpriteBatch batch)
{
text.Draw(batch);
diff --git a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs b/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs
index f6506db..b56796a 100644
--- a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs
+++ b/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs
@@ -16,10 +16,19 @@ namespace RecrownedAthenaeum.UI.Modular
List modules = new List();
Rectangle scissorBounds;
RasterizerState scissorRasterizer = new RasterizerState();
+ ///
+ /// Camera used by the module for cropping.
+ ///
public Camera2D Camera { get; set; }
+ ///
+ /// Creates a module group.
+ ///
+ /// Whether or not to crop out of bounds. Default is false.
+ /// What camera to use for cropping. Default is null.
public UIModuleGroup(bool crop = false, Camera2D camera = null)
{
+ if (crop && camera == null) throw new ArgumentException("Cannot crop without camera.");
Camera = camera;
if (crop)
{
diff --git a/RecrownedAthenaeum/UI/Skin/Definitions/TextButtonSkinDefinition.cs b/RecrownedAthenaeum/UI/Skin/Definitions/TextButtonSkinDefinition.cs
index 72ee626..cf22224 100644
--- a/RecrownedAthenaeum/UI/Skin/Definitions/TextButtonSkinDefinition.cs
+++ b/RecrownedAthenaeum/UI/Skin/Definitions/TextButtonSkinDefinition.cs
@@ -3,13 +3,31 @@ using System;
namespace RecrownedAthenaeum.UI.Skin.Definitions
{
+ ///
+ /// Definition for a text button for a skin theme.
+ ///
public class TextButtonSkinDefinition : ButtonSkinDefinition
{
+ ///
+ /// Name of font from the skin to use.
+ ///
public string fontName;
+
+ ///
+ /// Name of color from the skin to use for the font.
+ ///
public string fontColor;
+ ///
+ /// The type of module that will be using this definition.
+ ///
public new Type UIModuleType => typeof(TextButton);
+ ///
+ /// Creates this definition with the most minimal requirements.
+ ///
+ /// Texture region from skin that represents when the button is pressed down.
+ /// The texture region that represents when the button is not pressed.
public TextButtonSkinDefinition(string downRegion, string upRegion) : base(downRegion, upRegion)
{