A Razor UI component that displays a progress dial with text in the center. It visualizes a fill percentage using a conic gradient and changes color based on an alert state.
@namespace CitySim.Punchboard
@using Sandbox.UI
@inherits Panel
<root class="pb-dial @(Alert ? "alert" : "")" style="background-image: conic-gradient( @Ring 0%, @Ring @(Percent)%, #bc9567 @(Percent)%, #bc9567 100% );">
<div class="pb-dial-face"><span class="pb-dial-text">@(GameText.Plain(Text))</span></div>
</root>
@code
{
/// <summary>0 to 1, how much of the ring is filled.</summary>
[Parameter] public float Fill { get; set; } = 1f;
/// <summary>The number or short text in the middle, such as seconds left.</summary>
[Parameter] public string Text { get; set; }
/// <summary>Turns the ring red, for the last seconds.</summary>
[Parameter] public bool Alert { get; set; }
string Ring => Alert ? "#b94f3e" : "#d5a83d";
string Percent => Pb.F( Math.Clamp( Fill, 0f, 1f ) * 100f );
protected override int BuildHash() => HashCode.Combine(GameText.LanguageCode, HashCode.Combine( (int)(Fill * 100f), Text, Alert ));
}