ui/mainmenu/create_server_dialog.razor

A UI panel Razor component for the create-server dialog. It displays a background image and three centered buttons to Start Server, Select Map, and Back, loads a scene and a sound resource on start, and plays the sound or changes scene when buttons are clicked.

File Access
@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" style="top: 50%;"
onclick=@(() => {
var options = new SceneLoadOptions();
options.DeleteEverything = true;
options.IsAdditive = false;
options.ShowLoadingScreen = true;
options.SetScene(gqner2);
Game.ChangeScene(options);
})>
Start Server
</div>

<div class="button" style="top: 60%;"
onclick=@(() => {
Sound.Play(Blip);
Game.Overlay.ShowMapSelector((ident) => _game.CurrentlySelectedMap = ident);
})>
Select Map
</div>

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

</root>

@code {
SceneFile gqner2;
SoundEvent Blip;

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

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