private void BuildMenu(CCSPlayerController controller) { // Create a Menu object which holds all data var mainMenu = new MenuBase(new MenuValue("Main Menu") { Prefix = "<font class=\"fontSize-L\">", Suffix = "<font class=\"fontSize-sm\">" });
// Can add custom formatting, MenuValue[2] Cursor, MenuValue[2] Selector, MenuValue[2] Bool, MenuValue[4] Slider, MenuValue[1] Input var cursor = new MenuValue[2] { // MenuValue is the fundamental building block of everything in the Menu - MenuValue.Value, MenuValue.Prefix, MenuValue.Suffix new("--> ") { Prefix = "<font color=\"#FFFFFF\">", Suffix = "<font color=\"#FFFFFF\">" }, new(" <--") { Prefix = "<font color=\"#FFFFFF\">", Suffix = "<font color=\"#FFFFFF\">" } }; mainMenu.Cursor = cursor;
// Let's add a simple text field to the menu, each (row) is a MenuItem which holds data for that (row) // Again MenuValue is the fundamental building block of everything in the Menu - MenuValue.Value, MenuValue.Prefix, MenuValue.Suffix
var textItem = new MenuValue("Welcome to the new menu!");
// Let's modify the prefix and suffix of the textItem
textItem = new MenuValue("Welcome to the new menu!") { Prefix = "<font color=\"#FF0000\">", Suffix = "<font color=\"#FFFFFF\">" };
var simpleTextItem = new MenuItem(MenuItemType.Text, textItem);
// Now let's add the textItem to the menu mainMenu.AddItem(simpleTextItem);
// And let's add to the global stack to print to the player Menu.SetMenu(controller, mainMenu, (buttons, menu, item) => { });
// If you want to create a sub-menu use the following, this nests the menu ontop of the current menu if there's any, otherwise it follows the same logic as SetMenu Menu.AddMenu(controller, mainMenu, (buttons, menu, item) => { });
// The library automatically handles the deposition of the menu // Using Tab (Scoreboard) exists the menu, and Ctrl (Duck) will go back to the previous menu }