diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-15 20:00:47 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-15 20:00:47 -0300 |
| commit | 862b399fa37e6ca692d38177a22ee34860d2251e (patch) | |
| tree | 3c0c80efbe0096c8e8d606ee464b54b55eaa209c /scripts/GUI/Details.cs | |
| parent | befb39054656e3242e9408f2afe8c902df471ffa (diff) | |
Menu principal
Diffstat (limited to 'scripts/GUI/Details.cs')
| -rw-r--r-- | scripts/GUI/Details.cs | 34 |
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) |
