using heirarchy for definitions implemented.

This commit is contained in:
Harrison Deng 2019-01-29 16:00:13 -06:00
parent 2e984db135
commit e356a82190
2 changed files with 29 additions and 1 deletions

View File

@ -64,6 +64,18 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
highlightedTexture = skin.GetTextureAtlasRegion(skinDefinition.selectedRegion);
}
/// <summary>
/// Instantiates a button using a definition.
/// </summary>
/// <param name="skin">The skin the definition is defined in.</param>
/// <param name="skinDefinition">The definition itself.</param>
public Button(ISkin skin, ButtonSkinDefinition skinDefinition) :
this(skin.GetTextureAtlasRegion(skinDefinition.downRegion),
skin.GetTextureAtlasRegion(skinDefinition.upRegion),
skin.GetTextureAtlasRegion(skinDefinition.disabledRegion),
skin.GetTextureAtlasRegion(skinDefinition.selectedRegion))
{}
/// <summary>
/// Draws the button.
/// </summary>

View File

@ -43,13 +43,29 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
/// <param name="font">The font to be used.</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, SpriteFont font, ISkin skin, string definitionName = null) : base(skin, definitionName)
public TextButton(string text, SpriteFont font, ISkin skin, string definitionName = null) : base(skin, skin.ObtainDefinition<TextButtonSkinDefinition>(definitionName))
{
TextButtonSkinDefinition skinDefinition = skin.ObtainDefinition<TextButtonSkinDefinition>(definitionName);
this.text = new Text(font, text);
FontColor = skin.GetColor(skinDefinition.fontColor);
}
/// <summary>
/// Creates a text button with a given definition.
/// </summary>
/// <param name="text">The text to be displayed on this button.</param>
/// <param name="font">The font to use for this button.</param>
/// <param name="skin">The skin the definition is from.</param>
/// <param name="skinDefinition">The definition to use.</param>
public TextButton(string text, SpriteFont font, ISkin skin, TextButtonSkinDefinition skinDefinition) :
this(text,
font,
skin.GetTextureAtlasRegion(skinDefinition.downRegion),
skin.GetTextureAtlasRegion(skinDefinition.upRegion),
skin.GetTextureAtlasRegion(skinDefinition.disabledRegion),
skin.GetTextureAtlasRegion(skinDefinition.selectedRegion))
{ }
/// <summary>
/// Updates the text button.
/// </summary>