HUD Menus#

Before working on HUD, it’s recommended to extract the englishclient_frontend.bsp.pak000_dir.vpk vpk. This file contains all vanilla menus and UI logic and will be a very helpful reference!

Registering a menu#

In your mod.json, add a Before UI callback like this:

{
    "Path": "ui/profiles_menu.nut",
    "RunOn": "UI",
    "UICallback": {
        "Before": "InitProfilesMenu",
    }
}

In the script you referenced, create a global in which you register your menu with the AddMenu like this:

global function InitProfilesMenu

void function InitProfilesMenu()
{
    AddMenu( "MenuName", $"path/to/menu.menu"  )
}

If you want to, you can add a init to AddMenu like this: AddMenu( "MenuName", $"path/to/menu.menu", func )

The returns void and takes no parameters. It gets called once the menu is initialized.

It’s recommended to create a file struct in which you store menu states:

struct {
    var menu
} file

void function MenuInitCallback()
{
    file.menu = GetMenu( "MenuName" )
}

Registering a Submenu#

Footers#

To use footers, add this element to your menu:

FooterButtons
{
        ControlName                     CNestedPanel
        InheritProperties       FooterButtons
}
void AddMenuFooterOption( var menu, int input, string gamepadLabel, string mouseLabel = "", void functionref( var ) activateFunc = null, bool functionref() conditionCheckFunc = null, void functionref( InputDef ) updateFunc = null )

Adds a footer to a menu.

void AddPanelFooterOption( var panel, int input, string gamepadLabel, string mouseLabel = "", void functionref( var ) activateFunc = null, bool functionref() conditionCheckFunc = null, void functionref( InputDef ) updateFunc = null )

Adds a footer to a panel

void UpdateFooterOptions()#

Update the footers of the active menu.

void SetFooterText(var menu, int index, string text)#

Change the text of a specific footer.