From e356a8219072a0c64613d23512fc22e8d8e15586 Mon Sep 17 00:00:00 2001 From: Recrown Date: Tue, 29 Jan 2019 16:00:13 -0600 Subject: [PATCH] using heirarchy for definitions implemented. --- .../UI/Modular/Modules/Interactive/Button.cs | 12 ++++++++++++ .../Modular/Modules/Interactive/TextButton.cs | 18 +++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs index 2260141..5449c4c 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs +++ b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs @@ -64,6 +64,18 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive highlightedTexture = skin.GetTextureAtlasRegion(skinDefinition.selectedRegion); } + /// + /// Instantiates a button using a definition. + /// + /// The skin the definition is defined in. + /// The definition itself. + public Button(ISkin skin, ButtonSkinDefinition skinDefinition) : + this(skin.GetTextureAtlasRegion(skinDefinition.downRegion), + skin.GetTextureAtlasRegion(skinDefinition.upRegion), + skin.GetTextureAtlasRegion(skinDefinition.disabledRegion), + skin.GetTextureAtlasRegion(skinDefinition.selectedRegion)) + {} + /// /// Draws the button. /// diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs index 627cf1c..5478e70 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs +++ b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs @@ -43,13 +43,29 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive /// The font to be used. /// The skin to use. /// Name of the definition for this type in the skin given. - 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(definitionName)) { TextButtonSkinDefinition skinDefinition = skin.ObtainDefinition(definitionName); this.text = new Text(font, text); FontColor = skin.GetColor(skinDefinition.fontColor); } + /// + /// Creates a text button with a given definition. + /// + /// The text to be displayed on this button. + /// The font to use for this button. + /// The skin the definition is from. + /// The definition to use. + 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)) + { } + /// /// Updates the text button. ///