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/Game/CommandInputArea.cs | 45 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'Scripts/Game/CommandInputArea.cs') diff --git a/Scripts/Game/CommandInputArea.cs b/Scripts/Game/CommandInputArea.cs index af54a15..3b88417 100644 --- a/Scripts/Game/CommandInputArea.cs +++ b/Scripts/Game/CommandInputArea.cs @@ -1,32 +1,31 @@ using Godot; using Texty.Scripts.Terminal; -namespace Texty.Scripts.Game +namespace Texty.Scripts.Game; + +[Tool] +public partial class CommandInputArea : InputArea { - [Tool] - public partial class CommandInputArea : InputArea + [Signal] public delegate void CommandSubmittedEventHandler(Command command); + [Signal] public delegate void UnknownInputSubmittedEventHandler(string text); + + private CommandParser CommandParser => GetNodeOrNull($"%{nameof(CommandParser)}"); + + public override void _Ready() { - [Signal] public delegate void CommandSubmittedEventHandler(Command command); - [Signal] public delegate void UnknownInputSubmittedEventHandler(string text); - - private CommandParser CommandParser => GetNodeOrNull($"%{nameof(CommandParser)}"); - - public override void _Ready() - { - TextInput.GrabFocus(); - } + TextInput.GrabFocus(); + } - public override void OnTextEntered(string text) - { - if (text.Length == 0) - return; + public override void OnTextEntered(string text) + { + if (text.Length == 0) + return; - TextInput.Clear(); - var command = CommandParser.TryParse(text); - if (command != null) - EmitSignal(SignalName.CommandSubmitted, command); - else - EmitSignal(SignalName.UnknownInputSubmitted, text); - } + TextInput.Clear(); + var command = CommandParser.TryParse(text); + if (command != null) + EmitSignal(SignalName.CommandSubmitted, command); + else + EmitSignal(SignalName.UnknownInputSubmitted, text); } } \ No newline at end of file -- cgit v1.2.3