UI/InputHint.razor

A UI component (Razor) used in the Breakout project that displays an input glyph image for a named action and can render in a dark style. Each Tick it updates the image texture by asking the Sandbox input system for a glyph for the configured action. It overrides BuildHash to force rebuilds using the current time.

Networking
@using Sandbox;
@using Sandbox.UI;

@namespace Breakout
@inherits Panel

<image @ref="GlyphImage" class="glyph @(Dark ? "dark" : "")" />

@code
{
	public string Action { get; set; }
	public bool Dark { get; set; }
	public Sandbox.UI.Image GlyphImage { get; set; }

	public override void Tick()
	{
		base.Tick();

		if ( GlyphImage.IsValid() && !string.IsNullOrEmpty( Action ) )
		{
			GlyphImage.Texture = Input.GetGlyph( Action, InputGlyphSize.Medium, GlyphStyle.Knockout );
		}
	}

	protected override int BuildHash()
	{
		return System.HashCode.Combine( Time.Now );
	}
}