Creating A Game Menu
What is a game menu?
Not all games are created equal, so it's hard for us to create a menu screen that is suitable for all types of games. But that's cool because we let you create your own 100% custom menu.
Your game menu is responsible for setting the mood of your game and presenting options to help your players get started.
The simplest menu would just contain a "start game" option. From there you can scale into creating and finding servers, lobbies, statistics, character customization, settings, update news etc.
Defining Your Menu
When your game is opened in the menu, we look in your game for a Panel
or RootPanel
that implements the Sandbox.Menu.IGameMenuPanel
interface. If we find it, then we create it and that's your main menu.
So to create a main menu panel in plain c#, you'd do something like this.
or to define one in Razor you'd do
From there you can add stylesheets and panels as you would normally define any UI.
Resources
You probably don't want to make people download your whole game to view the menu, so we let you create a wildcard list of files that you want people to download before opening it. Here you'd define things like stylesheets, images and sounds. If you're doing something more exotic you can define specific maps, models and materials too.
Any resources needed for custom a Loading Screen will also be added here, and both downloaded before your Game Menu is loaded
Doing Stuff
Most interactions you're going to do with the game menu are available via the Game.Menu
global.
To start a game on an empty map, use the <empty>
map ident.
Reference
The default "scaffolding" main menu is available in the base addon. If you're wondering how to do something, it might be a good idea to look in there for how we've already done it.