#RichTextLabel not showing BBCode with C#

5 messages · Page 1 of 1 (latest)

rough tundra
#

I am working on making a game console window in my game and I want there to be BBCode for the output, however when I pass the text to the console it looks like all the bbcode formatting is escaped for some reason.

using Godot;
using System;

public partial class ConsoleComponent : Control
{
    public LineEdit ConsoleInput { get; set; }
    public RichTextLabel ConsoleOutput { get; set; }

    public override void _Ready()
    {
        ConsoleInput = GetNode<LineEdit>("VBoxConsoleWindow/MarginContainerInput/HBoxContainer/ConsoleInput");
        ConsoleOutput = GetNode<RichTextLabel>("VBoxConsoleWindow/MarginContainer/ScrollContainer/VBoxContainer/ConsoleOutput");
    }

    public override void _Process(double delta)
    {
        if (ConsoleInput.HasFocus() && Input.IsActionJustPressed("enter"))
        {
            string timestamp = DateTime.Now.ToString("HH:mm:ss");

            ConsoleOutput.AddText("\n[color=gray][" + timestamp + "]>[/color] " + ConsoleInput.Text);
            ConsoleOutput.ScrollToLine(ConsoleOutput.GetLineCount());
            ConsoleInput.Text = "";
        }
    }
}
fading kite
#

AppendText will parse it

#

im not sure it's a good idea to put all of the text into a single RichTextLabel though

#

any malformed bbcode added to the console might corrupt the entire thing