recrownedgtk/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs

49 lines
1.6 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RecrownedAthenaeum.UI.Modular.Modules;
using RecrownedAthenaeum.DataTypes;
using RecrownedAthenaeum.UI.Modular.Modules.Interactive;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RecrownedAthenaeum.UI.Skin.Definitions;
namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
{
public class TextButton : Button
{
private Text text;
public Color FontColor { get { return text.color; } set { text.color = value; } }
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
};
}
public TextButton(string text, Skin.Skin skin, string definitionName = null) : base(skin, definitionName)
{
TextButtonSkinDefinition skinDefinition = skin.ObtainDefinition<TextButtonSkinDefinition>(definitionName, GetType());
this.text = new Text(skin.fonts[skinDefinition.fontName], text);
FontColor = skin.colors[skinDefinition.fontColor];
}
public override void Update(GameTime gameTime)
{
text.bounds = bounds;
text.Update(gameTime);
base.Update(gameTime);
}
public override void Draw(SpriteBatch batch)
{
text.Draw(batch);
base.Draw(batch);
}
}
}