diff options
Diffstat (limited to 'scripts/GUI/Details.cs')
| -rw-r--r-- | scripts/GUI/Details.cs | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/scripts/GUI/Details.cs b/scripts/GUI/Details.cs index 814d2ac..3c64427 100644 --- a/scripts/GUI/Details.cs +++ b/scripts/GUI/Details.cs @@ -1,48 +1,57 @@ using Godot; -using System; +using TheLegendOfGustav.Entities; +using TheLegendOfGustav.Map; +using TheLegendOfGustav.Utils; + +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; - private VBoxContainer entityNames; - private Godot.Collections.Array<Entity> entities = []; + + private Map.Map Map { get; set; } + private VBoxContainer EntityNames { get; set; } + private Godot.Collections.Array<Entity> Entities { get; set; } = []; - private Godot.Collections.Array<Label> actorsLabel = []; + private Godot.Collections.Array<Label> ActorsLabel { get; set; } = []; public override void _Ready() { base._Ready(); - map = GetParent<Map>(); - entityNames = GetNode<VBoxContainer>("HBoxContainer/PanelContainer/ScrollContainer/Entities"); + Map = GetParent<Map.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; - entities = mapData.GetEntitiesAtPosition(pos); + public void OnInspectorWalk(Vector2I pos) + { + MapData mapData = Map.MapData; + Entities = mapData.GetEntitiesAtPosition(pos); UpdateLabels(); } - private void UpdateLabels() { - foreach(Label label in actorsLabel) { + private void UpdateLabels() + { + foreach (Label label in ActorsLabel) + { label.QueueFree(); } - actorsLabel.Clear(); - foreach (Entity entity in entities) { + ActorsLabel.Clear(); + + foreach (Entity entity in Entities) + { Label label = new() { Text = entity.DisplayName, LabelSettings = lblSettings }; - actorsLabel.Add(label); - entityNames.AddChild(label); + ActorsLabel.Add(label); + EntityNames.AddChild(label); } } } -
\ No newline at end of file |
