diff options
Diffstat (limited to 'scripts/GUI')
| -rw-r--r-- | scripts/GUI/Details.cs | 48 | ||||
| -rw-r--r-- | scripts/GUI/Details.cs.uid | 1 |
2 files changed, 49 insertions, 0 deletions
diff --git a/scripts/GUI/Details.cs b/scripts/GUI/Details.cs new file mode 100644 index 0000000..0e342aa --- /dev/null +++ b/scripts/GUI/Details.cs @@ -0,0 +1,48 @@ +using Godot; +using System; + +public partial class Details : CanvasLayer +{ + private static readonly LabelSettings lblSettings = GD.Load<LabelSettings>("res://assets/definitions/message_label_settings.tres"); + private Map map; + private VBoxContainer entityNames; + private Godot.Collections.Array<Actor> actors = []; + + private Godot.Collections.Array<Label> actorsLabel = []; + + public override void _Ready() + { + base._Ready(); + map = GetParent<Map>(); + entityNames = GetNode<VBoxContainer>("HBoxContainer/PanelContainer/ScrollContainer/Entities"); + + SignalBus.Instance.InspectorMoved += OnInspectorWalk; + SignalBus.Instance.EnterInspectionMode += () => Visible = true; + SignalBus.Instance.ExitInspectionMode += () => Visible = false; + } + + public void OnInspectorWalk(Vector2I pos) { + MapData mapData = map.Map_Data; + actors = mapData.GetActorsAtPosition(pos); + UpdateLabels(); + } + + private void UpdateLabels() { + foreach(Label label in actorsLabel) { + label.QueueFree(); + } + actorsLabel.Clear(); + + foreach (Actor actor in actors) { + Label label = new() + { + Text = actor.ActorName, + LabelSettings = lblSettings + }; + + actorsLabel.Add(label); + entityNames.AddChild(label); + } + } +} +
\ No newline at end of file diff --git a/scripts/GUI/Details.cs.uid b/scripts/GUI/Details.cs.uid new file mode 100644 index 0000000..52fcd9c --- /dev/null +++ b/scripts/GUI/Details.cs.uid @@ -0,0 +1 @@ +uid://c5f8urot55re6 |
