using Godot; using Newlon; using Newlon.Components.GUI.Seedpackets; using Newlon.Components.Plants; public partial class Previewport : SubViewport { private RuntimePlantData current_display; private Texture2D start_Field; [Export] private Label title; [Export] private RichTextLabel description; public override void _Ready() { GetParent().GetViewport().GuiFocusChanged += OnFocusChanged; start_Field = GetNode("FrameField").Texture; } public void OnFocusChanged(Control node) { if (node is Seedpacket packet) { ChangeDisplay(packet.GetPlantResource()); } } private void ChangeDisplay(PlantResource resource) { // Expand with updates if (current_display != null) { current_display.QueueFree(); } if (resource.customFrame != null && resource.customFrame.almanachField != null) { GetNode("FrameField").Texture = resource.customFrame.almanachField; } else GetNode("FrameField").Texture = start_Field; current_display = resource.Scene.Instantiate(); title.Text = resource.display_name; description.Text = resource.display_description; AddChild(current_display); current_display.DisableBrain(); } }