From d7eefa488135c477f39ea0953b032c7dcdad8bc7 Mon Sep 17 00:00:00 2001 From: Sophia Pearson Date: Sat, 26 Nov 2022 10:08:44 +0100 Subject: scripts: perform code cleanup actions --- Scripts/Terminal/OutputArea.cs | 60 ++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 31 deletions(-) (limited to 'Scripts/Terminal/OutputArea.cs') diff --git a/Scripts/Terminal/OutputArea.cs b/Scripts/Terminal/OutputArea.cs index e297c49..e5f7535 100644 --- a/Scripts/Terminal/OutputArea.cs +++ b/Scripts/Terminal/OutputArea.cs @@ -3,44 +3,42 @@ using System.Diagnostics; using System.Linq; using Godot; using Godot.Collections; -using Texty.Scripts.Game; -namespace Texty.Scripts.Terminal +namespace Texty.Scripts.Terminal; + +public partial class OutputArea : ScrollContainer { - public partial class OutputArea : ScrollContainer - { - [Export(PropertyHint.File, "*.tscn")] public PackedScene OutputBlockScene; - public Array TextBlocks => new Array(BlockNodes.ToList().Select(block => block.Content)); + [Export(PropertyHint.File, "*.tscn")] public PackedScene OutputBlockScene; + public Array TextBlocks => new(BlockNodes.ToList().Select(block => block.Content)); - private VBoxContainer LineContainer => GetNodeOrNull($"%{nameof(LineContainer)}"); + private VBoxContainer LineContainer => GetNodeOrNull($"%{nameof(LineContainer)}"); - private IEnumerable BlockNodes => - GD.Range(LineContainer?.GetChildCount() ?? 0) - .Select(index => LineContainer.GetChild(index)) - .Cast(); + private IEnumerable BlockNodes => + GD.Range(LineContainer?.GetChildCount() ?? 0) + .Select(index => LineContainer.GetChild(index)) + .Cast(); - public override void _Ready() - { - Debug.Assert(OutputBlockScene != null, "OutputBlockScene has not been configured!"); - Debug.Assert(OutputBlockScene.CanInstantiate(), "OutputBlockScene can not be instanced!"); - Clear(); - } + public override void _Ready() + { + Debug.Assert(OutputBlockScene != null, "OutputBlockScene has not been configured!"); + Debug.Assert(OutputBlockScene.CanInstantiate(), "OutputBlockScene can not be instanced!"); + Clear(); + } - public void Clear() + public void Clear() + { + BlockNodes.ToList().ForEach(block => { - BlockNodes.ToList().ForEach(block => - { - LineContainer.RemoveChild(block); - block.QueueFree(); - }); - } + LineContainer.RemoveChild(block); + block.QueueFree(); + }); + } - public void Push(string text) - { - if (string.IsNullOrEmpty(text)) return; - var block = OutputBlockScene.Instantiate(); - block.Content = text; - LineContainer.AddChild(block); - } + public void Push(string text) + { + if (string.IsNullOrEmpty(text)) return; + var block = OutputBlockScene.Instantiate(); + block.Content = text; + LineContainer.AddChild(block); } } \ No newline at end of file -- cgit v1.2.3