Barebones Console UI
This commit is contained in:
parent
d8d49c52a6
commit
ff1de4ae95
@ -12,7 +12,7 @@ config_version=5
|
||||
|
||||
config/name="TextRPG"
|
||||
run/main_scene="uid://cpbeaf3bpe42v"
|
||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||
config/features=PackedStringArray("4.6", "C#", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[dotnet]
|
||||
|
||||
36
scenes/ConsoleUI.cs
Normal file
36
scenes/ConsoleUI.cs
Normal file
@ -0,0 +1,36 @@
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
consoleInput.GrabFocus(); // Funktioniert nicht??
|
||||
}
|
||||
}
|
||||
}
|
||||
1
scenes/ConsoleUI.cs.uid
Normal file
1
scenes/ConsoleUI.cs.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://coaje60nccntq
|
||||
@ -1,15 +0,0 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class console : Node
|
||||
{
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
uid://rtd8xyot2bop
|
||||
@ -1,12 +1,21 @@
|
||||
[gd_scene format=3 uid="uid://bqfwbrtelarht"]
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" unique_id=29250469]
|
||||
[ext_resource type="Script" uid="uid://coaje60nccntq" path="res://scenes/ConsoleUI.cs" id="1_gf67r"]
|
||||
|
||||
[node name="Console" type="CanvasLayer" unique_id=29250469]
|
||||
script = ExtResource("1_gf67r")
|
||||
|
||||
[node name="ConsoleBG" type="ColorRect" parent="." unique_id=325200379]
|
||||
offset_right = 872.0
|
||||
offset_bottom = 575.0
|
||||
color = Color(0.446777, 0.44677705, 0.44677705, 1)
|
||||
|
||||
[node name="ConsoleOutput" type="Label" parent="." unique_id=340259312]
|
||||
offset_left = 18.0
|
||||
offset_top = 14.0
|
||||
offset_right = 857.0
|
||||
offset_bottom = 560.0
|
||||
|
||||
[node name="ConsoleInput" type="LineEdit" parent="." unique_id=1233554082]
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user