mirror of
https://codeberg.org/Ikatono/TierMaker.git
synced 2025-10-28 20:45:35 -05:00
functional card/row edit and drag
This commit is contained in:
19
row.cs
19
row.cs
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user