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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | 189x 189x 189x 17x 17x 374x 17x 238x 136x 17x 17x 17x 133x 125x 124x 124x 124x 124x 70x 96x 35x 18x 7x 1x 32x 3x 24x 17x 6x 1x | import type { BrowseCommand, BrowseEvent } from '../browse/state.ts';
import type { LibraryEntry } from '../library/entries.ts';
/**
* The sounds a theme gives the screens, whatever skin family it is: the select screen's cues (cursor, decide, cancel,
* folders, option panels and changes), the looping select BGM and the decide jingle, the result jingles (clear,
* fail, the generic result one, and a course run's), and the sounds a result screen plays as it closes (beatoraja's
* `resultclose` and `course_close`).
*/
export type SystemSoundSlot =
| 'cursor'
| 'decide'
| 'cancel'
| 'playStop'
| 'folderOpen'
| 'folderClose'
| 'optionOpen'
| 'optionClose'
| 'optionChange'
| 'selectBGM'
| 'decideBGM'
| 'clear'
| 'fail'
| 'result'
| 'courseClear'
| 'courseFail'
| 'resultClose'
| 'courseClose'
| GuideSoundSlot;
/**
* beatoraja's GUIDE SE: one sound per judgment (`guide-pg.wav` to `guide-ms.wav`), PGREAT, GREAT, GOOD, BAD, a missed
* note (POOR) and an empty POOR (MISS).
*/
export type GuideSoundSlot = 'guidePG' | 'guideGR' | 'guideGD' | 'guideBD' | 'guidePR' | 'guideMS';
/** The guide sound slots, in beatoraja's judge order. */
export const GUIDE_SOUND_SLOTS: readonly GuideSoundSlot[] = [
'guidePG',
'guideGR',
'guideGD',
'guideBD',
'guidePR',
'guideMS',
];
/** Every system sound slot. */
export const SYSTEM_SOUND_SLOTS: readonly SystemSoundSlot[] = [
'cursor',
'decide',
'cancel',
'playStop',
'folderOpen',
'folderClose',
'optionOpen',
'optionClose',
'optionChange',
'selectBGM',
'decideBGM',
'clear',
'fail',
'result',
'courseClear',
'courseFail',
'resultClose',
'courseClose',
...GUIDE_SOUND_SLOTS,
];
/**
* One system sound, resolved: its bytes (an LR2 theme's sounds are read up front), or its path in the theme's files to
* play through the theme's audio (a beatoraja theme's cues), or both.
*/
export type SystemSound =
| { readonly bytes: Uint8Array; readonly path?: string }
| { readonly path: string; readonly bytes?: undefined };
/** A theme's system sounds, by slot; a slot the theme does not fill stays silent. */
export type SystemSoundSet = { readonly [S in SystemSoundSlot]?: SystemSound };
/**
* The slot each command of an LR2 sound set (`LR2files/Sound/*.lr2ss`) fills: `SCRATCH` is the cursor cue, `PANEL_*`
* the option panel ones, `SELECT` / `DECIDE` the select BGM and the decide jingle. LR2 has no cancel cue and no
* generic result jingle command.
*/
export const LR2_SOUND_SET_SLOTS: Readonly<Record<string, SystemSoundSlot>> = {
SELECT: 'selectBGM',
DECIDE: 'decideBGM',
FOLDER_OPEN: 'folderOpen',
FOLDER_CLOSE: 'folderClose',
PANEL_OPEN: 'optionOpen',
PANEL_CLOSE: 'optionClose',
OPTION_CHANGE: 'optionChange',
CLEAR: 'clear',
FAIL: 'fail',
SCRATCH: 'cursor',
STOP: 'playStop',
COURSECLEAR: 'courseClear',
COURSEFAIL: 'courseFail',
};
function compact(entries: ReadonlyArray<readonly [SystemSoundSlot, SystemSound | undefined]>): SystemSoundSet {
const set: { [S in SystemSoundSlot]?: SystemSound } = {};
for (const [slot, sound] of entries) {
if (sound !== undefined) set[slot] = sound;
}
return set;
}
/** What a beatoraja theme gives: its cue paths, its select BGM path and its jingles (`BeatorajaThemeBGM`). */
export interface BeatorajaThemeSounds {
/** The cue paths found in the theme's files (`BeatorajaSelectSystemSoundPaths`). */
readonly paths?: {
readonly cursor?: string;
readonly playStop?: string;
readonly decide?: string;
readonly cancel?: string;
readonly folderOpen?: string;
readonly folderClose?: string;
readonly optionChange?: string;
readonly guidePG?: string;
readonly guideGR?: string;
readonly guideGD?: string;
readonly guideBD?: string;
readonly guidePR?: string;
readonly guideMS?: string;
};
readonly selectBGMPath?: string;
/** The jingles read up front, by bytes. */
readonly bgm?: {
readonly decide?: Uint8Array;
readonly clear?: Uint8Array;
readonly fail?: Uint8Array;
readonly result?: Uint8Array;
readonly courseClear?: Uint8Array;
readonly courseFail?: Uint8Array;
readonly resultClose?: Uint8Array;
readonly courseClose?: Uint8Array;
};
}
function fromPath(path: string | undefined): SystemSound | undefined {
return path === undefined || path.length === 0 ? undefined : { path };
}
function fromBytes(bytes: Uint8Array | undefined): SystemSound | undefined {
return bytes === undefined ? undefined : { bytes };
}
/**
* A beatoraja theme's sounds as a system sound set: the cues and the select BGM by path (they play through the theme's
* audio, which beatoraja's skins also drive), the jingles by bytes. beatoraja has no option panel cues.
*/
export function systemSoundSetFromBeatoraja(theme: BeatorajaThemeSounds): SystemSoundSet {
const paths = theme.paths ?? {};
const bgm = theme.bgm ?? {};
return compact([
['cursor', fromPath(paths.cursor)],
['playStop', fromPath(paths.playStop)],
['decide', fromPath(paths.decide)],
['cancel', fromPath(paths.cancel)],
['folderOpen', fromPath(paths.folderOpen)],
['folderClose', fromPath(paths.folderClose)],
['optionChange', fromPath(paths.optionChange)],
['selectBGM', fromPath(theme.selectBGMPath)],
['decideBGM', fromBytes(bgm.decide)],
['clear', fromBytes(bgm.clear)],
['fail', fromBytes(bgm.fail)],
['result', fromBytes(bgm.result)],
['courseClear', fromBytes(bgm.courseClear)],
['courseFail', fromBytes(bgm.courseFail)],
['resultClose', fromBytes(bgm.resultClose)],
['courseClose', fromBytes(bgm.courseClose)],
['guidePG', fromPath(paths.guidePG)],
['guideGR', fromPath(paths.guideGR)],
['guideGD', fromPath(paths.guideGD)],
['guideBD', fromPath(paths.guideBD)],
['guidePR', fromPath(paths.guidePR)],
['guideMS', fromPath(paths.guideMS)],
]);
}
/** Whether a set has any result jingle (clear, fail, the generic one or a course run's). */
export function hasResultJingle(set: SystemSoundSet): boolean {
return (
set.clear !== undefined ||
set.fail !== undefined ||
set.result !== undefined ||
set.courseClear !== undefined ||
set.courseFail !== undefined
);
}
/**
* The jingles a result screen plays: on a clear, on a failure, and the generic one either falls back to, and the sound
* it plays as it closes.
*/
export interface ResultJingles {
readonly clear?: SystemSound;
readonly fail?: SystemSound;
readonly result?: SystemSound;
/** Played as the screen starts to fade out, stopping the jingle (beatoraja's `RESULT_CLOSE` / `COURSE_CLOSE`). */
readonly close?: SystemSound;
}
/**
* The jingles a result plays, from the first of `sets` (in order of preference: the theme whose result skin is shown,
* then the others) that has any result jingle, kept whole as beatoraja plays every result from its one set.
* `courseJingles` (a course run's result) plays the course-clear / course-fail jingles, falling back to the clear /
* fail ones as LR2 and beatoraja do, and closes with the course-close sound, falling back to the result-close one as
* beatoraja's `CourseResult` does.
*/
export function resolveResultJingles(
sets: readonly (SystemSoundSet | undefined)[],
courseJingles: boolean,
): ResultJingles {
const set = sets.find((candidate) => candidate !== undefined && hasResultJingle(candidate)) ?? {};
const clear = (courseJingles ? set.courseClear : undefined) ?? set.clear;
const fail = (courseJingles ? set.courseFail : undefined) ?? set.fail;
const close = (courseJingles ? set.courseClose : undefined) ?? set.resultClose;
return {
...(clear !== undefined ? { clear } : {}),
...(fail !== undefined ? { fail } : {}),
...(set.result !== undefined ? { result: set.result } : {}),
...(close !== undefined ? { close } : {}),
};
}
/** The jingle a result plays: the clear or the fail one by its verdict, else the generic one. */
export function resolveResultJingle(jingles: ResultJingles, cleared: boolean): SystemSound | undefined {
return (cleared ? jingles.clear : jingles.fail) ?? jingles.result;
}
/**
* The cue a select screen plays for a browse command and what it did: the cursor cue on a cursor move, the folder cues
* on opening and closing a folder, the cancel cue on backing out at the root (beatoraja's), and the option-change cue
* when the sort or a filter changed the list. A search, a favourite or a command that changed nothing plays none.
*/
export function browseSystemSound(command: BrowseCommand, event: BrowseEvent): SystemSoundSlot | undefined {
switch (event.kind) {
case 'cursor':
return 'cursor';
case 'folder-opened':
return 'folderOpen';
case 'folder-closed':
return 'folderClose';
case 'at-root':
return 'cancel';
case 'list-changed':
return command.type === 'list' ? 'optionChange' : undefined;
case 'favorite':
case 'none':
return undefined;
}
}
/**
* The cue a select screen plays when the player starts the bar under the cursor: the decide cue for a chart or a
* playable course, the cancel cue for a course with a stage missing (beatoraja's `MusicSelector` refuses it so), none
* for a folder (opening it plays the folder cue).
*/
export function startSystemSound(entry: LibraryEntry): SystemSoundSlot | undefined {
switch (entry.kind) {
case 'chart':
return 'decide';
case 'course':
return entry.course.playable || entry.course.newCourse === true ? 'decide' : 'cancel';
case 'folder':
return undefined;
}
}
|