All files / app-play/src/ui replay-missing.ts

0% Statements 0/14
0% Branches 0/8
0% Functions 0/3
0% Lines 0/10

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                                               
import { html, render } from 'lit';
 
// The dialog a dropped replay opens when the charts it was played on are not loaded: a replay's chart, or the stage
// charts of a course replay (LR2 and beatoraja refuse a course replay with a stage chart missing too). It lists them,
// and the replay does not start.
 
/** Lists the charts a replay needs that are not loaded, under `hint` (what to do about them). */
export function showMissingReplayCharts(hint: string, charts: readonly string[]): void {
  const dialog = document.querySelector<HTMLDialogElement>('#replay-missing');
  if (dialog === null) return;
  const hintElement = dialog.querySelector<HTMLElement>('[data-replay-missing-hint]');
  if (hintElement !== null) render(hint, hintElement);
  const list = dialog.querySelector<HTMLElement>('[data-replay-missing-list]');
  if (list !== null)
    render(
      charts.map((chart) => html`<li>${chart}</li>`),
      list,
    );
 
  // The dialog owns keyboard navigation; its keys must not reach the player's shortcuts.
  dialog.onkeydown = (event) => event.stopPropagation();
  if (!dialog.open) dialog.showModal();
}