summaryrefslogtreecommitdiff
path: root/scripts/GUI/Details.cs
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/GUI/Details.cs')
-rw-r--r--scripts/GUI/Details.cs34
1 files changed, 28 insertions, 6 deletions
diff --git a/scripts/GUI/Details.cs b/scripts/GUI/Details.cs
index 3c64427..3ead3a9 100644
--- a/scripts/GUI/Details.cs
+++ b/scripts/GUI/Details.cs
@@ -8,31 +8,53 @@ namespace TheLegendOfGustav.GUI;
public partial class Details : CanvasLayer
{
private static readonly LabelSettings lblSettings = GD.Load<LabelSettings>("res://assets/definitions/message_label_settings.tres");
-
- private Map.Map Map { get; set; }
+
+ [Export]
+ private Map.Map map;
private VBoxContainer EntityNames { get; set; }
private Godot.Collections.Array<Entity> Entities { get; set; } = [];
private Godot.Collections.Array<Label> ActorsLabel { get; set; } = [];
+ private SignalBus.EnterInspectionModeEventHandler enterLambda;
+ private SignalBus.ExitInspectionModeEventHandler exitLambda;
+
public override void _Ready()
{
base._Ready();
- Map = GetParent<Map.Map>();
EntityNames = GetNode<VBoxContainer>("HBoxContainer/PanelContainer/ScrollContainer/Entities");
+ enterLambda = () => Visible = true;
+ exitLambda = () => Visible = false;
SignalBus.Instance.InspectorMoved += OnInspectorWalk;
- SignalBus.Instance.EnterInspectionMode += () => Visible = true;
- SignalBus.Instance.ExitInspectionMode += () => Visible = false;
+ SignalBus.Instance.EnterInspectionMode += enterLambda;
+ SignalBus.Instance.ExitInspectionMode += exitLambda;
}
public void OnInspectorWalk(Vector2I pos)
{
- MapData mapData = Map.MapData;
+ MapData mapData = map.MapData;
Entities = mapData.GetEntitiesAtPosition(pos);
UpdateLabels();
}
+ public override void _Notification(int what)
+ {
+ if (what == NotificationPredelete)
+ {
+ SignalBus.Instance.InspectorMoved -= OnInspectorWalk;
+ if (enterLambda != null)
+ {
+ SignalBus.Instance.EnterInspectionMode -= enterLambda;
+ }
+ if (exitLambda != null)
+ {
+ SignalBus.Instance.ExitInspectionMode -= exitLambda;
+ }
+ }
+ base._Notification(what);
+ }
+
private void UpdateLabels()
{
foreach (Label label in ActorsLabel)