diff --git a/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchData.cs b/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchData.cs
index 550fcef..d2d2560 100644
--- a/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchData.cs
+++ b/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchData.cs
@@ -1,17 +1,37 @@
-namespace RecrownedAthenaeum.Pipeline.NinePatch
+using RecrownedAthenaeum.Pipeline.TextureAtlas;
+
+namespace RecrownedAthenaeum.Pipeline.NinePatch
{
+ ///
+ /// Represents a data structure for 9patches.
+ ///
public class NinePatchData
{
+ ///
+ /// Name of texture associated with patch. May be null in the case of being apart of a
+ ///
public string textureName;
- public int left, right, down, top;
- public NinePatchData(string textureName, int left, int right, int down, int top)
+ ///
+ /// the boundaries of the patch.
+ ///
+ public int left, right, bottom, top;
+
+ ///
+ /// Constructs patch.
+ ///
+ /// Name of the texture. May be null.
+ /// Left bound.
+ /// Right bound.
+ /// Bottom bound.
+ /// Top bound.
+ public NinePatchData(string textureName, int left, int right, int bottom, int Top)
{
this.textureName = textureName;
this.left = left;
this.right = right;
- this.down = down;
- this.top = top;
+ this.bottom = bottom;
+ this.top = Top;
}
}
}
diff --git a/RecrownedAthenaeum/DataTypes/ISpecialDrawable.cs b/RecrownedAthenaeum/DataTypes/ISpecialDrawable.cs
index 0429510..7866c3a 100644
--- a/RecrownedAthenaeum/DataTypes/ISpecialDrawable.cs
+++ b/RecrownedAthenaeum/DataTypes/ISpecialDrawable.cs
@@ -3,8 +3,19 @@ using Microsoft.Xna.Framework.Graphics;
namespace RecrownedAthenaeum.DataTypes
{
+ ///
+ /// A wrapper that makes sure anything implementing can be drawn with options.
+ ///
public interface ISpecialDrawable
{
+ ///
+ /// Should draw whatever implements this.
+ ///
+ /// The batch to be used.
+ /// The location and dimensions to draw to.
+ /// The color tint to draw with.
+ /// The rotation to be used.
+ /// The origin for the rotation.
void Draw(SpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0f, Vector2 origin = default(Vector2));
}
}
diff --git a/RecrownedAthenaeum/DataTypes/NinePatch.cs b/RecrownedAthenaeum/DataTypes/NinePatch.cs
index 449a3b5..8656d08 100644
--- a/RecrownedAthenaeum/DataTypes/NinePatch.cs
+++ b/RecrownedAthenaeum/DataTypes/NinePatch.cs
@@ -4,9 +4,18 @@ using System;
namespace RecrownedAthenaeum.DataTypes
{
+ ///
+ /// An object that represents a ninepatch.
+ ///
public class NinePatch : ISpecialDrawable
{
+ ///
+ /// color of 9patch.
+ ///
public Color color;
+ ///
+ /// Dimensions in ninepatch. May also represent position in texture atlas.
+ ///
public Rectangle textureRegion;
readonly Texture2D texture;
readonly int left, right, bottom, top;
@@ -33,6 +42,11 @@ namespace RecrownedAthenaeum.DataTypes
color = Color.White;
}
+ ///
+ /// Draws the ninepatch.
+ ///
+ /// Batch to use.
+ /// Where to the patch.
public void Draw(SpriteBatch spriteBatch, Rectangle destination)
{
Rectangle sourceRectangle;
@@ -175,6 +189,14 @@ namespace RecrownedAthenaeum.DataTypes
spriteBatch.Draw(texture, drawnRectangle, sourceRectangle, color);
}
+ ///
+ /// Draw with more options.
+ ///
+ /// Spritebatch to use.
+ /// The destination to draw the patch.
+ /// The tint for each patch.
+ /// Not considered for 9patches.
+ /// Not considered for 9patches.
public void Draw(SpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
{
this.color = color;
diff --git a/RecrownedAthenaeum/DataTypes/Resolution.cs b/RecrownedAthenaeum/DataTypes/Resolution.cs
index e3aab1b..da32304 100644
--- a/RecrownedAthenaeum/DataTypes/Resolution.cs
+++ b/RecrownedAthenaeum/DataTypes/Resolution.cs
@@ -2,30 +2,50 @@
namespace RecrownedAthenaeum.DataTypes
{
- public class Resolution : IComparable
+ ///
+ /// Holds a width and height while allowing for easier comparison between other s.
+ ///
+ public struct Resolution : IComparable
{
+ ///
+ /// Dimensions of resolution.
+ ///
public int Width, Height;
+ ///
+ /// Constructs resolution given the dimensions.
+ ///
+ /// Width of resolution.
+ /// Height of resolution.
public Resolution(int width, int height)
{
Width = width;
Height = height;
}
- public Resolution()
- {
- }
-
+ ///
+ /// Compares area of this resolution to another.
+ ///
+ /// The other resolution to compare to.
+ /// A value less than 0 for this being the smaller resolution, 0 for the two being the same in area, and larger for this being the larger in area.
public int CompareTo(Resolution other)
{
return Area() - other.Area();
}
+ ///
+ /// Gets a string representation of this resolution.
+ ///
+ /// "WidthxHeight"
public override string ToString()
{
return Width + "x" + Height;
}
+ ///
+ /// Calculates area of resolution.
+ ///
+ /// Area of resolution.
public int Area()
{
return Width * Height;
diff --git a/RecrownedAthenaeum/Input/InputUtilities.cs b/RecrownedAthenaeum/Input/InputUtilities.cs
index a9d2aef..63b18a6 100644
--- a/RecrownedAthenaeum/Input/InputUtilities.cs
+++ b/RecrownedAthenaeum/Input/InputUtilities.cs
@@ -4,8 +4,14 @@ using System.Collections.Generic;
namespace RecrownedAthenaeum.Input
{
+ ///
+ /// Utilities to better manage input for the game.
+ ///
public static class InputUtilities
{
+ ///
+ /// Listeners for changes in input.
+ ///
public static List InputListeners;
static KeyboardState keyboardState;
static MouseState mouseState;
@@ -15,6 +21,10 @@ namespace RecrownedAthenaeum.Input
InputListeners = new List();
}
+ ///
+ /// Updates inputs.
+ /// Should be called once every game update to be up to date with new states of inputs.
+ ///
public static void Update()
{
KeyboardState updatedKeyboardState = Keyboard.GetState();
@@ -40,6 +50,10 @@ namespace RecrownedAthenaeum.Input
UpdateStates();
}
+ ///
+ /// Poll used to check if mouse was clicked.
+ ///
+ /// True if clicked.
public static bool MouseClicked()
{
if (mouseState.LeftButton == ButtonState.Pressed)
@@ -55,6 +69,11 @@ namespace RecrownedAthenaeum.Input
mouseState = Mouse.GetState();
}
+ ///
+ /// Checks whether mouse is within boundaries.
+ ///
+ /// Boundaries to check.
+ ///
public static bool MouseWithinBoundries(Rectangle bounds)
{
MouseState mouseState = Mouse.GetState();
diff --git a/RecrownedAthenaeum/Persistence/PreferencesManager.cs b/RecrownedAthenaeum/Persistence/PreferencesManager.cs
index 30e343d..e038009 100644
--- a/RecrownedAthenaeum/Persistence/PreferencesManager.cs
+++ b/RecrownedAthenaeum/Persistence/PreferencesManager.cs
@@ -6,12 +6,20 @@ using System.Xml.Serialization;
namespace RecrownedAthenaeum.Persistence
{
+ ///
+ /// Manages a bundle of preferences.
+ ///
public class PreferencesManager
{
private readonly Dictionary preferenceList;
string savePath;
XmlSerializer xmlSerializer;
+ ///
+ /// Constructs the preference manager.
+ ///
+ /// The path of the directory in which the preferences should be saved.
+ /// The preferences to be serialized and unserialized in XML format.
public PreferencesManager(string savePath, params object[] preferences)
{
this.savePath = savePath;
@@ -29,11 +37,19 @@ namespace RecrownedAthenaeum.Persistence
xmlSerializer = new XmlSerializer(typeof(object), preferenceTypes);
}
+ ///
+ /// Returns the preference by type.
+ ///
+ /// The preference needed.
+ /// The preference needed.
public T GetPreferences()
{
return (T)preferenceList[typeof(T)];
}
+ ///
+ /// Loads preferences.
+ ///
public void Load()
{
List keys = new List(preferenceList.Keys);
@@ -47,6 +63,9 @@ namespace RecrownedAthenaeum.Persistence
}
}
+ ///
+ /// Saves preferences.
+ ///
public void Save()
{
foreach (KeyValuePair prefs in preferenceList)
diff --git a/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs b/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs
index cf0abc0..db338ef 100644
--- a/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs
+++ b/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs
@@ -25,7 +25,7 @@ namespace RecrownedAthenaeum.Pipeline
if (regionData.ninePatchData != null)
{
NinePatchData nPatchData = regionData.ninePatchData;
- nPatch = new DataTypes.NinePatch(atlasTexture, nPatchData.left, nPatchData.right, nPatchData.down, nPatchData.down);
+ nPatch = new DataTypes.NinePatch(atlasTexture, nPatchData.left, nPatchData.right, nPatchData.bottom, nPatchData.bottom);
}
regions[regionID] = new DataTypes.TextureAtlas.TextureAtlasRegion(regionData.name, regionData.location, nPatch, atlasTexture);
diff --git a/RecrownedAthenaeum/Render/PrimitiveBatch.cs b/RecrownedAthenaeum/Render/PrimitiveBatch.cs
index 6356c16..c04f6b7 100644
--- a/RecrownedAthenaeum/Render/PrimitiveBatch.cs
+++ b/RecrownedAthenaeum/Render/PrimitiveBatch.cs
@@ -6,9 +6,15 @@ using System.Collections.Generic;
namespace RecrownedAthenaeum.Render
{
+ ///
+ /// A batch used to draw primitive shapes by batching together vertices.
+ ///
public class PrimitiveBatch : IDisposable
{
List vertices;
+ ///
+ /// The maximum vertices expected. The further off this expectancy is from the true value, the less efficient.
+ ///
public int MaxVertices { get { return vertices.Capacity; } set { vertices.Capacity = value; } }
int bufferPosition;
BasicEffect basicEffect;
@@ -80,7 +86,8 @@ namespace RecrownedAthenaeum.Render
if (primitiveType != PrimitiveType.LineStrip && primitiveType != PrimitiveType.TriangleStrip)
{
Flush();
- } else
+ }
+ else
{
throw new InvalidOperationException("Buffer size isn't large enough.");
}
@@ -103,23 +110,35 @@ namespace RecrownedAthenaeum.Render
bufferPosition = 0;
}
+ ///
+ /// Disposes this.
+ ///
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
- public void Dispose(bool disposing)
+ ///
+ /// Overridable dispose.
+ ///
+ /// True for when user called for this to be disposed. False otherwise.
+ public virtual void Dispose(bool disposing)
{
+ if (disposed) throw new ObjectDisposedException(this.GetType().Name);
+ disposed = true;
if (disposing && !disposed)
{
basicEffect.Dispose();
- disposed = true;
- }
- else
- {
- if (disposed) throw new ObjectDisposedException(this.GetType().Name);
}
}
+
+ ///
+ /// Destructor.
+ ///
+ ~PrimitiveBatch()
+ {
+ Dispose(false);
+ }
}
}
diff --git a/RecrownedAthenaeum/ScreenSystem/ITransition.cs b/RecrownedAthenaeum/ScreenSystem/ITransition.cs
index 7ccf295..f6c86f5 100644
--- a/RecrownedAthenaeum/ScreenSystem/ITransition.cs
+++ b/RecrownedAthenaeum/ScreenSystem/ITransition.cs
@@ -3,11 +3,14 @@ using Microsoft.Xna.Framework.Graphics;
namespace RecrownedAthenaeum.ScreenSystem
{
+ ///
+ /// Contracts a transition that the can use.
+ ///
public interface ITransition
{
///
/// Called once when the transition is needed.
- /// The dimensions of the screen.
+ /// The dimensions of the screen.
///
void InitiateTransition(Rectangle dimensions);
@@ -16,9 +19,8 @@ namespace RecrownedAthenaeum.ScreenSystem
///
/// The time passed in seconds since the last frame.
/// Whether or not this transition is waiting on something. Usually the .
- /// The frame being rendered by the screen as it exits. This can be null.
/// If this returns true, then it is considered that this transition is complete.
- bool EnteringTransition(double delta, bool waiting);
+ bool UpdateEnteringTransition(double delta, bool waiting);
///
/// Called every frame if the state of the screen this transition is placed upon is in the exit phase.
@@ -26,7 +28,7 @@ namespace RecrownedAthenaeum.ScreenSystem
/// The time passed in seconds since the last frame.
/// Whether or not this transition is waiting on something. Usually the .
/// If this returns true, then it is considered that this transition is complete.
- bool ExitingTransition(double delta, bool waiting);
+ bool UpdateExitingTransition(double delta, bool waiting);
///
/// Called once every frame while transition is active. Meant to draw transition.
diff --git a/RecrownedAthenaeum/ScreenSystem/LoadingScreen.cs b/RecrownedAthenaeum/ScreenSystem/LoadingScreen.cs
index 7ccfb36..075180f 100644
--- a/RecrownedAthenaeum/ScreenSystem/LoadingScreen.cs
+++ b/RecrownedAthenaeum/ScreenSystem/LoadingScreen.cs
@@ -5,6 +5,9 @@ using System;
namespace RecrownedAthenaeum.ScreenSystem
{
+ ///
+ /// A screen specifically meant to fill in loading times.
+ ///
public class LoadingScreen : Screen, ITransition
{
private const float ENTER_TIME = 2f;
@@ -22,6 +25,13 @@ namespace RecrownedAthenaeum.ScreenSystem
readonly bool rotate;
Vector2 origin;
+ ///
+ /// Constructs a loading screen.
+ ///
+ /// The game itself to adjust mouse settings and such.
+ ///
+ ///
+ ///
public LoadingScreen(Game game, Texture2D screenImage, float proportion, bool rotate = false) : base(true)
{
this.game = game;
@@ -31,18 +41,24 @@ namespace RecrownedAthenaeum.ScreenSystem
Transitions.Add(this);
}
+ ///
public override void Show()
{
game.IsMouseVisible = false;
base.Show();
}
+ ///
public override void Hide()
{
game.IsMouseVisible = true;
base.Hide();
}
+ ///
+ /// Sets things to correct values for start of transition.
+ ///
+ /// The window dimensions.
public void InitiateTransition(Rectangle dimensions)
{
color = Color.White;
@@ -63,13 +79,22 @@ namespace RecrownedAthenaeum.ScreenSystem
}
}
+ ///
+ /// Draws the transition.
+ ///
+ /// Batch to use.
public void DrawTransition(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texture, textureBounds, null, color, rotation, origin, SpriteEffects.None, 0f);
}
-
- public bool EnteringTransition(double delta, bool waiting)
+ ///
+ /// Updates the entering transition.
+ ///
+ /// Time passed between frames.
+ /// Whether or not this transition should be waiting.
+ /// Whether or not transition is complete.
+ public bool UpdateEnteringTransition(double delta, bool waiting)
{
float deltaf = (float)delta;
if (rotate)
@@ -106,7 +131,13 @@ namespace RecrownedAthenaeum.ScreenSystem
return false;
}
- public bool ExitingTransition(double delta, bool waiting)
+ ///
+ /// Updates the exiting transition.
+ ///
+ /// Time passed between frames.
+ /// Whether or not this transition should be waiting.
+ /// Whether or not transition is complete.
+ public bool UpdateExitingTransition(double delta, bool waiting)
{
float deltaf = (float)delta;
if (rotate)
diff --git a/RecrownedAthenaeum/ScreenSystem/Screen.cs b/RecrownedAthenaeum/ScreenSystem/Screen.cs
index 286a635..c2df13c 100644
--- a/RecrownedAthenaeum/ScreenSystem/Screen.cs
+++ b/RecrownedAthenaeum/ScreenSystem/Screen.cs
@@ -5,18 +5,72 @@ using System.Collections.Generic;
namespace RecrownedAthenaeum.ScreenSystem
{
- public enum ScreenState { EnterTransition, ExitTransition, Normal }
+ ///
+ /// Represents one of the poosible states a screen can be in.
+ ///
+ public enum ScreenState {
+ ///
+ /// Screen is transitioning in.
+ ///
+ EnterTransition,
+ ///
+ /// Screen is transitioning out.
+ ///
+ ExitTransition,
+ ///
+ /// Screen is currently displayed normally without transition.
+ ///
+ Normal
+ }
+ ///
+ /// A screen represents a virtual system of management that controls an system of items to be displayed.
+ ///
public class Screen
{
- public List Transitions;
- public bool UseRenderTargetForExitTransition;
+ ///
+ /// 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.
+ ///
+ public bool UseRenderTargetForExitTransition { get; private set; }
+
+ ///
+ /// The background color to be used to clear the screen.
+ ///
public Color BackgroundColor;
- public GraphicsDevice GraphicsDevice { get; private set; }
+
+ ///
+ /// The next screen to be displayed after exit transition finishes. May be null, leading to transition to previous screen or loading screen.
+ ///
public Screen NextScreen { get; set; }
+
+ ///
+ /// The current window size.
+ ///
public Rectangle ScreenSize { get; private set; }
+
+ ///
+ /// Whether or not screen have been initiated.
+ ///
public bool Initiated { get; private set; }
+
+ ///
+ /// The 2D camera to be used for the screen.
+ ///
public Camera2D Camera { get; private set; }
+
+ ///
+ /// Current state of the screen.
+ ///
+ public ScreenState State { get; private set; }
+
+ ///
+ /// Creates a new screen.
+ ///
+ /// True to start in entering transition state.
public Screen(bool useEnterTransition = false)
{
State = useEnterTransition ? ScreenState.EnterTransition : ScreenState.Normal;
@@ -26,11 +80,10 @@ namespace RecrownedAthenaeum.ScreenSystem
///
/// Called only once after initialization to give required parameters.
///
- public virtual void Initiate(GraphicsDevice graphicsDevice, Rectangle screenSize, Camera2D camera)
+ public virtual void Initiate(Rectangle screenSize, Camera2D camera)
{
this.Camera = camera;
this.ScreenSize = screenSize;
- GraphicsDevice = graphicsDevice;
Initiated = true;
}
@@ -82,7 +135,7 @@ namespace RecrownedAthenaeum.ScreenSystem
for (int transitionID = 0; transitionID < Transitions.Count; transitionID++)
{
ITransition transition = Transitions[transitionID];
- if (!transition.EnteringTransition(delta, waiting))
+ if (!transition.UpdateEnteringTransition(delta, waiting))
{
complete = false;
}
@@ -98,7 +151,7 @@ namespace RecrownedAthenaeum.ScreenSystem
bool complete = true;
foreach (ITransition transition in Transitions)
{
- if (!transition.ExitingTransition(delta, waiting))
+ if (!transition.UpdateExitingTransition(delta, waiting))
{
complete = false;
}
@@ -135,7 +188,6 @@ namespace RecrownedAthenaeum.ScreenSystem
}
- public ScreenState State { get; private set; }
///
/// Call this to begin exit transition.
diff --git a/RecrownedAthenaeum/ScreenSystem/ScreenManager.cs b/RecrownedAthenaeum/ScreenSystem/ScreenManager.cs
index 8a95c82..f7d7b6c 100644
--- a/RecrownedAthenaeum/ScreenSystem/ScreenManager.cs
+++ b/RecrownedAthenaeum/ScreenSystem/ScreenManager.cs
@@ -12,6 +12,9 @@ namespace RecrownedAthenaeum.ScreenSystem
/// The screen to show after the loading screen.
public delegate void ShowFirstScreen(Screen screen);
+ ///
+ /// A manager for screens. Helps with transitions and updating screens as well as resizes.
+ ///
public class ScreenManager : IDisposable
{
bool disposed = false;
@@ -42,7 +45,7 @@ namespace RecrownedAthenaeum.ScreenSystem
currentScreen = value;
if (!Screen.Initiated)
{
- Screen.Initiate(graphics.GraphicsDevice, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), camera);
+ Screen.Initiate(new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), camera);
}
if (previousScreen != null && previousScreenRenderTarget == null && previousScreen.UseRenderTargetForExitTransition)
{
@@ -163,12 +166,19 @@ namespace RecrownedAthenaeum.ScreenSystem
ShowFirstScreenEvent?.Invoke(screen);
}
+ ///
+ /// Disposes this.
+ ///
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
+ ///
+ /// An overridable dispose.
+ ///
+ /// True of user invoked dispose called.
public virtual void Dispose(bool disposing)
{
if (disposed) return;
@@ -178,5 +188,13 @@ namespace RecrownedAthenaeum.ScreenSystem
}
disposing = true;
}
+
+ ///
+ /// Destructor.
+ ///
+ ~ScreenManager()
+ {
+ Dispose(false);
+ }
}
}
diff --git a/RecrownedAthenaeum/UI/Book/Book.cs b/RecrownedAthenaeum/UI/Book/Book.cs
index b14beb9..5273ad9 100644
--- a/RecrownedAthenaeum/UI/Book/Book.cs
+++ b/RecrownedAthenaeum/UI/Book/Book.cs
@@ -63,7 +63,7 @@ namespace RecrownedAthenaeum.UI.Book
for (int pageIndex = 0; pageIndex < pages.Count; pageIndex++)
{
Page page = pages.ElementAt(pageIndex).Value;
- if (page.NeedsSizeUpdate) page.ApplySize(dimensions.Width, dimensions.Height);
+ if (page.requiresSizeUpdate) page.ApplySize(dimensions.Width, dimensions.Height);
page.Update(gameTime);
}
}
diff --git a/RecrownedAthenaeum/UI/Book/Page.cs b/RecrownedAthenaeum/UI/Book/Page.cs
index 97f602f..164da26 100644
--- a/RecrownedAthenaeum/UI/Book/Page.cs
+++ b/RecrownedAthenaeum/UI/Book/Page.cs
@@ -2,26 +2,42 @@
namespace RecrownedAthenaeum.UI.Book
{
+ ///
+ /// A page a part of a .
+ ///
public class Page : UIModuleGroup
{
private readonly int pageX, pageY;
- public bool NeedsSizeUpdate;
+ ///
+ /// Whether or not this book needs to be refreshed with new dimensions.
+ ///
+ public bool requiresSizeUpdate;
+ ///
+ /// Constructs a page.
+ ///
+ /// The X position in the book.
+ /// The Y position in the book.
public Page(int pageX, int pageY) : base(false)
{
this.pageX = pageX;
this.pageY = pageY;
- NeedsSizeUpdate = true;
+ requiresSizeUpdate = true;
Name = ToString();
}
+ ///
+ /// Called when this page is flagged as needing a size update.
+ ///
+ /// New width.
+ /// New Height
public virtual void ApplySize(int width, int height)
{
bounds.X = pageX * width;
bounds.Y = pageY * height;
bounds.Width = width;
bounds.Height = height;
- NeedsSizeUpdate = false;
+ requiresSizeUpdate = false;
}
}
}
diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Text.cs b/RecrownedAthenaeum/UI/Modular/Modules/Text.cs
index 9f6943e..2e8ea31 100644
--- a/RecrownedAthenaeum/UI/Modular/Modules/Text.cs
+++ b/RecrownedAthenaeum/UI/Modular/Modules/Text.cs
@@ -5,6 +5,9 @@ using System.Text;
namespace RecrownedAthenaeum.UI.Modular.Modules
{
+ ///
+ /// Represents text for the UI.
+ ///
public class Text : UIModule
{
private TextSkinDefinition skinDefinition;
@@ -14,28 +17,59 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
private string originalText;
private string displayedText;
private Vector2 modifiedTextSize;
+ ///
+ /// Whether or not to try and wrap text automatically. Meaning will check and attempt to wrap every update.
+ ///
public bool autoWrap;
+
+ ///
+ /// Whether or not to automatically scale the text every update. Happens after auto wrap if enabled.
+ ///
public bool autoScale;
+
+ ///
+ /// Should this use ellipses? Will perform this operation before auto wrapping or auto scalling.
+ ///
public bool useEllipses;
+
+ ///
+ /// The text to use for the ellipsis.
+ ///
public string ellipsis = "...";
private string ModifiedText { get { return displayedText; } set { displayedText = value; modifiedTextSize = font.MeasureString(value); } }
+
+ ///
+ /// The string to be displayed.
+ ///
public string Content { get { return originalText; } set { if (value == null) value = ellipsis; modifiedTextSize = font.MeasureString(value); originalText = value; displayedText = value; } }
-
+ ///
+ /// Creates a UI text object.
+ ///
+ /// The font to use.
+ /// The string for the text.
public Text(SpriteFont font, string content = null)
{
Content = content;
this.font = font;
}
- public Text(Skin.Skin skin, string skinDefinitionName = null, string content = null)
+ ///
+ /// Creates a UI text object
+ ///
+ ///
+ ///
+ ///
+ public Text(Skin.Skin skin, string skinDefinitionName = null, string content = null) : this(skin.fonts[skin.ObtainDefinition(skinDefinitionName, typeof(Text)).font])
{
- Content = content;
skinDefinition = skin.ObtainDefinition(skinDefinitionName, GetType());
- font = skin.fonts[skinDefinition.font];
color = skin.colors[skinDefinition.color];
}
+ ///
+ /// Updates the positioning and attempts to perform any operations that were marked automatic.
+ ///
+ /// The game time.
public override void Update(GameTime gameTime)
{
position.X = bounds.X;
@@ -48,12 +82,19 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
base.Update(gameTime);
}
+ ///
+ /// Draws the text.
+ ///
+ /// Batch to use.
public override void Draw(SpriteBatch batch)
{
batch.DrawString(font, Content, position, color, 0f, origin, scale, SpriteEffects.None, 0f);
base.Draw(batch);
}
+ ///
+ /// Attempts to apply ellipsis. Checks of nessecary.
+ ///
public void AttemptToApplyEllipsis()
{
if (modifiedTextSize.X * scale > bounds.Width && ModifiedText.Length > ellipsis.Length + 1)
@@ -71,6 +112,9 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
}
}
+ ///
+ /// Attempts to scale the font. Checks if nessecary.
+ ///
public void AttemptToScaleFont()
{
if (modifiedTextSize.X * scale > bounds.Width || modifiedTextSize.X * scale < bounds.Width - 5)
@@ -84,16 +128,26 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
}
}
+ ///
+ /// Removes line breaks.
+ ///
public void RemoveLineBreaks()
{
ModifiedText = ModifiedText.Replace("\n", " ");
}
+ ///
+ /// Resets to original text.
+ ///
public void ResetToOriginalText()
{
ModifiedText = originalText;
}
+ ///
+ /// Attempts to wrap text. Checks if nessecary.
+ ///
+ /// If true, will first unwrap text, and the wrap again. This occurs before nessecity check.
public void AttemptToWrapText(bool unwrap = false)
{
if (unwrap) RemoveLineBreaks();
diff --git a/RecrownedAthenaeum/UI/Skin/Skin.cs b/RecrownedAthenaeum/UI/Skin/Skin.cs
index 2b4ec6d..41381e7 100644
--- a/RecrownedAthenaeum/UI/Skin/Skin.cs
+++ b/RecrownedAthenaeum/UI/Skin/Skin.cs
@@ -27,9 +27,9 @@ namespace RecrownedAthenaeum.UI.Skin
Dictionary> definitions;
///
- ///
+ /// Creates a basic unfilled skin.
///
- ///
+ /// The texture atlas to use for this skin.
public Skin(TextureAtlas textureAtlas)
{
this.textureAtlas = textureAtlas;
@@ -38,7 +38,16 @@ namespace RecrownedAthenaeum.UI.Skin
definitions = new Dictionary>();
}
- public void Draw(string regionName, string color, SpriteBatch batch, Rectangle destination, Type type, float rotation = 0, Vector2 origin = default(Vector2))
+ ///
+ /// Draws a region from the texture atlas.
+ ///
+ /// Region to draw.
+ /// The color to tint the region.
+ /// The batch to use.
+ /// The destination to draw to.
+ /// The rotation to use in radians.
+ /// The origin for the rotation.
+ public void Draw(string regionName, string color, SpriteBatch batch, Rectangle destination, float rotation = 0, Vector2 origin = default(Vector2))
{
textureAtlas.Draw(regionName, batch, destination, colors[color], rotation, origin);
}
@@ -90,6 +99,11 @@ namespace RecrownedAthenaeum.UI.Skin
return ObtainDefinition(null, type);
}
+ ///
+ /// Adds the definition.
+ ///
+ /// The name of the definition.
+ /// The definition itself.
public void AddDefinition(string definitionName, ISkinDefinition skinDefinition)
{
if (!definitions.ContainsKey(skinDefinition.UIModuleType))
@@ -100,6 +114,11 @@ namespace RecrownedAthenaeum.UI.Skin
definitions[skinDefinition.UIModuleType].Add(definitionName, skinDefinition);
}
+ ///
+ /// Removes the definition.
+ ///
+ /// The name of the definition.
+ /// The type of the definition.
public void RemoveDefinition(string definitionName, Type definitionType)
{
if (definitions.ContainsKey(definitionType) && definitions[definitionType].ContainsKey(definitionName))