Prepicked plants editor
This commit is contained in:
parent
9eba7d3069
commit
56f75a5d06
43 changed files with 532 additions and 50 deletions
|
|
@ -0,0 +1,51 @@
|
|||
using Godot;
|
||||
using Newlon.Resources;
|
||||
|
||||
[Tool]
|
||||
public partial class DnDSeedpacket : TextureButton
|
||||
{
|
||||
[Signal] public delegate void SaveCallbackEventHandler();
|
||||
[Export] private TextureRect preview;
|
||||
public PlantResource HeldResource;
|
||||
|
||||
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||||
{
|
||||
if (data.VariantType == Variant.Type.Dictionary)
|
||||
{
|
||||
if ((string)data.AsGodotDictionary()["type"] == "files")
|
||||
{
|
||||
return ResourceLoader.Load(data.AsGodotDictionary()["files"].AsGodotArray<string>()[0]) is PlantResource;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void _DropData(Vector2 atPosition, Variant data)
|
||||
{
|
||||
HeldResource = ResourceLoader.Load(data.AsGodotDictionary()["files"].AsGodotArray<string>()[0]) as PlantResource;
|
||||
Update();
|
||||
}
|
||||
public override void _Pressed()
|
||||
{
|
||||
HeldResource = null;
|
||||
Update();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
RefreshTexture();
|
||||
EmitSignal(SignalName.SaveCallback);
|
||||
}
|
||||
public void RefreshTexture()
|
||||
{
|
||||
if (HeldResource != null)
|
||||
{
|
||||
preview.Texture = HeldResource.Preview;
|
||||
}
|
||||
else
|
||||
{
|
||||
preview.Texture = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue