Previewport
This commit is contained in:
parent
ad8ecb875a
commit
d256973d2d
3 changed files with 43 additions and 5 deletions
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=12 format=3 uid="uid://dpxxjfd5lv5sv"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://dpxxjfd5lv5sv"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://e8n88g31w7x7" path="res://resources/themes/ChooseYourSeeds.tres" id="1_bfo8i"]
|
||||
[ext_resource type="Texture2D" uid="uid://dr8a0rx42o3qy" path="res://assets/sprites/gui/ChooseYourSeeds/PlantFrame.tres" id="2_so2bw"]
|
||||
[ext_resource type="Script" uid="uid://covbig00p22di" path="res://scripts/components/gui/choose_your_seeds/Previewport.cs" id="3_fmc0y"]
|
||||
[ext_resource type="Texture2D" uid="uid://dycdvvgmgmfu6" path="res://assets/sprites/gui/ChooseYourSeeds/FrameField.tres" id="3_rn5vx"]
|
||||
[ext_resource type="Script" uid="uid://eq3ecja30mlj" path="res://scripts/components/gui/choose_your_seeds/GridLoader.cs" id="4_i7sou"]
|
||||
[ext_resource type="PackedScene" uid="uid://10b1egek6upx" path="res://scenes/gui/level_run_button.tscn" id="5_n80ic"]
|
||||
|
|
@ -97,7 +98,7 @@ _data = {
|
|||
}
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_rmoaa"]
|
||||
viewport_path = NodePath("Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/SubViewport")
|
||||
viewport_path = NodePath("Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/Previewport")
|
||||
|
||||
[node name="ChooseYourSeeds" type="Control"]
|
||||
process_mode = 3
|
||||
|
|
@ -150,14 +151,15 @@ layout_mode = 2
|
|||
layout_mode = 2
|
||||
texture = ExtResource("2_so2bw")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame"]
|
||||
[node name="Previewport" type="SubViewport" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame"]
|
||||
canvas_item_default_texture_filter = 0
|
||||
size = Vector2i(65, 65)
|
||||
script = ExtResource("3_fmc0y")
|
||||
|
||||
[node name="FrameField" type="Sprite2D" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/SubViewport"]
|
||||
[node name="FrameField" type="Sprite2D" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/Previewport"]
|
||||
texture = ExtResource("3_rn5vx")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/SubViewport"]
|
||||
[node name="Camera2D" type="Camera2D" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame/Previewport"]
|
||||
|
||||
[node name="Render" type="TextureRect" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/Frame"]
|
||||
show_behind_parent = true
|
||||
|
|
|
|||
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