Disordered editor start
This commit is contained in:
parent
24be556e38
commit
f9a3a5427c
18 changed files with 223 additions and 17 deletions
37
addons/pvzadventure/scripts/DnDCard.cs
Normal file
37
addons/pvzadventure/scripts/DnDCard.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
[Tool]
|
||||
public partial class DnDCard : PanelContainer
|
||||
{
|
||||
private Variant tempData;
|
||||
private PackedScene packedScene;
|
||||
private Node instantiated;
|
||||
|
||||
[Signal] public delegate void DnDDroppedEventHandler(PackedScene scene);
|
||||
|
||||
public override void _Notification(int what)
|
||||
{
|
||||
if (what == NotificationDragBegin)
|
||||
{
|
||||
tempData = GetViewport().GuiGetDragData();
|
||||
}
|
||||
else if (what == NotificationDragEnd && GetGlobalRect().HasPoint(GetGlobalMousePosition()))
|
||||
{
|
||||
var loaded = ResourceLoader.Load(tempData.AsGodotDictionary()["files"].AsStringArray()[0]);
|
||||
if (loaded is PackedScene scene)
|
||||
{
|
||||
packedScene = scene;
|
||||
EmitSignal(SignalName.DnDDropped, packedScene);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Refresh()
|
||||
{
|
||||
if (instantiated != null) instantiated.QueueFree();
|
||||
instantiated = packedScene.Instantiate();
|
||||
GetNode("SubViewport").AddChild(instantiated);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue