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