The tab menu (fl_tab_menu): the full screen menu that opens in place of the scoreboard, with a bar of buttons at the top and one content panel open at a time. The gamemode creates it through the theme's 'tab_menu' panel when the scoreboard key is pressed. Plugins add their entries in the AddTabMenuItems hook by calling add_menu_item with the class of the panel to open. When an entry is clicked the menu creates that panel, sizes it with the panel's get_menu_size, calls its rebuild and runs the OnMenuPanelOpen hook. The panel that was open when the menu closed is opened again the next time. open_panel switches to another entry and close_menu closes the menu, which runs the OnTabMenuClosed hook. set_faded fades the menu out of the way, so that the world behind it can be seen while something is dragged out of it. Code that wants the menu opened or closed goes through Flux.TabMenu.

Summary

Methods

Registers an item in the tab menu: a button that can open a panel.
Closes the menu: fades the active panel out, remembers it for the next time the menu opens, calls its on_close method, slides the button bar away before removing the menu and runs the OnTabMenuClosed hook.
Init()client
Builds the full screen tab menu: slides the button bar in, collects the menu items through the AddTabMenuItems hook, creates a button for each of them and opens the panel that was open last time, or the default one.
Checks whether the menu has been faded out with set_faded.
Closes the menu when the TAB key is pressed.
Shows the panel of a menu item, as if its button had been clicked.
Delegates drawing of the menu to the active theme's PaintTabMenu hook.
Fades the whole menu out, its blur and tint included, so that the world behind it can be seen, or fades it back in.
Think()client
Deactivates the active button once its panel is gone.

Methods

PANEL:add_menu_item(id, data, _index)

client packages/active_ui/views/cl_tabmenu.lua:234

Registers an item in the tab menu: a button that can open a panel. Meant to be called from the AddTabMenuItems hook; buttons are ordered by ascending priority. The opened panel may define get_menu_size, rebuild, on_change and on_close, which the menu calls when appropriate.

function Inventories:AddTabMenuItems(menu)
  menu:add_menu_item('inventory', {
    title = 'Inventory',
    panel = 'fl_inventory_menu',
    icon = 'fa-briefcase',
    default = true,
    priority = 30,
    callback = function(menu_panel, button)
      local inv = menu_panel.active_panel
      inv:SetTitle('Inventory')
    end
  })
end

Parameters

  • id String unique ID of the item
  • data Map item options. priority (Number) is required. Optional: title (String), icon (String FontAwesome ID), panel (String VGUI class to open on click), default (Boolean the item with the lowest priority that sets it opens when none was open before), callback (Function(menu_panel, button) called after the click was handled), override (Function(menu_panel, button) called instead of opening a panel)
  • _index Number optional, defaults to nil unused

Closes the menu: fades the active panel out, remembers it for the next time the menu opens, calls its on_close method, slides the button bar away before removing the menu and runs the OnTabMenuClosed hook. Does nothing if the menu is closing already.

Builds the full screen tab menu: slides the button bar in, collects the menu items through the AddTabMenuItems hook, creates a button for each of them and opens the panel that was open last time, or the default one.

Checks whether the menu has been faded out with set_faded.

Returns

  • Boolean

PANEL:OnKeyCodePressed(key)

client packages/active_ui/views/cl_tabmenu.lua:194

Closes the menu when the TAB key is pressed.

Parameters

  • key Number key code, one of the KEY_ enums

PANEL:open_panel(id)

client packages/active_ui/views/cl_tabmenu.lua:175

Shows the panel of a menu item, as if its button had been clicked.

Parameters

  • id String ID the item was added under with add_menu_item

Returns

  • Boolean false if the menu has no such item

Delegates drawing of the menu to the active theme's PaintTabMenu hook.

Parameters

  • w Number panel width
  • h Number panel height

PANEL:set_faded(faded)

client packages/active_ui/views/cl_tabmenu.lua:248

Fades the whole menu out, its blur and tint included, so that the world behind it can be seen, or fades it back in. The menu keeps taking the mouse while it is faded: panels fade it while something is dragged out of them onto the world, and the drop still reaches the receivers of the menu. Does nothing while the menu is closing.

Parameters

  • faded Boolean true to fade the menu out, false to bring it back

Deactivates the active button once its panel is gone.

Defined in