All files / player-ui/src/components play-settings.ts

15.38% Statements 2/13
0% Branches 0/60
0% Functions 0/3
18.18% Lines 2/11

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 87 88 89 90 91 92 93 94 95 96                  48x                               48x                                                                                                                                            
import { css, html, nothing, type CSSResultGroup, type TemplateResult } from 'lit';
import { DataElement } from '../base.ts';
import type { BeMusicSettingsData } from '../models.ts';
import { structureStyles } from '../styles/structure.ts';
import { stats } from '../templates.ts';
 
/** What follows the judge timing for each automatic adjustment. */
const JUDGE_TIMING_AUTO_ADJUST_LABELS: Readonly<
  Record<BeMusicSettingsData['options']['judgeTimingAutoAdjust'], string>
> = {
  OFF: '',
  BEATORAJA: ' · AUTO (beatoraja)',
  'LR2-ON': ' · AUTO (LR2)',
  'LR2-SILENT': ' · AUTO (LR2 SILENT)',
};
 
/** A gauge pick as the Options dialog names it: `lr2:HARD` as `HARD (LR2)`, a bare gauge as it is. */
function gaugeLabel(pick: string): string {
  const colon = pick.indexOf(':');
  if (colon < 0) return pick;
  const source = pick.slice(0, colon);
  return `${pick.slice(colon + 1)} (${source === 'lr2' ? 'LR2' : source === '____' ? '????' : source})`;
}
 
export class BeMusicPlaySettingsElement extends DataElement<BeMusicSettingsData> {
  static override styles: CSSResultGroup = [
    structureStyles,
    css`
      :host {
        display: grid;
        gap: var(--be-music-gap, 8px);
      }
    `,
  ];
  protected override render(): TemplateResult | typeof nothing {
    const d = this.data;
    if (!d) return nothing;
    const { view, options: o, runtime: r } = d;
    return html`<section class="panel" part="panel">
        <h3>Speed &amp; lanes</h3>
        ${stats([
          [
            'Speed mode',
            view.hiSpeed.floating
              ? 'FLOATING (AC 32 measured)'
              : view.hiSpeed.classic
                ? 'CLASSIC'
                : view.hiSpeed.normalLevel !== undefined
                  ? 'NORMAL'
                  : '—',
          ],
          ['Fixed display area', view.fixedDisplayArea ? 'ON' : 'OFF'],
          ['Hi-speed', view.hiSpeed.player.toFixed(2)],
          ['Drawn speed', view.hiSpeed.drawn.toFixed(2)],
          ['HS-FIX', view.hsFix ?? o.hsFix],
          ['Green number', r.greenNumber === undefined ? '—' : Math.round(r.greenNumber)],
          ['Visible time', r.visibleMs === undefined ? '—' : `${Math.round(r.visibleMs)} ms`],
          [
            'BPM range',
            r.minBPM === undefined || r.maxBPM === undefined ? '—' : `${Math.round(r.minBPM)}–${Math.round(r.maxBPM)}`,
          ],
          ['Main BPM', r.mainBPM === undefined ? '—' : Math.round(r.mainBPM)],
        ])}${view.covers.map((c) => html`<p class="muted">${c.side} · SUD ${c.suddenOn ? Math.round(c.sudden * 100) + '%' : 'OFF'} · HID ${c.hiddenOn ? Math.round(c.hidden * 100) + '%' : 'OFF'} · LIFT ${Math.round(c.lift * 100)}%</p>`)}
      </section>
      <section class="panel" part="panel">
        <h3>Play settings</h3>
        ${stats([
          ['Ruleset', r.rulesetLabel === '____' ? '????' : (r.rulesetLabel ?? '—')],
          ['Random 1P / 2P', `${o.random1P} / ${o.random2P}`],
          ['Effective gauge', r.gaugeLabel ?? '—'],
          ['Gauge auto-shift', o.gaugeAutoShift.replaceAll('_', ' ')],
          [
            'Lowest shift gauge',
            o.gaugeAutoShift === 'BEST_CLEAR' || o.gaugeAutoShift === 'SELECT_TO_UNDER'
              ? r.rulesetLabel === 'lr2'
                ? // LR2 has no ASSIST EASY: its lowest shift gauge is EASY.
                  o.bottomShiftableGauge === 'ASSIST-EASY'
                  ? 'EASY'
                  : o.bottomShiftableGauge
                : o.bottomShiftableGauge === 'GROOVE'
                  ? 'NORMAL'
                  : o.bottomShiftableGauge
              : '—',
          ],
          ['Gauge 1P / 2P', `${gaugeLabel(o.gauge1P)} / ${gaugeLabel(o.gauge2P)}`],
          ['Long notes', o.longNoteModifier === 'LEGACY' ? 'LEGACY NOTE' : o.longNoteModifier.replaceAll('_', ' ')],
          ['LN add rate', o.longNoteModifier.startsWith('ADD_') ? `${Math.round(o.longNoteRate * 1000) / 10}%` : '—'],
          ['Auto scratch', `1P ${o.autoScratch1P ? 'ON' : 'OFF'} / 2P ${o.autoScratch2P ? 'ON' : 'OFF'}`],
          ['Judge timing', `${o.judgeTimingMs} ms${JUDGE_TIMING_AUTO_ADJUST_LABELS[o.judgeTimingAutoAdjust] ?? ''}`],
          ['DP flip', o.dpFlip ? 'ON' : 'OFF'],
          ['BGA', o.bga],
        ])}
      </section>`;
  }
}