summaryrefslogtreecommitdiff
path: root/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Scripts')
-rw-r--r--Scripts/Credits.cs22
-rw-r--r--Scripts/Game/Command.cs31
-rw-r--r--Scripts/Game/CommandInputArea.cs45
-rw-r--r--Scripts/Game/CommandParser.cs25
-rw-r--r--Scripts/Game/Commands/LookCommand.cs91
-rw-r--r--Scripts/Game/Game.cs33
-rw-r--r--Scripts/GodotExtensions/ArrayExtensions.cs11
-rw-r--r--Scripts/GodotExtensions/NodeExtensions.cs11
-rw-r--r--Scripts/Location.cs9
-rw-r--r--Scripts/Menus/MainMenu.cs39
-rw-r--r--Scripts/Menus/MainMenuButtons.cs55
-rw-r--r--Scripts/Terminal/ButtonBlock.cs35
-rw-r--r--Scripts/Terminal/InputArea.cs18
-rw-r--r--Scripts/Terminal/MenuScreen.cs35
-rw-r--r--Scripts/Terminal/OutputArea.cs60
-rw-r--r--Scripts/Terminal/OutputBlock.cs37
-rw-r--r--Scripts/Terminal/StatusArea.cs37
17 files changed, 286 insertions, 308 deletions
diff --git a/Scripts/Credits.cs b/Scripts/Credits.cs
index 5432d02..11b7e08 100644
--- a/Scripts/Credits.cs
+++ b/Scripts/Credits.cs
@@ -1,16 +1,12 @@
using Godot;
-namespace Texty.Scripts
-{
- public partial class Credits : Node
- {
- public override void _UnhandledKeyInput(InputEvent @event)
- {
- if (@event is InputEventKey { Keycode: Key.Escape })
- {
- GetTree().ChangeSceneToFile("res://Scenes/Menus/MainMenu.tscn");
- }
- }
- }
-}
+namespace Texty.Scripts;
+public partial class Credits : Node
+{
+ public override void _UnhandledKeyInput(InputEvent @event)
+ {
+ if (@event is InputEventKey { Keycode: Key.Escape })
+ GetTree().ChangeSceneToFile("res://Scenes/Menus/MainMenu.tscn");
+ }
+} \ No newline at end of file
diff --git a/Scripts/Game/Command.cs b/Scripts/Game/Command.cs
index 20b8437..56d80a7 100644
--- a/Scripts/Game/Command.cs
+++ b/Scripts/Game/Command.cs
@@ -1,25 +1,24 @@
using Godot;
-namespace Texty.Scripts.Game
+namespace Texty.Scripts.Game;
+
+public enum CommandType
+{
+ Look
+}
+
+public partial class Command : Object
{
- public enum CommandType
+ public Command()
{
- Look
}
- public partial class Command : Object
+ public Command(CommandType type, string[] arguments)
{
- public Command()
- {
- }
-
- public Command(CommandType type, string[] arguments)
- {
- RawArguments = arguments;
- Type = type;
- }
-
- public string[] RawArguments { get; }
- public CommandType Type { get; }
+ RawArguments = arguments;
+ Type = type;
}
+
+ public string[] RawArguments { get; }
+ public CommandType Type { get; }
} \ No newline at end of file
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
diff --git a/Scripts/Game/CommandParser.cs b/Scripts/Game/CommandParser.cs
index 9b02ee5..6c29545 100644
--- a/Scripts/Game/CommandParser.cs
+++ b/Scripts/Game/CommandParser.cs
@@ -2,22 +2,21 @@ using System.Linq;
using Godot;
using Texty.Scripts.Commands;
-namespace Texty.Scripts.Game
+namespace Texty.Scripts.Game;
+
+public partial class CommandParser : Node
{
- public partial class CommandParser : Node
+ public override void _Ready()
{
- public override void _Ready()
- {
- }
+ }
- public Command TryParse(string text)
+ public Command TryParse(string text)
+ {
+ var components = text.Split(' ');
+ return components[0].ToLower() switch
{
- var components = text.Split(' ');
- return components[0].ToLower() switch
- {
- "look" => new LookCommand(components.Skip(1).ToArray()),
- _ => null
- };
- }
+ "look" => new LookCommand(components.Skip(1).ToArray()),
+ _ => null
+ };
}
} \ No newline at end of file
diff --git a/Scripts/Game/Commands/LookCommand.cs b/Scripts/Game/Commands/LookCommand.cs
index 22ba77e..c66fa43 100644
--- a/Scripts/Game/Commands/LookCommand.cs
+++ b/Scripts/Game/Commands/LookCommand.cs
@@ -1,58 +1,57 @@
using System.Linq;
using Texty.Scripts.Game;
-namespace Texty.Scripts.Commands
+namespace Texty.Scripts.Commands;
+
+public enum LookModifier
+{
+ At,
+ Around
+}
+
+public partial class LookCommand : Command
{
- public enum LookModifier
+ public LookCommand()
{
- At,
- Around
}
- public partial class LookCommand : Command
+ public LookCommand(string[] arguments) : base(CommandType.Look, arguments)
{
- public LookCommand()
- {
- }
+ (Modifier, arguments) = TryParseModifier(arguments);
+ Target = string.Join(" ", arguments);
+ }
- public LookCommand(string[] arguments) : base(CommandType.Look, arguments)
- {
- (Modifier, arguments) = TryParseModifier(arguments);
- Target = string.Join(" ", arguments);
- }
-
- public string Target { get; }
- public LookModifier? Modifier { get; }
-
- /// <summary>
- /// Access this <c>LookCommand</c>'s modifier as a string.
- /// </summary>
- /// <remarks>
- /// This function is provided as a means for testing the modifier parsing from GDScript.
- /// </remarks>
- private string ModifierAsString => Modifier?.ToString();
-
- public override string ToString()
- {
- return $"look {ModifierAsString?.ToLower()} {string.Join(" ", Target)}";
- }
-
- /// <summary>
- /// Try to parse this <c>LookCommand</c>'s modifier from the given arguments.
- /// </summary>
- /// <param name="arguments">The arguments given to this look commands</param>
- /// <returns>A pair consisting of the parse modifier and the remaining arguments</returns>
- private static (LookModifier?, string[]) TryParseModifier(string[] arguments)
+ public string Target { get; }
+ public LookModifier? Modifier { get; }
+
+ /// <summary>
+ /// Access this <c>LookCommand</c>'s modifier as a string.
+ /// </summary>
+ /// <remarks>
+ /// This function is provided as a means for testing the modifier parsing from GDScript.
+ /// </remarks>
+ private string ModifierAsString => Modifier?.ToString();
+
+ public override string ToString()
+ {
+ return $"look {ModifierAsString?.ToLower()} {string.Join(" ", Target)}";
+ }
+
+ /// <summary>
+ /// Try to parse this <c>LookCommand</c>'s modifier from the given arguments.
+ /// </summary>
+ /// <param name="arguments">The arguments given to this look commands</param>
+ /// <returns>A pair consisting of the parse modifier and the remaining arguments</returns>
+ private static (LookModifier?, string[]) TryParseModifier(string[] arguments)
+ {
+ if (arguments.Length == 0)
+ return (null, arguments);
+
+ return arguments[0].ToLower() switch
{
- if (arguments.Length == 0)
- return (null, arguments);
-
- return arguments[0].ToLower() switch
- {
- "at" => (LookModifier.At, arguments.Skip(1).ToArray()),
- "around" => (LookModifier.Around, new string[] { }),
- _ => (null, arguments)
- };
- }
+ "at" => (LookModifier.At, arguments.Skip(1).ToArray()),
+ "around" => (LookModifier.Around, new string[] { }),
+ _ => (null, arguments)
+ };
}
} \ No newline at end of file
diff --git a/Scripts/Game/Game.cs b/Scripts/Game/Game.cs
index 07d42b2..e6d4c6a 100644
--- a/Scripts/Game/Game.cs
+++ b/Scripts/Game/Game.cs
@@ -1,26 +1,25 @@
using Godot;
using Texty.Scripts.Terminal;
-namespace Texty.Scripts.Game
+namespace Texty.Scripts.Game;
+
+public partial class Game : Node
{
- public partial class Game : Node
- {
- private InputArea InputArea => GetNodeOrNull<InputArea>($"%{nameof(InputArea)}");
- private OutputArea OutputArea => GetNodeOrNull<OutputArea>($"%{nameof(OutputArea)}");
- private StatusArea StatusArea => GetNodeOrNull<StatusArea>($"%{nameof(StatusArea)}");
+ private InputArea InputArea => GetNodeOrNull<InputArea>($"%{nameof(InputArea)}");
+ private OutputArea OutputArea => GetNodeOrNull<OutputArea>($"%{nameof(OutputArea)}");
+ private StatusArea StatusArea => GetNodeOrNull<StatusArea>($"%{nameof(StatusArea)}");
- public override void _Ready()
- {
- }
+ public override void _Ready()
+ {
+ }
- public void OnCommandSubmitted(Command command)
- {
- OutputArea.Push($"! {command}");
- }
+ public void OnCommandSubmitted(Command command)
+ {
+ OutputArea.Push($"! {command}");
+ }
- public void OnUnknownInputSubmitted(string text)
- {
- OutputArea.Push($"? {text}");
- }
+ public void OnUnknownInputSubmitted(string text)
+ {
+ OutputArea.Push($"? {text}");
}
} \ No newline at end of file
diff --git a/Scripts/GodotExtensions/ArrayExtensions.cs b/Scripts/GodotExtensions/ArrayExtensions.cs
index 2712232..ad72f94 100644
--- a/Scripts/GodotExtensions/ArrayExtensions.cs
+++ b/Scripts/GodotExtensions/ArrayExtensions.cs
@@ -2,13 +2,12 @@ using System;
using Godot;
using Godot.Collections;
-namespace Texty.Scripts.GodotExtensions
+namespace Texty.Scripts.GodotExtensions;
+
+public static class ArrayExtensions
{
- public static class ArrayExtensions
+ public static void ForEach<[MustBeVariant] T>(this Array<T> array, Action<T> action)
{
- public static void ForEach<[MustBeVariant] T>(this Array<T> array, Action<T> action)
- {
- foreach (var element in array) action.Invoke(element);
- }
+ foreach (var element in array) action.Invoke(element);
}
} \ No newline at end of file
diff --git a/Scripts/GodotExtensions/NodeExtensions.cs b/Scripts/GodotExtensions/NodeExtensions.cs
index c361496..0acc012 100644
--- a/Scripts/GodotExtensions/NodeExtensions.cs
+++ b/Scripts/GodotExtensions/NodeExtensions.cs
@@ -2,13 +2,12 @@ using System.Linq;
using Godot;
using Godot.Collections;
-namespace Texty.Scripts.GodotExtensions
+namespace Texty.Scripts.GodotExtensions;
+
+public static class NodeExtensions
{
- public static class NodeExtensions
+ public static Array<T> GetChildren<[MustBeVariant] T>(this Node node)
{
- public static Array<T> GetChildren<[MustBeVariant] T>(this Node node)
- {
- return new Array<T>(node.GetChildren().OfType<T>());
- }
+ return new Array<T>(node.GetChildren().OfType<T>());
}
} \ No newline at end of file
diff --git a/Scripts/Location.cs b/Scripts/Location.cs
index aaca980..8cebcf1 100644
--- a/Scripts/Location.cs
+++ b/Scripts/Location.cs
@@ -1,9 +1,8 @@
using Godot;
-namespace Texty.Scripts
+namespace Texty.Scripts;
+
+public partial class Location : Resource
{
- public partial class Location : Resource
- {
- [Export(PropertyHint.MultilineText)] public string FlavourText = string.Empty;
- }
+ [Export(PropertyHint.MultilineText)] public string FlavourText = string.Empty;
} \ No newline at end of file
diff --git a/Scripts/Menus/MainMenu.cs b/Scripts/Menus/MainMenu.cs
index 2991fec..5a7c3dd 100644
--- a/Scripts/Menus/MainMenu.cs
+++ b/Scripts/Menus/MainMenu.cs
@@ -1,26 +1,25 @@
using Godot;
-namespace Texty.Scripts.Menus
+namespace Texty.Scripts.Menus;
+
+public partial class MainMenu : Node
{
- public partial class MainMenu : Node
- {
- public override void _Ready()
- {
- }
+ public override void _Ready()
+ {
+ }
- private void OnStartButtonPressed()
- {
- GetTree().ChangeSceneToFile("res://Scenes/Game/Game.tscn");
- }
+ private void OnStartButtonPressed()
+ {
+ GetTree().ChangeSceneToFile("res://Scenes/Game/Game.tscn");
+ }
- private void OnCreditsButtonPressed()
- {
- GetTree().ChangeSceneToFile("res://Scenes/Credits.tscn");
- }
+ private void OnCreditsButtonPressed()
+ {
+ GetTree().ChangeSceneToFile("res://Scenes/Credits.tscn");
+ }
- private void OnQuitButtonPressed()
- {
- GetTree().Quit();
- }
- }
-}
+ private void OnQuitButtonPressed()
+ {
+ GetTree().Quit();
+ }
+} \ No newline at end of file
diff --git a/Scripts/Menus/MainMenuButtons.cs b/Scripts/Menus/MainMenuButtons.cs
index 64e8914..e343135 100644
--- a/Scripts/Menus/MainMenuButtons.cs
+++ b/Scripts/Menus/MainMenuButtons.cs
@@ -2,38 +2,37 @@ using System;
using Godot;
using Texty.Scripts.Terminal;
-namespace Texty.Scripts.Menus
+namespace Texty.Scripts.Menus;
+
+public partial class MainMenuButtons : ButtonBlock
{
- public partial class MainMenuButtons : ButtonBlock
- {
- [Signal] public delegate void CreditsButtonPressedEventHandler();
- [Signal] public delegate void QuitButtonPressedEventHandler();
- [Signal] public delegate void StartButtonPressedEventHandler();
+ [Signal] public delegate void CreditsButtonPressedEventHandler();
+ [Signal] public delegate void QuitButtonPressedEventHandler();
+ [Signal] public delegate void StartButtonPressedEventHandler();
- protected override void OnButtonPressed(int index)
+ protected override void OnButtonPressed(int index)
+ {
+ if (!Enum.IsDefined(typeof(Buttons), 1)) return;
+ switch ((Buttons)index)
{
- if (!Enum.IsDefined(typeof(Buttons), 1)) return;
- switch ((Buttons)index)
- {
- case Buttons.Start:
- EmitSignal(SignalName.StartButtonPressed);
- break;
- case Buttons.Credits:
- EmitSignal(SignalName.CreditsButtonPressed);
- break;
- case Buttons.Quit:
- EmitSignal(SignalName.QuitButtonPressed);
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(index), index, "Button not implemented!");
- }
+ case Buttons.Start:
+ EmitSignal(SignalName.StartButtonPressed);
+ break;
+ case Buttons.Credits:
+ EmitSignal(SignalName.CreditsButtonPressed);
+ break;
+ case Buttons.Quit:
+ EmitSignal(SignalName.QuitButtonPressed);
+ break;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(index), index, "Button not implemented!");
}
+ }
- private enum Buttons
- {
- Start = 0,
- Credits = 1,
- Quit = 2
- }
+ private enum Buttons
+ {
+ Start = 0,
+ Credits = 1,
+ Quit = 2
}
} \ No newline at end of file
diff --git a/Scripts/Terminal/ButtonBlock.cs b/Scripts/Terminal/ButtonBlock.cs
index ef25f8c..ff0e83e 100644
--- a/Scripts/Terminal/ButtonBlock.cs
+++ b/Scripts/Terminal/ButtonBlock.cs
@@ -2,27 +2,26 @@ using System.Linq;
using Godot;
using Texty.Scripts.GodotExtensions;
-namespace Texty.Scripts.Terminal
+namespace Texty.Scripts.Terminal;
+
+public partial class ButtonBlock : MarginContainer
{
- public partial class ButtonBlock : MarginContainer
- {
- private VBoxContainer Buttons => GetNodeOrNull<VBoxContainer>($"%{nameof(Buttons)}");
+ private VBoxContainer Buttons => GetNodeOrNull<VBoxContainer>($"%{nameof(Buttons)}");
- public override void _Ready()
- {
- ConnectButtons();
- Buttons.GetChildren<Button>().ForEach(button => button.MouseFilter = MouseFilterEnum.Ignore);
- Buttons.GetChildren<Button>().FirstOrDefault()?.GrabFocus();
- }
+ public override void _Ready()
+ {
+ ConnectButtons();
+ Buttons.GetChildren<Button>().ForEach(button => button.MouseFilter = MouseFilterEnum.Ignore);
+ Buttons.GetChildren<Button>().FirstOrDefault()?.GrabFocus();
+ }
- protected virtual void OnButtonPressed(int index)
- {
- }
+ protected virtual void OnButtonPressed(int index)
+ {
+ }
- private void ConnectButtons()
- {
- foreach (var (button, index) in Buttons.GetChildren<Button>().Select((button, index) => (button, index)))
- button.Pressed += () => OnButtonPressed(index);
- }
+ private void ConnectButtons()
+ {
+ foreach (var (button, index) in Buttons.GetChildren<Button>().Select((button, index) => (button, index)))
+ button.Pressed += () => OnButtonPressed(index);
}
} \ No newline at end of file
diff --git a/Scripts/Terminal/InputArea.cs b/Scripts/Terminal/InputArea.cs
index a32ad2c..04c0887 100644
--- a/Scripts/Terminal/InputArea.cs
+++ b/Scripts/Terminal/InputArea.cs
@@ -1,17 +1,15 @@
using Godot;
-namespace Texty.Scripts.Terminal
+namespace Texty.Scripts.Terminal;
+
+public partial class InputArea : HBoxContainer
{
- public partial class InputArea : HBoxContainer
- {
- protected Label PromptLabel => GetNodeOrNull<Label>($"%{nameof(PromptLabel)}");
- protected LineEdit TextInput => GetNodeOrNull<LineEdit>($"%{nameof(TextInput)}");
+ protected Label PromptLabel => GetNodeOrNull<Label>($"%{nameof(PromptLabel)}");
+ protected LineEdit TextInput => GetNodeOrNull<LineEdit>($"%{nameof(TextInput)}");
- public new bool HasFocus => TextInput?.HasFocus() ?? false;
+ public new bool HasFocus => TextInput?.HasFocus() ?? false;
- public virtual void OnTextEntered(string text)
- {
-
- }
+ public virtual void OnTextEntered(string text)
+ {
}
} \ No newline at end of file
diff --git a/Scripts/Terminal/MenuScreen.cs b/Scripts/Terminal/MenuScreen.cs
index 1259b31..ee6e765 100644
--- a/Scripts/Terminal/MenuScreen.cs
+++ b/Scripts/Terminal/MenuScreen.cs
@@ -1,27 +1,26 @@
using Godot;
-namespace Texty.Scripts.Terminal
+namespace Texty.Scripts.Terminal;
+
+[Tool]
+public partial class MenuScreen : Control
{
- [Tool]
- public partial class MenuScreen : Control
- {
- private string _title = "";
- private StatusArea TitleArea => GetNodeOrNull<StatusArea>($"%{nameof(TitleArea)}");
+ private string _title = "";
+ private StatusArea TitleArea => GetNodeOrNull<StatusArea>($"%{nameof(TitleArea)}");
- [Export]
- public string Title
+ [Export]
+ public string Title
+ {
+ get => _title;
+ set
{
- get => _title;
- set
- {
- _title = value;
- if (TitleArea != null) TitleArea.Title = $"[center]{GodotSharp.Singleton.Tr(_title)}[/center]";
- }
+ _title = value;
+ if (TitleArea != null) TitleArea.Title = $"[center]{GodotSharp.Singleton.Tr(_title)}[/center]";
}
+ }
- public override void _Ready()
- {
- Title = _title;
- }
+ public override void _Ready()
+ {
+ Title = _title;
}
} \ No newline at end of file
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<string> TextBlocks => new Array<string>(BlockNodes.ToList().Select(block => block.Content));
+ [Export(PropertyHint.File, "*.tscn")] public PackedScene OutputBlockScene;
+ public Array<string> TextBlocks => new(BlockNodes.ToList().Select(block => block.Content));
- private VBoxContainer LineContainer => GetNodeOrNull<VBoxContainer>($"%{nameof(LineContainer)}");
+ private VBoxContainer LineContainer => GetNodeOrNull<VBoxContainer>($"%{nameof(LineContainer)}");
- private IEnumerable<OutputBlock> BlockNodes =>
- GD.Range(LineContainer?.GetChildCount() ?? 0)
- .Select(index => LineContainer.GetChild(index))
- .Cast<OutputBlock>();
+ 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.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<OutputBlock>();
- block.Content = text;
- LineContainer.AddChild(block);
- }
+ public void Push(string text)
+ {
+ if (string.IsNullOrEmpty(text)) return;
+ var block = OutputBlockScene.Instantiate<OutputBlock>();
+ block.Content = text;
+ LineContainer.AddChild(block);
}
} \ No newline at end of file
diff --git a/Scripts/Terminal/OutputBlock.cs b/Scripts/Terminal/OutputBlock.cs
index 4512446..3f50f44 100644
--- a/Scripts/Terminal/OutputBlock.cs
+++ b/Scripts/Terminal/OutputBlock.cs
@@ -1,29 +1,28 @@
using Godot;
-namespace Texty.Scripts.Terminal
+namespace Texty.Scripts.Terminal;
+
+[Tool]
+public partial class OutputBlock : MarginContainer
{
- [Tool]
- public partial class OutputBlock : MarginContainer
- {
- private string _content = "";
+ private string _content = "";
- private RichTextLabel ContentLabel => GetNodeOrNull<RichTextLabel>($"%{nameof(ContentLabel)}");
+ private RichTextLabel ContentLabel => GetNodeOrNull<RichTextLabel>($"%{nameof(ContentLabel)}");
- [Export(PropertyHint.MultilineText)]
- public string Content
+ [Export(PropertyHint.MultilineText)]
+ public string Content
+ {
+ get => ContentLabel?.Text ?? "";
+ set
{
- get => ContentLabel?.Text ?? "";
- set
- {
- _content = value;
- if (ContentLabel != null)
- ContentLabel.Text = GodotSharp.Singleton.Tr(_content);
- }
+ _content = value;
+ if (ContentLabel != null)
+ ContentLabel.Text = GodotSharp.Singleton.Tr(_content);
}
+ }
- public override void _Ready()
- {
- Content = _content;
- }
+ public override void _Ready()
+ {
+ Content = _content;
}
} \ No newline at end of file
diff --git a/Scripts/Terminal/StatusArea.cs b/Scripts/Terminal/StatusArea.cs
index 3099168..8357735 100644
--- a/Scripts/Terminal/StatusArea.cs
+++ b/Scripts/Terminal/StatusArea.cs
@@ -1,28 +1,27 @@
using Godot;
-namespace Texty.Scripts.Terminal
+namespace Texty.Scripts.Terminal;
+
+[Tool]
+public partial class StatusArea : HBoxContainer
{
- [Tool]
- public partial class StatusArea : HBoxContainer
- {
- private string _titleText = "";
- private RichTextLabel TitleLabel => GetNodeOrNull<RichTextLabel>($"%{nameof(TitleLabel)}");
+ private string _titleText = "";
+ private RichTextLabel TitleLabel => GetNodeOrNull<RichTextLabel>($"%{nameof(TitleLabel)}");
- [Export]
- public string Title
+ [Export]
+ public string Title
+ {
+ get => _titleText;
+ set
{
- get => _titleText;
- set
- {
- _titleText = value;
- if (TitleLabel != null)
- TitleLabel.Text = GodotSharp.Singleton.Tr(value);
- }
+ _titleText = value;
+ if (TitleLabel != null)
+ TitleLabel.Text = GodotSharp.Singleton.Tr(value);
}
+ }
- public override void _Ready()
- {
- Title = _titleText;
- }
+ public override void _Ready()
+ {
+ Title = _titleText;
}
} \ No newline at end of file