diff options
| author | Sophia Pearson <codergal89@gmail.com> | 2022-05-27 23:52:37 +0200 |
|---|---|---|
| committer | Sophia Pearson <codergal89@gmail.com> | 2022-05-27 23:52:37 +0200 |
| commit | 0477b9ab34817165ac7b11ad77a6740995f55892 (patch) | |
| tree | 5721a9c7a1f0437fb8c526544bc7e63a0ea9cc66 /Scripts | |
| parent | 1010b138a0e52f860ef73d5552b0be236573c46b (diff) | |
| download | texty-0477b9ab34817165ac7b11ad77a6740995f55892.tar.xz texty-0477b9ab34817165ac7b11ad77a6740995f55892.zip | |
gui: add signals to start menu
Diffstat (limited to 'Scripts')
| -rw-r--r-- | Scripts/StartMenu.cs | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/Scripts/StartMenu.cs b/Scripts/StartMenu.cs index 70b84b2..a1f64cc 100644 --- a/Scripts/StartMenu.cs +++ b/Scripts/StartMenu.cs @@ -2,11 +2,15 @@ using Godot; namespace Texty.Scripts { - public class StartMenu : MarginContainer - { - public Button CreditsButton; - public Button QuitButton; - public Button StartButton; + public class StartMenu : MarginContainer + { + [Signal] public delegate void QuitGame(); + [Signal] public delegate void ShowCredits(); + [Signal] public delegate void StartGame(); + + public Button CreditsButton; + public Button QuitButton; + public Button StartButton; public override void _Ready() { @@ -15,5 +19,28 @@ namespace Texty.Scripts QuitButton = buttons.GetNode<Button>(nameof(QuitButton)); StartButton = buttons.GetNode<Button>(nameof(StartButton)); } + + public void OnCreditsButtonPressed() + { + EmitSignal(nameof(ShowCredits)); + } + + public void OnQuitButtonPressed() + { + EmitSignal(nameof(QuitGame)); + } + + public void OnStartButtonPressed() + { + EmitSignal(nameof(StartGame)); + } + + public void OnVisibilityChanged() + { + if(Visible) + StartButton.GrabFocus(); + else + StartButton.ReleaseFocus(); + } } }
\ No newline at end of file |
