functional card/row edit and drag

This commit is contained in:
2024-04-23 23:31:42 -05:00
parent 8e01e9cb9b
commit 56dcbb62af
29 changed files with 674 additions and 48 deletions

19
row.cs
View File

@@ -98,7 +98,7 @@ public partial class row : Control
{
}
public void DropOn(Vector2 atPosition, Variant data)
public void DropCardOn(Vector2 atPosition, Variant data)
{
GD.Print($"Dropping at {atPosition}");
card c = data.As<card>()
@@ -128,6 +128,23 @@ public partial class row : Control
{
throw new Exception($"Can't find card {c.CardId}");
}
}
public override bool _CanDropData(Vector2 atPosition, Variant data)
{
return data.As<row>() is not null;
}
public override void _DropData(Vector2 atPosition, Variant data)
{
var r = data.As<row>()
?? throw new Exception("Invalid drop row");
if (ReferenceEquals(this, r))
return;
var toIndex = GetIndex();
if (atPosition.Y > Size.Y / 2)
toIndex++;
if (r.GetIndex() < GetIndex())
toIndex--;
GetParent().MoveChild(r, toIndex);
}
public void AddCard(card card, int? toIndex = null)
{