summaryrefslogtreecommitdiff
path: root/Scripts/Game/CommandInputArea.cs
diff options
context:
space:
mode:
authorSophia Pearson <codergal89@gmail.com>2022-11-26 10:08:44 +0100
committerSophia Pearson <codergal89@gmail.com>2022-11-26 10:08:44 +0100
commitd7eefa488135c477f39ea0953b032c7dcdad8bc7 (patch)
treed9725b73b342ff3d9df4d800616dd010b48c7222 /Scripts/Game/CommandInputArea.cs
parent8e8a58bac339aa06e860b977670f16c8b4eb30a8 (diff)
downloadtexty-d7eefa488135c477f39ea0953b032c7dcdad8bc7.tar.xz
texty-d7eefa488135c477f39ea0953b032c7dcdad8bc7.zip
scripts: perform code cleanup actions
Diffstat (limited to 'Scripts/Game/CommandInputArea.cs')
-rw-r--r--Scripts/Game/CommandInputArea.cs45
1 files changed, 22 insertions, 23 deletions
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<CommandParser>($"%{nameof(CommandParser)}");
+
+ public override void _Ready()
{
- [Signal] public delegate void CommandSubmittedEventHandler(Command command);
- [Signal] public delegate void UnknownInputSubmittedEventHandler(string text);
-
- private CommandParser CommandParser => GetNodeOrNull<CommandParser>($"%{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