minor changes to text label

This commit is contained in:
Harrison Deng 2018-11-20 19:52:51 -06:00
parent a402df1475
commit 75da4db4fe

View File

@ -42,16 +42,16 @@ namespace RhythmBullet.UI.Modular.Modules
} }
set set
{ {
if (value == null) value = "...";
modifiedTextSize = font.MeasureString(value); modifiedTextSize = font.MeasureString(value);
originalText = value; originalText = value;
displayedText = value; displayedText = value;
} }
} }
public TextLabel(string text, SpriteFont font, int height) public TextLabel(SpriteFont font, string text = null)
{ {
Text = text; Text = text;
bounds.Height = height;
this.font = font; this.font = font;
} }
@ -84,7 +84,7 @@ namespace RhythmBullet.UI.Modular.Modules
stringBuilder.Remove(stringBuilder.Length, ellipsis.Length - 1); stringBuilder.Remove(stringBuilder.Length, ellipsis.Length - 1);
stringBuilder.Insert(stringBuilder.Length, ellipsis); stringBuilder.Insert(stringBuilder.Length, ellipsis);
} }
while (font.MeasureString(stringBuilder).X *scale > bounds.Width); while (font.MeasureString(stringBuilder).X * scale > bounds.Width);
ModifiedText = stringBuilder.ToString(); ModifiedText = stringBuilder.ToString();
} }
@ -92,12 +92,12 @@ namespace RhythmBullet.UI.Modular.Modules
public void AttemptToScaleFont() public void AttemptToScaleFont()
{ {
if (modifiedTextSize.X * scale > bounds.Width || modifiedTextSize.X * scale < bounds.Width) if (modifiedTextSize.X * scale > bounds.Width || modifiedTextSize.X * scale < bounds.Width - 5)
{ {
scale = bounds.Width / modifiedTextSize.X; scale = bounds.Width / modifiedTextSize.X;
} }
if (modifiedTextSize.Y * scale > bounds.Height || modifiedTextSize.Y * scale > bounds.Height) if (modifiedTextSize.Y * scale > bounds.Height || modifiedTextSize.Y * scale < bounds.Height - 5)
{ {
scale = bounds.Height / modifiedTextSize.Y; scale = bounds.Height / modifiedTextSize.Y;
} }