mirror of
https://codeberg.org/Ikatono/TierMaker.git
synced 2025-10-28 20:45:35 -05:00
forgot to push for a while, got drag-and-drop mostly working
This commit is contained in:
32
UnassignedCardPanel.cs
Normal file
32
UnassignedCardPanel.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class UnassignedCardPanel : PanelContainer
|
||||
{
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||||
{
|
||||
return data.As<card>() is not null;
|
||||
}
|
||||
public override void _DropData(Vector2 atPosition, Variant data)
|
||||
{
|
||||
card c = data.As<card>()
|
||||
?? throw new Exception("invalid drag data");
|
||||
var g = this.GetParentOfType<game>()
|
||||
?? throw new Exception("game instance not found");
|
||||
if (g.ClaimCard(c.CardId) is card _c)
|
||||
{
|
||||
if (!ReferenceEquals(c, _c))
|
||||
throw new Exception($"card move mismatch");
|
||||
GetNode<HFlowContainer>("%UnassignedCardContainer").AddChild(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user