using Godot;

namespace ReactorMaintenance.Godot.Controls;

public partial class StateBadge : Label
{
    public override void _Ready()
    {
        HorizontalAlignment = HorizontalAlignment.Center;
        VerticalAlignment = VerticalAlignment.Center;
        CustomMinimumSize = new(96, 28);
    }

    public void SetState(string state)
    {
        Text = state;
        AddThemeColorOverride("font_color", GetColor(state));
    }

    private static Color GetColor(string state)
    {
        return state.ToLowerInvariant() switch {
            "stable" => new(0.72f, 0.86f, 0.76f),
            "caution" => new(1.0f, 0.76f, 0.24f),
            "critical" or "lost" => new(1.0f, 0.36f, 0.32f),
            "ready" or "won" => new(0.45f, 1.0f, 0.58f),
            _ => Colors.White
        };
    }
}