開發工具¶
tools/dev/中的開發執行器與檢查工具,以及tools/docs/中的文件輔助工具。它們如何搭配,請見開發執行器。以下API說明為英文。
amfp_dev
¶
AMFP-2026 dev cycle driver: stage the build into _stage, launch straight into a map (no logos, profile screen or main menu), and drive the game through the dev bridge (Game/src/game/LuxDevBridge.cpp) instead of mouse clicks.
pixi run dev -- --map 00_rainy_hall.map --wait-active --shot out.png
pixi run dev -- --tour tools/dev/tours/menus.tour # scripted run -> _tour/menus/sheet.png
pixi run dev -- --no-build --script "GiveHint(\"a\", \"Hints\", \"x\", 0);" --shot out.png
Everything runs in the _stage sandbox with its own save folder; the Steam install is never written to.
Bridge
¶
Writes "
dev_main_settings
¶
dev_main_settings(text: str, language: str | None = None, width: int = 1280, height: int = 720, extra: list[str] | None = None) -> str
Sandbox main_settings.cfg: no pre-menu or menu, default profile, windowed, bridge on.
documents_dir
¶
Parent of the game's Amnesia/
stage_links
¶
A sandbox linked to the game's data (Linux ~/amfp_stage, Windows 64-bit _stage64): links to the game folders, copies of its small root files, its own Enhanced config (test profile). The game's exes and DLLs stay out, so only the build under test and its libraries run.
set_user_settings
¶
Write Section.Key=value items into the dev profile's user_settings.cfg (created from the Enhanced defaults when the profile has none yet).
start_watchdog
¶
Hard limit for a run: the game is force-closed after this many seconds, whatever it is doing.
bring_to_front
¶
macOS: a game started from a script stays behind the terminal; ask it to activate (an Apple Event to the running app, so no Accessibility permission is needed) once its window is up.
flatten_screenshot
¶
The framebuffer's alpha is 0 in most of the scene; keep RGB only so viewers show it.
player_in_control
¶
Active, allowed to move (scripted standstills set move_mul 0) and not fast-forwarding.
skip_story
¶
Skip story scenes (the in-game Esc / B skip, pressed twice) until the player has control.
tour
¶
Scripted dev tours: drive the game through the dev bridge from a small step file, waiting on game state (never on guesses), screenshot as you go, and finish with one contact sheet.
pixi run dev --tour tools/dev/tours/menus.tour # build, run, sheet in _tour/menus/
Step file, one step per line, '#' comments: pad
window= also takes names: profiles options keyconfig loadgame customstories customstory title.
doc_shots
¶
Documentation screenshots: Original vs Enhanced pairs and single shots for the guide.
pixi run docs-shots # build, run the game three times, write the WebP files
pixi run docs-shots --no-build # use the current build
pixi run docs-shots --only comfort-roll # re-take some shots (their runs still play in full)
pixi run docs-shots --convert-only # convert the last runs' PNGs again (no game)
It drives the game with the dev runner (amfp_dev.py) and the step file
tools/dev/tours/doc_shots.tour, once per run in RUNS, each with its own settings: the Original
run uses the Original preset, the Enhanced run the Modern preset. Every run starts from the
same place, so a pair differs only in the settings. The PNGs land in tour/doc_shots
<id>-original.webp, <id>-enhanced.webp a pair, shown with the before / after slider
<id>.webp a single shot
comfort-headbob.svg a chart of the camera height while walking
The guide shows a marked placeholder for every shot that has no file yet (tools/docs/macros.py), so the docs build without any of them.
The shots show the game's own art: keep them few and small (max 1280 px wide, WebP).
Run
dataclass
¶
Run(name: str, section: str, comfort: str, main: tuple[str, ...] = (), user: tuple[str, ...] = (), skip_story: bool = True, lang: str = 'english.lang', optional: str | None = None)
One game run: a tour section with its settings.
Shot
dataclass
¶
Shot(id: str, what: str, where: str, runs: tuple[str, ...] = ('enhanced',), page: str = '', chart: bool = False, clip: bool = False, caption_below: bool = False)
One figure in the guide. A pair has an Original and an Enhanced side.
tour_for
¶
The tour for one run: its #@section, its #@original / #@enhanced lines,
and {comfort} filled in.
check
¶
Problems between SHOTS and the tour: each screenshot taken in exactly its runs.
find_clip
¶
Frames and their times (s) of the last clip of a shot, or None if it was a still.
clip_to_webp
¶
An endlessly looping animated WebP that plays at the captured speed.
headbob_svg
¶
headbob_svg(original: list[list[float]], comfort: list[list[float]], reduced: list[list[float]] | None = None) -> str
A small line chart of the camera height (cm, trend removed) over time: Original, Comfort and (when traced) Reduced.
Mid-tone colours that read on the guide's light and dark themes alike (an SVG shown as an image cannot use the page's CSS).
convert
¶
Write the WebP / SVG files from the last runs' output; returns the files written.
set_user_settings
¶
The run's values in the dev profile's user_settings.cfg (amfp_dev.set_user_settings).
comfort_check
¶
Check the comfort tour's camera traces (tools/dev/tours/comfort.tour).
Each trace line: step yaw pitch roll fov aspect x y z (degrees, one line per logic step, 60/s). Prints a table per effect for Original, Reduced and Comfort and checks the Comfort limits: level horizon, forced turns under the cap, a small hit jolt, gentle zoom pulses. pixi run python tools/dev/comfort_check.py _tour/comfort
physics_check
¶
Physics parity: the same scripted pushes on two builds, compared step by step.
Each build starts the first map, skips to the point the player can move, then pushes a door,
a chair, a bottle and a lever (AddPropImpulse) while the dev bridge records the object's main
physics body every logic step (trace). Tumbling objects never follow identical paths on two
physics engines, so the comparison looks at behaviour: did it move, how far, how far did it
swing, when did it settle, and where did it come to rest.
pixi run python tools/dev/physics_check.py --baseline <32-bit exe> [--steps 300]
The baseline is the 32-bit exe with Frictional's original Newton; the other run is the 64-bit CMake build (--x64 sandbox). Traces and the report go to _tour/physics/.
fbx_oracle
¶
Check the ufbx FBX loader against the original Autodesk SDK loader's output.
The game ships .anm files that the original exe cached for most of its FBX animations. For each FBX that has one, the game (through the dev bridge) loads the animation both ways and reports the differences: missing tracks, key counts, key times, positions, rotations, length.
pixi run dev --keep --menu # start a game to talk to (any screen)
pixi run python tools/dev/fbx_oracle.py [--limit N]
Nothing from the game is copied into the repository; results go to _tour/fbx_oracle.txt.
fbx_with_cache
¶
Paths (relative to the game folder) of FBX files that have an .anm next to them.
build_api
¶
Build the C++ and Rust API reference for the documentation website.
pixi run -e docs docs-api # -> build/docs-api/cpp (Doxygen), build/docs-api/rust (rustdoc)
The MkDocs hook (tools/docs/hooks.py) copies both folders into the built site under api/;
the Reference pages link to them. Only the code AMFP Enhanced added is documented:
- C++: every header under
Game/src/gameandHPL2/corewhose first comment starts withAMFP-2026:(the files the fork added; stock engine files that only carry a marked change are left out), plus the C header of the Rust text library. - Rust: the
hpl-cjk-textcrate (no dependencies are documented). - Python: the text module's type stub, copied to build/docs-api/py for mkdocstrings.
is_fork_file
¶
True for a file the fork added: its first comment starts with AMFP-2026:.
Added files open with /* and * AMFP-2026: ... or with // AMFP-2026: .... Stock
engine files carry the marker only next to a change, so they are left out.
cpp_inputs
¶
The C++ files to document, sorted, as paths relative to the repository root.
build_py_stub
¶
The text module's type stub as a stub-only package, the form mkdocstrings (griffe) reads.
maturin wants the stub as hpl_cjk_text.pyi next to pyproject.toml; griffe finds a
compiled module's stub only as <name>/__init__.pyi. mkdocs.yml lists this folder.
doxy_filter
¶
Doxygen INPUT_FILTER for the files AMFP Enhanced added (the source files stay unchanged).
- The leading header comment becomes the file's description. The files open with a plain
block comment (
/*then* AMFP-2026: ...) or a run of// AMFP-2026: ...lines, which Doxygen would ignore; the filter turns it into a@fileblock. - Placeholders in comments such as
<game>/amfp_enhanced/binor<map>are escaped, so Doxygen does not read them as unknown HTML tags.
Doxygen runs it as python tools/docs/doxy_filter.py <file> and reads the result.
filter_text
¶
The file text with its header comment made a @file block and placeholders escaped.
check_links
¶
Check every local link and anchor in the built documentation site.
pixi run -e docs docs-check # builds first, then checks site/
python tools/docs/check_links.py site # an existing build
MkDocs' strict mode checks links between Markdown pages, but not links written as HTML (the
API reference links), nor anchors inside the generated API pages. This walks every page the
guide itself produced (everything outside api/) and checks each href and src that
points inside the site: the file must exist and, for #anchor links, the target page must
have an element with that id. External links (http, https, mailto) are not fetched.
site_base
¶
The path the site is served under, from site_url in mkdocs.yml ("/amfp-enhanced/").
resolve
¶
The file a link points to (None for external links) and its anchor.
Absolute paths count from base, the path the site is served under.
check
¶
All broken local links of the guide's pages, as readable lines.