On this page
Battlefield 2142's HUD: what it shares and what is its own
2142's HUD is Battlefield 2's machine with new parts. The node tree, the builder's script commands and the variable layer are the same; the functions that write the variables were rewritten where the game changed: the weapon panel, the crosshair, the Titans, the item bar. Battlefield Heroes was built from 2142, so several of 2142's writers run in Heroes too.
What is the same#
Everything on Battlefield 2's HUD page about how the HUD is built holds: BF2HudManager::init (BF2142.exe!0x0075cfa0) makes the menu system, the builder and the sub-managers, loads the node file and runs the HUD scripts; the variables are registered by name in the same layer; the map node draws the minimap, the spawn screen's map and the commander's map; two chat managers fill the chat and kill lists.
What is 2142's own#
| Part | 2142 | Ours |
|---|---|---|
| the weapon panel | updatePrimaryWeapon (0x007c1f10): the rounds as %i, empty with endless ammunition, not written while a reload runs; the ammunition bar; the reload bar shown strictly between 0 and 1; a heat bar | hud_writers.rs primary_weapon_2142, primary_ammo_2142 |
| the fire rate icon | its own show flag and picture path (0x007be640) | primary_weapon_2142 |
| the crosshair | its parts placed by updateCrosshairPositions (0x007be770) | crosshair_positions |
| a vehicle's armor | the bar is the ratio; the number is a percent (0x007a18a0) | hud_vehicle.rs vehicle_armor_2142 |
| the capture interface | 2142's form of the two capture bars and the lock line | hud_live.rs CpInterface2142 |
| the watched player's name | the spectator HUD (0x00752050) | spectator_hud.rs |
| the map's icons | 2142's object icons (0x00793b60) and icon colours for its own screens | crates/bf2-hud render/map.rs |
The Titans#
In Titan mode the top of the screen shows the two Titans instead of plain tickets: each Titan's strategic objects with their state, and the row of missile silos. The writers are strategic_objects_2142, object_destroyed_2142, cannon_row_2142 and titan_mode_2142 in hud_live.rs; the mode's number for the HUD's script is game_mode_index_2142 (game modes).
What Heroes took from it#
Heroes runs 2142's arm for the ammunition (primary_ammo_2142), the capture interface (CpInterface2142) and the vehicle's armor bar, and has its own writers for what it changed: the health number in hit points, the item bar, the level arc (the Heroes HUD). Where a Heroes row of the sweep says "2142's arm, which Heroes runs", this page's function is the one meant.
What the port still lacks#
The 2142 HUD is the youngest of the three in the port. A list of its functions without a Rust counterpart is kept and worked down (notes/bf2142/hud-missing.md): from 69 addresses it went to 35 in five slices, and further since. What is left is mostly small: constructors and destructors of HUD classes, a few console methods of the commander's comm rose, parts of the bar node's marks, and front-end glue that the in-game HUD does not use. The health number's own 2142 twin was not read: a 2142 process keeps Battlefield 2's statements for it.
Each function was read in the decompilation, and in the disassembly wherever a compare, a rounding or the order of arguments mattered. A row says what the function does, its Battlefield 2 twin when it has one, and what blocks the port: usually that the class was not identified, or that nothing of ours would call it yet.
How it is tested#
- The weapon panel's writers (
crates/bf2-client/src/hud_writers.rs): 2142's rockets, the clip string per game, the crosshair when zoomed. - On the game's own HUD scripts: the Titan HUD's silo row and destroyed parts (
hud_titan_2142.rs), the commander's Titan move line on the map (map_titan_line_2142.rs), the commander's target screens, the comm rose's nine nodes. - Each in a 2142 process: the game is a process-wide setting, so every such program sets it first and tests nothing else.
All seven addresses of this page stand in a test's text. What the page lists under "still lacks" has none.
In the code#
| What | Where |
|---|---|
| the shared HUD | crates/bf2-hud |
| 2142's writers | crates/bf2-client/src/ (hud_writers.rs, hud_live.rs, hud_vehicle.rs, spectator_hud.rs) |
| what is missing | notes/bf2142/hud-missing.md |
Notes: notes/subsystems/hud.md, notes/bf2142/hud-missing.md, notes/bf2142/titan.md.
docs/dev/ui/hud-2142.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.