TF2’s user interface is built on VGUI2 (Valve GUI 2), a retained-mode panel system declared inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sr2echa/TF2-Source-Code/llms.txt
Use this file to discover all available pages before exploring further.
public/vgui/ and implemented in vgui2/. All HUD elements — health, ammo, objectives, charge meters — and menus are VGUI2 panels. The game-specific HUD lives in game/client/tf/ and game/client/hud_*.cpp.
VGUI2 panel system
Every UI element inherits fromvgui::Panel (or a subclass). Panels form a tree; each panel owns its children and is responsible for layout and painting.
| Class | File | Usage |
|---|---|---|
EditablePanel | vgui_controls/EditablePanel.h | Container panels loaded from .res files |
Frame | vgui_controls/Frame.h | Movable dialog windows |
ImagePanel | vgui_controls/ImagePanel.h | Texture display |
Label | vgui_controls/Label.h | Text display |
Button | vgui_controls/Button.h | Clickable buttons |
RichText | vgui_controls/RichText.h | Multi-line formatted text |
HUD element system
TF2 HUD elements inherit fromCHudElement (game/client/hudelement.h). They register with GetHud() via the DECLARE_HUDELEMENT macro and receive ShouldDraw(), Init(), Reset(), and Paint() callbacks each frame.
TF2-specific HUD components
Health and ammo display
Health and ammo display
CTFHudPlayerHealth and CTFHudAmmoWeapons (in game/client/tf/) read from the local player’s networked health and ammo variables and draw the corresponding numeric and icon panels.Charge meters
Charge meters
Medi Gun ÜberCharge, Bonk energy, and similar meters use
CTFHudItemEffectMeter — a generic charge bar that reads an item attribute or condition value from CTFPlayerShared.Control point HUD
Control point HUD
CHudControlPointIcons (game/client/hud_controlpointicons.cpp) reads from CTFObjectiveResource (replicated from server) to display capping progress, team ownership icons, and lock states.Kill feed and damage numbers
Kill feed and damage numbers
CHudDeathNotice displays the kill feed. Floating damage numbers are drawn by CTFHudDamageAccount using world-to-screen projection of the damage position.MvM wave HUD
MvM wave HUD
CTFHudMannVsMachineStatus displays wave progress, robot counts, and the money collected tracker. It reads from CTFObjectiveResource network variables populated by the MvM game logic.Schemes and fonts
VGUI2 schemes (.res files in resource/) define fonts, colors, and border styles. Game code retrieves scheme values via IScheme:
.res layout files
Panel layout is driven by KeyValues.res files loaded at runtime, so UI can be resized and repositioned without recompilation. EditablePanel::LoadControlSettings() parses the file and applies xpos, ypos, wide, tall, and labelText keys to child controls.