using Godot; using Chessistics.Engine.Model; namespace Chessistics.Scripts.UI; public partial class DetailPanel : PanelContainer { [Signal] public delegate void RemoveRequestedEventHandler(int pieceId); private Label _infoLabel = null!; private Button _removeButton = null!; private int _currentPieceId; public override void _Ready() { var vbox = new VBoxContainer(); var title = new Label { Text = "DETAIL" }; title.AddThemeFontSizeOverride("font_size", 14); vbox.AddChild(title); _infoLabel = new Label { Text = "" }; _infoLabel.AddThemeFontSizeOverride("font_size", 11); vbox.AddChild(_infoLabel); _removeButton = new Button { Text = "Retirer" }; _removeButton.Pressed += () => EmitSignal(SignalName.RemoveRequested, _currentPieceId); vbox.AddChild(_removeButton); AddChild(vbox); Visible = false; } public void ShowPiece(PieceSnapshot piece) { _currentPieceId = piece.Id; var kindName = piece.Kind switch { PieceKind.Rook => "Tour II", PieceKind.Bishop => "Fou II", PieceKind.Knight => "Cavalier", _ => piece.Kind.ToString() }; var cargoText = piece.Cargo != null ? piece.Cargo.Value.ToString() : "aucun"; _infoLabel.Text = $"{kindName} (ID: {piece.Id})\n" + $"Trajet: {piece.StartCell} ↔ {piece.EndCell}\n" + $"Statut social: {piece.SocialStatus}\n" + $"Porte: {cargoText}"; Visible = true; } public new void Hide() => Visible = false; }