ui/mainmenu/play_dialog.razor

A UI Razor component for the main menu play dialog. It renders three centered buttons (Join Server, Create Server, Back), plays a blip sound when navigating, and calls Networking.JoinBestLobby with a hardcoded lobby id when joining. It also loads a SoundEvent and a SceneFile resource on start and resets EscapePressed in OnUpdate.

NetworkingEmbedded Secret
@inherits PanelComponent
@using Sandbox.ui.mainmenu

<root>

<style>

.button {
position: absolute; top: 50%; left: 50%;
transform: translate(-50%, -50%);
background: #000; color: #fff;
font-family: courier; font-size: 32px;
pointer-events: all; outline: 1px solid white;
}

</style>

<img src="prereqs/textures/gqner2/gqner2.vtex"
style="position: absolute; top: 25%; left: 50%;
transform: translate(-50%, -50%);"> />

<div
class="button"
onclick=@(() => Networking.JoinBestLobby("dvlpmnt.gqner2"))>
Join Server
</div>

<div
class="button"
onclick=@(() => {
AddComponent<create_server_dialog>();
Sound.Play(Blip);
Destroy();
})
style="top: 60%;">
Create Server
</div>

<div
class="button"
onclick=@(() => {
AddComponent<mainmenu>();
Sound.Play(Blip);
Destroy();
})
style="top: 70%;">
Back
</div>

</root>

@code {
SoundEvent Blip;
SceneFile gqner2;

protected override void OnStart() {
Blip = ResourceLibrary.Get<SoundEvent>("prereqs/sound/effects/blip/blip.sound");
gqner2 = ResourceLibrary.Get<SceneFile>("scenes/gqner2.scene");}

protected override void OnUpdate() {
if (Input.EscapePressed)
Input.EscapePressed = false;
}
}