summaryrefslogtreecommitdiff
path: root/scripts/GUI
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-11-10 12:56:00 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-11-10 12:56:00 -0300
commit0f3c49b7743f7c7fabf41fdf4cb3ffe1a4ac3bf4 (patch)
treedf940efb7502899441295acd5039311b9e6e4927 /scripts/GUI
parentc4f5404211ef654944d5615e9055c714441f8234 (diff)
Placar.
Diffstat (limited to 'scripts/GUI')
-rw-r--r--scripts/GUI/LeaderboardItem.cs41
-rw-r--r--scripts/GUI/LeaderboardItem.cs.uid1
-rw-r--r--scripts/GUI/MainMenu.cs12
3 files changed, 54 insertions, 0 deletions
diff --git a/scripts/GUI/LeaderboardItem.cs b/scripts/GUI/LeaderboardItem.cs
new file mode 100644
index 0000000..c05bf58
--- /dev/null
+++ b/scripts/GUI/LeaderboardItem.cs
@@ -0,0 +1,41 @@
+using Godot;
+
+namespace TheLegendOfGustav.GUI;
+
+public partial class LeaderboardItem : HBoxContainer
+{
+ [Export]
+ public string PlayerName { get; set; } = "Jogador";
+ [Export]
+ public string Floor { get; set; } = "Andar Máximo";
+ [Export]
+ public string Kills { get; set; } = "Inimigos Mortos";
+ [Export]
+ public string Damage { get; set; } = "Dano tomado";
+
+ private Label nameLabel;
+ private Label floorLabel;
+ private Label killsLabel;
+ private Label damageLabel;
+
+
+ // Called when the node enters the scene tree for the first time.
+ public override void _Ready()
+ {
+ nameLabel = GetNode<Label>("hdNome");
+ floorLabel = GetNode<Label>("hdAndar");
+ killsLabel = GetNode<Label>("hdkills");
+ damageLabel = GetNode<Label>("hddamage");
+
+
+ UpdateLabels();
+ }
+
+ public void UpdateLabels()
+ {
+ nameLabel.Text = PlayerName;
+ floorLabel.Text = Floor;
+ killsLabel.Text = Kills;
+ damageLabel.Text = Damage;
+ }
+}
diff --git a/scripts/GUI/LeaderboardItem.cs.uid b/scripts/GUI/LeaderboardItem.cs.uid
new file mode 100644
index 0000000..ddac2bd
--- /dev/null
+++ b/scripts/GUI/LeaderboardItem.cs.uid
@@ -0,0 +1 @@
+uid://cbjltiujfsw4v
diff --git a/scripts/GUI/MainMenu.cs b/scripts/GUI/MainMenu.cs
index fc46cd2..0d6c8c6 100644
--- a/scripts/GUI/MainMenu.cs
+++ b/scripts/GUI/MainMenu.cs
@@ -7,9 +7,12 @@ public partial class MainMenu : Control
private Button newGameButton;
private Button loadGameButton;
private Button quitButton;
+ private Button leaderboardButton;
[Signal]
public delegate void GameRequestEventHandler(bool load);
+ [Signal]
+ public delegate void LeaderboardRequestEventHandler();
public override void _Ready()
{
@@ -18,14 +21,18 @@ public partial class MainMenu : Control
newGameButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/neogame");
loadGameButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/continue");
quitButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/quit");
+ leaderboardButton = GetNode<Button>("VBoxContainer/CenterContainer/VBoxContainer/leaderboard");
newGameButton.Pressed += OnNewGameButtonPressed;
loadGameButton.Pressed += OnLoadGameButtonPressed;
quitButton.Pressed += OnQuitButtonPressed;
+ leaderboardButton.Pressed += OnLeaderBoardRequest;
newGameButton.GrabFocus();
bool hasSaveFile = FileAccess.FileExists("user://save_game.json");
+ bool hasLeaderboard = FileAccess.FileExists("user://placar.json");
loadGameButton.Disabled = !hasSaveFile;
+ leaderboardButton.Disabled = !hasLeaderboard;
}
private void OnNewGameButtonPressed()
@@ -38,6 +45,11 @@ public partial class MainMenu : Control
EmitSignal(SignalName.GameRequest, true);
}
+ private void OnLeaderBoardRequest()
+ {
+ EmitSignal(SignalName.LeaderboardRequest);
+ }
+
private void OnQuitButtonPressed()
{
GetTree().Quit();