rhythmbullet/RhythmBullet/Zer01HD/Utilities/UI/Modular/Text.cs

44 lines
1.1 KiB
C#
Raw Normal View History

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.UI.Modular
{
2018-11-09 05:48:24 +00:00
public class Text : UIModule
{
private SpriteFont font;
private float scale;
2018-11-11 17:32:06 +00:00
private Vector2 position;
public string DisplayedText
{
get
{
return DisplayedText;
}
set
{
Vector2 size = font.MeasureString(value);
2018-11-11 17:32:06 +00:00
Bounds.Width = (int) size.X;
scale = Bounds.Height / size.Y;
}
}
public Text(string displayedText, SpriteFont font, int height)
{
2018-11-11 17:32:06 +00:00
Bounds.Height = height;
this.font = font;
}
public override void Draw(SpriteBatch batch)
{
2018-11-11 17:32:06 +00:00
position.X = Bounds.X;
position.Y = Bounds.Y;
batch.DrawString(font, DisplayedText, position, Color);
base.Draw(batch);
}
}
}