diff options
Diffstat (limited to 'Scripts/Terminal')
| -rw-r--r-- | Scripts/Terminal/ButtonBlock.cs | 28 | ||||
| -rw-r--r-- | Scripts/Terminal/MenuScreen.cs | 27 |
2 files changed, 55 insertions, 0 deletions
diff --git a/Scripts/Terminal/ButtonBlock.cs b/Scripts/Terminal/ButtonBlock.cs new file mode 100644 index 0000000..769fdf8 --- /dev/null +++ b/Scripts/Terminal/ButtonBlock.cs @@ -0,0 +1,28 @@ +using System.Linq; +using Godot; +using Godot.Collections; +using Texty.Scripts.GodotExtensions; + +namespace Texty.Scripts.Terminal +{ + [Tool] + public abstract class ButtonBlock : MarginContainer + { + 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(); + } + + protected abstract void OnButtonPressed(int index); + + private void ConnectButtons() + { + foreach (var (button, index) in Buttons.GetChildren<Button>().Select((button, index) => (button, index))) + button.Connect("pressed", this, nameof(OnButtonPressed), new Array(index)); + } + } +}
\ No newline at end of file diff --git a/Scripts/Terminal/MenuScreen.cs b/Scripts/Terminal/MenuScreen.cs new file mode 100644 index 0000000..5c3abfb --- /dev/null +++ b/Scripts/Terminal/MenuScreen.cs @@ -0,0 +1,27 @@ +using Godot; + +namespace Texty.Scripts.Terminal +{ + [Tool] + public class MenuScreen : Control + { + private string _title = ""; + private StatusArea TitleArea => GetNodeOrNull<StatusArea>($"%{nameof(TitleArea)}"); + + [Export] + public string Title + { + get => _title; + set + { + _title = value; + if (TitleArea != null) TitleArea.Title = $"[center]{GodotSharp.Singleton.Tr(_title)}[/center]"; + } + } + + public override void _Ready() + { + Title = _title; + } + } +}
\ No newline at end of file |
