All files / app-play/src/ui/options capture.ts

0% Statements 0/13
100% Branches 0/0
0% Functions 0/6
0% Lines 0/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46                                                                                           
import { paneOptions, selectBinding } from '../../pane-controls.ts';
import { onPlayerLangChange, playerLang } from '../../player-copy.ts';
import { optionLabel } from './labels.ts';
// The Options dialog's Capture folder. It is built with the dialog as `this` (`OptionsDialog`).
import { RECORD_LABEL } from '../../recording-controller.ts';
import { recordingFormatOptions, recordingQualityOptions } from '../../recording-format-choice.ts';
import { storeRecordingFormat } from '../../services/settings.ts';
import type { OptionsDialog } from './index.ts';
/** Capture: recording the play screen as a video in the chosen format, and screenshots. */
export function buildCaptureFolder(this: OptionsDialog): void {
  this.recordController = this.place('record')
    .addButton({ title: RECORD_LABEL })
    .on('click', () => this.guiState['record']());
  // The container and codec of the video: MP4 · H.264 unless the player picks another, remembered across visits.
  const format = selectBinding(
    this.place('recordingFormat'),
    this.guiState,
    'recordingFormat',
    'Video format',
    recordingFormatOptions(),
  ).on('change', ({ value: key }) => storeRecordingFormat(key));
  // The bitrates: Low to Very high, scaled by the canvas size. Standard unless the player picks another.
  const quality = selectBinding(
    this.place('recordingQuality'),
    this.guiState,
    'recordingQuality',
    'Video quality',
    recordingQualityOptions(),
  );
  // The dialog relabels its controls, not a select's choices: these follow the player's language here.
  const relabelQualities = () => {
    quality.options = paneOptions(recordingQualityOptions()).map((choice) => ({
      ...choice,
      text: optionLabel(choice.text, playerLang()),
    }));
  };
  relabelQualities();
  onPlayerLangChange(relabelQualities);
  this.recordingSettingControllers = [format, quality];
  // Screenshot button — captures the Pixi stage at its native size (= the renderer's current screen dimensions;
  // matches what the user sees in the canvas, downloaded as PNG). See `captureScreenshot` for the extract pipeline.
  this.place('screenshot')
    .addButton({ title: '📸 Screenshot' })
    .on('click', () => this.guiState['screenshot']());
}