68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
|
|
using Godot;
|
||
|
|
using Chessistics.Engine.Model;
|
||
|
|
|
||
|
|
namespace Chessistics.Scripts.UI;
|
||
|
|
|
||
|
|
public partial class MetricsOverlay : PanelContainer
|
||
|
|
{
|
||
|
|
[Signal]
|
||
|
|
public delegate void NextLevelPressedEventHandler();
|
||
|
|
[Signal]
|
||
|
|
public delegate void RetryPressedEventHandler();
|
||
|
|
|
||
|
|
private Label _metricsLabel = null!;
|
||
|
|
|
||
|
|
public override void _Ready()
|
||
|
|
{
|
||
|
|
var vbox = new VBoxContainer();
|
||
|
|
vbox.SetAnchorsPreset(LayoutPreset.Center);
|
||
|
|
|
||
|
|
var title = new Label
|
||
|
|
{
|
||
|
|
Text = "VICTOIRE !",
|
||
|
|
HorizontalAlignment = HorizontalAlignment.Center
|
||
|
|
};
|
||
|
|
title.AddThemeFontSizeOverride("font_size", 24);
|
||
|
|
title.AddThemeColorOverride("font_color", new Color("#FFD700"));
|
||
|
|
vbox.AddChild(title);
|
||
|
|
|
||
|
|
vbox.AddChild(new HSeparator());
|
||
|
|
|
||
|
|
_metricsLabel = new Label
|
||
|
|
{
|
||
|
|
Text = "",
|
||
|
|
HorizontalAlignment = HorizontalAlignment.Center
|
||
|
|
};
|
||
|
|
_metricsLabel.AddThemeFontSizeOverride("font_size", 14);
|
||
|
|
vbox.AddChild(_metricsLabel);
|
||
|
|
|
||
|
|
vbox.AddChild(new HSeparator());
|
||
|
|
|
||
|
|
var buttons = new HBoxContainer();
|
||
|
|
buttons.Alignment = BoxContainer.AlignmentMode.Center;
|
||
|
|
|
||
|
|
var retryBtn = new Button { Text = "Rejouer" };
|
||
|
|
retryBtn.Pressed += () => EmitSignal(SignalName.RetryPressed);
|
||
|
|
buttons.AddChild(retryBtn);
|
||
|
|
|
||
|
|
var nextBtn = new Button { Text = "Niveau suivant" };
|
||
|
|
nextBtn.Pressed += () => EmitSignal(SignalName.NextLevelPressed);
|
||
|
|
buttons.AddChild(nextBtn);
|
||
|
|
|
||
|
|
vbox.AddChild(buttons);
|
||
|
|
AddChild(vbox);
|
||
|
|
|
||
|
|
Visible = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void ShowMetrics(Metrics metrics)
|
||
|
|
{
|
||
|
|
_metricsLabel.Text = $"Pieces utilisees: {metrics.PiecesUsed}\n" +
|
||
|
|
$"Coups: {metrics.TurnsTaken}\n" +
|
||
|
|
$"Cases occupees: {metrics.CellsOccupied}";
|
||
|
|
Visible = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public new void Hide() => Visible = false;
|
||
|
|
}
|