2026-04-10 14:58:03 +02:00
|
|
|
using Godot;
|
|
|
|
|
using Chessistics.Engine.Model;
|
2026-04-10 23:21:38 +02:00
|
|
|
using Chessistics.Scripts.Pieces;
|
2026-04-10 14:58:03 +02:00
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
2026-04-10 23:21:38 +02:00
|
|
|
var style = new StyleBoxFlat
|
|
|
|
|
{
|
|
|
|
|
BgColor = new Color(0.14f, 0.14f, 0.16f, 0.95f),
|
|
|
|
|
BorderColor = new Color("#444448"),
|
|
|
|
|
BorderWidthTop = 1,
|
|
|
|
|
CornerRadiusTopLeft = 4, CornerRadiusTopRight = 4,
|
|
|
|
|
ContentMarginLeft = 12, ContentMarginRight = 12,
|
|
|
|
|
ContentMarginTop = 8, ContentMarginBottom = 8
|
|
|
|
|
};
|
|
|
|
|
AddThemeStyleboxOverride("panel", style);
|
|
|
|
|
|
2026-04-10 14:58:03 +02:00
|
|
|
var vbox = new VBoxContainer();
|
2026-04-10 23:21:38 +02:00
|
|
|
vbox.AddThemeConstantOverride("separation", 4);
|
2026-04-10 14:58:03 +02:00
|
|
|
|
|
|
|
|
var title = new Label { Text = "DETAIL" };
|
2026-04-10 23:21:38 +02:00
|
|
|
title.AddThemeFontSizeOverride("font_size", 13);
|
|
|
|
|
title.AddThemeColorOverride("font_color", new Color("#B8942A"));
|
2026-04-10 14:58:03 +02:00
|
|
|
vbox.AddChild(title);
|
|
|
|
|
|
|
|
|
|
_infoLabel = new Label { Text = "" };
|
|
|
|
|
_infoLabel.AddThemeFontSizeOverride("font_size", 11);
|
2026-04-10 23:21:38 +02:00
|
|
|
_infoLabel.AddThemeColorOverride("font_color", new Color("#CCCCCC"));
|
2026-04-10 14:58:03 +02:00
|
|
|
vbox.AddChild(_infoLabel);
|
|
|
|
|
|
2026-04-10 23:21:38 +02:00
|
|
|
_removeButton = new Button { Text = "Retirer", CustomMinimumSize = new Vector2(80, 26) };
|
|
|
|
|
_removeButton.AddThemeFontSizeOverride("font_size", 11);
|
|
|
|
|
var btnStyle = new StyleBoxFlat
|
|
|
|
|
{
|
|
|
|
|
BgColor = new Color("#5A2A2A"),
|
|
|
|
|
CornerRadiusTopLeft = 4, CornerRadiusTopRight = 4,
|
|
|
|
|
CornerRadiusBottomLeft = 4, CornerRadiusBottomRight = 4,
|
|
|
|
|
ContentMarginLeft = 8, ContentMarginRight = 8,
|
|
|
|
|
ContentMarginTop = 2, ContentMarginBottom = 2
|
|
|
|
|
};
|
|
|
|
|
_removeButton.AddThemeStyleboxOverride("normal", btnStyle);
|
2026-04-10 14:58:03 +02:00
|
|
|
_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
|
|
|
|
|
{
|
2026-04-10 23:21:38 +02:00
|
|
|
PieceKind.Pawn => "Pion",
|
2026-04-10 14:58:03 +02:00
|
|
|
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;
|
|
|
|
|
}
|