UI panel for the main menu written as a Razor component. It displays a background image and three centered buttons for Play, Options and Exit, plays a blip sound when opening dialogs, and handles Escape key clearing.
@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=@(() => {
AddComponent<play_dialog>(); Sound.Play(Blip); Destroy();
})> Play </div>
<div class="button" style="top: 60%;"
onclick=@(() => {
Game.Overlay.ShowSettingsModal();
Sound.Play(Blip);})>
Options </div>
<div class="button" style="top: 70%;"
onclick=@(() => Game.Close())> Exit </div>
</root>
@code {
SoundEvent Blip;
protected override void OnStart()
{Blip = ResourceLibrary.Get<SoundEvent>("prereqs/sound/effects/blip/blip.sound");}
protected override void OnUpdate() {
if (Input.EscapePressed)
Input.EscapePressed = false;
}
}