diff options
| author | Sophia Pearson <codergal89@gmail.com> | 2022-09-04 15:43:12 +0200 |
|---|---|---|
| committer | Sophia Pearson <codergal89@gmail.com> | 2022-09-04 15:44:04 +0200 |
| commit | 2f3abbb6f1141f15ef77ac27e431bc66bb0c7899 (patch) | |
| tree | 17f7ee50161e1de1c11c6dd14a54a11614e7de03 /Scripts/OutputRow.cs | |
| parent | 0967a4654c9fa67b5cfc19edf3cfc075bf6bde92 (diff) | |
| download | texty-2f3abbb6f1141f15ef77ac27e431bc66bb0c7899.tar.xz texty-2f3abbb6f1141f15ef77ac27e431bc66bb0c7899.zip | |
game: adapt scripts to new design
Diffstat (limited to 'Scripts/OutputRow.cs')
| -rw-r--r-- | Scripts/OutputRow.cs | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/Scripts/OutputRow.cs b/Scripts/OutputRow.cs deleted file mode 100644 index cfbb2e7..0000000 --- a/Scripts/OutputRow.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using Godot; - -namespace Texty.Scripts -{ - public abstract class OutputRow : VBoxContainer - { - [Signal] public delegate void InputTextChanged(string newText); - [Signal] public delegate void OutputTextChanged(string newText); - - private string _inputText = ""; - private string _outputText = ""; - - public Label Input; - public Label Output; - - [Export] - public string InputText - { - get => _inputText; - set => UpdateText(Field.Input, value ?? ""); - } - - [Export] - public string OutputText - { - get => _outputText; - set => UpdateText(Field.Output, value ?? ""); - } - - public override void _Ready() - { - Input = GetNode<Label>(nameof(Input)); - UpdateLabel(Input, _inputText); - Output = GetNode<Label>(nameof(Output)); - UpdateLabel(Output, _outputText); - } - - private void UpdateText(Field field, string value) - { - switch (field) - { - case Field.Input: - _inputText = value; - EmitSignal(nameof(InputTextChanged), _inputText); - UpdateLabel(Input, value); - break; - case Field.Output: - _outputText = value; - EmitSignal(nameof(OutputTextChanged), value); - UpdateLabel(Output, value); - break; - default: - throw new ArgumentOutOfRangeException(nameof(field), field, "No such field!"); - } - } - - private static void UpdateLabel(Label label, string value) - { - if (label != null) label.Text = value; - } - - private enum Field - { - Input, - Output - } - } -}
\ No newline at end of file |
