UI/InputHint.razor

A Razor UI component that displays an input glyph image for a named action. It sets the image Texture each Tick using Sandbox.Input.GetGlyph and exposes Action and Dark properties.

Networking
@using Sandbox;
@using Sandbox.UI;

@namespace Machines.UI
@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 );
	}
}