Previewport

This commit is contained in:
Rendo 2025-06-22 23:55:44 +05:00
commit d256973d2d
3 changed files with 43 additions and 5 deletions

View file

@ -0,0 +1,35 @@
using Godot;
using Newlon;
using Newlon.Components.GUI.Seedpackets;
using Newlon.Components.Plants;
public partial class Previewport : SubViewport
{
private RuntimePlantData current_display;
public override void _Ready()
{
GetParent().GetViewport().GuiFocusChanged += OnFocusChanged;
}
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();
}
current_display = resource.Scene.Instantiate<RuntimePlantData>();
AddChild(current_display);
current_display.DisableBrain();
}
}

View file

@ -0,0 +1 @@
uid://covbig00p22di