Main menu Razor UI component for the game's navigation host. It renders the main menu root with navigator canvas, a lobby status overlay and a map rating modal, and manages a static Instance reference and DefaultUrl selection based on networking state.
@using Sandbox;
@using Sandbox.UI;
@using Sandbox.UI.Navigation;
@namespace Machines.UI
@inherits NavigationHost
<root class="main-menu main-bg">
<div class="navigator-canvas" slot="navigator-canvas"></div>
<LobbyStatusOverlay />
<MapRatingModal />
</root>
@code
{
/// <summary>
/// Live navigator instance; lets systems check the current page via <see cref="Sandbox.UI.Navigation.NavigationHost.CurrentUrl"/>.
/// </summary>
public static MainMenuPanel Instance { get; private set; }
public MainMenuPanel()
{
Instance = this;
DefaultUrl = "/";
}
protected override void OnParametersSet()
{
// If already in a session (e.g. invite), open on /play; otherwise /home.
if ( CurrentUrl == null )
DefaultUrl = Sandbox.Networking.IsActive ? "/play" : "/";
base.OnParametersSet();
}
public override void OnDeleted()
{
base.OnDeleted();
if ( Instance == this )
Instance = null;
}
}