using Godot; using Chessistics.Engine.Model; namespace Chessistics.Scripts.Board; public partial class CellView : Node2D { private ColorRect _background = null!; private ColorRect _highlight = null!; private Label _label = null!; public Coords Coords { get; private set; } private static readonly Color LightColor = new("#F0D9B5"); private static readonly Color DarkColor = new("#B58863"); private static readonly Color WallColor = new("#555555"); private static readonly Color ProductionColor = new("#6B8E5A"); private static readonly Color DemandColor = new("#C9A833"); private static readonly Color HighlightColor = new("#44FF4444"); public void Setup(Coords coords, CellType cellType, int cellSize) { Coords = coords; Position = new Vector2(coords.Col * cellSize, -coords.Row * cellSize); _background = new ColorRect { Size = new Vector2(cellSize, cellSize), Position = Vector2.Zero }; var baseColor = coords.IsLight ? LightColor : DarkColor; _background.Color = cellType switch { CellType.Wall => WallColor, CellType.Production => ProductionColor, CellType.Demand => DemandColor, _ => baseColor }; AddChild(_background); _highlight = new ColorRect { Size = new Vector2(cellSize, cellSize), Position = Vector2.Zero, Color = HighlightColor, Visible = false }; AddChild(_highlight); _label = new Label { Position = new Vector2(2, 2), Text = "", }; _label.AddThemeFontSizeOverride("font_size", 10); AddChild(_label); } public void SetLabel(string text) => _label.Text = text; public void SetHighlight(bool on) => _highlight.Visible = on; public void SetHighlightColor(Color color) { _highlight.Color = color; _highlight.Visible = true; } }