Recording terminal captures

To show a bug or a fix in a PR, record the curses build with asciinema. Then turn the recording into a GIF with just term-capture. PR #11041 has a before and an after capture.

Requirements

  • the curses build: cmake --preset linux-curses and cmake --build --preset linux-curses --target cataclysm-bn (see CMake)
  • asciinema to record
  • agg to render the recording
  • uv to run just term-capture

Record

  1. Make the terminal small, for example 120 columns and 40 rows. The file is smaller with a small terminal.

  2. Make a directory outside the repository for the saves, the settings and the recordings:

    mkdir -p ~/bn-capture
    
  3. From the repository root, start the game in asciinema:

    asciinema rec -c "out/build/linux-curses/src/cataclysm-bn --userdir $HOME/bn-capture/ --configdir $HOME/bn-capture/config/" ~/bn-capture/before.cast
    

    With --userdir and --configdir, the game uses new saves and settings and does not change your own.

  4. Use the debug menu to set up the scene, then do the steps that show the bug.

  5. Quit the game from its menu.

  6. Record ~/bn-capture/after.cast the same way with the fixed build.

Make the GIF

Run the just term-capture commands from the repository root.

just term-capture render ~/bn-capture/before.cast ~/bn-capture/before.gif

The GIF plays at 2x speed. Pauses longer than 1 s become 0.5 s.

Drag the GIF into the PR description or a comment. The GIF must be 10 MB or smaller.

Add captions

To cut the game start and show a caption for each step:

  1. Save each frame of the GIF as a PNG file:

    just term-capture frames ~/bn-capture/before.gif ~/bn-capture/before-frames/
    
  2. Open the PNG files in an image viewer. Find the first frame of each step and the last frame to keep. The frame number is the PNG file name.

  3. Write the steps to ~/bn-capture/scenes.json. color is optional and can be red or green.

    [
      { "start": 40, "caption": "enable UPS charging" },
      { "start": 67, "caption": "next turn: invalid ammo error", "color": "red" }
    ]
    
  4. Make the captioned GIF. Give the number of the last frame to keep with --last:

    just term-capture encode ~/bn-capture/before.gif ~/bn-capture/before-captioned.gif --scenes ~/bn-capture/scenes.json --last 80
    

    The GIF starts at the first step and ends at the --last frame. The last frame of each step stays on screen for 2 s, and the last frame of the GIF stays for 6 s.