forgot to commit for a while

This commit is contained in:
2024-04-21 15:43:32 -05:00
parent 885bc5ad6e
commit 3ac7bf33c4
18 changed files with 1607 additions and 38 deletions

38
row.cs
View File

@@ -6,6 +6,7 @@ using System.Linq;
public partial class row : Control
{
private Settings Settings => GetNode<Settings>("/root/Settings");
[Export]
private Color _RowColor;
public Color RowColor
@@ -77,22 +78,6 @@ public partial class row : Control
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
if (false)
{
RowColor = new Color
{
R = 1,
G = 0,
B = 0,
A = 1,
};
var scene = GD.Load<PackedScene>("res://card.tscn");
var card = scene.Instantiate<card>();
//GD.Print(card);
card.CardId = "new id";
card.CardName = "new name";
AddCard(card);
}
//needs to wait until ready first
PropogateColor();
PropogateCardSize();
@@ -135,14 +120,29 @@ public partial class row : Control
throw new Exception($"Can't find card {c.CardId}");
}
}
public void AddCard(card card)
public void AddCard(card card, int? toIndex = null)
{
GetNode("%RowCardContainer").AddChild(card);
var n = GetNode("%RowCardContainer");
n.AddChild(card);
if (toIndex is int i)
{
n.MoveChild(card, i);
}
}
public card GetCard(string id)
{
//inefficient to iterate through all children
return GetNode("%RowCardContainer").GetChildren().OfType<card>().FirstOrDefault(c => c.CardId == id);
return GetNode("%RowCardContainer").GetChildren()
.OfType<card>().FirstOrDefault(c => c.CardId == id);
}
public List<card> ClaimAllCards()
{
var cs = this.GetAllDescendents<card>().ToList();
foreach (var c in cs)
{
RemoveChild(c);
}
return cs;
}
public card TryRemoveCard(string id)
{