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 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | import type {
LR2BarBodyKind,
LR2BarGraphMuki,
LR2BarLampKind,
LR2BarLevelKind,
LR2BarRankKind,
LR2BarRivalKind,
LR2CustomFile,
LR2CustomOption,
LR2DestinationRect,
LR2NumberAlignment,
LR2ScratchFlip,
LR2SkinTiming,
LR2SliderMuki,
LR2TextAlignment,
} from './types.ts';
export interface SourceRect {
gr: number;
x: number;
y: number;
w: number;
h: number;
divx: number;
divy: number;
cycle: number;
timer: number;
/**
* CSV-stream declaration index assigned by `parseSource` from `ParseContext.nextDeclarationOrder`. Captures the
* relative order this `#SRC_*` line appeared at so the renderer can stratify chrome elements (`#SRC_IMAGE` /
* `#SRC_NUMBER` / `#SRC_SLIDER` / `#SRC_TEXT` / `#SRC_BUTTON` / `#SRC_ONMOUSE`) around the bar list
* (`#SRC_BAR_BODY`). Internal — only propagated to public element types via the typed `declarationOrder` field on
* each `LR2*Element`.
*/
declarationOrder: number;
}
interface NumberSourceEntry {
source: SourceRect;
num: number;
alignment: LR2NumberAlignment;
padding: number;
}
interface GrooveGaugeSourceEntry {
source: SourceRect;
index: number;
addX: number;
addY: number;
}
interface NowComboSourceEntry {
source: SourceRect;
index: number;
alignment: LR2NumberAlignment;
padding: number;
side: '1P' | '2P';
}
interface JudgeLineSourceEntry {
source: SourceRect;
index: number;
}
interface MeasureLineSourceEntry {
source: SourceRect;
index: number;
}
interface BGASourceEntry {
noBase: boolean;
noLayer: boolean;
noPoor: boolean;
}
interface TextSourceEntry {
font: number;
st: number;
alignment: LR2TextAlignment;
edit: number;
panel: number;
/**
* `#SRC_TEXT` doesn't carry an embedded `SourceRect`, so we stamp the CSV-stream order here directly. Same semantics
* as the other entries' `source.declarationOrder`.
*/
declarationOrder: number;
}
interface BarGraphSourceEntry {
source: SourceRect;
type: number;
muki: LR2BarGraphMuki;
}
interface SliderSourceEntry {
source: SourceRect;
type: number;
muki: LR2SliderMuki;
range: number;
}
interface GaugeChartSourceEntry {
source: SourceRect;
index: number;
fieldWidth: number;
fieldHeight: number;
start: number;
end: number;
side: '1P' | '2P';
}
interface ScoreChartSourceEntry {
source: SourceRect;
index: number;
fieldWidth: number;
fieldHeight: number;
start: number;
end: number;
}
interface ButtonSourceEntry {
source: SourceRect;
type: number;
click: number;
panel: number;
plusOnly: number;
}
interface OnMouseSourceEntry {
source: SourceRect;
panel: number;
hitOffsetX: number;
hitOffsetY: number;
hitWidth: number;
hitHeight: number;
}
interface ReadmeSourceEntry {
font: number;
lineSpacing: number;
}
export interface BarRivalSourceEntry {
kind: LR2BarRivalKind;
source: SourceRect;
}
export interface BarBodySourceEntry {
kind: LR2BarBodyKind;
source: SourceRect;
}
interface BarTitleSourceEntry {
font: number;
}
export interface BarLevelSourceEntry {
kind: LR2BarLevelKind;
source: SourceRect;
alignment: LR2NumberAlignment;
padding: number;
}
export interface BarLampSourceEntry {
kind: LR2BarLampKind;
source: SourceRect;
}
export interface BarRankSourceEntry {
kind: LR2BarRankKind;
source: SourceRect;
}
export interface ParseContext {
imagePaths: string[];
/** Declared `#LR2FONT` paths (declaration index = font index). */
lr2FontPaths: string[];
/** Declared `#FONT,size` sizes for system-font fallback. */
systemFontSizes: number[];
imageSources: SourceRect[];
imageDstGroups: LR2DestinationRect[][];
noteSources: Map<string, SourceRect[]>;
nowJudge1PSources: SourceRect[];
/**
* Full keyframe chain per judgement id — [first DST, … last DST]. The renderer needs the whole sequence (not just the
* first row) to play the judge plate's fade-in / fade-out animation off timer 46.
*/
nowJudge1PDstGroups: LR2DestinationRect[][];
/**
* 2P-side counterparts for DP charts. LR2's `play_14.lr2skin` and any DP-aware skin authors a separate set of
* `#SRC_NOWJUDGE_2P` / `#DST_NOWJUDGE_2P` rows so the 2P judge plate renders at the 2P-side coordinates rather than
* overlapping the 1P plate.
*/
nowJudge2PSources: SourceRect[];
nowJudge2PDstGroups: LR2DestinationRect[][];
numberSources: NumberSourceEntry[];
numberDstGroups: LR2DestinationRect[][];
grooveGaugeSources: GrooveGaugeSourceEntry[];
grooveGaugeDstGroups: LR2DestinationRect[][];
/**
* `#SRC_NOWCOMBO_*` entries from both sides. The `side` field on each entry distinguishes 1P from 2P so the renderer
* can pick the right block at runtime.
*/
nowComboSources: NowComboSourceEntry[];
nowComboDstGroups: LR2DestinationRect[][];
judgeLineSources: JudgeLineSourceEntry[];
judgeLineDstGroups: LR2DestinationRect[][];
measureLineSources: MeasureLineSourceEntry[];
measureLineDstGroups: LR2DestinationRect[][];
bgaSources: BGASourceEntry[];
bgaDstGroups: LR2DestinationRect[][];
textSources: TextSourceEntry[];
textDstGroups: LR2DestinationRect[][];
bargraphSources: BarGraphSourceEntry[];
bargraphDstGroups: LR2DestinationRect[][];
sliderSources: SliderSourceEntry[];
sliderDstGroups: LR2DestinationRect[][];
/**
* `#SRC_GAUGECHART_1P` and `#SRC_GAUGECHART_2P` staging arrays. Pairing with `#DST_*` mirrors the `imageSources` /
* `imageDstGroups` pattern: each new SRC starts a new keyframe group; the next DST extends the group at the same
* array index.
*/
gaugeChartSources: GaugeChartSourceEntry[];
gaugeChartDstGroups: LR2DestinationRect[][];
/** `#SRC_SCORECHART` staging arrays (1P only — `index` carries side meaning). */
scoreChartSources: ScoreChartSourceEntry[];
scoreChartDstGroups: LR2DestinationRect[][];
buttonSources: ButtonSourceEntry[];
buttonDstGroups: LR2DestinationRect[][];
onMouseSources: OnMouseSourceEntry[];
onMouseDstGroups: LR2DestinationRect[][];
readmeSources: ReadmeSourceEntry[];
readmeDstGroups: LR2DestinationRect[][];
mouseCursorSources: SourceRect[];
mouseCursorDstGroups: LR2DestinationRect[][];
/** `#SRC_BAR_FLASH` source (single SRC per spec, last-wins). */
barFlashSource?: SourceRect;
/** `#DST_BAR_FLASH` keyframes. */
barFlashDst: LR2DestinationRect[];
/** `#SRC_BAR_RIVAL` per-outcome sources. */
barRivalSources: BarRivalSourceEntry[];
barRivalDst: LR2DestinationRect[];
/** Rival-mode lamp variants. */
barMyLampSources: BarLampSourceEntry[];
barMyLampDst: LR2DestinationRect[];
barRivalLampSources: BarLampSourceEntry[];
barRivalLampDst: LR2DestinationRect[];
/**
* Song-select bar `#SRC_BAR_BODY` definitions (one per kind id 0..9). Sparse — only kinds the skin actually defines
* have an entry.
*/
barBodySources: BarBodySourceEntry[];
/**
* `#DST_BAR_BODY_OFF` keyframes per slot index 0..29. Sparse like the play-skin DST groups — slot 0 is the topmost
* off-state position.
*/
barBodyOffDstGroups: LR2DestinationRect[][];
/** `#DST_BAR_BODY_ON` keyframes per slot index 0..29 (focus-state). */
barBodyOnDstGroups: LR2DestinationRect[][];
/** `#BAR_CENTER` value (clamped to slot range at finalization). */
barCenter: number;
/** `#BAR_AVAILABLE` value (clamped to slot range at finalization). */
barAvailable: number;
/**
* `#SRC_BAR_TITLE` source. LR2 spec only allows one. We keep the latest one wins to mirror how the LR2 default skin
* chains an `#IF`-gated alt definition for the focus state.
*/
barTitleSource?: BarTitleSourceEntry;
/** `#DST_BAR_TITLE` keyframes (relative to the bar's xy). */
barTitleDst: LR2DestinationRect[];
/** `#SRC_BAR_LEVEL` per-difficulty cell sheets (sparse by kind). */
barLevelSources: BarLevelSourceEntry[];
/** `#DST_BAR_LEVEL` shared keyframes (LR2 only ships one DST chain). */
barLevelDst: LR2DestinationRect[];
/** `#SRC_BAR_LAMP` per-clear-lamp sprites. */
barLampSources: BarLampSourceEntry[];
/** `#DST_BAR_LAMP` shared keyframes. */
barLampDst: LR2DestinationRect[];
/** `#SRC_BAR_RANK` per-clear-rank sprites. */
barRankSources: BarRankSourceEntry[];
/** `#DST_BAR_RANK` shared keyframes. */
barRankDst: LR2DestinationRect[];
laneRects: LR2DestinationRect[];
customOptions: LR2CustomOption[];
customFiles: LR2CustomFile[];
customFileLookup: Map<string, string>;
transparentColor?: { r: number; g: number; b: number };
trueOps: Set<number>;
timing: LR2SkinTiming;
scratchFlip: LR2ScratchFlip;
name: string;
width: number;
height: number;
/**
* `true` once the parser has seen an valid `#RESOLUTION,<index>` or `#RESOLUTION,<w>,<h>` directive. When the skin omits the directive
* entirely we leave this `false` and {@link autoDetectCanvasFromObservedCoordinates} kicks in at the end of the
* parse, snapping {@link width} / {@link height} to the smallest standard canvas that contains the bulk of the
* skin's authored DST coordinates. LR2 themes from the 1280×720 / 1920×1080 era frequently ship without
* `#RESOLUTION` (LITONE4 is the smoking gun — every coord is in 1920×1080 space, header is empty), so the
* post-parse detection is what keeps the chrome from getting clipped to the legacy 640×480 default canvas.
*/
explicitResolution: boolean;
/**
* Right-bottom corner `(x + w, y + h)` of every `#DST_*` keyframe parsed in this skin. Used by the canvas
* auto-detector to find the design resolution when `#RESOLUTION` is omitted. We push from
* {@link appendDestinationKeyframe} so EVERY `#DST_*` lineage contributes — image / number / text / slider / bar
* body / etc. all share the same canvas. Entries with negative `x` or `y` (animation slide-in / slide-out
* starting points that arrive from / depart to off-screen) are excluded; including them would skew the
* percentile-based detection toward the animation reach instead of the rendered canvas.
*/
observedDstCorners: Array<readonly [number, number]>;
/**
* Monotonic counter that increments every time we record a `#SRC_*` declaration the renderer wants z-order context
* for (currently `#SRC_SLIDER` and the first `#SRC_BAR_BODY`). The counter is process-local to a single skin parse —
* so a later reference's `declarationOrder > earlier reference's` iff it appeared later in the CSV stream (including
* across `#INCLUDE`s, which feed back into the same `readLR2Path` call chain).
*/
nextDeclarationOrder: number;
/**
* `nextDeclarationOrder` value assigned to the first `#SRC_BAR_BODY` we saw, or `undefined` when the skin has no bar
* layout. Used to decide which side of the bar list each chrome element sits on.
*/
barLayoutDeclarationOrder?: number;
}
|