36 lines
912 B
C#
36 lines
912 B
C#
using Godot;
|
|
using System;
|
|
|
|
public partial class ConsoleUI : CanvasLayer
|
|
{
|
|
private Label consoleOutput;
|
|
private LineEdit consoleInput;
|
|
|
|
public override void _Ready()
|
|
{
|
|
consoleOutput = GetNode<Label>("ConsoleOutput");
|
|
consoleInput = GetNode<LineEdit>("ConsoleInput");
|
|
|
|
consoleInput.TextSubmitted += OnTextSubmitted;
|
|
|
|
consoleInput.GrabFocus();
|
|
}
|
|
|
|
private void OnTextSubmitted(string submittedText)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(submittedText))
|
|
{
|
|
string currentOutput = consoleOutput.Text;
|
|
if (!string.IsNullOrEmpty(currentOutput))
|
|
{
|
|
consoleOutput.Text = currentOutput + "\n" + submittedText;
|
|
}
|
|
else
|
|
{
|
|
consoleOutput.Text = submittedText;
|
|
}
|
|
|
|
consoleInput.Clear();
|
|
}
|
|
}
|
|
} |