diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-15 20:00:47 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-15 20:00:47 -0300 |
| commit | 862b399fa37e6ca692d38177a22ee34860d2251e (patch) | |
| tree | 3c0c80efbe0096c8e8d606ee464b54b55eaa209c /scripts/GUI/MainMenu.cs | |
| parent | befb39054656e3242e9408f2afe8c902df471ffa (diff) | |
Menu principal
Diffstat (limited to 'scripts/GUI/MainMenu.cs')
| -rw-r--r-- | scripts/GUI/MainMenu.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/GUI/MainMenu.cs b/scripts/GUI/MainMenu.cs new file mode 100644 index 0000000..4d89b36 --- /dev/null +++ b/scripts/GUI/MainMenu.cs @@ -0,0 +1,46 @@ +using Godot; + +namespace TheLegendOfGustav.GUI; + +public partial class MainMenu : Control +{ + private Button NewGameButton; + private Button LoadGameButton; + private Button QuitButton; + + [Signal] + public delegate void GameRequestEventHandler(bool load); + + public override void _Ready() + { + base._Ready(); + + NewGameButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/neogame"); + LoadGameButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/continue"); + QuitButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/quit"); + + NewGameButton.Pressed += OnNewGameButtonPressed; + LoadGameButton.Pressed += OnLoadGameButtonPressed; + QuitButton.Pressed += OnQuitButtonPressed; + + NewGameButton.GrabFocus(); + bool hasSaveFile = FileAccess.FileExists("user://save.dat"); + LoadGameButton.Disabled = !hasSaveFile; + } + + private void OnNewGameButtonPressed() + { + GD.Print("Signal EMIT!"); + EmitSignal(SignalName.GameRequest, false); + } + + private void OnLoadGameButtonPressed() + { + EmitSignal(SignalName.GameRequest, true); + } + + private void OnQuitButtonPressed() + { + GetTree().Quit(); + } +} |
