using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using RecrownedAthenaeum.SpecialTypes; 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) { autoScale = true }; } /// /// Constructs a text button using a skin and definition. /// /// The text to display. /// 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, Skin.Skin skin, string definitionName = null) : base(skin, definitionName) { TextButtonSkinDefinition skinDefinition = skin.ObtainDefinition(definitionName, GetType()); this.text = new Text(font, text); FontColor = skin.GetColor(skinDefinition.fontColor); } /// /// Updates the text button. /// /// Snapshot of information about time for game. public override void Update(GameTime gameTime) { text.bounds = bounds; text.Update(gameTime); 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); base.Draw(batch); } } }