blob: 07dab9a2944afdf3847451847e140fd9ccd9b72e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
using System.Diagnostics;
using Godot;
namespace Texty.Scripts
{
public abstract class Game : MarginContainer
{
public CommandParser CommandParser;
public VBoxContainer LayoutContainer;
public OutputContainer OutputContainer;
[Export(PropertyHint.File, "*.tscn")] public PackedScene OutputRowScene;
public override void _Ready()
{
Debug.Assert(OutputRowScene != null, $"The {nameof(OutputRowScene)} was not set!");
CommandParser = GetNode<CommandParser>(nameof(CommandParser));
LayoutContainer = GetNode<VBoxContainer>(nameof(LayoutContainer));
OutputContainer = LayoutContainer.GetNode<OutputContainer>(nameof(OutputContainer));
}
public void OnInputSubmitted(string text)
{
var newRow = OutputRowScene.Instance<OutputRow>();
newRow.InputText = text;
var command = CommandParser.TryParse(text);
newRow.OutputText = command == null ? "Please rephrase your command" : "THE OUTPUT SHOULD GO HERE!";
OutputContainer.Add(newRow);
}
}
}
|