The info display: a row of round icons in the top left corner of the HUD that each show a percentage, such as health and armor. An icon is registered with InfoDisplay:add under an ID, with a Font Awesome icon, a size and a callback that updates its percentage before every draw. The icon sits on a dark disc, is drawn dimmed and then filled with its color from the bottom up to that percentage. It is hidden while the percentage is outside of the range between min_percentage and max_percentage, so that the health icon, for example, only appears once the player is hurt. Flux registers the 'health' and 'armor' icons itself and draws all of the icons with InfoDisplay:draw_all from its HUD paint hook while the local player is alive.

Summary

Methods

Adds an icon to the HUD info display.
all()client
Returns all of the registered info display icons.
Draws a single info display icon after running its callback.
Draws all of the registered info display icons next to each other.
Removes an icon from the info display.
Sets the gap between the info display icons and the edges of the screen.

Methods

InfoDisplay:add(id, data)

client packages/active_ui/lib/cl_info_display.lua:44

Adds an icon to the HUD info display. The icon is filled from the bottom according to its percentage, and is hidden while the percentage is outside of the (min_percentage, max_percentage) range.

InfoDisplay:add('armor', {
  icon = 'fa-shield-alt',
  min_percentage = 2,
  max_percentage = 101,
  size = 80,
  callback = function(data)
    data.percentage = (PLAYER:Armor() / 100) * 100
  end
})

Parameters

  • id String unique ID, converted with string.to_id
  • data Map settings: icon, size, color (of the filled part, the 'text' color of the theme by default), dim_color (of the empty part, the 'text_dim' color of the theme by default), back_color (of the disc behind the icon, the 'hud_backdrop' color of the theme by default), percentage, min_percentage, max_percentage, offset_x, offset_y, and callback, which is called with this hash before every draw; missing keys get defaults

Returns

  • InfoDisplay self, for chaining

Returns all of the registered info display icons.

Returns

  • Map icon data by ID

InfoDisplay:draw(info)

client packages/active_ui/lib/cl_info_display.lua:87

Draws a single info display icon after running its callback. Can be prevented with the 'PreDrawInfoDisplayItem' hook.

Parameters

  • info Map icon data, as stored by InfoDisplay#add

Returns

  • Number width the icon takes up along with its margin, 0 if nothing was drawn

InfoDisplay:draw_all()

client packages/active_ui/lib/cl_info_display.lua:142

Draws all of the registered info display icons next to each other. Can be prevented with the 'PreDrawInfoDisplay' hook.

Returns

  • InfoDisplay self, for chaining

InfoDisplay:remove(id)

client packages/active_ui/lib/cl_info_display.lua:70

Removes an icon from the info display.

Parameters

  • id String ID of the icon, exactly as it is stored

Returns

  • InfoDisplay self, for chaining

InfoDisplay:set_margin(val)

client packages/active_ui/lib/cl_info_display.lua:78

Sets the gap between the info display icons and the edges of the screen.

Parameters

  • val Number margin in pixels

Returns

  • InfoDisplay self, for chaining

Defined in