@terrafirmagreg-team/recipe 1.2.21 → 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 +5 -5
- 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/paged-card.tsx +5 -0
- package/src/components/cards/scroll-card/index.tsx +668 -0
- 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/components/tree.tsx +30 -32
- 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 +202 -0
|
@@ -4,71 +4,23 @@ import { useState } from 'react';
|
|
|
4
4
|
import { Check, Copy } from 'lucide-react';
|
|
5
5
|
import { useCopyButton } from '@terrafirmagreg-team/ui/hooks/use-copy-button';
|
|
6
6
|
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
7
|
+
import { CardPager } from '@terrafirmagreg-team/recipe/components/cards/controls/card-pager';
|
|
8
|
+
import { texturePublicUrl } from '@terrafirmagreg-team/dump/lib/dump/assets/urls';
|
|
9
|
+
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
dir,
|
|
12
|
-
scale,
|
|
13
|
-
disabled,
|
|
14
|
-
onClick,
|
|
15
|
-
}: {
|
|
11
|
+
const BUTTONS_TEX = 'emi:textures/gui/buttons.png';
|
|
12
|
+
|
|
13
|
+
export function StripCardTagPager(props: {
|
|
16
14
|
left: number;
|
|
17
15
|
top: number;
|
|
18
16
|
dir: -1 | 1;
|
|
19
17
|
scale: number;
|
|
20
18
|
disabled: boolean;
|
|
21
19
|
onClick: () => void;
|
|
20
|
+
dataset: DatasetRef;
|
|
22
21
|
}) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const arrow = `${3.5 * scale}px solid ${disabled ? 'var(--color-mc-inset)' : hover ? 'var(--color-mc-arrow-dark)' : 'var(--color-mc-arrow)'}`;
|
|
26
|
-
return (
|
|
27
|
-
<button
|
|
28
|
-
type="button"
|
|
29
|
-
aria-label={
|
|
30
|
-
dir < 0
|
|
31
|
-
? t('Previous Page', { note: 'ui.prev_page' })
|
|
32
|
-
: t('Next Page', { note: 'ui.next_page' })
|
|
33
|
-
}
|
|
34
|
-
disabled={disabled}
|
|
35
|
-
onClick={onClick}
|
|
36
|
-
onMouseEnter={() => setHover(true)}
|
|
37
|
-
onMouseLeave={() => setHover(false)}
|
|
38
|
-
onFocus={() => setHover(true)}
|
|
39
|
-
onBlur={() => setHover(false)}
|
|
40
|
-
className="absolute flex cursor-pointer items-center justify-center border-0 bg-transparent p-0 outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-default"
|
|
41
|
-
style={{
|
|
42
|
-
left: left - 4 * scale,
|
|
43
|
-
top: top - 4 * scale,
|
|
44
|
-
width: 20 * scale,
|
|
45
|
-
height: 20 * scale,
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<span
|
|
49
|
-
aria-hidden
|
|
50
|
-
className="flex items-center justify-center"
|
|
51
|
-
style={{
|
|
52
|
-
width: 12 * scale,
|
|
53
|
-
height: 12 * scale,
|
|
54
|
-
background: disabled ? 'var(--color-mc-dim)' : hover ? 'var(--color-mc-bright)' : 'var(--color-mc-panel)',
|
|
55
|
-
boxShadow: `inset ${scale}px ${scale}px 0 rgba(255,255,255,0.65), inset -${scale}px -${scale}px 0 rgba(0,0,0,0.45)`,
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
58
|
-
<span
|
|
59
|
-
aria-hidden
|
|
60
|
-
className="block"
|
|
61
|
-
style={{
|
|
62
|
-
width: 0,
|
|
63
|
-
height: 0,
|
|
64
|
-
borderTop: `${2.5 * scale}px solid transparent`,
|
|
65
|
-
borderBottom: `${2.5 * scale}px solid transparent`,
|
|
66
|
-
...(dir < 0 ? { borderRight: arrow } : { borderLeft: arrow }),
|
|
67
|
-
}}
|
|
68
|
-
/>
|
|
69
|
-
</span>
|
|
70
|
-
</button>
|
|
71
|
-
);
|
|
22
|
+
const { dataset, ...rest } = props;
|
|
23
|
+
return <CardPager {...rest} tex={texturePublicUrl(dataset, BUTTONS_TEX)} />;
|
|
72
24
|
}
|
|
73
25
|
|
|
74
26
|
export function StripCardTagCopy({
|
|
@@ -189,6 +189,7 @@ export function StripCard({
|
|
|
189
189
|
scale={scale}
|
|
190
190
|
disabled={clamped <= 0}
|
|
191
191
|
onClick={() => setPage(clamped - 1)}
|
|
192
|
+
dataset={dataset}
|
|
192
193
|
/>
|
|
193
194
|
<StripCardTagPager
|
|
194
195
|
left={(margin + guiW - 14) * scale}
|
|
@@ -197,6 +198,7 @@ export function StripCard({
|
|
|
197
198
|
scale={scale}
|
|
198
199
|
disabled={clamped + 1 >= pages}
|
|
199
200
|
onClick={() => setPage(clamped + 1)}
|
|
201
|
+
dataset={dataset}
|
|
200
202
|
/>
|
|
201
203
|
</>
|
|
202
204
|
)}
|
|
@@ -3,6 +3,7 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
|
3
3
|
|
|
4
4
|
import Link from 'next/link';
|
|
5
5
|
import { EntryIcon } from '@terrafirmagreg-team/game/components/entry/icon';
|
|
6
|
+
import { McText } from '@terrafirmagreg-team/game/components/entry/mc-text';
|
|
6
7
|
import {
|
|
7
8
|
EntryTooltip,
|
|
8
9
|
type EntryTooltipLevel,
|
|
@@ -31,6 +32,8 @@ export function StripCardMember({
|
|
|
31
32
|
x,
|
|
32
33
|
y,
|
|
33
34
|
pitch,
|
|
35
|
+
hideIcon,
|
|
36
|
+
tooltipLines,
|
|
34
37
|
interactive = true,
|
|
35
38
|
tooltipLevel,
|
|
36
39
|
}: {
|
|
@@ -42,12 +45,17 @@ export function StripCardMember({
|
|
|
42
45
|
x: number;
|
|
43
46
|
y: number;
|
|
44
47
|
pitch: number;
|
|
48
|
+
hideIcon?: boolean;
|
|
49
|
+
tooltipLines?: string[];
|
|
45
50
|
interactive?: boolean;
|
|
46
51
|
tooltipLevel?: EntryTooltipLevel;
|
|
47
52
|
}) {
|
|
48
53
|
const kind = MEMBER_KIND[member.kind ?? 'item'] ?? 'item';
|
|
49
54
|
const name = stackDisplayName(langMap, member.id);
|
|
50
|
-
const checkKind =
|
|
55
|
+
const checkKind =
|
|
56
|
+
kind === 'item' || kind === 'fluid' || kind === 'block' || kind === 'entity'
|
|
57
|
+
? kind
|
|
58
|
+
: undefined;
|
|
51
59
|
const stackPeek =
|
|
52
60
|
dataset && checkKind
|
|
53
61
|
? loadStackDisplay.peek(dataset, member.id, checkKind)
|
|
@@ -77,15 +85,20 @@ export function StripCardMember({
|
|
|
77
85
|
}
|
|
78
86
|
const inner = (
|
|
79
87
|
<>
|
|
80
|
-
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
{hideIcon ? null : (
|
|
89
|
+
<span
|
|
90
|
+
className="pointer-events-none absolute flex justify-center"
|
|
91
|
+
style={{ inset: 0, alignItems: 'center' }}
|
|
92
|
+
>
|
|
93
|
+
<EntryIcon
|
|
94
|
+
id={member.id}
|
|
95
|
+
kind={kind}
|
|
96
|
+
dataset={dataset}
|
|
97
|
+
size={Math.max(8, pitch - 4)}
|
|
98
|
+
missing="placeholder"
|
|
99
|
+
/>
|
|
100
|
+
</span>
|
|
101
|
+
)}
|
|
89
102
|
{badges.length > 0 && (
|
|
90
103
|
<span
|
|
91
104
|
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-white [text-shadow:1px_1px_0_var(--color-mc-arrow)]"
|
|
@@ -96,6 +109,15 @@ export function StripCardMember({
|
|
|
96
109
|
)}
|
|
97
110
|
</>
|
|
98
111
|
);
|
|
112
|
+
const footer = tooltipLines?.length ? (
|
|
113
|
+
<>
|
|
114
|
+
{tooltipLines.map((line, index) => (
|
|
115
|
+
<p key={`${index}:${line}`} className="text-muted-foreground">
|
|
116
|
+
<McText text={line} surface="inverted" />
|
|
117
|
+
</p>
|
|
118
|
+
))}
|
|
119
|
+
</>
|
|
120
|
+
) : undefined;
|
|
99
121
|
const faceStyle = { left: x, top: y, width: pitch, height: pitch };
|
|
100
122
|
const hover = {
|
|
101
123
|
onMouseEnter: () => {
|
|
@@ -118,10 +140,11 @@ export function StripCardMember({
|
|
|
118
140
|
dataset={dataset}
|
|
119
141
|
id={member.id}
|
|
120
142
|
name={name}
|
|
121
|
-
kind={kind
|
|
143
|
+
kind={kind}
|
|
122
144
|
lang={lang}
|
|
123
145
|
langMap={langMap}
|
|
124
146
|
level={tooltipLevel}
|
|
147
|
+
footer={footer}
|
|
125
148
|
>
|
|
126
149
|
<span
|
|
127
150
|
{...hover}
|
|
@@ -139,10 +162,11 @@ export function StripCardMember({
|
|
|
139
162
|
dataset={dataset}
|
|
140
163
|
id={member.id}
|
|
141
164
|
name={name}
|
|
142
|
-
kind={kind
|
|
165
|
+
kind={kind}
|
|
143
166
|
lang={lang}
|
|
144
167
|
langMap={langMap}
|
|
145
168
|
level={tooltipLevel}
|
|
169
|
+
footer={footer}
|
|
146
170
|
>
|
|
147
171
|
<span
|
|
148
172
|
{...hover}
|
package/src/components/tree.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { encodeQueryValue } from '@terrafirmagreg-team/translate/lib/url';
|
|
|
13
13
|
import { recipeBasePath } from '@terrafirmagreg-team/recipe/lib/links';
|
|
14
14
|
import { sectionDatasets } from '@terrafirmagreg-team/kit/lib/datasets';
|
|
15
15
|
import type { DumpRecipeCategory } from '@terrafirmagreg-team/recipe/lib/data/category/dto';
|
|
16
|
+
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
16
17
|
import type { SectionTrees } from '@terrafirmagreg-team/kit/types';
|
|
17
18
|
|
|
18
19
|
function categoryIcon(
|
|
@@ -53,48 +54,45 @@ function categoryLeaf(
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
const recipeTreesCache = createAsyncCache(
|
|
56
|
-
|
|
57
|
-
() =>
|
|
57
|
+
(lang: Lang): Promise<SectionTrees> => buildRecipeTrees(lang),
|
|
58
|
+
(lang) => `recipe-trees/${lang}`,
|
|
58
59
|
DUMP_POINTER_TTL,
|
|
59
60
|
);
|
|
60
61
|
|
|
61
|
-
export function recipeTrees(): Promise<SectionTrees> {
|
|
62
|
-
return recipeTreesCache();
|
|
62
|
+
export function recipeTrees(lang: Lang): Promise<SectionTrees> {
|
|
63
|
+
return recipeTreesCache(lang);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
async function buildRecipeTrees(): Promise<SectionTrees> {
|
|
66
|
+
async function buildRecipeTrees(lang: Lang): Promise<SectionTrees> {
|
|
66
67
|
const { defaultLanguage } = loadLocaleRegistry();
|
|
67
68
|
const datasets = await sectionDatasets('recipe');
|
|
68
69
|
const trees: SectionTrees = {};
|
|
69
70
|
for (const { id, title: datasetTitle, languages } of datasets) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
.filter((row) => (row.count ?? 0) > 0)
|
|
80
|
-
.map((row) => row.id),
|
|
81
|
-
)
|
|
82
|
-
: undefined;
|
|
83
|
-
const leaves = [...categories]
|
|
84
|
-
.filter((category) => !nonEmpty || nonEmpty.has(category.id))
|
|
85
|
-
.sort(
|
|
86
|
-
(a, b) =>
|
|
87
|
-
creativeTabName(map, a.display?.name).localeCompare(
|
|
88
|
-
creativeTabName(map, b.display?.name),
|
|
89
|
-
) || a.id.localeCompare(b.id),
|
|
71
|
+
if (!(languages ?? [defaultLanguage]).includes(lang)) continue;
|
|
72
|
+
const ref = { id };
|
|
73
|
+
const map = await loadMergedLangMap(ref, lang);
|
|
74
|
+
const source = getRecipeSource();
|
|
75
|
+
const categories = await source.categories(ref);
|
|
76
|
+
const types = (await source.manifest(ref))?.indexes.recipes.types;
|
|
77
|
+
const nonEmpty = types
|
|
78
|
+
? new Set(
|
|
79
|
+
types.filter((row) => (row.count ?? 0) > 0).map((row) => row.id),
|
|
90
80
|
)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
: undefined;
|
|
82
|
+
const leaves = [...categories]
|
|
83
|
+
.filter((category) => !nonEmpty || nonEmpty.has(category.id))
|
|
84
|
+
.sort(
|
|
85
|
+
(a, b) =>
|
|
86
|
+
creativeTabName(map, a.display?.name).localeCompare(
|
|
87
|
+
creativeTabName(map, b.display?.name),
|
|
88
|
+
) || a.id.localeCompare(b.id),
|
|
89
|
+
)
|
|
90
|
+
.map((category) => categoryLeaf(ref, category, map));
|
|
91
|
+
(trees[lang] ??= {})[id] = {
|
|
92
|
+
name: datasetTitle ?? id,
|
|
93
|
+
children: leaves,
|
|
94
|
+
$id: `recipe/${id}/${lang}`,
|
|
95
|
+
} satisfies PageTree.Root;
|
|
98
96
|
}
|
|
99
97
|
return trees;
|
|
100
98
|
}
|
package/src/hooks/use-index.ts
CHANGED
|
@@ -30,6 +30,7 @@ export function useRecipeIndex(dataset: DatasetRef | undefined, lang: string) {
|
|
|
30
30
|
const [loaded, setLoaded] = useState<LoadedIndex | null>(null);
|
|
31
31
|
const [complete, setComplete] = useState<string | null>(null);
|
|
32
32
|
const [lastFull, setLastFull] = useState<RecipeCompactIndex | null>(null);
|
|
33
|
+
const [warmKey, setWarmKey] = useState<string | null>(null);
|
|
33
34
|
const nonce = useDumpRetryNonce();
|
|
34
35
|
const { locales: items } = useLang();
|
|
35
36
|
const locales = useMemo(
|
|
@@ -62,20 +63,19 @@ export function useRecipeIndex(dataset: DatasetRef | undefined, lang: string) {
|
|
|
62
63
|
[lang]: { ...entityNames, ...index.names[lang] },
|
|
63
64
|
},
|
|
64
65
|
});
|
|
65
|
-
|
|
66
|
+
setWarmKey(key);
|
|
67
|
+
}, [dataset, lang, nonce, key]);
|
|
66
68
|
|
|
67
69
|
useAsyncEffect(async (isCancelled) => {
|
|
68
|
-
if (!dataset) return;
|
|
69
|
-
const
|
|
70
|
-
for (const entry of others) {
|
|
71
|
-
if (isCancelled()) return;
|
|
70
|
+
if (!dataset || warmKey !== key) return;
|
|
71
|
+
for (const entry of locales.filter((item) => item !== lang)) {
|
|
72
72
|
await idle();
|
|
73
73
|
if (isCancelled()) return;
|
|
74
|
-
const
|
|
74
|
+
const other = await loadRecipeChromeClient(dataset, entry);
|
|
75
75
|
if (isCancelled()) return;
|
|
76
|
-
await loadRecipeCompactIndex(dataset,
|
|
76
|
+
await loadRecipeCompactIndex(dataset, other);
|
|
77
77
|
}
|
|
78
|
-
}, [dataset, lang, locales]);
|
|
78
|
+
}, [dataset, lang, locales, warmKey, key]);
|
|
79
79
|
|
|
80
80
|
const active = loaded?.key === key ? loaded.index : null;
|
|
81
81
|
const index = active?.items.length ? active : (lastFull ?? active);
|
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { usePathname } from 'next/navigation';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
2
|
import type * as PageTree from 'fumadocs-core/page-tree';
|
|
5
|
-
import {
|
|
3
|
+
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
6
4
|
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
7
5
|
import { useLastValue } from '@terrafirmagreg-team/ui/hooks/use-last-value';
|
|
8
6
|
import { skeletonTree } from '@terrafirmagreg-team/ui/lib/tree';
|
|
9
7
|
import { useRecipeModNames } from '@terrafirmagreg-team/recipe/hooks/use-mod-names';
|
|
10
8
|
import { useSidebarGroup } from '@terrafirmagreg-team/recipe/hooks/use-sidebar-group';
|
|
11
9
|
import { groupRecipeSidebarByMod } from '@terrafirmagreg-team/recipe/lib/browser/sidebar';
|
|
12
|
-
import { parseSectionLocation } from '@terrafirmagreg-team/sites/location';
|
|
13
|
-
import { useVersionPreference } from '@terrafirmagreg-team/kit/hooks/use-version-pref';
|
|
14
10
|
|
|
15
|
-
export function useRecipeLeftSidebarTree(
|
|
16
|
-
|
|
11
|
+
export function useRecipeLeftSidebarTree(
|
|
12
|
+
tree: PageTree.Root,
|
|
13
|
+
dataset?: DatasetRef,
|
|
14
|
+
): PageTree.Root {
|
|
17
15
|
const lang = useResolvedLang();
|
|
18
16
|
const { sidebarGroup } = useSidebarGroup();
|
|
19
|
-
const scopeKey = datasetId ?? '';
|
|
20
|
-
const versionParam = useLocationSearchParams().get('version') ?? undefined;
|
|
21
|
-
const preferred = useVersionPreference(datasetId);
|
|
22
|
-
const version = versionParam ?? preferred;
|
|
23
|
-
const dataset = useMemo(
|
|
24
|
-
() => (datasetId ? { id: datasetId, version } : undefined),
|
|
25
|
-
[datasetId, version],
|
|
26
|
-
);
|
|
27
17
|
const result = useRecipeModNames(
|
|
28
18
|
sidebarGroup === 'mod' ? dataset : undefined,
|
|
29
19
|
lang,
|
|
30
20
|
);
|
|
31
|
-
const modNames = useLastValue(result.value,
|
|
21
|
+
const modNames = useLastValue(result.value, dataset?.id ?? '');
|
|
32
22
|
if (sidebarGroup === 'mod' && !modNames && result.pending)
|
|
33
23
|
return skeletonTree('recipe:skeleton');
|
|
34
24
|
return sidebarGroup === 'mod' && modNames
|
|
@@ -4,26 +4,22 @@ import type {
|
|
|
4
4
|
RecipeChrome,
|
|
5
5
|
RecipeStackGroup,
|
|
6
6
|
} from '@terrafirmagreg-team/recipe/types';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
clientDumpLang,
|
|
9
|
+
clientDumpNames,
|
|
10
|
+
loadClientManifest,
|
|
11
|
+
} from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
8
12
|
import {
|
|
9
13
|
creativeTabName,
|
|
10
14
|
dumpTextString,
|
|
11
15
|
} from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
loadClientRegistry,
|
|
15
|
-
loadClientRegistryOrder,
|
|
16
|
-
resolveClientStackDisplay,
|
|
17
|
-
} from '@terrafirmagreg-team/dump/lib/dump/client/registry';
|
|
16
|
+
import { loadClientRegistryOrder } from '@terrafirmagreg-team/dump/lib/dump/client/registry';
|
|
18
17
|
import { loadClientTagMembers } from '@terrafirmagreg-team/dump/lib/dump/client/tags';
|
|
19
18
|
import { loadClientTabs } from '@terrafirmagreg-team/dump/lib/dump/client/tabs';
|
|
20
19
|
import { loadDatasetRecipeCategories } from '@terrafirmagreg-team/recipe/lib/data/category/load';
|
|
21
20
|
import { loadClientRegistryGroups } from '@terrafirmagreg-team/dump/lib/dump/client/groups';
|
|
22
21
|
import { loadClientModNames } from '@terrafirmagreg-team/dump/lib/dump/client/mods';
|
|
23
|
-
import {
|
|
24
|
-
import { lookupSpriteInBundle } from '@terrafirmagreg-team/dump/lib/dump/assets/atlas/lookup';
|
|
25
|
-
import { stackIdBase, stackIdFromRef } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
26
|
-
import type { AtlasBundle } from '@terrafirmagreg-team/dump/lib/dump/assets/atlas/dto';
|
|
22
|
+
import { stackIdFromRef } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
27
23
|
import { createDatasetCache } from '@terrafirmagreg-team/dump/lib/dump/reader';
|
|
28
24
|
|
|
29
25
|
async function clientEntityNames(
|
|
@@ -31,49 +27,15 @@ async function clientEntityNames(
|
|
|
31
27
|
lang: string,
|
|
32
28
|
ids: Iterable<string>,
|
|
33
29
|
): Promise<Record<string, string>> {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const info = new Map<string, { baseId: string; langKey?: string }>();
|
|
41
|
-
const mods = new Set<string>();
|
|
42
|
-
for (const id of all) {
|
|
43
|
-
const baseId = stackIdBase(id);
|
|
44
|
-
const langKey = resolveClientStackDisplay(id, items, fluids)?.name;
|
|
45
|
-
info.set(id, { baseId, ...(langKey ? { langKey } : {}) });
|
|
46
|
-
if (!langKey && baseId.includes(':') && !baseId.startsWith('#')) {
|
|
47
|
-
const mod = baseId.split(':', 2)[0];
|
|
48
|
-
if (mod) mods.add(mod);
|
|
30
|
+
const table = await clientDumpNames(dataset, lang);
|
|
31
|
+
for (const id of ids) {
|
|
32
|
+
if (table[id] === undefined) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`dump names missing id "${id}" for ${dataset.id} lang=${lang}`,
|
|
35
|
+
);
|
|
49
36
|
}
|
|
50
37
|
}
|
|
51
|
-
|
|
52
|
-
await Promise.all(
|
|
53
|
-
[...mods].map(async (mod) => {
|
|
54
|
-
atlases.set(mod, await loadClientModAtlases(dataset, mod));
|
|
55
|
-
}),
|
|
56
|
-
);
|
|
57
|
-
const names: Record<string, string> = { ...map };
|
|
58
|
-
let processed = 0;
|
|
59
|
-
for (const [id, entry] of info) {
|
|
60
|
-
if (++processed % 2000 === 0) {
|
|
61
|
-
await new Promise((resolve) => setTimeout(resolve));
|
|
62
|
-
}
|
|
63
|
-
const langKey =
|
|
64
|
-
entry.langKey ??
|
|
65
|
-
lookupSpriteInBundle(
|
|
66
|
-
atlases.get(entry.baseId.split(':', 2)[0] ?? ''),
|
|
67
|
-
entry.baseId,
|
|
68
|
-
)?.sprite.langKey;
|
|
69
|
-
const kind = entry.baseId.startsWith('#')
|
|
70
|
-
? undefined
|
|
71
|
-
: fluids.has(entry.baseId)
|
|
72
|
-
? 'fluid'
|
|
73
|
-
: 'item';
|
|
74
|
-
names[id] = stackDisplayName(map, id, kind, langKey);
|
|
75
|
-
}
|
|
76
|
-
return names;
|
|
38
|
+
return { ...table };
|
|
77
39
|
}
|
|
78
40
|
|
|
79
41
|
async function clientNamedCategories(
|
|
@@ -56,12 +56,13 @@ const typeRowsCache = createDatasetCache(
|
|
|
56
56
|
});
|
|
57
57
|
}),
|
|
58
58
|
);
|
|
59
|
-
|
|
59
|
+
const rows = buckets
|
|
60
60
|
.flat()
|
|
61
61
|
.sort(
|
|
62
62
|
(a, b) =>
|
|
63
63
|
(a.o ?? Number.MAX_SAFE_INTEGER) - (b.o ?? Number.MAX_SAFE_INTEGER),
|
|
64
64
|
);
|
|
65
|
+
return rows;
|
|
65
66
|
},
|
|
66
67
|
(dataset, _index, typeId) => `${dataset.id}/${dataset.version ?? ''} ${typeId}`,
|
|
67
68
|
);
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asBool,
|
|
3
|
+
asNumber,
|
|
4
|
+
asRecord,
|
|
5
|
+
asString,
|
|
6
|
+
} from '@terrafirmagreg-team/dump/lib/dump/contract/read';
|
|
7
|
+
import {
|
|
8
|
+
asTaggedReference,
|
|
9
|
+
type TaggedReference,
|
|
10
|
+
} from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
11
|
+
|
|
12
|
+
export type ScrollRect = { x: number; y: number; w: number; h: number };
|
|
13
|
+
|
|
14
|
+
export type ScrollBarSkinPiece = {
|
|
15
|
+
u: number;
|
|
16
|
+
v: number;
|
|
17
|
+
w: number;
|
|
18
|
+
h: number;
|
|
19
|
+
s: number | number[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ScrollBarSkin = {
|
|
23
|
+
track: ScrollBarSkinPiece;
|
|
24
|
+
thumb: ScrollBarSkinPiece;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type ScrollFrame = {
|
|
28
|
+
tex: string;
|
|
29
|
+
u: number;
|
|
30
|
+
v: number;
|
|
31
|
+
s: number;
|
|
32
|
+
t: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type ScrollElement = {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
w: number;
|
|
39
|
+
h: number;
|
|
40
|
+
kind: 'slot' | 'text' | 'block' | 'entity';
|
|
41
|
+
ref?: TaggedReference;
|
|
42
|
+
base?: TaggedReference;
|
|
43
|
+
mark?: boolean;
|
|
44
|
+
tooltip?: string[];
|
|
45
|
+
label?: string;
|
|
46
|
+
text?: string;
|
|
47
|
+
color?: number;
|
|
48
|
+
pin?: boolean;
|
|
49
|
+
u?: number;
|
|
50
|
+
v?: number;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type RecipeScroll = {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
w: number;
|
|
57
|
+
h: number;
|
|
58
|
+
axis: 'vertical' | 'horizontal';
|
|
59
|
+
contentH: number;
|
|
60
|
+
contentW: number;
|
|
61
|
+
bar?: ScrollRect;
|
|
62
|
+
viewport?: ScrollRect;
|
|
63
|
+
clipTop?: number;
|
|
64
|
+
guiTex?: string;
|
|
65
|
+
barSkin?: ScrollBarSkin;
|
|
66
|
+
frame?: ScrollFrame;
|
|
67
|
+
slotTex?: string;
|
|
68
|
+
overlay?: string;
|
|
69
|
+
overlayW?: number;
|
|
70
|
+
overlayH?: number;
|
|
71
|
+
decomposed?: boolean;
|
|
72
|
+
elements?: ScrollElement[];
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
function scrollRect(value: unknown): ScrollRect | undefined {
|
|
76
|
+
const raw = asRecord(value);
|
|
77
|
+
if (!raw) return undefined;
|
|
78
|
+
const x = asNumber(raw.x);
|
|
79
|
+
const y = asNumber(raw.y);
|
|
80
|
+
const w = asNumber(raw.w);
|
|
81
|
+
const h = asNumber(raw.h);
|
|
82
|
+
if (x === undefined || y === undefined || !w || !h) return undefined;
|
|
83
|
+
return { x, y, w, h };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function skinPiece(value: unknown): ScrollBarSkinPiece | undefined {
|
|
87
|
+
const raw = asRecord(value);
|
|
88
|
+
if (!raw) return undefined;
|
|
89
|
+
const u = asNumber(raw.u);
|
|
90
|
+
const v = asNumber(raw.v);
|
|
91
|
+
const w = asNumber(raw.w);
|
|
92
|
+
const h = asNumber(raw.h);
|
|
93
|
+
if (u === undefined || v === undefined || !w || !h) return undefined;
|
|
94
|
+
const s = raw.s;
|
|
95
|
+
const slices = Array.isArray(s)
|
|
96
|
+
? s.map(asNumber).filter((n): n is number => n !== undefined)
|
|
97
|
+
: (asNumber(s) ?? 0);
|
|
98
|
+
return { u, v, w, h, s: slices };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function scrollFrame(value: unknown): ScrollFrame | undefined {
|
|
102
|
+
const raw = asRecord(value);
|
|
103
|
+
if (!raw) return undefined;
|
|
104
|
+
const tex = asString(raw.tex);
|
|
105
|
+
const u = asNumber(raw.u);
|
|
106
|
+
const v = asNumber(raw.v);
|
|
107
|
+
const s = asNumber(raw.s);
|
|
108
|
+
const t = asNumber(raw.t);
|
|
109
|
+
if (!tex || u === undefined || v === undefined || !s || !t) return undefined;
|
|
110
|
+
return { tex, u, v, s, t };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function scrollElement(value: unknown): ScrollElement | undefined {
|
|
114
|
+
const raw = asRecord(value);
|
|
115
|
+
if (!raw) return undefined;
|
|
116
|
+
const x = asNumber(raw.x);
|
|
117
|
+
const y = asNumber(raw.y);
|
|
118
|
+
if (x === undefined || y === undefined) return undefined;
|
|
119
|
+
const kind = asString(raw.kind);
|
|
120
|
+
if (
|
|
121
|
+
kind !== 'slot' &&
|
|
122
|
+
kind !== 'text' &&
|
|
123
|
+
kind !== 'block' &&
|
|
124
|
+
kind !== 'entity'
|
|
125
|
+
)
|
|
126
|
+
return undefined;
|
|
127
|
+
const w = asNumber(raw.w);
|
|
128
|
+
const h = asNumber(raw.h);
|
|
129
|
+
return {
|
|
130
|
+
x,
|
|
131
|
+
y,
|
|
132
|
+
w: w ?? 18,
|
|
133
|
+
h: h ?? 18,
|
|
134
|
+
kind,
|
|
135
|
+
ref: asTaggedReference(raw.ref),
|
|
136
|
+
base: asTaggedReference(raw.base),
|
|
137
|
+
mark: asBool(raw.mark) === true || undefined,
|
|
138
|
+
tooltip: Array.isArray(raw.tooltip)
|
|
139
|
+
? raw.tooltip
|
|
140
|
+
.map(asString)
|
|
141
|
+
.filter((line): line is string => line !== undefined && line.length > 0)
|
|
142
|
+
: undefined,
|
|
143
|
+
label: asString(raw.label),
|
|
144
|
+
text: asString(raw.text),
|
|
145
|
+
color: asNumber(raw.color),
|
|
146
|
+
pin: asBool(raw.pin) === true || undefined,
|
|
147
|
+
u: asNumber(raw.u),
|
|
148
|
+
v: asNumber(raw.v),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function recipeScroll(
|
|
153
|
+
properties: Record<string, unknown> | undefined,
|
|
154
|
+
): RecipeScroll | undefined {
|
|
155
|
+
const raw = asRecord(properties?.scroll);
|
|
156
|
+
if (!raw) return undefined;
|
|
157
|
+
const x = asNumber(raw.x);
|
|
158
|
+
const y = asNumber(raw.y);
|
|
159
|
+
const w = asNumber(raw.w);
|
|
160
|
+
const h = asNumber(raw.h);
|
|
161
|
+
const contentH = asNumber(raw.contentH) ?? 0;
|
|
162
|
+
const contentW = asNumber(raw.contentW) ?? 0;
|
|
163
|
+
if (x === undefined || y === undefined || !w || !h) return undefined;
|
|
164
|
+
const axis = asString(raw.axis) === 'horizontal' ? 'horizontal' : 'vertical';
|
|
165
|
+
const rawSkin = asRecord(raw.barSkin);
|
|
166
|
+
const barSkin =
|
|
167
|
+
rawSkin !== undefined
|
|
168
|
+
? {
|
|
169
|
+
track: skinPiece(rawSkin.track),
|
|
170
|
+
thumb: skinPiece(rawSkin.thumb),
|
|
171
|
+
}
|
|
172
|
+
: undefined;
|
|
173
|
+
const elements = Array.isArray(raw.elements)
|
|
174
|
+
? raw.elements
|
|
175
|
+
.map(scrollElement)
|
|
176
|
+
.filter((el): el is ScrollElement => el !== undefined)
|
|
177
|
+
: undefined;
|
|
178
|
+
return {
|
|
179
|
+
x,
|
|
180
|
+
y,
|
|
181
|
+
w,
|
|
182
|
+
h,
|
|
183
|
+
axis,
|
|
184
|
+
contentH,
|
|
185
|
+
contentW,
|
|
186
|
+
bar: scrollRect(raw.bar),
|
|
187
|
+
viewport: scrollRect(raw.viewport),
|
|
188
|
+
clipTop: asNumber(raw.clipTop) || undefined,
|
|
189
|
+
guiTex: asString(raw.guiTex),
|
|
190
|
+
barSkin:
|
|
191
|
+
barSkin?.track !== undefined && barSkin.thumb !== undefined
|
|
192
|
+
? { track: barSkin.track, thumb: barSkin.thumb }
|
|
193
|
+
: undefined,
|
|
194
|
+
frame: scrollFrame(raw.frame),
|
|
195
|
+
slotTex: asString(raw.slotTex),
|
|
196
|
+
overlay: asString(raw.overlay),
|
|
197
|
+
overlayW: asNumber(raw.overlayW),
|
|
198
|
+
overlayH: asNumber(raw.overlayH),
|
|
199
|
+
decomposed: asBool(raw.decomposed) === true || undefined,
|
|
200
|
+
elements: elements && elements.length > 0 ? elements : undefined,
|
|
201
|
+
};
|
|
202
|
+
}
|