refactored naming of ui text from text label to text.

This commit is contained in:
Harrison Deng 2018-12-11 01:12:25 -06:00
parent af7653dbdd
commit f3bfba0045
2 changed files with 8 additions and 33 deletions

View File

@ -13,11 +13,11 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
{ {
public class TextButton : Button public class TextButton : Button
{ {
private TextLabel label; private Text label;
public TextButton(string text, SpriteFont font, NinePatch background) : base(background) public TextButton(string text, SpriteFont font, NinePatch background) : base(background)
{ {
label = new TextLabel(font, text); label = new Text(font, text);
label.autoScale = true; label.autoScale = true;
} }

View File

@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace RecrownedAthenaeum.UI.Modular.Modules namespace RecrownedAthenaeum.UI.Modular.Modules
{ {
public class TextLabel : UIModule public class Text : UIModule
{ {
private SpriteFont font; private SpriteFont font;
private float scale; private float scale;
@ -21,37 +21,12 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
public bool autoScale; public bool autoScale;
public bool useEllipses; public bool useEllipses;
public string ellipsis = "..."; public string ellipsis = "...";
private string ModifiedText private string ModifiedText { get { return displayedText; } set { displayedText = value; modifiedTextSize = font.MeasureString(value); } }
{ public string Content { get { return originalText; } set { if (value == null) value = "..."; modifiedTextSize = font.MeasureString(value); originalText = value; displayedText = value; } }
get
{
return displayedText;
}
set public Text(SpriteFont font, string content = null)
{
displayedText = value;
modifiedTextSize = font.MeasureString(value);
}
}
public string Text
{ {
get Content = content;
{
return originalText;
}
set
{
if (value == null) value = "...";
modifiedTextSize = font.MeasureString(value);
originalText = value;
displayedText = value;
}
}
public TextLabel(SpriteFont font, string text = null)
{
Text = text;
this.font = font; this.font = font;
} }
@ -69,7 +44,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
public override void Draw(SpriteBatch batch) public override void Draw(SpriteBatch batch)
{ {
batch.DrawString(font, Text, position, color, 0f, origin, scale, SpriteEffects.None, 0f); batch.DrawString(font, Content, position, color, 0f, origin, scale, SpriteEffects.None, 0f);
base.Draw(batch); base.Draw(batch);
} }