Previewport
This commit is contained in:
parent
ad8ecb875a
commit
d256973d2d
3 changed files with 43 additions and 5 deletions
35
scripts/components/gui/choose_your_seeds/Previewport.cs
Normal file
35
scripts/components/gui/choose_your_seeds/Previewport.cs
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://covbig00p22di
|
||||
Loading…
Add table
Add a link
Reference in a new issue