All files / player-browser/src/skins/synesthesia layout.ts

96.66% Statements 29/30
85.71% Branches 18/21
100% Functions 4/4
100% Lines 27/27

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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86                      27x     27x                 20x 16x 4x   4x 4x                     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x       27x                     11x 1x 1x 1x                         4x 4x    
import {
  STAGE_BGA_BAND,
  STAGE_SIDE_COLUMN,
  resolveCabinetLayout,
  type BeMusicGameplayLayout,
  type BeMusicRect,
} from '@be-music/player-skin-sdk';
 
/** Synesthesia's own HUD geometry on the 16:9 stage, and on the 9:16 portrait stage. */
 
/** The legacy landscape gauge slot (its cells are inset vertically). */
export const GROOVE = { x: 44, y: 387, w: 200, h: 14 } as const;
 
/** Side margin of the portrait HUD, and the gutter between its BGA monitor and HUD column. */
export const PORTRAIT_MARGIN = 12;
 
/**
 * The actual gauge cells for `layout`: the cabinet geometry in standard landscape play, the inset legacy cells in
 * touch play, and the full-width strip between the monitor and lanes in portrait play.
 */
export function resolveGrooveRect(
  layout: Pick<BeMusicGameplayLayout, 'orientation' | 'mode' | 'twoPlayer' | 'stage' | 'playfield'>,
): BeMusicRect {
  if (layout.orientation !== 'portrait') {
    if (layout.mode === 'standard') return resolveCabinetLayout(layout).gauge;
    return { ...GROOVE, y: GROOVE.y + 2, h: GROOVE.h - 4 };
  }
  const x = PORTRAIT_MARGIN + 4;
  return { x, y: layout.playfield.top - 18, w: layout.stage.width - 2 * x, h: 10 };
}
 
/**
 * The portrait HUD column right of the BGA monitor (`bga`, or a monitor-sized stand-in when the layout has none), from
 * the monitor's top to its bottom, split into the track and score panels, with the judgement tally at the foot of the same column.
 */
export function resolvePortraitHUDColumn(
  stage: { width: number },
  bga: BeMusicRect | undefined,
): { plate: BeMusicRect; score: BeMusicRect; tally: BeMusicRect } {
  const monitor = bga && bga.w > 0 ? bga : { x: PORTRAIT_MARGIN, y: 46, w: 206, h: 206 };
  const x = monitor.x + monitor.w + PORTRAIT_MARGIN;
  const w = stage.width - PORTRAIT_MARGIN - x;
  const top = monitor.y;
  const bottom = monitor.y + monitor.h;
  const gap = 8;
  const plateH = 58;
  const tallyH = 64;
  const plate = { x, y: top, w, h: plateH };
  const tally = { x, y: bottom - tallyH, w, h: tallyH };
  const scoreY = top + plateH + gap;
  const score = { x, y: scoreY, w, h: tally.y - gap - scoreY };
  return { plate, score, tally };
}
 
/** Height of the judgement tally panel in the landscape side column (it starts 6 px above the BGA band). */
export const TALLY_HEIGHT = 186;
 
/**
 * Where a combo milestone plays when the layout has no BGA monitor to play it on (the landscape touch layout, a
 * page-wide keyboard field): the side column under the judgement tally, down to the bottom HUD band — clear of the
 * lanes and of the gauge / score panels. `undefined` when there is a monitor, on a portrait stage (which always has
 * one), or when the playfield reaches into the side column.
 */
export function resolveMilestoneSpot(
  layout: Pick<BeMusicGameplayLayout, 'orientation' | 'bga' | 'playfield'>,
): { x: number; y: number; w: number } | undefined {
  if (layout.orientation === 'portrait' || (layout.bga && layout.bga.w > 0)) return undefined;
  Iif (layout.playfield.right > STAGE_SIDE_COLUMN.x) return undefined;
  const top = STAGE_BGA_BAND.top - 6 + TALLY_HEIGHT;
  return {
    x: STAGE_SIDE_COLUMN.x + STAGE_SIDE_COLUMN.w / 2,
    y: Math.round((top + STAGE_BGA_BAND.bottom) / 2) - 10,
    w: STAGE_SIDE_COLUMN.w,
  };
}
 
/** Human-readable ancestry, with the search scope retained rather than replacing the current location. */
export function formatSelectBreadcrumb(
  folderPath: readonly string[] | undefined,
  folderLabel: string | undefined,
  searchQuery: string,
): string {
  const path = folderPath ?? (folderLabel ? [folderLabel] : []);
  return ['Library', ...path, ...(searchQuery ? [`Search: ${searchQuery}`] : [])].join(' › ');
}