Done basic documentation. Further expansion may be needed. Maybe. But only maybe.

This commit is contained in:
2019-01-14 20:00:11 -06:00
parent b019b7cf10
commit 2a2a7cba49
5 changed files with 133 additions and 3 deletions

View File

@@ -5,11 +5,27 @@ using RecrownedAthenaeum.UI.Skin.Definitions;
namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
{
/// <summary>
/// Button that holds a string.
/// </summary>
public class TextButton : Button
{
private Text text;
/// <summary>
/// The color the font should be rendered in.
/// </summary>
public Color FontColor { get { return text.color; } set { text.color = value; } }
/// <summary>
/// Constructs text button with the positions represented by <see cref="ISpecialDrawable"/>
/// </summary>
/// <param name="text">The string representing the text to be displayed.</param>
/// <param name="font">The font to be used to display the text.</param>
/// <param name="down">What to draw as button is pushed down.</param>
/// <param name="up">What to draw as button is not pushed.</param>
/// <param name="disabled">What to draw as button is disabled.</param>
/// <param name="selected">What to draw as button is selected.</param>
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
};
}
/// <summary>
/// Constructs a text button using a skin and definition.
/// </summary>
/// <param name="text">The text to display.</param>
/// <param name="skin">The skin to use.</param>
/// <param name="definitionName">Name of the definition for this type in the skin given.</param>
public TextButton(string text, Skin.Skin skin, string definitionName = null) : base(skin, definitionName)
{
TextButtonSkinDefinition skinDefinition = skin.ObtainDefinition<TextButtonSkinDefinition>(definitionName, GetType());
@@ -25,6 +47,10 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
FontColor = skin.colors[skinDefinition.fontColor];
}
/// <summary>
/// Updates the text button.
/// </summary>
/// <param name="gameTime">Snapshot of information about time for game.</param>
public override void Update(GameTime gameTime)
{
text.bounds = bounds;
@@ -32,6 +58,10 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
base.Update(gameTime);
}
/// <summary>
/// Called whenever game wants to render this button.
/// </summary>
/// <param name="batch">Batch to use. Batch should already be started.</param>
public override void Draw(SpriteBatch batch)
{
text.Draw(batch);

View File

@@ -16,10 +16,19 @@ namespace RecrownedAthenaeum.UI.Modular
List<UIModule> modules = new List<UIModule>();
Rectangle scissorBounds;
RasterizerState scissorRasterizer = new RasterizerState();
/// <summary>
/// Camera used by the module for cropping.
/// </summary>
public Camera2D Camera { get; set; }
/// <summary>
/// Creates a module group.
/// </summary>
/// <param name="crop">Whether or not to crop out of bounds. Default is false.</param>
/// <param name="camera">What camera to use for cropping. Default is null.</param>
public UIModuleGroup(bool crop = false, Camera2D camera = null)
{
if (crop && camera == null) throw new ArgumentException("Cannot crop without camera.");
Camera = camera;
if (crop)
{