Initial data
This commit is contained in:
parent
c18c7f4db7
commit
f65cb11474
12 changed files with 340 additions and 48 deletions
|
|
@ -1,15 +1,46 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
[Tool]
|
||||
public partial class UNI_GridItem : PanelContainer
|
||||
{
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
private string path;
|
||||
public int index;
|
||||
[Signal] public delegate void ResourceChangedEventHandler(string path, int index);
|
||||
public void SetData(string data)
|
||||
{
|
||||
path = data;
|
||||
UpdateContent();
|
||||
}
|
||||
private void UpdateContent()
|
||||
{
|
||||
if (path == null || path == "")
|
||||
{
|
||||
GetNode<TextureRect>("Texture").Texture = null;
|
||||
return;
|
||||
}
|
||||
GetNode<TextureRect>("Texture").Call("set_path", path);
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
public override Variant _GetDragData(Vector2 atPosition)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||||
{
|
||||
return data.AsGodotDictionary<string, string>().ContainsKey("files") && ResourceLoader.Exists(data.AsGodotDictionary<string, Variant>()["files"].AsStringArray()[0]);
|
||||
}
|
||||
public override void _DropData(Vector2 atPosition, Variant data)
|
||||
{
|
||||
SetData(data.AsGodotDictionary<string, Variant>()["files"].AsStringArray()[0]);
|
||||
EmitSignal(SignalName.ResourceChanged, path, index);
|
||||
|
||||
}
|
||||
public override void _GuiInput(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventMouseButton buttonEvent && buttonEvent.ButtonIndex == MouseButton.Right )
|
||||
{
|
||||
SetData(null);
|
||||
EmitSignal(SignalName.ResourceChanged, path, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue