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

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Godot;
using Godot.NativeInterop;
public static class ExtensionHelper
{
@@ -65,10 +66,11 @@ public static class ExtensionHelper
i++;
}
}
public static string GetUnusedCardId(this SceneTree tree)
public static string GetUnusedCardId(this SceneTree tree, params string[] otherIds)
{
//use hashset because there are (probably) more cards than rows
var ids = tree.GetNodesInGroup("CardGroup").OfType<card>().Select(c => c.CardId).ToHashSet();
var ids = tree.GetNodesInGroup("CardGroup").OfType<card>().Select(c => c.CardId)
.Concat(otherIds).ToHashSet();
int i = 1;
while (true)
{
@@ -91,4 +93,17 @@ public static class ExtensionHelper
=> new(Math.Max(vect.X, other.X), Math.Max(vect.Y, other.Y));
public static Vector2I Union(this Vector2I vect, Vector2 other)
=> new((int)Math.Max(vect.X, other.X), (int)Math.Max(vect.Y, other.Y));
public static System.Drawing.Color ToSystemColor(this Godot.Color color)
=> System.Drawing.Color.FromArgb(
(int)(color.R * 255),
(int)(color.G * 255),
(int)(color.B * 255)
);
public static Godot.Color ToGodotColor(this System.Drawing.Color color)
=> new Godot.Color(
color.R / 255.0f,
color.G / 255.0f,
color.B / 255.0f,
1
);
}