From 05d29ccce1898ed89c0b650c77242c2fa2805128 Mon Sep 17 00:00:00 2001 From: Sophia Pearson Date: Fri, 20 May 2022 00:45:25 +0200 Subject: texty: initial commit --- Scripts/Game.cs | 30 +++++++++++++++++++ Scripts/InputContainer.cs | 44 ++++++++++++++++++++++++++++ Scripts/OutputContainer.cs | 53 ++++++++++++++++++++++++++++++++++ Scripts/OutputRow.cs | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 199 insertions(+) create mode 100644 Scripts/Game.cs create mode 100644 Scripts/InputContainer.cs create mode 100644 Scripts/OutputContainer.cs create mode 100644 Scripts/OutputRow.cs (limited to 'Scripts') diff --git a/Scripts/Game.cs b/Scripts/Game.cs new file mode 100644 index 0000000..645c922 --- /dev/null +++ b/Scripts/Game.cs @@ -0,0 +1,30 @@ +using System.Diagnostics; +using Godot; + +namespace Texty.Scripts +{ + public abstract class Game : MarginContainer + { + 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!"); + + LayoutContainer = GetNode(nameof(LayoutContainer)); + OutputContainer = LayoutContainer.GetNode(nameof(OutputContainer)); + } + + public void OnInputSubmitted(string text) + { + var newRow = OutputRowScene.Instance(); + newRow.InputText = text; + newRow.OutputText = "THE OUTPUT SHOULD GO HERE!"; + + OutputContainer.Add(newRow); + } + } +} \ No newline at end of file diff --git a/Scripts/InputContainer.cs b/Scripts/InputContainer.cs new file mode 100644 index 0000000..485086e --- /dev/null +++ b/Scripts/InputContainer.cs @@ -0,0 +1,44 @@ +using Godot; + +namespace Texty.Scripts +{ + public abstract class InputContainer : HBoxContainer + { + [Signal] + public delegate void InputSubmitted(string text); + + public LineEdit InputField; + public Button SubmitButton; + + public override void _Ready() + { + InputField = GetNode(nameof(InputField)); + SubmitButton = GetNode