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

45 lines
1.1 KiB
C#
Raw Normal View History

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
2018-11-12 05:05:51 +00:00
using RhythmBullet.Zer01HD.Utilities.Camera;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2018-11-13 01:54:33 +00:00
namespace RhythmBullet.Zer01HD.UI.Modular.Modules
{
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);
}
}
}