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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | 2x | import { optionDefault } from '../../option-defaults.ts';
import { paneOptions, selectBinding } from '../../pane-controls.ts';
import { onPlayerLangChange, playerLang } from '../../player-copy.ts';
import { recordingQualityOptions } from '../../recording-format-choice.ts';
import { optionLabel } from './labels.ts';
// The Options dialog's Library & records folder. It is built with the dialog as `this` (`OptionsDialog`).
import { LocalDataPanel } from '../../local-data-panel.ts';
import { parseURLMediaParams } from '../../url-load.ts';
import { mountBemuseServerManager } from './bemuse-servers.ts';
import { mountCourseTableManager } from './course-tables.ts';
import type { ReplayAutoSaveRule } from '../../services/replay-slots.ts';
import type { OptionsDialog } from './index.ts';
/** Each replay slot auto-save rule, as beatoraja's launcher names it. */
const REPLAY_AUTO_SAVE_LABELS: Record<string, ReplayAutoSaveRule> = {
'Never (save by hand)': 'never',
'Better EX score': 'score-update',
'Better or equal EX score': 'score-update-or-equal',
'Fewer BP': 'miss-count-update',
'Fewer or equal BP': 'miss-count-update-or-equal',
'Better max combo': 'max-combo-update',
'Better or equal max combo': 'max-combo-update-or-equal',
'Better clear lamp': 'clear-update',
'Better or equal clear lamp': 'clear-update-or-equal',
'Any of them better': 'any-update',
Always: 'always',
};
/**
* Loading from URLs (the same path as the `?music=` / `?skin=` parameters) and the play-history and best-record
* stores.
*/
export function buildLibraryFolder(this: OptionsDialog): void {
// Where charts come from, one tab each (`librarySources`): folders and files on this device, Bemuse music servers,
// difficulty tables.
const folderManager = document.createElement('div');
folderManager.dataset.rememberedFolderManager = '';
this.place('localFolders').addElement(folderManager);
// The select screen's F8 / F2, for a player without a keyboard: the folders, Bemuse servers and tables read again.
this.place('reloadFolders')
.addButton({ title: 'Reload folders' })
.on('click', () => void this.library.reloadCharts());
const bemuseServers = document.createElement('div');
this.place('bemuseServers').addElement(bemuseServers);
mountBemuseServerManager(bemuseServers, {
library: this.library,
setStatus: (text) => this.setStatus(text),
saveSettings: () => this.scheduleSettingsSave(),
});
// Bemuse's own volume for each server song (its `replaygain`). Read as a play starts, so it is locked while one runs.
this.trackPlayOption(
this.place('bemuseReplayGain')
.addBinding(this.guiState, 'bemuseReplayGain', { label: 'Bemuse ReplayGain' })
.on('change', ({ value }) => {
this.guiState.bemuseReplayGain = value;
this.library.refreshBemuseReplayGain();
}),
);
// The difficulty tables whose courses are listed: remembered, and imported again on load.
const courseTables = document.createElement('div');
this.place('courseTables').addElement(courseTables);
mountCourseTableManager(courseTables, {
library: this.library,
setStatus: (text) => this.setStatus(text),
saveSettings: () => this.scheduleSettingsSave(),
});
const urlParams = parseURLMediaParams(window.location.href);
const urls = {
music: urlParams.musicURL ?? optionDefault<string>('musicURL'),
skin: urlParams.skinURL ?? optionDefault<string>('skinURL'),
load: () => {
const musicURL = urls.music.trim() || undefined;
const skinURL = urls.skin.trim() || undefined;
if (!musicURL && !skinURL) {
this.setStatus('Enter a music or skin ZIP URL first');
return;
}
void this.library.loadFromURL({ musicURL, skinURL });
},
};
this.place('musicURL').addBinding(urls, 'music', { label: 'Music ZIP URL' });
this.place('skinURL').addBinding(urls, 'skin', { label: 'Skin ZIP URL' });
this.place('loadFromURLs')
.addButton({ title: 'Load from URLs' })
.on('click', () => urls['load']());
// Play-history auto-save — OFF by default. When enabled, every finished play downloads its replay
// (`*.bmplay.json`, the raw input replay defined in `@be-music/player-engine/replay`) as soon as the result scene
// mounts. The file feeds the `bms-replay` CLI, which re-derives LR2 / beatoraja / That-Which-Must-Not-Be-Named scores from the replay.
// The value is LATCHED at song start (`lockReplayOptionsForPlay`) and the controller is disabled while a song
// is playing — replay options cannot change mid-play.
this.replaySaveController = this.place('autoSaveReplay')
.addBinding(this.guiState, 'autoSaveReplay', { label: 'Auto-download replays' })
.on('change', ({ value }) => {
this.guiState.autoSaveReplay = value;
});
// Off by default: a replay then records each input's coarse device class only. On, it also keeps each controller's
// `Gamepad.id`, which often names its vendor and product ids, in every replay it records (files, slots, Leaderboard).
// Read as a play starts, so it is locked while one runs.
this.trackPlayOption(
this.place('replayDeviceNames')
.addBinding(this.guiState, 'replayDeviceNames', { label: 'Record device names in replays' })
.on('change', ({ value }) => {
this.guiState.replayDeviceNames = value;
}),
);
// Slots select a replay from history when its result meets the rule or the player assigns it by hand.
for (const slot of [1, 2, 3, 4] as const) {
selectBinding(
this.place(`replaySlotAutoSave${slot}`),
this.guiState,
`replaySlotAutoSave${slot}`,
`Slot ${slot} auto-save`,
REPLAY_AUTO_SAVE_LABELS,
);
}
// What the player keeps in this browser, read-only; built on first use.
let localData: LocalDataPanel | undefined;
this.place('localData')
.addButton({ title: 'Local data…' })
.on('click', () => (localData ??= new LocalDataPanel()).open());
}
/** The BGA transcode settings, which apply while charts load (the Advanced folder's BGA video transcode). */
export function buildBGATranscodeFolder(this: OptionsDialog): void {
// BGA video transcode controls. Both settings are seeded into the next play scene's settings (see
// `preloadGameplay` / `playChart` for the wiring), so changing them mid-session takes effect on the next chart mount
// — no need to rebuild gameplay if the user is between songs. We don't push live into the running gameplay because
// BGA assets are loaded once at chart- prepare time and the codec / resize decisions are encoded into the cached
// video bytes.
//
// Both controls are dropdowns rather than free-form fields: the meaningful options cluster around standard video
// heights (SD / 720p / 1080p / 4K) and a discrete codec pick. `0` in the resize dropdown is the magic "Off" value —
// the consumer treats anything `≤ 0` as "preserve resolution". Earlier iterations split resize into a checkbox +
// size pair, but users would change the size without realizing they also had to flip the checkbox — the resize was
// silently a no-op. Folding both into one control with an explicit `Off` row removes that footgun.
// WebCodecs `VideoEncoder` is a browser feature; gate the checkbox on its existence so the user can't toggle a
// state the runtime can't honor. On unsupported browsers (Safari < 17, older Firefox builds) the controller is
// disabled and the seed value stays at `false`.
const webCodecsSupported = typeof window !== 'undefined' && 'VideoEncoder' in window;
const webCodecsController = this.place('bgaUseWebCodecs')
.addBinding(this.guiState, 'bgaUseWebCodecs', {
label: webCodecsSupported ? 'Use WebCodecs encoder' : 'Use WebCodecs encoder (unsupported)',
})
.on('change', ({ value }) => {
this.guiState.bgaUseWebCodecs = value;
});
if (!webCodecsSupported) {
webCodecsController.disabled = true;
}
// The bitrate the transcode spends, as the Capture tab's Video quality picks a recording's: libx264's -crf, or the
// WebCodecs encoder's bitrate. Standard is the long-standing one.
const quality = selectBinding(
this.place('bgaTranscodeQuality'),
this.guiState,
'bgaTranscodeQuality',
'Transcode quality',
recordingQualityOptions(),
).on('change', ({ value }) => {
this.guiState.bgaTranscodeQuality = value;
});
const relabelQualities = (): void => {
quality.options = paneOptions(recordingQualityOptions()).map((choice) => ({
...choice,
text: optionLabel(choice.text, playerLang()),
}));
};
relabelQualities();
onPlayerLangChange(relabelQualities);
selectBinding(this.place('bgaResizeMaxEdgePx'), this.guiState, 'bgaResizeMaxEdgePx', 'Resize', {
'Off (preserve resolution)': 0,
'256 px (BMS spec)': 256,
'360 px (≈ SD)': 360,
'480 px (SD)': 480,
'512 px': 512,
'720 px (HD)': 720,
'1080 px (FHD)': 1080,
'1440 px (QHD)': 1440,
'2160 px (4K)': 2160,
}).on('change', ({ value }) => {
this.guiState.bgaResizeMaxEdgePx = value;
});
}
|