blob: 15ccc3362b19219383be869cfd700ea4a8424b46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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();
}
}
|