@terrafirmagreg-team/recipe 1.2.33 → 1.2.35
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 +4 -4
- package/src/components/cards/card/strip.tsx +1 -0
- package/src/components/cards/card/text.tsx +4 -3
- package/src/components/cards/scroll-card/index.tsx +2 -1
- package/src/components/cards/slot-hitbox.tsx +2 -2
- package/src/components/cards/strip-card/member-cell.tsx +1 -1
- package/src/components/views/browser/frame.tsx +1 -0
- package/src/components/views/browser/item-panel/index.tsx +2 -2
- package/src/components/views/browser/item-panel-grid/cell.tsx +6 -4
- package/src/components/views/browser/item-panel-grid/index.tsx +0 -4
- package/src/components/views/browser/query-controls.tsx +1 -0
- package/src/components/views/browser/type-tabs.tsx +1 -0
- package/src/components/views/calc/calculator/index.tsx +2 -3
- package/src/hooks/calc/use-actions.ts +1 -11
- package/src/hooks/calc/use-far-mode.ts +2 -2
- package/src/hooks/calc/use-view-mode.ts +1 -1
- package/src/hooks/use-hide-unused.ts +1 -1
- package/src/hooks/use-panel-cells.ts +11 -1
- package/src/hooks/use-panel-tabs.ts +8 -3
- package/src/lib/browser/lookup.ts +22 -4
- package/src/lib/browser/panel.ts +38 -6
- package/src/types/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/recipe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.35",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Recipe viewer and calculator",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@terrafirmagreg-team/data": "^1.2.14",
|
|
27
27
|
"@terrafirmagreg-team/dump": "^1.2.25",
|
|
28
|
-
"@terrafirmagreg-team/game": "^1.2.
|
|
29
|
-
"@terrafirmagreg-team/kit": "^1.2.
|
|
28
|
+
"@terrafirmagreg-team/game": "^1.2.15",
|
|
29
|
+
"@terrafirmagreg-team/kit": "^1.2.34",
|
|
30
30
|
"@terrafirmagreg-team/mdx": "^1.2.14",
|
|
31
31
|
"@terrafirmagreg-team/preview": "^1.2.12",
|
|
32
32
|
"@terrafirmagreg-team/sites": "^1.2.5",
|
|
33
33
|
"@terrafirmagreg-team/translate": "^1.2.14",
|
|
34
|
-
"@terrafirmagreg-team/ui": "^1.2.
|
|
34
|
+
"@terrafirmagreg-team/ui": "^1.2.26",
|
|
35
35
|
"@types/pathfinding": "^0.1.0",
|
|
36
36
|
"comlink": "^4.4.2",
|
|
37
37
|
"fflate": "0.8.3",
|
|
@@ -111,6 +111,7 @@ export function CardStrip({
|
|
|
111
111
|
top: widget.y * scale,
|
|
112
112
|
width: widget.w * scale,
|
|
113
113
|
height: widget.h * scale,
|
|
114
|
+
backgroundColor: 'var(--color-mc-inset)',
|
|
114
115
|
backgroundImage: `url(${widgetsUrl})`,
|
|
115
116
|
backgroundSize: `${256 * scale}px ${256 * scale}px`,
|
|
116
117
|
backgroundPosition: '0px 0px',
|
|
@@ -26,7 +26,8 @@ export function CardText({
|
|
|
26
26
|
: widget.text;
|
|
27
27
|
if (!content) return null;
|
|
28
28
|
const wrap = widget.type === 'paragraph';
|
|
29
|
-
const rgb = widget.color
|
|
29
|
+
const rgb = (widget.color ?? 0xffffff) & 0xffffff;
|
|
30
|
+
const ink = rgb === 0xffffff ? 0x000000 : rgb;
|
|
30
31
|
return (
|
|
31
32
|
<span
|
|
32
33
|
className={`font-mc pointer-events-none absolute leading-none ${wrap ? 'whitespace-pre-wrap' : 'whitespace-pre'}`}
|
|
@@ -44,10 +45,10 @@ export function CardText({
|
|
|
44
45
|
...(wrap ? { width: widget.w * scale } : {}),
|
|
45
46
|
}),
|
|
46
47
|
fontSize: size ?? 8 * scale,
|
|
47
|
-
color: `#${
|
|
48
|
+
color: `#${ink.toString(16).padStart(6, '0')}`,
|
|
48
49
|
}}
|
|
49
50
|
>
|
|
50
|
-
<McText text={content} surface="
|
|
51
|
+
<McText text={content} surface="light" />
|
|
51
52
|
</span>
|
|
52
53
|
);
|
|
53
54
|
}
|
|
@@ -363,6 +363,7 @@ export function ScrollCard(props: Props) {
|
|
|
363
363
|
aria-hidden
|
|
364
364
|
className="absolute inset-0 block"
|
|
365
365
|
style={{
|
|
366
|
+
backgroundColor: 'var(--color-mc-inset)',
|
|
366
367
|
backgroundImage: `url(${slotTexUrl})`,
|
|
367
368
|
backgroundSize: `${ATLAS * scale}px ${ATLAS * scale}px`,
|
|
368
369
|
backgroundPosition: `-${(el.u ?? 0) * scale}px -${(el.v ?? 0) * scale}px`,
|
|
@@ -411,7 +412,7 @@ export function ScrollCard(props: Props) {
|
|
|
411
412
|
) : null}
|
|
412
413
|
{el.label ? (
|
|
413
414
|
<span
|
|
414
|
-
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-
|
|
415
|
+
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-black"
|
|
415
416
|
style={{ fontSize: (el.w / 16) * 7 * scale }}
|
|
416
417
|
>
|
|
417
418
|
{el.label}
|
|
@@ -142,7 +142,7 @@ export function SlotHitbox({
|
|
|
142
142
|
{widget.kind === 'tag' ? (
|
|
143
143
|
<span
|
|
144
144
|
aria-hidden
|
|
145
|
-
className="font-mc pointer-events-none absolute top-0 left-0 leading-none text-
|
|
145
|
+
className="font-mc pointer-events-none absolute top-0 left-0 leading-none text-black"
|
|
146
146
|
style={{
|
|
147
147
|
paddingLeft: scale / 2,
|
|
148
148
|
fontSize: (Math.min(widget.w, widget.h) / 16) * 7 * scale,
|
|
@@ -163,7 +163,7 @@ export function SlotHitbox({
|
|
|
163
163
|
widget.count !== undefined && widget.count > 1 ? (
|
|
164
164
|
<span
|
|
165
165
|
aria-hidden
|
|
166
|
-
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-
|
|
166
|
+
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-black"
|
|
167
167
|
style={{
|
|
168
168
|
paddingRight: scale,
|
|
169
169
|
paddingBottom: scale,
|
|
@@ -109,7 +109,7 @@ export function StripCardMember({
|
|
|
109
109
|
)}
|
|
110
110
|
{badges.length > 0 && (
|
|
111
111
|
<span
|
|
112
|
-
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-
|
|
112
|
+
className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-black"
|
|
113
113
|
style={{ fontSize: (pitch / 16) * (kind === 'fluid' ? 4 : 7) }}
|
|
114
114
|
>
|
|
115
115
|
{badges.join(' ')}
|
|
@@ -96,7 +96,7 @@ export const ItemPanel = memo(function ItemPanel({
|
|
|
96
96
|
const [expandedGroups, setExpandedGroups] = useState<ReadonlySet<string>>(
|
|
97
97
|
new Set(),
|
|
98
98
|
);
|
|
99
|
-
const { cells, favoriteIds, dIndex, dNames, dLang } =
|
|
99
|
+
const { cells, favoriteIds, dIndex, dNames, dLang, used } =
|
|
100
100
|
usePanelCells({
|
|
101
101
|
dataset,
|
|
102
102
|
index,
|
|
@@ -254,7 +254,7 @@ export const ItemPanel = memo(function ItemPanel({
|
|
|
254
254
|
);
|
|
255
255
|
};
|
|
256
256
|
|
|
257
|
-
const tabOptions = usePanelTabs(dIndex, dNames, dLang);
|
|
257
|
+
const tabOptions = usePanelTabs(dIndex, dNames, dLang, used);
|
|
258
258
|
|
|
259
259
|
const failed = isDatasetFailed(useFailedDatasets(), dataset);
|
|
260
260
|
|
|
@@ -66,7 +66,6 @@ export const PanelCell = memo(function PanelCell({
|
|
|
66
66
|
names,
|
|
67
67
|
nav,
|
|
68
68
|
favIds,
|
|
69
|
-
expandLabel,
|
|
70
69
|
draggableStacks,
|
|
71
70
|
onPress,
|
|
72
71
|
onHover,
|
|
@@ -78,7 +77,6 @@ export const PanelCell = memo(function PanelCell({
|
|
|
78
77
|
names: Record<string, Record<string, string>>;
|
|
79
78
|
nav: RecipeHrefOpts;
|
|
80
79
|
favIds?: ReadonlySet<string>;
|
|
81
|
-
expandLabel: string;
|
|
82
80
|
draggableStacks?: boolean;
|
|
83
81
|
onPress: (id: string, ref?: 'item' | 'fluid') => void;
|
|
84
82
|
onHover?: (target: FavoriteHoverTarget | undefined) => void;
|
|
@@ -117,7 +115,7 @@ export const PanelCell = memo(function PanelCell({
|
|
|
117
115
|
fav={cell.fav}
|
|
118
116
|
/>
|
|
119
117
|
) : cell.kind === 'group' ? (
|
|
120
|
-
<Hint label={cell.
|
|
118
|
+
<Hint label={cell.label}>
|
|
121
119
|
<button
|
|
122
120
|
type="button"
|
|
123
121
|
aria-label={cell.label}
|
|
@@ -126,7 +124,11 @@ export const PanelCell = memo(function PanelCell({
|
|
|
126
124
|
className="block rounded-sm"
|
|
127
125
|
>
|
|
128
126
|
<span className="relative flex size-9 items-center justify-center">
|
|
129
|
-
<EntryGroup
|
|
127
|
+
<EntryGroup
|
|
128
|
+
members={cell.members}
|
|
129
|
+
kind={cell.ref === 'fluid' ? 'fluid' : 'item'}
|
|
130
|
+
size="lg"
|
|
131
|
+
/>
|
|
130
132
|
<Badge className="absolute -right-0.5 -bottom-0.5 z-10 h-auto rounded-sm px-0.5 py-0 leading-tight">
|
|
131
133
|
{cell.expanded ? (
|
|
132
134
|
<Minus className="size-3" />
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
3
3
|
|
|
4
4
|
import { memo } from 'react';
|
|
5
|
-
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
6
5
|
import { PanelCell } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel-grid/cell';
|
|
7
6
|
import { useMountLimit } from '@terrafirmagreg-team/recipe/hooks/use-mount-limit';
|
|
8
7
|
import { useGroupOutlines } from '@terrafirmagreg-team/recipe/hooks/use-group-outlines';
|
|
@@ -47,8 +46,6 @@ export const ItemPanelGrid = memo(function ItemPanelGrid({
|
|
|
47
46
|
eager?: boolean;
|
|
48
47
|
frozen?: boolean;
|
|
49
48
|
}) {
|
|
50
|
-
const t = useTranslations();
|
|
51
|
-
const expandLabel = t('Expand', { note: 'recipe.expand' });
|
|
52
49
|
const limit = useMountLimit(cells.length, resetKey, eager);
|
|
53
50
|
const shown = frozen
|
|
54
51
|
? []
|
|
@@ -81,7 +78,6 @@ export const ItemPanelGrid = memo(function ItemPanelGrid({
|
|
|
81
78
|
names={names}
|
|
82
79
|
nav={nav}
|
|
83
80
|
favIds={favIds}
|
|
84
|
-
expandLabel={expandLabel}
|
|
85
81
|
draggableStacks={draggableStacks}
|
|
86
82
|
onPress={onPress}
|
|
87
83
|
onHover={onHover}
|
|
@@ -61,6 +61,7 @@ export function RecipeTypeTabs({
|
|
|
61
61
|
help: category?.display?.name
|
|
62
62
|
? creativeTabName(langMap ?? {}, category.display.name)
|
|
63
63
|
: recipeItemName(names, lang, id),
|
|
64
|
+
helpKey: category?.display?.name ?? id,
|
|
64
65
|
};
|
|
65
66
|
});
|
|
66
67
|
}, [index, ids, lang, names, dataset, langMap]);
|
|
@@ -84,7 +84,6 @@ export function Calculator({ session }: { session: RecipeSession }) {
|
|
|
84
84
|
nodes: deferredNodes,
|
|
85
85
|
tagMembers,
|
|
86
86
|
ensureMaterial,
|
|
87
|
-
fluids: session.index?.fluids,
|
|
88
87
|
});
|
|
89
88
|
|
|
90
89
|
const iconItems = useMemo(
|
|
@@ -158,8 +157,8 @@ export function Calculator({ session }: { session: RecipeSession }) {
|
|
|
158
157
|
focusNodeId={focusNodeId}
|
|
159
158
|
onFocusedNode={() => setFocusNodeId(null)}
|
|
160
159
|
empty={
|
|
161
|
-
<div className="absolute inset-0 z-10 grid place-items-center overflow-auto p-4">
|
|
162
|
-
<div className="flex flex-col items-center gap-4">
|
|
160
|
+
<div className="pointer-events-none absolute inset-0 z-10 grid place-items-center overflow-auto p-4">
|
|
161
|
+
<div className="pointer-events-auto flex flex-col items-center gap-4">
|
|
163
162
|
<EmptyState variant="empty">
|
|
164
163
|
{t('Click an item in the catalog to add a card.', { note: 'recipe.calc.empty' })}
|
|
165
164
|
</EmptyState>
|
|
@@ -50,7 +50,6 @@ export function useCalcActions({
|
|
|
50
50
|
nodes,
|
|
51
51
|
tagMembers,
|
|
52
52
|
ensureMaterial,
|
|
53
|
-
fluids,
|
|
54
53
|
}: {
|
|
55
54
|
dataset: DatasetRef;
|
|
56
55
|
lang: Lang;
|
|
@@ -68,9 +67,7 @@ export function useCalcActions({
|
|
|
68
67
|
nodes: CalcNode[];
|
|
69
68
|
tagMembers?: (tagId: string) => TagResolution | undefined;
|
|
70
69
|
ensureMaterial?: (materialId: string) => void;
|
|
71
|
-
fluids?: readonly string[];
|
|
72
70
|
}) {
|
|
73
|
-
const fluidIds = useMemo(() => new Set(fluids ?? []), [fluids]);
|
|
74
71
|
const { checked: shared, onClick: onShare } = useCopyButton(async () => {
|
|
75
72
|
const tree = encodeShare();
|
|
76
73
|
const { id: datasetId, version } = dataset;
|
|
@@ -133,13 +130,6 @@ export function useCalcActions({
|
|
|
133
130
|
|
|
134
131
|
const onAddCard = useCallback(
|
|
135
132
|
(materialId: string, kind: CalcKind, pos?: { x: number; y: number }) => {
|
|
136
|
-
if (kind === 'item' && materialId.endsWith('_bucket')) {
|
|
137
|
-
const fluidId = materialId.slice(0, -'_bucket'.length);
|
|
138
|
-
if (fluidIds.has(fluidId)) {
|
|
139
|
-
materialId = fluidId;
|
|
140
|
-
kind = 'fluid';
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
133
|
const id = newCardId();
|
|
144
134
|
persist({
|
|
145
135
|
cards: [
|
|
@@ -152,7 +142,7 @@ export function useCalcActions({
|
|
|
152
142
|
setFocusNodeId(id);
|
|
153
143
|
return id;
|
|
154
144
|
},
|
|
155
|
-
[flushAmounts, persist, wires, tagSelections, setFocusNodeId
|
|
145
|
+
[flushAmounts, persist, wires, tagSelections, setFocusNodeId],
|
|
156
146
|
);
|
|
157
147
|
|
|
158
148
|
const onSupplyInput = useCallback(
|
|
@@ -15,10 +15,10 @@ import type { CalcFarMode } from '@terrafirmagreg-team/recipe/lib/calc/flow';
|
|
|
15
15
|
const FAR_MODES: CalcFarMode[] = ['full', 'preview', 'hidden'];
|
|
16
16
|
const useStoredMode = createStoredValue(
|
|
17
17
|
'calc:far',
|
|
18
|
-
literalCodec(FAR_MODES, '
|
|
18
|
+
literalCodec(FAR_MODES, 'full'),
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
-
const CalcFarContext = createContext<CalcFarMode>('
|
|
21
|
+
const CalcFarContext = createContext<CalcFarMode>('full');
|
|
22
22
|
|
|
23
23
|
export const CalcFarProvider = CalcFarContext.Provider;
|
|
24
24
|
|
|
@@ -10,7 +10,7 @@ import type { CalcViewMode } from '@terrafirmagreg-team/recipe/lib/calc/flow';
|
|
|
10
10
|
const MODES: CalcViewMode[] = ['mini', 'normal', 'detailed'];
|
|
11
11
|
const useStoredMode = createStoredValue(
|
|
12
12
|
'calc:view',
|
|
13
|
-
literalCodec(MODES, '
|
|
13
|
+
literalCodec(MODES, 'detailed'),
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
export function useCalcViewMode() {
|
|
@@ -112,13 +112,23 @@ export function usePanelCells({
|
|
|
112
112
|
: [],
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
|
+
const fluidIds = new Set(dIndex?.fluids ?? []);
|
|
115
116
|
return buildPanelCells(
|
|
116
117
|
deferredFiltered,
|
|
117
118
|
dIndex?.groups,
|
|
118
119
|
expandedGroups,
|
|
120
|
+
fluidIds,
|
|
119
121
|
);
|
|
120
122
|
}, [deferredFiltered, dIndex, mode, expandedGroups, favorites.entries]);
|
|
121
123
|
|
|
122
|
-
return {
|
|
124
|
+
return {
|
|
125
|
+
cells,
|
|
126
|
+
filtered: deferredFiltered,
|
|
127
|
+
favoriteIds,
|
|
128
|
+
dIndex,
|
|
129
|
+
dNames,
|
|
130
|
+
dLang,
|
|
131
|
+
used,
|
|
132
|
+
};
|
|
123
133
|
}
|
|
124
134
|
|
|
@@ -5,12 +5,16 @@ import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
|
|
|
5
5
|
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
6
6
|
import { panelTabRows } from '@terrafirmagreg-team/recipe/lib/browser/panel';
|
|
7
7
|
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
RecipeCompactIndex,
|
|
10
|
+
UsedItems,
|
|
11
|
+
} from '@terrafirmagreg-team/recipe/types';
|
|
9
12
|
|
|
10
13
|
export function usePanelTabs(
|
|
11
14
|
index: RecipeCompactIndex | null,
|
|
12
15
|
names: Record<string, Record<string, string>>,
|
|
13
16
|
lang: Lang,
|
|
17
|
+
used?: UsedItems,
|
|
14
18
|
) {
|
|
15
19
|
const t = useTranslations();
|
|
16
20
|
return useMemo(
|
|
@@ -25,7 +29,7 @@ export function usePanelTabs(
|
|
|
25
29
|
}),
|
|
26
30
|
help: t('All items', { note: 'recipe.all_items' }),
|
|
27
31
|
},
|
|
28
|
-
...panelTabRows(index, names, lang).map((row) => ({
|
|
32
|
+
...panelTabRows(index, names, lang, used).map((row) => ({
|
|
29
33
|
id: row.id,
|
|
30
34
|
icon: createElement(Entry, {
|
|
31
35
|
...(row.iconRef
|
|
@@ -35,9 +39,10 @@ export function usePanelTabs(
|
|
|
35
39
|
href: false,
|
|
36
40
|
}),
|
|
37
41
|
help: row.help,
|
|
42
|
+
helpKey: row.helpKey,
|
|
38
43
|
})),
|
|
39
44
|
],
|
|
40
|
-
[index, lang, names, t],
|
|
45
|
+
[index, lang, names, t, used],
|
|
41
46
|
);
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -56,7 +56,13 @@ export async function recipesForOutput(
|
|
|
56
56
|
]);
|
|
57
57
|
const extra = io?.outputs.get(base) ?? [];
|
|
58
58
|
const ids = extra.length ? [...new Set([...refs, ...extra])] : refs;
|
|
59
|
-
|
|
59
|
+
const keepTagRows = opts?.includeTagRows ?? false;
|
|
60
|
+
return (await resolveRecipeRows(dataset, index, ids, opts)).filter(
|
|
61
|
+
(row) =>
|
|
62
|
+
row.out.includes(base) ||
|
|
63
|
+
(keepTagRows &&
|
|
64
|
+
(row.cat ?? index.types[row.type]) === 'emi:tag'),
|
|
65
|
+
);
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
export async function usesForInput(
|
|
@@ -88,10 +94,12 @@ export async function usesForInput(
|
|
|
88
94
|
...tagKinds.map((tagKind) => loadTagSlice(dataset, tagKind, ns)),
|
|
89
95
|
]);
|
|
90
96
|
const tagKeys: string[] = [];
|
|
97
|
+
const acceptedTags = new Set<string>();
|
|
91
98
|
for (const [i, slice] of tagSlices.entries()) {
|
|
92
99
|
const registry = `${tagKinds[i]}s`;
|
|
93
100
|
for (const tag of slice[base] ?? slice[item] ?? []) {
|
|
94
101
|
const raw = tag.startsWith('#') ? tag.slice(1) : tag;
|
|
102
|
+
acceptedTags.add(`#${raw}`);
|
|
95
103
|
const parts = splitDumpId(raw);
|
|
96
104
|
if (parts) tagKeys.push(`${parts.ns}:${registry}/${parts.path}`);
|
|
97
105
|
}
|
|
@@ -111,11 +119,21 @@ export async function usesForInput(
|
|
|
111
119
|
const allRefs = ioRefs.length
|
|
112
120
|
? [...new Set([...refs, ...ioRefs])]
|
|
113
121
|
: refs;
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
const [refRows, tagRows] = await Promise.all([
|
|
123
|
+
resolveRecipeRows(dataset, index, allRefs, {
|
|
124
|
+
includeTagRows: false,
|
|
125
|
+
...opts,
|
|
126
|
+
}),
|
|
127
|
+
resolveRecipeRows(dataset, index, tagRefs, {
|
|
116
128
|
includeTagRows: false,
|
|
117
129
|
...opts,
|
|
118
|
-
})
|
|
130
|
+
}),
|
|
131
|
+
]);
|
|
132
|
+
return uniqueRows([
|
|
133
|
+
...refRows.filter((row) => row.in.includes(base)),
|
|
134
|
+
...tagRows.filter((row) =>
|
|
135
|
+
row.in.some((id) => acceptedTags.has(id)),
|
|
136
|
+
),
|
|
119
137
|
...stationRows.flat(),
|
|
120
138
|
]);
|
|
121
139
|
}
|
package/src/lib/browser/panel.ts
CHANGED
|
@@ -3,16 +3,22 @@ import {
|
|
|
3
3
|
type TaggedReference,
|
|
4
4
|
} from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
5
5
|
import { registryId } from '@terrafirmagreg-team/dump/lib/dump/paths';
|
|
6
|
+
import { creativeTabName } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
6
7
|
import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
8
|
+
import {
|
|
9
|
+
filterUsedIds,
|
|
10
|
+
hasRecipeUsage,
|
|
11
|
+
} from '@terrafirmagreg-team/recipe/lib/browser/used-items';
|
|
7
12
|
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
8
13
|
import type {
|
|
9
14
|
ItemPanelCell,
|
|
10
15
|
RecipeCompactIndex,
|
|
11
16
|
RecipeStackGroup,
|
|
17
|
+
UsedItems,
|
|
12
18
|
} from '@terrafirmagreg-team/recipe/types';
|
|
13
19
|
|
|
14
20
|
function catalogPool(index: RecipeCompactIndex, tab?: string): string[] {
|
|
15
|
-
if (!tab) return index.items;
|
|
21
|
+
if (!tab) return [...index.items, ...(index.fluids ?? [])];
|
|
16
22
|
return index.tabItems?.[tab] ?? [];
|
|
17
23
|
}
|
|
18
24
|
|
|
@@ -23,6 +29,7 @@ type ItemPanelTabRow = {
|
|
|
23
29
|
icon: string;
|
|
24
30
|
iconRef?: TaggedReference;
|
|
25
31
|
help: string;
|
|
32
|
+
helpKey?: string;
|
|
26
33
|
};
|
|
27
34
|
|
|
28
35
|
export function panelPool(
|
|
@@ -39,8 +46,13 @@ export function buildPanelCells(
|
|
|
39
46
|
ids: readonly string[],
|
|
40
47
|
groups: RecipeStackGroup[] | undefined,
|
|
41
48
|
expandedGroups: ReadonlySet<string>,
|
|
49
|
+
fluidIds?: ReadonlySet<string>,
|
|
42
50
|
): ItemPanelCell[] {
|
|
43
|
-
|
|
51
|
+
const cell = (id: string): ItemPanelCell =>
|
|
52
|
+
fluidIds?.has(registryId(id))
|
|
53
|
+
? { kind: 'stack', id, ref: 'fluid' }
|
|
54
|
+
: { kind: 'stack', id };
|
|
55
|
+
if (!groups?.length) return ids.map(cell);
|
|
44
56
|
const byMember = new Map<string, RecipeStackGroup>();
|
|
45
57
|
for (const group of groups)
|
|
46
58
|
for (const member of group.members) {
|
|
@@ -56,7 +68,7 @@ export function buildPanelCells(
|
|
|
56
68
|
seen.add(base);
|
|
57
69
|
const group = byMember.get(base);
|
|
58
70
|
if (!group) {
|
|
59
|
-
out.push(
|
|
71
|
+
out.push(cell(id));
|
|
60
72
|
continue;
|
|
61
73
|
}
|
|
62
74
|
const members = group.members.filter((member) =>
|
|
@@ -64,20 +76,29 @@ export function buildPanelCells(
|
|
|
64
76
|
);
|
|
65
77
|
for (const member of members) seen.add(registryId(member));
|
|
66
78
|
if (members.length <= 1) {
|
|
67
|
-
out.push(
|
|
79
|
+
out.push(cell(members[0] ?? id));
|
|
68
80
|
continue;
|
|
69
81
|
}
|
|
70
82
|
const expanded = expandedGroups.has(group.id);
|
|
83
|
+
const fluid = members.every((member) =>
|
|
84
|
+
fluidIds?.has(registryId(member)),
|
|
85
|
+
);
|
|
71
86
|
out.push({
|
|
72
87
|
kind: 'group',
|
|
73
88
|
id: group.id,
|
|
74
89
|
label: group.name ?? group.id,
|
|
75
90
|
members,
|
|
76
91
|
expanded,
|
|
92
|
+
...(fluid ? { ref: 'fluid' as const } : {}),
|
|
77
93
|
});
|
|
78
94
|
if (expanded)
|
|
79
95
|
for (const member of members)
|
|
80
|
-
out.push({
|
|
96
|
+
out.push({
|
|
97
|
+
kind: 'stack',
|
|
98
|
+
id: member,
|
|
99
|
+
groupId: group.id,
|
|
100
|
+
...(fluidIds?.has(registryId(member)) ? { ref: 'fluid' as const } : {}),
|
|
101
|
+
});
|
|
81
102
|
}
|
|
82
103
|
return out;
|
|
83
104
|
}
|
|
@@ -86,9 +107,17 @@ export function panelTabRows(
|
|
|
86
107
|
index: RecipeCompactIndex | null,
|
|
87
108
|
names: Record<string, Record<string, string>>,
|
|
88
109
|
lang: Lang,
|
|
110
|
+
used?: UsedItems,
|
|
89
111
|
): ItemPanelTabRow[] {
|
|
112
|
+
const hideEmpty = used !== undefined && hasRecipeUsage(used);
|
|
90
113
|
const rows: ItemPanelTabRow[] = [];
|
|
91
114
|
for (const row of index?.tabs ?? []) {
|
|
115
|
+
if (
|
|
116
|
+
hideEmpty &&
|
|
117
|
+
filterUsedIds(index?.tabItems?.[row.id] ?? [], used).length === 0
|
|
118
|
+
) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
92
121
|
const icon =
|
|
93
122
|
(row.icon ? stackIdFromRef(row.icon) : undefined) ??
|
|
94
123
|
index?.tabItems?.[row.id]?.[0];
|
|
@@ -97,7 +126,10 @@ export function panelTabRows(
|
|
|
97
126
|
id: row.id,
|
|
98
127
|
icon,
|
|
99
128
|
iconRef: row.icon,
|
|
100
|
-
help:
|
|
129
|
+
help: row.display?.name
|
|
130
|
+
? creativeTabName(names[lang] ?? names.en_us ?? {}, row.display.name)
|
|
131
|
+
: recipeItemName(names, lang, row.id),
|
|
132
|
+
helpKey: row.display?.name ?? row.id,
|
|
101
133
|
});
|
|
102
134
|
}
|
|
103
135
|
return rows;
|