diff options
Diffstat (limited to 'Scripts/Game/Output.cs')
| -rw-r--r-- | Scripts/Game/Output.cs | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/Scripts/Game/Output.cs b/Scripts/Game/Output.cs deleted file mode 100644 index abd3328..0000000 --- a/Scripts/Game/Output.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using Godot; -using Godot.Collections; - -namespace Texty.Scripts.Game -{ - public class Output : PanelContainer - { - [Export(PropertyHint.File, "*.tscn")] public PackedScene OutputBlockScene; - public Array<string> TextBlocks => new Array<string>(BlockNodes.ToList().Select(block => block.Content)); - - private VBoxContainer LineContainer => GetNodeOrNull<VBoxContainer>($"%{nameof(LineContainer)}"); - - private IEnumerable<OutputBlock> BlockNodes => - GD.Range(LineContainer?.GetChildCount() ?? 0) - .Select(index => LineContainer.GetChild(index)) - .Cast<OutputBlock>(); - - public override void _Ready() - { - Debug.Assert(OutputBlockScene != null, "OutputBlockScene has not been configured!"); - Debug.Assert(OutputBlockScene.CanInstance(), "OutputBlockScene can not be instanced!"); - Clear(); - } - - public void Clear() - { - BlockNodes.ToList().ForEach(block => - { - LineContainer.RemoveChild(block); - block.QueueFree(); - }); - } - - public void Push(string text) - { - if (text.Empty()) return; - var block = OutputBlockScene.Instance<OutputBlock>(); - block.Content = text; - LineContainer.AddChild(block); - } - } -}
\ No newline at end of file |
