diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-11-04 12:54:13 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-11-04 12:54:13 -0300 |
| commit | 63e4f75e9292e1276cc0b5d11ebad010f147aa68 (patch) | |
| tree | 4b6c9a1c39b7e2fedb0ba27a8df47631bb2abea9 | |
| parent | 5d2f66f1e7f8a9f35456e0f6acc478d1b2ecb294 (diff) | |
Display de andar
| -rw-r--r-- | scenes/GUI/hud.tscn | 21 | ||||
| -rw-r--r-- | scripts/GUI/Hud.cs | 23 | ||||
| -rw-r--r-- | scripts/Map/Map.cs | 7 | ||||
| -rw-r--r-- | scripts/Utils/SignalBus.cs | 3 |
4 files changed, 42 insertions, 12 deletions
diff --git a/scenes/GUI/hud.tscn b/scenes/GUI/hud.tscn index 034d2d9..eaf687a 100644 --- a/scenes/GUI/hud.tscn +++ b/scenes/GUI/hud.tscn @@ -40,15 +40,19 @@ theme_override_constants/margin_top = 5 theme_override_constants/margin_right = 5 theme_override_constants/margin_bottom = 5 -[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/InfoBar/Stats/MarginContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/InfoBar/Stats/MarginContainer"] layout_mode = 2 -[node name="AspectRatioContainer" type="AspectRatioContainer" parent="VBoxContainer/InfoBar/Stats/MarginContainer/HBoxContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="AspectRatioContainer" type="AspectRatioContainer" parent="VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 ratio = 5.0 -[node name="HPbar" type="TextureProgressBar" parent="VBoxContainer/InfoBar/Stats/MarginContainer/HBoxContainer/AspectRatioContainer"] +[node name="HPbar" type="TextureProgressBar" parent="VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer/AspectRatioContainer"] custom_minimum_size = Vector2(50, 10) layout_mode = 2 size_flags_horizontal = 3 @@ -58,12 +62,12 @@ texture_under = ExtResource("2_p7vwb") texture_over = ExtResource("3_ktti3") texture_progress = ExtResource("4_cgfq5") -[node name="AspectRatioContainer2" type="AspectRatioContainer" parent="VBoxContainer/InfoBar/Stats/MarginContainer/HBoxContainer"] +[node name="AspectRatioContainer2" type="AspectRatioContainer" parent="VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 ratio = 5.0 -[node name="MPbar" type="TextureProgressBar" parent="VBoxContainer/InfoBar/Stats/MarginContainer/HBoxContainer/AspectRatioContainer2"] +[node name="MPbar" type="TextureProgressBar" parent="VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer/AspectRatioContainer2"] custom_minimum_size = Vector2(50, 10) layout_mode = 2 size_flags_horizontal = 3 @@ -73,6 +77,13 @@ texture_under = ExtResource("4_8dubc") texture_over = ExtResource("5_p7vwb") texture_progress = ExtResource("6_ktti3") +[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="floorLabel" type="Label" parent="VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +text = "Andar: X" + [node name="MessagelogContainer" type="PanelContainer" parent="VBoxContainer/InfoBar"] layout_mode = 2 size_flags_horizontal = 3 diff --git a/scripts/GUI/Hud.cs b/scripts/GUI/Hud.cs index a1511b8..60e1e91 100644 --- a/scripts/GUI/Hud.cs +++ b/scripts/GUI/Hud.cs @@ -1,5 +1,6 @@ using System.Runtime.InteropServices; using Godot; +using TheLegendOfGustav.Utils; namespace TheLegendOfGustav.GUI; @@ -7,12 +8,25 @@ public partial class Hud : CanvasLayer { private TextureProgressBar hpBar; private TextureProgressBar mpBar; + private Label floorLabel; public override void _Ready() { base._Ready(); - hpBar = GetNode<TextureProgressBar>("VBoxContainer/InfoBar/Stats/MarginContainer/HBoxContainer/AspectRatioContainer/HPbar"); - mpBar = GetNode<TextureProgressBar>("VBoxContainer/InfoBar/Stats/MarginContainer/HBoxContainer/AspectRatioContainer2/MPbar"); + hpBar = GetNode<TextureProgressBar>("VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer/AspectRatioContainer/HPbar"); + mpBar = GetNode<TextureProgressBar>("VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer/AspectRatioContainer/HPbar"); + floorLabel = GetNode<Label>("VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer2/floorLabel"); + + SignalBus.Instance.DungeonFloorChanged += OnFloorChanged; + } + + public override void _Notification(int what) + { + base._Notification(what); + if (what == NotificationPredelete) + { + SignalBus.Instance.DungeonFloorChanged -= OnFloorChanged; + } } public void OnHealthChanged(int hp, int maxHp) @@ -26,4 +40,9 @@ public partial class Hud : CanvasLayer mpBar.Value = mp; mpBar.MaxValue = maxMp; } + + public void OnFloorChanged(int floor) + { + floorLabel.Text = $"Andar: {floor}"; + } } diff --git a/scripts/Map/Map.cs b/scripts/Map/Map.cs index 2913c1f..104d658 100644 --- a/scripts/Map/Map.cs +++ b/scripts/Map/Map.cs @@ -32,9 +32,6 @@ public partial class Map : Node2D /// </summary> public MapData MapData { get; private set; } - [Signal] - public delegate void DungeonFloorChangedEventHandler(int floor); - private SignalBus.PlayerDescentEventHandler joinSignal; public override void _Ready() { @@ -83,7 +80,7 @@ public partial class Map : Node2D PlaceTiles(); PlaceEntities(); - EmitSignal(SignalName.DungeonFloorChanged, currentFloor); + SignalBus.Instance.EmitSignal(SignalBus.SignalName.DungeonFloorChanged, currentFloor); } /// <summary> @@ -142,7 +139,7 @@ public partial class Map : Node2D PlaceEntities(); MapData.EntityPlaced += OnEntityPlaced; - EmitSignal(SignalName.DungeonFloorChanged, MapData.CurrentFloor); + SignalBus.Instance.EmitSignal(SignalBus.SignalName.DungeonFloorChanged, MapData.CurrentFloor); return true; } diff --git a/scripts/Utils/SignalBus.cs b/scripts/Utils/SignalBus.cs index a7eccf8..db3e390 100644 --- a/scripts/Utils/SignalBus.cs +++ b/scripts/Utils/SignalBus.cs @@ -37,6 +37,9 @@ public partial class SignalBus : Node [Signal] public delegate void PlayerDescentEventHandler(); + [Signal] + public delegate void DungeonFloorChangedEventHandler(int floor); + public override void _Ready() { base._Ready(); |
