BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
On this page

What goes into a Flash menu

The main menu, the server browser, the options and the end-of-round screens are Flash movies. The original plays them with SwiffPlayer.dll, a build of the open-source gameswf player; the movies draw their own art and call the game through native objects under _global.dice. bf2-rs plays the same files with Ruffle plus a patch set that makes it behave like that gameswf build.

BF22142Heroes

The files#

A menu is a SWF 7 movie with ActionScript 2 bytecode, under Menu/External/FlashMenu/. Its art is partly inside the movie (vector shapes, embedded bitmaps) and partly loaded at run time from images next to it (loadMovie of a .png, .dds or .tga, resolved through the file system like any other file). 2142 and Heroes ship their movies as .dfm: the SWF bytes XOR the key 0B AD F0 0D repeating (SwiffPlayer.dll@2142!0x101019f4), decrypted on load (bf2_ui::swf::decode_dfm).

The movies never use fscommand or getURL. Everything the game provides, from the server list to the player's name, comes from native methods that SwiffPlayer registers, for example dice.bf2.Logic.active, dice.bf2.Locale.getString, dice.bf2.Cursor.setCursor; Heroes adds its own under dice.bfh. The retail table of those natives (object paths, methods, handler addresses) is re/data/flash_api.tsv, what each one does re/data/flash_natives.tsv.

How our player draws them#

PartWhat it doesbf2-rs
the nativesthe game side of every dice.* method: argument rules, the settings, the lists the menus page throughcrates/bf2-ui (host.rs, natives*.rs, lists*), Heroes' in crates/bfh-ui
the playerRuffle with the gameswf patch set: number printing, depth counters, edit text, the frame and event order of gameswfcrates/bf2-ui/player (Bf2Host), Ruffle in third_party/ruffle-bf2
the screenthe movie is stretched to the window (ISwiff::setScale(screen_w / movie_w, screen_h / movie_h), BF2.exe!0x004a2fb0); the client draws Ruffle's wgpu output over the 3D viewthe client app's menu.rs, Ruffle's wgpu renderer
engine textmenu labels drawn with the game's bitmap fonts instead of Flash fonts, as SwiffRender doesbf2-ui swiff_text.rs, bf2-font
One frame of the Heroes main menu, rendered offscreen by our player after 90 frames with the model natives and nothing connected; right: every native call the movie made in those frames. Generated by crates/bf2-ui/player/examples/menu_frame.rs.
One frame of the Heroes main menu, rendered offscreen by our player after 90 frames with the model natives and nothing connected; right: every native call the movie made in those frames. Generated by crates/bf2-ui/player/examples/menu_frame.rs.

The frame is the movie on its own: the logo, the header and the footer bars are its art, the empty panels are what the lobby fills once a session exists (the login, the hero list, the store). The same player renders the scripted menu walkthroughs of the test suite (examples/walkthrough.rs, one image hash per frame) and the menus in the browser build. The in-game HUD is not Flash in any of the three games: it is built from the game's BFMeme .con layout (crates/bf2-hud) and drawn as quads in the last stage of the render pipeline.

Per game#

BF22142Heroes 1.126
movies.swf in Menu_client.zip.dfm in the Menu_*.zip archives (mainMenu.dfm), encryptedtwo .dfm: mainMenu_west.dfm (1.7 MB) and endOfRound_west.dfm in Menu_server.zip
artinside the movies plus imagesthe sameMenu_client.zip holds 6,562 images (DDS, PNG, TGA, JPG): items, abilities, store art
nativesnatives.rs, natives2*, natives3, natives4natives2142.rs (BFHQ, unlocks, the diagram)crates/bfh-ui (store, missions, friends, server browser, hero preview)
playerSwiffPlayer.dllSwiffPlayer.dll@2142SwiffPlayer.dll@bfh126, loaded by MainMenuLogic::activate (BFHeroes.exe!0x004c9219, bf2-client frontend.rs)

How it is tested#

  • The menu's data against the original (crates/bf2-ui/tests): the end-of-round data, the award and kit catalogues, and number-to-text conversions, each against the original's own function or C runtime (the Flash layer).
  • Every shipped font file is read (crates/bf2-font/tests/retail.rs).
  • The movies themselves are the game's files, played by a third-party player with the project's patches; no test compares its drawing with the original player's.

Where it is read and drawn#

Stepbf2-rs
decrypt, patch in memorybf2-ui swf.rs (decode_dfm, inject_init_action)
nativesbf2-ui natives*.rs, bfh-ui
play and drawcrates/bf2-ui/player (Ruffle), the client app's menu layer
the picturecrates/bf2-ui/player/examples/menu_frame.rs

The full analysis (the ISwiff interface, gameswf behaviour, every native, the Ruffle patches) is notes/subsystems/menu-flash.md.

Source: docs/dev/assets/flash.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.