mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Font renderer improvements + component for scripting
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using GlitchyEngine.Core;
|
||||
using GlitchyEngine.Math;
|
||||
|
||||
namespace GlitchyEngine.Graphics;
|
||||
|
||||
/// <summary>
|
||||
/// Renders text.
|
||||
/// </summary>
|
||||
public class TextRenderer : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets whether the text is rich text.<br/>
|
||||
/// If <see langword="true"/>, the text will be parsed for rich text tags; if <see langword="false"/>, the text will be rendered as plain text.
|
||||
/// </summary>
|
||||
public bool IsRichText
|
||||
{
|
||||
get => ScriptGlue.TextRenderer_GetIsRichText(_uuid);
|
||||
set => ScriptGlue.TextRenderer_SetIsRichText(_uuid, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text.
|
||||
/// </summary>
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
ScriptGlue.TextRenderer_GetText(_uuid, out string text);
|
||||
return text;
|
||||
}
|
||||
set => ScriptGlue.TextRenderer_SetText(_uuid, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The color that will be used to render the text. This color can be overridden by rich text tags.
|
||||
/// </summary>
|
||||
public ColorRGBA Color
|
||||
{
|
||||
get
|
||||
{
|
||||
ScriptGlue.TextRenderer_GetColor(_uuid, out ColorRGBA color);
|
||||
|
||||
return color;
|
||||
}
|
||||
set => ScriptGlue.TextRenderer_SetColor(_uuid, value);
|
||||
}
|
||||
|
||||
// TODO: PreparedText component
|
||||
}
|
||||
@@ -255,6 +255,28 @@ internal static class ScriptGlue
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextRenderer
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool TextRenderer_GetIsRichText(UUID entityId);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void TextRenderer_SetIsRichText(UUID entityId, bool isRichText);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void TextRenderer_GetText(UUID entityId, out string text);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void TextRenderer_SetText(UUID entityId, string text);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void TextRenderer_GetColor(UUID entityId, out ColorRGBA color);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void TextRenderer_SetColor(UUID entityId, ColorRGBA color);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Math
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
|
||||
Reference in New Issue
Block a user