UI WIP
This commit is contained in:
39
DaggerFramework/Source/UI/TextLabel.cs
Normal file
39
DaggerFramework/Source/UI/TextLabel.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using DaggerFramework.Rendering;
|
||||
|
||||
namespace DaggerFramework.UI;
|
||||
|
||||
public class TextLabel : UIElement
|
||||
{
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public Font Font
|
||||
{
|
||||
get => _font; set
|
||||
{
|
||||
_isDirty = true;
|
||||
_font = value;
|
||||
}
|
||||
}
|
||||
public int FontSize { get; set; } = 16;
|
||||
public Color FontColor { get; set; } = Color.White;
|
||||
protected override void OnRender(Renderer renderer)
|
||||
{
|
||||
if (_isDirty && _font != null)
|
||||
{
|
||||
_fontHandle = renderer.LoadFont(_font);
|
||||
_isDirty = false;
|
||||
}
|
||||
|
||||
if (_font == null)
|
||||
{
|
||||
renderer.DrawDebugText(Text, FontSize, FontColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.DrawText(_fontHandle, Text, FontSize, FontColor);
|
||||
}
|
||||
}
|
||||
|
||||
private Font? _font;
|
||||
private int _fontHandle;
|
||||
private bool _isDirty;
|
||||
}
|
||||
Reference in New Issue
Block a user