summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/GUI/LeaderboardItem.cs41
-rw-r--r--scripts/GUI/LeaderboardItem.cs.uid1
-rw-r--r--scripts/GUI/MainMenu.cs12
-rw-r--r--scripts/GameManager.cs8
4 files changed, 62 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();
diff --git a/scripts/GameManager.cs b/scripts/GameManager.cs
index df93954..4215475 100644
--- a/scripts/GameManager.cs
+++ b/scripts/GameManager.cs
@@ -10,6 +10,7 @@ public partial class GameManager : Node
private PackedScene mainMenuScene = GD.Load<PackedScene>("res://scenes/GUI/main_menu.tscn");
private PackedScene gameScene = GD.Load<PackedScene>("res://scenes/Game.tscn");
private PackedScene nameScene = GD.Load<PackedScene>("res://scenes/name_thyself.tscn");
+ private PackedScene leaderboardScene = GD.Load<PackedScene>("res://scenes/GUI/Leaderboard.tscn");
private Node currentScene;
@@ -44,6 +45,7 @@ public partial class GameManager : Node
MainMenu menu = (MainMenu)SwitchToScene(mainMenuScene);
Stats.Instance.Clear();
menu.GameRequest += OnGameRequest;
+ menu.LeaderboardRequest += OnLeaderboardRequest;
}
private void LoadGame()
@@ -88,4 +90,10 @@ public partial class GameManager : Node
LoadGame();
}
}
+
+ private void OnLeaderboardRequest()
+ {
+ Leaderboard scene = (Leaderboard)SwitchToScene(leaderboardScene);
+ scene.MenuRequested += LoadMainMenu;
+ }
}