Loading/LoadingHud.razor

A loading screen HUD panel for the 'bingle' game. Draws a title, current step or area name, a progress bar fed by Loading.Progress, and a tip line, rebuilt only when text, percent or tip changes.

@using System;
@using Sandbox;
@using Sandbox.UI;
@namespace BingleUi
@inherits PanelComponent

<root>
	<div class="title">bingle</div>
	<div class="step">@Text</div>
	<div class="bar"><div class="fill" style="width: @(Percent)%"></div></div>
	<div class="tip">@Tip</div>
</root>

@code
{
	string Tip => global::Loading.Tip;
	string Text => global::Loading.AreaShowing && global::Loading.Ready ? global::Loading.AreaTitle : global::Loading.Step;
	int Percent => global::Loading.Ready ? 100 : (int)(Math.Clamp( global::Loading.Progress, 0f, 1f ) * 100f);

	protected override int BuildHash() => HashCode.Combine( Text, Percent, Tip );
}