@terrafirmagreg-team/recipe 1.2.22 → 1.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/components/cards/card/strip.tsx +18 -0
- package/src/components/cards/controls/card-pager.tsx +101 -0
- package/src/components/cards/controls/card-scrollbar.tsx +370 -0
- package/src/components/cards/scroll-card/index.tsx +605 -131
- package/src/components/cards/slot-hitbox.tsx +19 -1
- package/src/components/cards/strip-card/buttons.tsx +9 -57
- package/src/components/cards/strip-card/index.tsx +2 -0
- package/src/components/cards/strip-card/member-cell.tsx +36 -12
- package/src/hooks/use-index.ts +8 -8
- package/src/hooks/use-left-sidebar-tree.ts +6 -16
- package/src/lib/client-index/chrome.ts +14 -52
- package/src/lib/client-index/rows.ts +2 -1
- package/src/lib/data/scroll.ts +172 -2
|
@@ -1,47 +1,183 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useMemo, useRef, useState, type ComponentProps } from 'react';
|
|
4
|
-
import {
|
|
3
|
+
import { useId, useMemo, useRef, useState, type ComponentProps } from 'react';
|
|
4
|
+
import { RecipeCard } from '@terrafirmagreg-team/recipe/components/cards/card';
|
|
5
5
|
import { StripCardMember } from '@terrafirmagreg-team/recipe/components/cards/strip-card/member-cell';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { CardScrollbar } from '@terrafirmagreg-team/recipe/components/cards/controls/card-scrollbar';
|
|
7
|
+
import {
|
|
8
|
+
recipeScroll,
|
|
9
|
+
type ScrollElement,
|
|
10
|
+
type ScrollFrame,
|
|
11
|
+
} from '@terrafirmagreg-team/recipe/lib/data/scroll';
|
|
12
|
+
import { texturePublicUrl } from '@terrafirmagreg-team/dump/lib/dump/assets/urls';
|
|
13
|
+
import { dumpRelPublicUrl } from '@terrafirmagreg-team/dump/lib/dump/paths';
|
|
8
14
|
import { useInView } from '@terrafirmagreg-team/ui/hooks/use-in-view';
|
|
9
15
|
import { useSwipe } from '@terrafirmagreg-team/ui/hooks/use-swipe';
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
16
|
+
import { McText } from '@terrafirmagreg-team/game/components/entry/mc-text';
|
|
17
|
+
import { stackIdFromRef } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
12
18
|
|
|
13
19
|
const FALLBACK_PITCH = 18;
|
|
20
|
+
const BAR_SPAN = 4;
|
|
21
|
+
const ATLAS = 256;
|
|
14
22
|
|
|
15
23
|
type Props = ComponentProps<typeof RecipeCard>;
|
|
16
24
|
|
|
25
|
+
function Stretch({
|
|
26
|
+
tex,
|
|
27
|
+
sx,
|
|
28
|
+
sy,
|
|
29
|
+
sw,
|
|
30
|
+
sh,
|
|
31
|
+
x,
|
|
32
|
+
y,
|
|
33
|
+
w,
|
|
34
|
+
h,
|
|
35
|
+
}: {
|
|
36
|
+
tex: string;
|
|
37
|
+
sx: number;
|
|
38
|
+
sy: number;
|
|
39
|
+
sw: number;
|
|
40
|
+
sh: number;
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
w: number;
|
|
44
|
+
h: number;
|
|
45
|
+
}) {
|
|
46
|
+
if (w <= 0 || h <= 0 || sw <= 0 || sh <= 0) return null;
|
|
47
|
+
const kx = w / sw;
|
|
48
|
+
const ky = h / sh;
|
|
49
|
+
return (
|
|
50
|
+
<span
|
|
51
|
+
aria-hidden
|
|
52
|
+
className="absolute block"
|
|
53
|
+
style={{
|
|
54
|
+
left: x,
|
|
55
|
+
top: y,
|
|
56
|
+
width: w,
|
|
57
|
+
height: h,
|
|
58
|
+
backgroundImage: `url(${tex})`,
|
|
59
|
+
backgroundSize: `${ATLAS * kx}px ${ATLAS * ky}px`,
|
|
60
|
+
backgroundPosition: `-${sx * kx}px -${sy * ky}px`,
|
|
61
|
+
imageRendering: 'pixelated',
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function FramePatch({
|
|
68
|
+
tex,
|
|
69
|
+
frame,
|
|
70
|
+
x,
|
|
71
|
+
y,
|
|
72
|
+
w,
|
|
73
|
+
h,
|
|
74
|
+
scale,
|
|
75
|
+
}: {
|
|
76
|
+
tex: string;
|
|
77
|
+
frame: ScrollFrame;
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
w: number;
|
|
81
|
+
h: number;
|
|
82
|
+
scale: number;
|
|
83
|
+
}) {
|
|
84
|
+
const s = frame.s;
|
|
85
|
+
const t = frame.t;
|
|
86
|
+
const ss = s * scale;
|
|
87
|
+
const u = frame.u;
|
|
88
|
+
const v = frame.v;
|
|
89
|
+
const parts = [
|
|
90
|
+
{ sx: u, sy: v, sw: s, sh: s, dx: 0, dy: 0, dw: ss, dh: ss },
|
|
91
|
+
{ sx: u + s, sy: v, sw: t, sh: s, dx: ss, dy: 0, dw: w - ss * 2, dh: ss },
|
|
92
|
+
{ sx: u + s + t, sy: v, sw: s, sh: s, dx: w - ss, dy: 0, dw: ss, dh: ss },
|
|
93
|
+
{ sx: u, sy: v + s, sw: s, sh: t, dx: 0, dy: ss, dw: ss, dh: h - ss * 2 },
|
|
94
|
+
{
|
|
95
|
+
sx: u + s,
|
|
96
|
+
sy: v + s,
|
|
97
|
+
sw: t,
|
|
98
|
+
sh: t,
|
|
99
|
+
dx: ss,
|
|
100
|
+
dy: ss,
|
|
101
|
+
dw: w - ss * 2,
|
|
102
|
+
dh: h - ss * 2,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
sx: u + s + t,
|
|
106
|
+
sy: v + s,
|
|
107
|
+
sw: s,
|
|
108
|
+
sh: t,
|
|
109
|
+
dx: w - ss,
|
|
110
|
+
dy: ss,
|
|
111
|
+
dw: ss,
|
|
112
|
+
dh: h - ss * 2,
|
|
113
|
+
},
|
|
114
|
+
{ sx: u, sy: v + s + t, sw: s, sh: s, dx: 0, dy: h - ss, dw: ss, dh: ss },
|
|
115
|
+
{
|
|
116
|
+
sx: u + s,
|
|
117
|
+
sy: v + s + t,
|
|
118
|
+
sw: t,
|
|
119
|
+
sh: s,
|
|
120
|
+
dx: ss,
|
|
121
|
+
dy: h - ss,
|
|
122
|
+
dw: w - ss * 2,
|
|
123
|
+
dh: ss,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
sx: u + s + t,
|
|
127
|
+
sy: v + s + t,
|
|
128
|
+
sw: s,
|
|
129
|
+
sh: s,
|
|
130
|
+
dx: w - ss,
|
|
131
|
+
dy: h - ss,
|
|
132
|
+
dw: ss,
|
|
133
|
+
dh: ss,
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
return (
|
|
137
|
+
<span
|
|
138
|
+
aria-hidden
|
|
139
|
+
className="absolute block"
|
|
140
|
+
style={{ left: x, top: y, width: w, height: h }}
|
|
141
|
+
>
|
|
142
|
+
{parts.map((part, i) => (
|
|
143
|
+
<Stretch
|
|
144
|
+
key={i}
|
|
145
|
+
tex={tex}
|
|
146
|
+
sx={part.sx}
|
|
147
|
+
sy={part.sy}
|
|
148
|
+
sw={part.sw}
|
|
149
|
+
sh={part.sh}
|
|
150
|
+
x={part.dx}
|
|
151
|
+
y={part.dy}
|
|
152
|
+
w={part.dw}
|
|
153
|
+
h={part.dh}
|
|
154
|
+
/>
|
|
155
|
+
))}
|
|
156
|
+
</span>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
17
160
|
export function ScrollCard(props: Props) {
|
|
18
|
-
const {
|
|
19
|
-
recipe,
|
|
20
|
-
dataset,
|
|
21
|
-
lang,
|
|
22
|
-
langMap,
|
|
23
|
-
nav,
|
|
24
|
-
title,
|
|
25
|
-
src,
|
|
26
|
-
onFail,
|
|
27
|
-
naturalW,
|
|
28
|
-
naturalH,
|
|
29
|
-
interactive = true,
|
|
30
|
-
slotTooltip,
|
|
31
|
-
eager,
|
|
32
|
-
frameOnly,
|
|
33
|
-
} = props;
|
|
161
|
+
const { recipe, interactive = true, slotTooltip, eager, frameOnly, dataset } = props;
|
|
34
162
|
const scale = recipe.scale ?? 2;
|
|
35
163
|
const margin = recipe.margin ?? 0;
|
|
36
164
|
const scroll = recipeScroll(recipe.properties);
|
|
37
165
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
38
166
|
const observedInView = useInView(rootRef);
|
|
39
167
|
const inView = eager || observedInView;
|
|
40
|
-
const [
|
|
168
|
+
const [offsetRaw, setOffset] = useState(0);
|
|
169
|
+
|
|
170
|
+
const horizontal = scroll?.axis === 'horizontal';
|
|
171
|
+
const decomposed =
|
|
172
|
+
scroll?.decomposed === true && (scroll.elements?.length ?? 0) > 0;
|
|
173
|
+
const elements = useMemo(
|
|
174
|
+
() => (decomposed ? (scroll?.elements ?? []) : []),
|
|
175
|
+
[decomposed, scroll],
|
|
176
|
+
);
|
|
177
|
+
const paneId = useId();
|
|
41
178
|
|
|
42
179
|
const members = useMemo(() => {
|
|
43
|
-
if (!scroll) return [];
|
|
44
|
-
const horizontal = scroll.axis === 'horizontal';
|
|
180
|
+
if (!scroll || decomposed) return [];
|
|
45
181
|
const paneStart = horizontal ? scroll.y : scroll.x;
|
|
46
182
|
const paneEnd = paneStart + (horizontal ? scroll.h : scroll.w);
|
|
47
183
|
return Object.values(recipe.slots ?? {}).filter((slot) => {
|
|
@@ -49,146 +185,484 @@ export function ScrollCard(props: Props) {
|
|
|
49
185
|
const mid = horizontal ? slot.y + 9 : slot.x + 9;
|
|
50
186
|
return mid >= paneStart && mid < paneEnd;
|
|
51
187
|
});
|
|
52
|
-
}, [recipe.slots, scroll]);
|
|
188
|
+
}, [recipe.slots, scroll, horizontal, decomposed]);
|
|
53
189
|
|
|
54
190
|
const pitch = useMemo(() => {
|
|
55
|
-
if (!scroll) return FALLBACK_PITCH;
|
|
56
|
-
const horizontal = scroll.axis === 'horizontal';
|
|
57
191
|
const coords = Array.from(
|
|
58
|
-
new Set(
|
|
192
|
+
new Set(
|
|
193
|
+
(decomposed ? elements : members)
|
|
194
|
+
.map((el) => (horizontal ? el.x : el.y) ?? 0),
|
|
195
|
+
),
|
|
59
196
|
).sort((a, b) => a - b);
|
|
60
197
|
let min = 0;
|
|
61
198
|
for (let i = 1; i < coords.length; i++) {
|
|
62
|
-
const delta = coords[i] - coords[i - 1]
|
|
63
|
-
if (delta
|
|
199
|
+
const delta = coords[i]! - coords[i - 1]!;
|
|
200
|
+
if (delta >= FALLBACK_PITCH / 2 && (min === 0 || delta < min))
|
|
201
|
+
min = delta;
|
|
64
202
|
}
|
|
65
203
|
return min || FALLBACK_PITCH;
|
|
66
|
-
}, [members,
|
|
204
|
+
}, [members, elements, decomposed, horizontal]);
|
|
67
205
|
|
|
68
|
-
const horizontal = scroll?.axis === 'horizontal';
|
|
69
206
|
const paneSpan = scroll ? (horizontal ? scroll.w : scroll.h) : 0;
|
|
70
|
-
const perPage = Math.max(1, Math.floor(paneSpan / pitch));
|
|
71
207
|
const contentSpan = useMemo(() => {
|
|
72
208
|
if (!scroll) return 0;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
209
|
+
const start = horizontal ? scroll.x : scroll.y;
|
|
210
|
+
let extent = start + (horizontal ? scroll.contentW : scroll.contentH);
|
|
211
|
+
const cells: ({ x?: number; y?: number; w?: number; h?: number } | ScrollElement)[] = decomposed
|
|
212
|
+
? elements
|
|
213
|
+
: members;
|
|
214
|
+
for (const cell of cells) {
|
|
215
|
+
const pos = horizontal ? cell.x : cell.y;
|
|
216
|
+
const size = (horizontal ? cell.w : cell.h) ?? FALLBACK_PITCH;
|
|
217
|
+
if (pos !== undefined) extent = Math.max(extent, pos + size);
|
|
218
|
+
}
|
|
219
|
+
return extent - start;
|
|
220
|
+
}, [members, elements, scroll, horizontal, decomposed]);
|
|
221
|
+
|
|
222
|
+
const clipStart = scroll?.clipTop ?? 0;
|
|
223
|
+
const maxOffset = Math.max(0, contentSpan - paneSpan);
|
|
224
|
+
const starts = useMemo(() => {
|
|
225
|
+
if (decomposed || members.length === 0) return [0];
|
|
226
|
+
const rows = Array.from(
|
|
227
|
+
new Set(members.map((slot) => (horizontal ? slot.x : slot.y) ?? 0)),
|
|
228
|
+
).sort((a, b) => a - b);
|
|
229
|
+
const first = rows[0] ?? 0;
|
|
230
|
+
const out = [0];
|
|
231
|
+
let start = 0;
|
|
232
|
+
for (;;) {
|
|
233
|
+
const next = rows.find(
|
|
234
|
+
(r) => r - first > start && r + pitch > first + start + paneSpan,
|
|
78
235
|
);
|
|
236
|
+
if (next === undefined) {
|
|
237
|
+
const last = (rows[rows.length - 1] ?? first) - first;
|
|
238
|
+
if (last > start) out.push(last);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
const to = next - first;
|
|
242
|
+
if (to <= start) break;
|
|
243
|
+
out.push(to);
|
|
244
|
+
start = to;
|
|
245
|
+
}
|
|
246
|
+
return out;
|
|
247
|
+
}, [members, decomposed, horizontal, paneSpan, pitch]);
|
|
248
|
+
const scrollable = decomposed ? scroll.bar !== undefined : starts.length > 1;
|
|
249
|
+
const offset = useMemo(() => {
|
|
250
|
+
const clamped = Math.min(maxOffset, offsetRaw);
|
|
251
|
+
if (decomposed) return clamped;
|
|
252
|
+
let best = 0;
|
|
253
|
+
for (const s of starts) {
|
|
254
|
+
if (Math.abs(s - clamped) < Math.abs(best - clamped)) best = s;
|
|
79
255
|
}
|
|
80
|
-
return
|
|
81
|
-
}, [
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setPage((p) => Math.max(0, Math.min(pages - 1, p + dir))),
|
|
256
|
+
return best;
|
|
257
|
+
}, [offsetRaw, starts, decomposed, maxOffset]);
|
|
258
|
+
|
|
259
|
+
const swipe = useSwipe(
|
|
260
|
+
(dir) => setOffset(Math.max(0, Math.min(maxOffset, offset + dir * paneSpan))),
|
|
261
|
+
horizontal ? 'x' : 'y',
|
|
87
262
|
);
|
|
88
263
|
|
|
89
264
|
if (!scroll) return null;
|
|
265
|
+
const cardW = recipe.w ?? 0;
|
|
266
|
+
const cardH = recipe.h ?? 0;
|
|
90
267
|
const pane = {
|
|
91
268
|
left: (scroll.x + margin) * scale,
|
|
92
269
|
top: (scroll.y + margin) * scale,
|
|
93
|
-
width: scroll.w * scale,
|
|
94
|
-
height: scroll.h * scale,
|
|
270
|
+
width: Math.max(0, Math.min(scroll.w * scale, cardW - (scroll.x + margin) * scale)),
|
|
271
|
+
height: Math.max(0, Math.min(scroll.h * scale, cardH - (scroll.y + margin) * scale)),
|
|
272
|
+
};
|
|
273
|
+
const barRect = scroll.bar
|
|
274
|
+
? {
|
|
275
|
+
left: (scroll.bar.x + margin) * scale,
|
|
276
|
+
top: (scroll.bar.y + margin) * scale,
|
|
277
|
+
w: scroll.bar.w * scale,
|
|
278
|
+
h: scroll.bar.h * scale,
|
|
279
|
+
}
|
|
280
|
+
: horizontal
|
|
281
|
+
? {
|
|
282
|
+
left: pane.left + scale,
|
|
283
|
+
top: pane.top + pane.height - BAR_SPAN * scale,
|
|
284
|
+
w: pane.width - scale * 2,
|
|
285
|
+
h: BAR_SPAN * scale,
|
|
286
|
+
}
|
|
287
|
+
: {
|
|
288
|
+
left: pane.left + pane.width - BAR_SPAN * scale,
|
|
289
|
+
top: pane.top + scale,
|
|
290
|
+
w: BAR_SPAN * scale,
|
|
291
|
+
h: pane.height - scale * 2,
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const viewport = scroll.viewport ?? {
|
|
295
|
+
x: scroll.x,
|
|
296
|
+
y: scroll.y,
|
|
297
|
+
w: scroll.w - (horizontal ? 0 : 9),
|
|
298
|
+
h: scroll.h - (horizontal ? 9 : 0),
|
|
95
299
|
};
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
300
|
+
const guiTexUrl = scroll.guiTex ? texturePublicUrl(dataset, scroll.guiTex) : undefined;
|
|
301
|
+
const frameUrl = scroll.frame ? texturePublicUrl(dataset, scroll.frame.tex) : undefined;
|
|
302
|
+
const slotTexUrl = scroll.slotTex ? texturePublicUrl(dataset, scroll.slotTex) : undefined;
|
|
303
|
+
const overlayUrl = scroll.overlay ? dumpRelPublicUrl(dataset, scroll.overlay) : undefined;
|
|
304
|
+
const barSkin =
|
|
305
|
+
guiTexUrl && scroll.barSkin
|
|
306
|
+
? {
|
|
307
|
+
tex: guiTexUrl,
|
|
308
|
+
atlasW: ATLAS,
|
|
309
|
+
atlasH: ATLAS,
|
|
310
|
+
skin: scroll.barSkin,
|
|
311
|
+
viewSpan: horizontal ? viewport.w : viewport.h,
|
|
312
|
+
contentSpan: horizontal ? scroll.contentW : scroll.contentH,
|
|
313
|
+
}
|
|
314
|
+
: undefined;
|
|
315
|
+
|
|
316
|
+
const renderText = (el: ScrollElement, index: number, moving: boolean) => {
|
|
317
|
+
const rgb = (el.color ?? 0xffffff) & 0xffffff;
|
|
318
|
+
const shadowRgb = ((rgb & 0xfcfcfc) >> 2) & 0xffffff;
|
|
319
|
+
const x = (el.x - viewport.x) * scale;
|
|
320
|
+
const y = (el.y - viewport.y) * scale;
|
|
321
|
+
const shifted = (horizontal ? x : y) - (moving ? offset * scale : 0);
|
|
322
|
+
return (
|
|
323
|
+
<span
|
|
324
|
+
key={`t:${index}`}
|
|
325
|
+
className="font-mc absolute leading-none whitespace-pre"
|
|
326
|
+
style={{
|
|
327
|
+
left: horizontal ? shifted : x,
|
|
328
|
+
top: horizontal ? y : shifted,
|
|
329
|
+
fontSize: Math.max(6, (el.h - 1 || 8) * scale),
|
|
330
|
+
color: `#${rgb.toString(16).padStart(6, '0')}`,
|
|
331
|
+
textShadow: `${scale}px ${scale}px 0 #${shadowRgb.toString(16).padStart(6, '0')}`,
|
|
332
|
+
}}
|
|
333
|
+
>
|
|
334
|
+
<McText text={el.text ?? ''} surface="dark" />
|
|
335
|
+
</span>
|
|
336
|
+
);
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
const renderSlot = (el: ScrollElement, index: number) => {
|
|
340
|
+
const x = (el.x - viewport.x) * scale;
|
|
341
|
+
const y = (el.y - viewport.y) * scale;
|
|
342
|
+
const shifted = (horizontal ? x : y) - offset * scale;
|
|
343
|
+
const cell = Math.max(el.w, el.h) * scale;
|
|
344
|
+
if (shifted < -cell || shifted > paneSpan * scale) return null;
|
|
345
|
+
const member = el.ref?.id
|
|
346
|
+
? {
|
|
347
|
+
id: stackIdFromRef(el.ref),
|
|
348
|
+
kind: el.ref.kind,
|
|
349
|
+
amount: 1,
|
|
350
|
+
}
|
|
351
|
+
: null;
|
|
352
|
+
return (
|
|
353
|
+
<span
|
|
354
|
+
key={`s:${index}`}
|
|
355
|
+
className="absolute"
|
|
356
|
+
style={{
|
|
357
|
+
left: horizontal ? shifted : x,
|
|
358
|
+
top: horizontal ? y : shifted,
|
|
359
|
+
width: el.w * scale,
|
|
360
|
+
height: el.h * scale,
|
|
361
|
+
}}
|
|
362
|
+
>
|
|
363
|
+
{slotTexUrl ? (
|
|
364
|
+
<span
|
|
365
|
+
aria-hidden
|
|
366
|
+
className="absolute inset-0 block"
|
|
367
|
+
style={{
|
|
368
|
+
backgroundImage: `url(${slotTexUrl})`,
|
|
369
|
+
backgroundSize: `${ATLAS * scale}px ${ATLAS * scale}px`,
|
|
370
|
+
backgroundPosition: `-${(el.u ?? 0) * scale}px -${(el.v ?? 0) * scale}px`,
|
|
371
|
+
imageRendering: 'pixelated',
|
|
372
|
+
}}
|
|
373
|
+
/>
|
|
374
|
+
) : (
|
|
375
|
+
<span
|
|
376
|
+
aria-hidden
|
|
377
|
+
className="absolute inset-0 block"
|
|
378
|
+
style={{
|
|
379
|
+
background: 'var(--color-mc-inset)',
|
|
380
|
+
boxShadow: `inset ${scale}px ${scale}px 0 var(--color-mc-bevel-dark), inset -${scale}px -${scale}px 0 var(--color-mc-bevel-light)`,
|
|
381
|
+
}}
|
|
382
|
+
/>
|
|
383
|
+
)}
|
|
384
|
+
{el.mark ? (
|
|
385
|
+
<span
|
|
386
|
+
aria-hidden
|
|
387
|
+
className="pointer-events-none absolute"
|
|
388
|
+
style={{
|
|
389
|
+
left: scale,
|
|
390
|
+
top: scale,
|
|
391
|
+
right: scale,
|
|
392
|
+
bottom: scale,
|
|
393
|
+
background: 'rgba(0, 0, 0, 0.25)',
|
|
394
|
+
}}
|
|
395
|
+
/>
|
|
396
|
+
) : null}
|
|
397
|
+
{member ? (
|
|
398
|
+
<span className="pointer-events-auto absolute inset-0">
|
|
399
|
+
<StripCardMember
|
|
400
|
+
member={member}
|
|
401
|
+
dataset={dataset}
|
|
402
|
+
lang={props.lang}
|
|
403
|
+
langMap={props.langMap}
|
|
404
|
+
nav={props.nav}
|
|
405
|
+
x={0}
|
|
406
|
+
y={0}
|
|
407
|
+
pitch={el.w * scale}
|
|
408
|
+
tooltipLines={el.tooltip}
|
|
409
|
+
interactive={interactive}
|
|
410
|
+
tooltipLevel={slotTooltip}
|
|
411
|
+
/>
|
|
412
|
+
</span>
|
|
413
|
+
) : null}
|
|
414
|
+
{el.label ? (
|
|
415
|
+
<span
|
|
416
|
+
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-white [text-shadow:1px_1px_0_var(--color-mc-arrow)]"
|
|
417
|
+
style={{ fontSize: (el.w * scale) / 4 }}
|
|
418
|
+
>
|
|
419
|
+
{el.label}
|
|
420
|
+
</span>
|
|
421
|
+
) : null}
|
|
422
|
+
</span>
|
|
423
|
+
);
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const renderBlock = (el: ScrollElement, index: number, moving: boolean = true) => {
|
|
427
|
+
const x = (el.x - viewport.x) * scale;
|
|
428
|
+
const y = (el.y - viewport.y) * scale;
|
|
429
|
+
const shifted = (horizontal ? x : y) - (moving ? offset * scale : 0);
|
|
430
|
+
const cell = Math.max(el.w, el.h) * scale;
|
|
431
|
+
if (shifted < -cell || shifted > paneSpan * scale) return null;
|
|
432
|
+
const member = el.ref?.id
|
|
433
|
+
? {
|
|
434
|
+
id: stackIdFromRef(el.ref),
|
|
435
|
+
kind: el.ref.kind,
|
|
436
|
+
amount: 1,
|
|
437
|
+
}
|
|
438
|
+
: null;
|
|
439
|
+
return (
|
|
440
|
+
<span
|
|
441
|
+
key={`b:${index}`}
|
|
442
|
+
className="absolute"
|
|
443
|
+
style={{
|
|
444
|
+
left: horizontal ? shifted : x,
|
|
445
|
+
top: horizontal ? y : shifted,
|
|
446
|
+
width: el.w * scale,
|
|
447
|
+
height: el.h * scale,
|
|
448
|
+
}}
|
|
449
|
+
>
|
|
450
|
+
{member ? (
|
|
451
|
+
<span className="pointer-events-auto absolute inset-0">
|
|
452
|
+
<StripCardMember
|
|
453
|
+
member={member}
|
|
454
|
+
dataset={dataset}
|
|
455
|
+
lang={props.lang}
|
|
456
|
+
langMap={props.langMap}
|
|
457
|
+
nav={props.nav}
|
|
458
|
+
x={0}
|
|
459
|
+
y={0}
|
|
460
|
+
pitch={cell}
|
|
461
|
+
hideIcon
|
|
462
|
+
tooltipLines={el.tooltip}
|
|
463
|
+
interactive={interactive}
|
|
464
|
+
tooltipLevel={slotTooltip}
|
|
465
|
+
/>
|
|
466
|
+
</span>
|
|
467
|
+
) : null}
|
|
468
|
+
</span>
|
|
469
|
+
);
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
const overlayImg = (shifted: boolean) =>
|
|
473
|
+
overlayUrl ? (
|
|
474
|
+
// eslint-disable-next-line @next/next/no-img-element -- dump asset
|
|
475
|
+
<img
|
|
476
|
+
src={overlayUrl}
|
|
477
|
+
alt=""
|
|
478
|
+
aria-hidden
|
|
479
|
+
draggable={false}
|
|
480
|
+
className="absolute block max-w-none"
|
|
481
|
+
style={{
|
|
482
|
+
left: horizontal && shifted ? -offset * scale : 0,
|
|
483
|
+
top: !horizontal && shifted ? -offset * scale : 0,
|
|
484
|
+
width: (scroll.overlayW ?? scroll.contentW) * scale,
|
|
485
|
+
height: (scroll.overlayH ?? scroll.contentH) * scale,
|
|
486
|
+
imageRendering: 'pixelated',
|
|
487
|
+
}}
|
|
488
|
+
/>
|
|
489
|
+
) : null;
|
|
102
490
|
|
|
103
491
|
return (
|
|
104
492
|
<div
|
|
105
493
|
ref={rootRef}
|
|
106
|
-
className=
|
|
494
|
+
className="relative w-fit"
|
|
107
495
|
{...swipe}
|
|
108
496
|
onWheel={(event) => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
497
|
+
const delta = horizontal ? event.deltaY || event.deltaX : event.deltaY;
|
|
498
|
+
if (delta === 0) return;
|
|
499
|
+
const next = Math.max(0, Math.min(maxOffset, offset + Math.sign(delta) * pitch));
|
|
500
|
+
if (next === offset) return;
|
|
112
501
|
event.stopPropagation();
|
|
113
|
-
|
|
502
|
+
setOffset(next);
|
|
114
503
|
}}
|
|
115
504
|
>
|
|
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
|
-
|
|
505
|
+
{decomposed ? (
|
|
506
|
+
<div
|
|
507
|
+
role="img"
|
|
508
|
+
aria-label={props.title}
|
|
509
|
+
className="relative w-fit overflow-hidden rounded-sm bg-mc-panel"
|
|
510
|
+
style={{ width: cardW, height: cardH }}
|
|
511
|
+
>
|
|
512
|
+
{frameUrl && scroll.frame ? (
|
|
513
|
+
<FramePatch
|
|
514
|
+
tex={frameUrl}
|
|
515
|
+
frame={scroll.frame}
|
|
516
|
+
x={0}
|
|
517
|
+
y={0}
|
|
518
|
+
w={cardW}
|
|
519
|
+
h={cardH}
|
|
520
|
+
scale={scale}
|
|
521
|
+
/>
|
|
522
|
+
) : null}
|
|
523
|
+
{inView && !frameOnly ? (
|
|
524
|
+
<div
|
|
525
|
+
id={paneId}
|
|
526
|
+
className="pointer-events-none absolute overflow-hidden"
|
|
527
|
+
style={{
|
|
528
|
+
left: pane.left,
|
|
529
|
+
top: pane.top,
|
|
530
|
+
width: pane.width,
|
|
531
|
+
height: pane.height,
|
|
532
|
+
}}
|
|
533
|
+
>
|
|
534
|
+
<div
|
|
535
|
+
className="absolute overflow-hidden"
|
|
536
|
+
style={{
|
|
537
|
+
left: (viewport.x - scroll.x) * scale,
|
|
538
|
+
top: (viewport.y - scroll.y) * scale,
|
|
539
|
+
width: viewport.w * scale,
|
|
540
|
+
height: viewport.h * scale,
|
|
541
|
+
}}
|
|
542
|
+
>
|
|
543
|
+
<div
|
|
544
|
+
className="absolute inset-0"
|
|
545
|
+
style={
|
|
546
|
+
clipStart > 0
|
|
547
|
+
? {
|
|
548
|
+
clipPath: horizontal
|
|
549
|
+
? `inset(0 0 0 ${clipStart * scale}px)`
|
|
550
|
+
: `inset(${clipStart * scale}px 0 0 0)`,
|
|
551
|
+
}
|
|
552
|
+
: undefined
|
|
553
|
+
}
|
|
151
554
|
>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
555
|
+
{overlayImg(true)}
|
|
556
|
+
{elements.map((el, index) =>
|
|
557
|
+
el.kind === 'slot'
|
|
558
|
+
? renderSlot(el, index)
|
|
559
|
+
: (el.kind === 'block' || el.kind === 'entity') && !el.pin
|
|
560
|
+
? renderBlock(el, index)
|
|
561
|
+
: null,
|
|
562
|
+
)}
|
|
563
|
+
{elements.map((el, index) =>
|
|
564
|
+
el.kind === 'text' && !el.pin
|
|
565
|
+
? renderText(el, index, true)
|
|
566
|
+
: null,
|
|
567
|
+
)}
|
|
568
|
+
</div>
|
|
569
|
+
{clipStart > 0 ? (
|
|
570
|
+
<div
|
|
571
|
+
className="absolute overflow-hidden"
|
|
572
|
+
style={
|
|
573
|
+
horizontal
|
|
574
|
+
? { left: 0, top: 0, width: clipStart * scale, height: viewport.h * scale }
|
|
575
|
+
: { left: 0, top: 0, width: viewport.w * scale, height: clipStart * scale }
|
|
576
|
+
}
|
|
577
|
+
>
|
|
578
|
+
{overlayImg(false)}
|
|
579
|
+
</div>
|
|
580
|
+
) : null}
|
|
581
|
+
</div>
|
|
582
|
+
{elements.map((el, index) => {
|
|
583
|
+
if (!el.pin) return null;
|
|
584
|
+
if (el.kind === 'text') return renderText(el, index, false);
|
|
585
|
+
if (el.kind === 'entity' || el.kind === 'block')
|
|
586
|
+
return renderBlock(el, index, false);
|
|
587
|
+
return null;
|
|
588
|
+
})}
|
|
589
|
+
</div>
|
|
590
|
+
) : null}
|
|
591
|
+
</div>
|
|
592
|
+
) : (
|
|
173
593
|
<>
|
|
174
|
-
<
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
594
|
+
<RecipeCard {...props} />
|
|
595
|
+
<div
|
|
596
|
+
id={paneId}
|
|
597
|
+
className="pointer-events-none absolute overflow-hidden"
|
|
598
|
+
style={{
|
|
599
|
+
left: pane.left,
|
|
600
|
+
top: pane.top,
|
|
601
|
+
width: pane.width,
|
|
602
|
+
height: pane.height,
|
|
603
|
+
}}
|
|
604
|
+
>
|
|
605
|
+
{inView && !frameOnly
|
|
606
|
+
? members.map((slot, index) => {
|
|
607
|
+
const ref = slot.ref;
|
|
608
|
+
if (!ref?.id) return null;
|
|
609
|
+
const member = {
|
|
610
|
+
id: stackIdFromRef(ref),
|
|
611
|
+
kind: ref.kind,
|
|
612
|
+
amount: slot.count ?? slot.amount,
|
|
613
|
+
chance: slot.chance,
|
|
614
|
+
};
|
|
615
|
+
const x = (slot.x! - scroll.x) * scale;
|
|
616
|
+
const y = (slot.y! - scroll.y) * scale;
|
|
617
|
+
const cell =
|
|
618
|
+
Math.max(slot.w ?? 0, slot.h ?? 0, FALLBACK_PITCH) * scale;
|
|
619
|
+
const shifted = (horizontal ? x : y) - offset * scale;
|
|
620
|
+
if (shifted < -cell || shifted > paneSpan * scale) return null;
|
|
621
|
+
return (
|
|
622
|
+
<span
|
|
623
|
+
key={`${member.id}:${index}`}
|
|
624
|
+
className="pointer-events-auto absolute"
|
|
625
|
+
style={{
|
|
626
|
+
left: horizontal ? shifted : x,
|
|
627
|
+
top: horizontal ? y : shifted,
|
|
628
|
+
width: cell,
|
|
629
|
+
height: cell,
|
|
630
|
+
}}
|
|
631
|
+
>
|
|
632
|
+
<StripCardMember
|
|
633
|
+
member={member}
|
|
634
|
+
dataset={dataset}
|
|
635
|
+
lang={props.lang}
|
|
636
|
+
langMap={props.langMap}
|
|
637
|
+
nav={props.nav}
|
|
638
|
+
x={0}
|
|
639
|
+
y={0}
|
|
640
|
+
pitch={cell}
|
|
641
|
+
interactive={interactive}
|
|
642
|
+
tooltipLevel={slotTooltip}
|
|
643
|
+
/>
|
|
644
|
+
</span>
|
|
645
|
+
);
|
|
646
|
+
})
|
|
647
|
+
: null}
|
|
648
|
+
</div>
|
|
190
649
|
</>
|
|
191
650
|
)}
|
|
651
|
+
{scrollable && (
|
|
652
|
+
<CardScrollbar
|
|
653
|
+
controlsId={paneId}
|
|
654
|
+
left={barRect.left}
|
|
655
|
+
top={barRect.top}
|
|
656
|
+
w={barRect.w}
|
|
657
|
+
h={barRect.h}
|
|
658
|
+
axis={horizontal ? 'horizontal' : 'vertical'}
|
|
659
|
+
thumbRatio={paneSpan / Math.max(1, contentSpan)}
|
|
660
|
+
position={maxOffset > 0 ? offset / maxOffset : 0}
|
|
661
|
+
scale={scale}
|
|
662
|
+
onScroll={(pos) => setOffset(pos * maxOffset)}
|
|
663
|
+
skin={barSkin}
|
|
664
|
+
/>
|
|
665
|
+
)}
|
|
192
666
|
</div>
|
|
193
667
|
);
|
|
194
668
|
}
|