Editor slight refactor
This commit is contained in:
parent
285b90f503
commit
8cfbad01cf
23 changed files with 9 additions and 8 deletions
|
|
@ -1,48 +0,0 @@
|
|||
using Godot;
|
||||
using Newlon.Resources;
|
||||
|
||||
|
||||
[Tool]
|
||||
public partial class ZE_GridItem : Control
|
||||
{
|
||||
private ZombieResource resource;
|
||||
public int index;
|
||||
[Signal] public delegate void ResourceChangedEventHandler(ZombieResource resource, int index);
|
||||
public void SetData(ZombieResource data)
|
||||
{
|
||||
resource = data;
|
||||
UpdateContent();
|
||||
}
|
||||
private void UpdateContent()
|
||||
{
|
||||
if (resource == null)
|
||||
{
|
||||
GetNode<TextureRect>("Texture").Texture = null;
|
||||
return;
|
||||
}
|
||||
GetNode<TextureRect>("Texture").Texture = resource.Preview;
|
||||
}
|
||||
|
||||
public override Variant _GetDragData(Vector2 atPosition)
|
||||
{
|
||||
return resource;
|
||||
}
|
||||
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||||
{
|
||||
return data.AsGodotObject() is ZombieResource;
|
||||
}
|
||||
public override void _DropData(Vector2 atPosition, Variant data)
|
||||
{
|
||||
SetData((ZombieResource)data.AsGodotObject());
|
||||
EmitSignal(SignalName.ResourceChanged, resource, index);
|
||||
}
|
||||
public override void _GuiInput(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventMouseButton buttonEvent && buttonEvent.ButtonIndex == MouseButton.Right )
|
||||
{
|
||||
SetData(null);
|
||||
EmitSignal(SignalName.ResourceChanged, resource, index);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue