@terrafirmagreg-team/recipe 1.2.41 → 1.2.42
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 +1 -1
- package/src/components/cards/calc-add-item.tsx +55 -0
- package/src/components/cards/card/index.tsx +2 -0
- package/src/components/cards/card/text.tsx +20 -4
- package/src/components/views/browser/card-grid.tsx +11 -23
- package/src/components/views/browser/frame.tsx +1 -3
- package/src/components/views/browser/item-view/index.tsx +8 -10
- package/src/components/views/browser/settings.tsx +6 -0
- package/src/components/views/browser/type-view.tsx +8 -10
- package/src/components/views/calc/calculator/index.tsx +4 -0
- package/src/components/views/calc/flow/index.tsx +42 -1
- package/src/components/views/calc/flow/picker-dialogs.tsx +15 -8
- package/src/components/views/calc/flow/toolbar.tsx +2 -0
- package/src/components/views/calc/flow/view-menu.tsx +13 -0
- package/src/components/views/calc/member-picker.tsx +7 -2
- package/src/components/views/calc/node-card/full.tsx +34 -5
- package/src/components/views/calc/node-card/menu.tsx +32 -0
- package/src/components/views/calc/recipe-picker/body.tsx +9 -9
- package/src/hooks/calc/flow/use-layout.ts +1 -1
- package/src/hooks/calc/flow/use-pickers.ts +14 -10
- package/src/hooks/calc/use-actions.ts +54 -31
- package/src/hooks/calc/use-recipe-ids.ts +33 -0
- package/src/hooks/use-card-grid.ts +14 -0
- package/src/lib/alloy/parse.ts +6 -3
- package/src/lib/browser/card-dim.test.ts +39 -0
- package/src/lib/browser/card-dim.ts +38 -0
- package/src/lib/browser/lookup.ts +3 -2
- package/src/lib/browser/row-match.test.ts +34 -0
- package/src/lib/browser/row-match.ts +8 -0
- package/src/lib/calc/flow.ts +3 -1
- package/src/lib/calc/member.test.ts +178 -0
- package/src/lib/calc/member.ts +90 -0
- package/src/lib/calc/scheme.test.ts +213 -0
- package/src/lib/calc/scheme.ts +8 -3
- package/src/lib/calc/tree/index.ts +5 -1
- package/src/lib/calc/tree/recipe.test.ts +88 -0
- package/src/lib/calc/tree/recipe.ts +19 -3
- package/src/lib/calc/wire.test.ts +70 -0
- package/src/lib/calc/wire.ts +6 -2
- package/src/lib/cards/model.test.ts +61 -1
- package/src/lib/cards/model.ts +9 -2
- package/src/types/calc-flow-props.ts +2 -0
- package/styles/calc.css +4 -0
package/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import type { RecipeCompactRow, RecipeSession } from '@terrafirmagreg-team/recipe/types';
|
|
3
|
+
|
|
4
|
+
import { Workflow } from 'lucide-react';
|
|
5
|
+
import { ContextMenuItem } from '@terrafirmagreg-team/ui/components/ui/context-menu';
|
|
6
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
7
|
+
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
8
|
+
import { encodeCalcState } from '@terrafirmagreg-team/recipe/lib/calc/tree';
|
|
9
|
+
import { recipeCalcHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
10
|
+
import { stackIdBase } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
11
|
+
import { pushUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
12
|
+
|
|
13
|
+
export function CalcAddMenuItem({
|
|
14
|
+
session,
|
|
15
|
+
row,
|
|
16
|
+
}: {
|
|
17
|
+
session: RecipeSession;
|
|
18
|
+
row: RecipeCompactRow;
|
|
19
|
+
}) {
|
|
20
|
+
const t = useTranslations();
|
|
21
|
+
const resolved = useResolvedLang();
|
|
22
|
+
const out = row.out[0];
|
|
23
|
+
if (!out) return null;
|
|
24
|
+
const materialId = stackIdBase(out);
|
|
25
|
+
const kind = session.index?.fluids?.includes(materialId) ? 'fluid' : 'item';
|
|
26
|
+
return (
|
|
27
|
+
<ContextMenuItem
|
|
28
|
+
onClick={() =>
|
|
29
|
+
pushUrlState(
|
|
30
|
+
recipeCalcHref(
|
|
31
|
+
session.dataset,
|
|
32
|
+
resolved,
|
|
33
|
+
encodeCalcState({
|
|
34
|
+
cards: [
|
|
35
|
+
{
|
|
36
|
+
id: `c${crypto.randomUUID()}`,
|
|
37
|
+
materialId,
|
|
38
|
+
kind,
|
|
39
|
+
recipeId: row.id,
|
|
40
|
+
crafts: 1,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
wires: [],
|
|
44
|
+
tagSelections: {},
|
|
45
|
+
}),
|
|
46
|
+
session.nav.version,
|
|
47
|
+
),
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
>
|
|
51
|
+
<Workflow />
|
|
52
|
+
{t('Add to new scheme', { note: 'recipe.calc.new_scheme' })}
|
|
53
|
+
</ContextMenuItem>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -104,6 +104,7 @@ export function RecipeCard({
|
|
|
104
104
|
return (
|
|
105
105
|
<div
|
|
106
106
|
ref={rootRef}
|
|
107
|
+
data-marquee-hover
|
|
107
108
|
className="relative w-fit overflow-hidden rounded-sm bg-mc-panel"
|
|
108
109
|
>
|
|
109
110
|
{src ? (
|
|
@@ -209,6 +210,7 @@ export function RecipeCard({
|
|
|
209
210
|
scale={scale}
|
|
210
211
|
langMap={langMap}
|
|
211
212
|
size={micro}
|
|
213
|
+
rightGui={margin + contentGuiW}
|
|
212
214
|
{...(labelSlot
|
|
213
215
|
? {
|
|
214
216
|
anchor: {
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { McText } from '@terrafirmagreg-team/game/components/entry/mc-text';
|
|
4
4
|
import { dumpTextString } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
5
|
+
import { Marquee } from '@terrafirmagreg-team/ui/components/blocks/text/marquee';
|
|
5
6
|
import { widgetTextColor } from '@terrafirmagreg-team/recipe/lib/cards/model';
|
|
6
7
|
import type { RecipeTextWidget } from '@terrafirmagreg-team/recipe/lib/data/dto';
|
|
7
8
|
|
|
9
|
+
const LEFT_INSET = 1;
|
|
10
|
+
|
|
8
11
|
export function CardText({
|
|
9
12
|
widget,
|
|
10
13
|
offX = 0,
|
|
@@ -13,6 +16,7 @@ export function CardText({
|
|
|
13
16
|
langMap,
|
|
14
17
|
anchor,
|
|
15
18
|
size,
|
|
19
|
+
rightGui,
|
|
16
20
|
}: {
|
|
17
21
|
widget: RecipeTextWidget;
|
|
18
22
|
offX?: number;
|
|
@@ -21,6 +25,7 @@ export function CardText({
|
|
|
21
25
|
langMap?: Record<string, string>;
|
|
22
26
|
anchor?: { x: number; y: number; w: number };
|
|
23
27
|
size?: number;
|
|
28
|
+
rightGui?: number;
|
|
24
29
|
}) {
|
|
25
30
|
const content = widget.component
|
|
26
31
|
? dumpTextString(langMap ?? {}, widget.component) || widget.text
|
|
@@ -29,6 +34,12 @@ export function CardText({
|
|
|
29
34
|
const wrap = widget.type === 'paragraph';
|
|
30
35
|
const rgb = widgetTextColor(widget.color, widget.shadow === true);
|
|
31
36
|
const shadowRgb = ((rgb & 0xfcfcfc) >> 2) & 0xffffff;
|
|
37
|
+
const relX = widget.x + offX;
|
|
38
|
+
const clamped = !anchor && !wrap && rightGui !== undefined;
|
|
39
|
+
const leftGui = clamped ? Math.max(relX, LEFT_INSET) : relX;
|
|
40
|
+
const widthGui = clamped
|
|
41
|
+
? Math.max(rightGui - leftGui, 0)
|
|
42
|
+
: widget.w;
|
|
32
43
|
return (
|
|
33
44
|
<span
|
|
34
45
|
className={`font-mc pointer-events-none absolute leading-none ${wrap ? 'whitespace-pre-wrap' : 'whitespace-pre'}`}
|
|
@@ -41,9 +52,9 @@ export function CardText({
|
|
|
41
52
|
textAlign: 'right' as const,
|
|
42
53
|
}
|
|
43
54
|
: {
|
|
44
|
-
left:
|
|
55
|
+
left: leftGui * scale,
|
|
45
56
|
top: (widget.y + offY) * scale,
|
|
46
|
-
...(wrap ? { width:
|
|
57
|
+
...(wrap || clamped ? { width: widthGui * scale } : {}),
|
|
47
58
|
}),
|
|
48
59
|
fontSize: size ?? 8 * scale,
|
|
49
60
|
fontWeight: 700,
|
|
@@ -55,8 +66,13 @@ export function CardText({
|
|
|
55
66
|
: {}),
|
|
56
67
|
}}
|
|
57
68
|
>
|
|
58
|
-
|
|
69
|
+
{clamped ? (
|
|
70
|
+
<Marquee>
|
|
71
|
+
<McText text={content} surface="normal" />
|
|
72
|
+
</Marquee>
|
|
73
|
+
) : (
|
|
74
|
+
<McText text={content} surface="normal" />
|
|
75
|
+
)}
|
|
59
76
|
</span>
|
|
60
77
|
);
|
|
61
78
|
}
|
|
62
|
-
|
|
@@ -6,6 +6,7 @@ import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-transl
|
|
|
6
6
|
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
7
7
|
import { PagedCard } from '@terrafirmagreg-team/recipe/components/cards/paged-card';
|
|
8
8
|
import { RecipeDefaultMenuItem } from '@terrafirmagreg-team/recipe/components/cards/default-item';
|
|
9
|
+
import { CalcAddMenuItem } from '@terrafirmagreg-team/recipe/components/cards/calc-add-item';
|
|
9
10
|
import { CopyIdMenu } from '@terrafirmagreg-team/game/components/entry/copy-id-menu';
|
|
10
11
|
import { EmptyState } from '@terrafirmagreg-team/ui/components/blocks/page/empty-state';
|
|
11
12
|
import { Skeleton } from '@terrafirmagreg-team/ui/components/ui/skeleton';
|
|
@@ -19,35 +20,14 @@ import { pushUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
|
19
20
|
import { useSwipe } from '@terrafirmagreg-team/ui/hooks/use-swipe';
|
|
20
21
|
import { dismissOpenTooltips } from '@terrafirmagreg-team/ui/lib/dismiss-tooltips';
|
|
21
22
|
import { favoriteHover } from '@terrafirmagreg-team/recipe/lib/browser/favorite-hover';
|
|
23
|
+
import { FALLBACK_DIM } from '@terrafirmagreg-team/recipe/lib/browser/card-dim';
|
|
22
24
|
import { recipeTitle } from '@terrafirmagreg-team/recipe/lib/data/parse';
|
|
23
25
|
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
24
|
-
import type { FitDim } from '@terrafirmagreg-team/ui/hooks/page/use-fit-pages';
|
|
25
26
|
import type {
|
|
26
|
-
RecipeCategory,
|
|
27
|
-
RecipeCompactIndex,
|
|
28
27
|
RecipeCompactRow,
|
|
29
28
|
RecipeSession,
|
|
30
29
|
} from '@terrafirmagreg-team/recipe/types';
|
|
31
30
|
|
|
32
|
-
const FALLBACK_DIM: FitDim = { w: 320, h: 80 };
|
|
33
|
-
|
|
34
|
-
export function recipeCardDim(
|
|
35
|
-
index: RecipeCompactIndex | null,
|
|
36
|
-
categoriesById: Map<string, RecipeCategory>,
|
|
37
|
-
row: RecipeCompactRow,
|
|
38
|
-
): FitDim {
|
|
39
|
-
if (row.d) return { w: row.d.w, h: row.d.h };
|
|
40
|
-
const typeId = index?.types[row.type];
|
|
41
|
-
const layout = typeId ? categoriesById.get(typeId)?.layout : undefined;
|
|
42
|
-
if (!layout) return FALLBACK_DIM;
|
|
43
|
-
const scale = layout.scale ?? 2;
|
|
44
|
-
const margin = layout.margin ?? 0;
|
|
45
|
-
return {
|
|
46
|
-
w: (layout.w + margin * 2) * scale,
|
|
47
|
-
h: (layout.h + margin * 2) * scale,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
31
|
function RecipeGridCard({
|
|
52
32
|
row,
|
|
53
33
|
session,
|
|
@@ -122,6 +102,7 @@ function RecipeGridCard({
|
|
|
122
102
|
materialId={defaultMaterial ?? row.out[0]}
|
|
123
103
|
recipeId={row.id}
|
|
124
104
|
/>
|
|
105
|
+
<CalcAddMenuItem session={session} row={row} />
|
|
125
106
|
{menuExtra?.(row)}
|
|
126
107
|
</>
|
|
127
108
|
}
|
|
@@ -217,6 +198,7 @@ export function RecipeCardGrid({
|
|
|
217
198
|
boxRef,
|
|
218
199
|
maxH,
|
|
219
200
|
maxW,
|
|
201
|
+
vertical,
|
|
220
202
|
loading,
|
|
221
203
|
empty,
|
|
222
204
|
onSwipe,
|
|
@@ -229,6 +211,7 @@ export function RecipeCardGrid({
|
|
|
229
211
|
boxRef: RefObject<HTMLDivElement | null>;
|
|
230
212
|
maxH?: number;
|
|
231
213
|
maxW?: number;
|
|
214
|
+
vertical?: boolean;
|
|
232
215
|
loading?: boolean;
|
|
233
216
|
empty?: string;
|
|
234
217
|
onSwipe?: (dir: -1 | 1) => void;
|
|
@@ -276,7 +259,12 @@ export function RecipeCardGrid({
|
|
|
276
259
|
ref={boxRef}
|
|
277
260
|
{...swipe}
|
|
278
261
|
onScroll={dismissOpenTooltips}
|
|
279
|
-
className=
|
|
262
|
+
className={cn(
|
|
263
|
+
'flex min-h-0 flex-1 items-center gap-2 overflow-x-clip overflow-y-auto',
|
|
264
|
+
vertical
|
|
265
|
+
? 'flex-col'
|
|
266
|
+
: 'flex-row flex-wrap content-start justify-center',
|
|
267
|
+
)}
|
|
280
268
|
>
|
|
281
269
|
{body}
|
|
282
270
|
</div>
|
|
@@ -136,9 +136,7 @@ export function RecipeFrame({
|
|
|
136
136
|
) : null}
|
|
137
137
|
<div className="relative flex min-h-0 flex-1 overflow-hidden pt-2">
|
|
138
138
|
{rail ? (
|
|
139
|
-
<div className="z-10 flex
|
|
140
|
-
{rail}
|
|
141
|
-
</div>
|
|
139
|
+
<div className="z-10 flex shrink-0 flex-col">{rail}</div>
|
|
142
140
|
) : null}
|
|
143
141
|
<div
|
|
144
142
|
onWheel={(event) => goPage(event.deltaY > 0 ? 1 : -1)}
|
|
@@ -5,14 +5,13 @@ import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-transl
|
|
|
5
5
|
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
6
6
|
import { RecipeFrame } from '@terrafirmagreg-team/recipe/components/views/browser/frame';
|
|
7
7
|
import { ItemViewHeader } from '@terrafirmagreg-team/recipe/components/views/browser/item-view-header';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
recipeCardDim,
|
|
11
|
-
} from '@terrafirmagreg-team/recipe/components/views/browser/card-grid';
|
|
8
|
+
import { RecipeCardGrid } from '@terrafirmagreg-team/recipe/components/views/browser/card-grid';
|
|
9
|
+
import { recipeCardFitDim } from '@terrafirmagreg-team/recipe/lib/browser/card-dim';
|
|
12
10
|
import { RecipeTypeTabs } from '@terrafirmagreg-team/recipe/components/views/browser/type-tabs';
|
|
13
11
|
import { WorkstationRail } from '@terrafirmagreg-team/recipe/components/views/browser/workstation-rail';
|
|
14
12
|
import { PaneTabs } from '@terrafirmagreg-team/recipe/components/views/browser/pane-tabs';
|
|
15
13
|
import { useFitPages } from '@terrafirmagreg-team/ui/hooks/page/use-fit-pages';
|
|
14
|
+
import { useCardGrid } from '@terrafirmagreg-team/recipe/hooks/use-card-grid';
|
|
16
15
|
import { useCategoriesById } from '@terrafirmagreg-team/recipe/hooks/use-categories-by-id';
|
|
17
16
|
import { useTypeFilter } from '@terrafirmagreg-team/recipe/hooks/use-type-filter';
|
|
18
17
|
import { useFavorites } from '@terrafirmagreg-team/recipe/hooks/use-favorites';
|
|
@@ -93,17 +92,15 @@ export function ItemView({ session }: { session: RecipeSession }) {
|
|
|
93
92
|
const focusIndex = recipeId
|
|
94
93
|
? typeFilter.rows.findIndex((row) => row.id === recipeId)
|
|
95
94
|
: -1;
|
|
95
|
+
const { grid } = useCardGrid();
|
|
96
96
|
const list = useFitPages(
|
|
97
97
|
boxRef,
|
|
98
98
|
typeFilter.rows,
|
|
99
|
-
(row, box) =>
|
|
100
|
-
const d = recipeCardDim(index, categoriesById, row);
|
|
101
|
-
return d.h > box.h ? { w: d.w, h: box.h } : d;
|
|
102
|
-
},
|
|
99
|
+
(row, box) => recipeCardFitDim(index, categoriesById, row, box),
|
|
103
100
|
rpage,
|
|
104
101
|
8,
|
|
105
102
|
focusIndex >= 0 ? focusIndex : undefined,
|
|
106
|
-
|
|
103
|
+
!grid,
|
|
107
104
|
);
|
|
108
105
|
|
|
109
106
|
const onSwipe = (dir: -1 | 1) => {
|
|
@@ -177,7 +174,8 @@ export function ItemView({ session }: { session: RecipeSession }) {
|
|
|
177
174
|
boxRef={boxRef}
|
|
178
175
|
maxH={list.box.h}
|
|
179
176
|
maxW={list.box.w}
|
|
180
|
-
|
|
177
|
+
vertical={!grid}
|
|
178
|
+
loading={feeds.pending || !list.measured}
|
|
181
179
|
empty={t('No recipes of this type.', { note: 'recipe.empty_type' })}
|
|
182
180
|
onSwipe={onSwipe}
|
|
183
181
|
/>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Settings2 } from 'lucide-react';
|
|
4
4
|
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
5
|
+
import { useCardGrid } from '@terrafirmagreg-team/recipe/hooks/use-card-grid';
|
|
5
6
|
import { useHideUnused } from '@terrafirmagreg-team/recipe/hooks/use-hide-unused';
|
|
6
7
|
import { useSidebarGroup } from '@terrafirmagreg-team/recipe/hooks/use-sidebar-group';
|
|
7
8
|
import { Button } from '@terrafirmagreg-team/ui/components/ui/button';
|
|
@@ -17,6 +18,7 @@ export function RecipeSettings() {
|
|
|
17
18
|
const t = useTranslations();
|
|
18
19
|
const { hideUnused, setHideUnused } = useHideUnused();
|
|
19
20
|
const { sidebarGroup, setSidebarGroup } = useSidebarGroup();
|
|
21
|
+
const { grid, setGrid } = useCardGrid();
|
|
20
22
|
|
|
21
23
|
return (
|
|
22
24
|
<Popover>
|
|
@@ -45,6 +47,10 @@ export function RecipeSettings() {
|
|
|
45
47
|
/>
|
|
46
48
|
{t('Group sidebar by mod', { note: 'recipe.sidebar_group_mod' })}
|
|
47
49
|
</Label>
|
|
50
|
+
<Label className="gap-1.5 text-sm font-normal">
|
|
51
|
+
<Switch size="sm" checked={grid} onCheckedChange={setGrid} />
|
|
52
|
+
{t('Cards grid', { note: 'recipe.cards_grid' })}
|
|
53
|
+
</Label>
|
|
48
54
|
</PopoverContent>
|
|
49
55
|
</Popover>
|
|
50
56
|
);
|
|
@@ -6,11 +6,10 @@ import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-transl
|
|
|
6
6
|
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
7
7
|
import { useAsyncResult } from '@terrafirmagreg-team/ui/hooks/use-async-value';
|
|
8
8
|
import { RecipeFrame } from '@terrafirmagreg-team/recipe/components/views/browser/frame';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
recipeCardDim,
|
|
12
|
-
} from '@terrafirmagreg-team/recipe/components/views/browser/card-grid';
|
|
9
|
+
import { RecipeCardGrid } from '@terrafirmagreg-team/recipe/components/views/browser/card-grid';
|
|
10
|
+
import { recipeCardFitDim } from '@terrafirmagreg-team/recipe/lib/browser/card-dim';
|
|
13
11
|
import { PlaceHeader } from '@terrafirmagreg-team/recipe/components/views/browser/place-header';
|
|
12
|
+
import { useCardGrid } from '@terrafirmagreg-team/recipe/hooks/use-card-grid';
|
|
14
13
|
import { useCategoriesById } from '@terrafirmagreg-team/recipe/hooks/use-categories-by-id';
|
|
15
14
|
import { useFitPages } from '@terrafirmagreg-team/ui/hooks/page/use-fit-pages';
|
|
16
15
|
import {
|
|
@@ -93,17 +92,15 @@ export function TypeView({ session }: { session: RecipeSession }) {
|
|
|
93
92
|
}),
|
|
94
93
|
);
|
|
95
94
|
}, [focusIndex, focusRes.pending, focusRes.value, index, nav, dataset, resolved, recipeId, rows, shown]);
|
|
95
|
+
const { grid } = useCardGrid();
|
|
96
96
|
const list = useFitPages(
|
|
97
97
|
boxRef,
|
|
98
98
|
feedRows,
|
|
99
|
-
(row, box) =>
|
|
100
|
-
const d = recipeCardDim(index, categoriesById, row);
|
|
101
|
-
return d.h > box.h ? { w: d.w, h: box.h } : d;
|
|
102
|
-
},
|
|
99
|
+
(row, box) => recipeCardFitDim(index, categoriesById, row, box),
|
|
103
100
|
rpage,
|
|
104
101
|
8,
|
|
105
102
|
feedFocus >= 0 ? feedFocus : undefined,
|
|
106
|
-
|
|
103
|
+
!grid,
|
|
107
104
|
);
|
|
108
105
|
|
|
109
106
|
const goCategory = (dir: -1 | 1) => {
|
|
@@ -155,7 +152,8 @@ export function TypeView({ session }: { session: RecipeSession }) {
|
|
|
155
152
|
boxRef={boxRef}
|
|
156
153
|
maxH={list.box.h}
|
|
157
154
|
maxW={list.box.w}
|
|
158
|
-
|
|
155
|
+
vertical={!grid}
|
|
156
|
+
loading={indexLoading || (shown != null && rows === undefined) || !list.measured}
|
|
159
157
|
empty={t('No recipes of this type.', { note: 'recipe.empty_type' })}
|
|
160
158
|
onSwipe={onSwipe}
|
|
161
159
|
/>
|
|
@@ -16,12 +16,14 @@ import type { RecipeSession } from '@terrafirmagreg-team/recipe/types';
|
|
|
16
16
|
import { useCalcData } from '@terrafirmagreg-team/recipe/hooks/calc/use-data';
|
|
17
17
|
import { useCalcViewMode } from '@terrafirmagreg-team/recipe/hooks/calc/use-view-mode';
|
|
18
18
|
import { useCalcFarMode } from '@terrafirmagreg-team/recipe/hooks/calc/use-far-mode';
|
|
19
|
+
import { useCalcRecipeIdsMode } from '@terrafirmagreg-team/recipe/hooks/calc/use-recipe-ids';
|
|
19
20
|
|
|
20
21
|
export function Calculator({ session }: { session: RecipeSession }) {
|
|
21
22
|
const t = useTranslations();
|
|
22
23
|
const { dataset, lang } = session;
|
|
23
24
|
const [mode, setMode] = useCalcViewMode();
|
|
24
25
|
const [farCards, setFarCards] = useCalcFarMode();
|
|
26
|
+
const [recipeIds, setRecipeIds] = useCalcRecipeIdsMode();
|
|
25
27
|
const {
|
|
26
28
|
cards,
|
|
27
29
|
wires,
|
|
@@ -151,6 +153,8 @@ export function Calculator({ session }: { session: RecipeSession }) {
|
|
|
151
153
|
onModeChange={setMode}
|
|
152
154
|
farCards={farCards}
|
|
153
155
|
onFarCardsChange={setFarCards}
|
|
156
|
+
recipeIds={recipeIds}
|
|
157
|
+
onRecipeIdsChange={setRecipeIds}
|
|
154
158
|
treeReady={settled}
|
|
155
159
|
resetGen={resetGen}
|
|
156
160
|
canvasId={activeTabId ?? undefined}
|
|
@@ -28,6 +28,7 @@ import { EmptyState } from '@terrafirmagreg-team/ui/components/blocks/page/empty
|
|
|
28
28
|
import { CalcEdge } from '@terrafirmagreg-team/recipe/components/views/calc/edge';
|
|
29
29
|
import { CalcSessionProvider } from '@terrafirmagreg-team/recipe/hooks/calc/use-calc-session';
|
|
30
30
|
import { CalcFarProvider } from '@terrafirmagreg-team/recipe/hooks/calc/use-far-mode';
|
|
31
|
+
import { CalcRecipeIdsProvider } from '@terrafirmagreg-team/recipe/hooks/calc/use-recipe-ids';
|
|
31
32
|
import { CalcTierProvider } from '@terrafirmagreg-team/recipe/hooks/calc/use-tier';
|
|
32
33
|
import { useFlowPickers } from '@terrafirmagreg-team/recipe/hooks/calc/flow/use-pickers';
|
|
33
34
|
import { useFlowLayout } from '@terrafirmagreg-team/recipe/hooks/calc/flow/use-layout';
|
|
@@ -77,6 +78,8 @@ function CalcFlowInner({
|
|
|
77
78
|
onModeChange,
|
|
78
79
|
farCards,
|
|
79
80
|
onFarCardsChange,
|
|
81
|
+
recipeIds,
|
|
82
|
+
onRecipeIdsChange,
|
|
80
83
|
treeReady = true,
|
|
81
84
|
resetGen = 0,
|
|
82
85
|
canvasId,
|
|
@@ -176,6 +179,40 @@ function CalcFlowInner({
|
|
|
176
179
|
focusId,
|
|
177
180
|
});
|
|
178
181
|
|
|
182
|
+
const boundsKey = useStore((s) => {
|
|
183
|
+
let out = '';
|
|
184
|
+
for (const node of s.nodeLookup.values()) {
|
|
185
|
+
const hb = node.internals?.handleBounds;
|
|
186
|
+
out +=
|
|
187
|
+
`${node.id}:` +
|
|
188
|
+
(hb?.source?.map((h) => h.id).join('+') ?? '') +
|
|
189
|
+
'/' +
|
|
190
|
+
(hb?.target?.map((h) => h.id).join('+') ?? '') +
|
|
191
|
+
'|';
|
|
192
|
+
}
|
|
193
|
+
return out;
|
|
194
|
+
});
|
|
195
|
+
const readyEdges = useMemo(() => {
|
|
196
|
+
const bounds = new Map<
|
|
197
|
+
string,
|
|
198
|
+
{ src: Set<string | null>; tgt: Set<string | null> }
|
|
199
|
+
>();
|
|
200
|
+
for (const part of boundsKey.split('|')) {
|
|
201
|
+
if (!part) continue;
|
|
202
|
+
const [id, rest = ''] = part.split(':');
|
|
203
|
+
const [src = '', tgt = ''] = rest.split('/');
|
|
204
|
+
bounds.set(id, {
|
|
205
|
+
src: new Set(src ? src.split('+') : []),
|
|
206
|
+
tgt: new Set(tgt ? tgt.split('+') : []),
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return edges.filter(
|
|
210
|
+
(e) =>
|
|
211
|
+
bounds.get(e.source)?.src.has(e.sourceHandle ?? null) &&
|
|
212
|
+
bounds.get(e.target)?.tgt.has(e.targetHandle ?? null),
|
|
213
|
+
);
|
|
214
|
+
}, [edges, boundsKey]);
|
|
215
|
+
|
|
179
216
|
const [prevCanvasId, setPrevCanvasId] = useState(canvasId);
|
|
180
217
|
if (prevCanvasId !== canvasId) {
|
|
181
218
|
setPrevCanvasId(canvasId);
|
|
@@ -217,6 +254,7 @@ function CalcFlowInner({
|
|
|
217
254
|
return (
|
|
218
255
|
<CalcSessionProvider value={session}>
|
|
219
256
|
<CalcFarProvider value={farCards}>
|
|
257
|
+
<CalcRecipeIdsProvider value={recipeIds}>
|
|
220
258
|
<CalcTierProvider value={tier}>
|
|
221
259
|
<FlowCanvas<AnyCalcFlowNode>
|
|
222
260
|
shellProps={shellProps}
|
|
@@ -227,7 +265,7 @@ function CalcFlowInner({
|
|
|
227
265
|
)}
|
|
228
266
|
|
|
229
267
|
nodes={tier === 'dot' ? EMPTY_FLOW : nodes}
|
|
230
|
-
edges={tier === 'dot' ? EMPTY_EDGES :
|
|
268
|
+
edges={tier === 'dot' ? EMPTY_EDGES : readyEdges}
|
|
231
269
|
extraRects={extraRects}
|
|
232
270
|
fitNodes={fitRecipeNodes}
|
|
233
271
|
nodeTypes={nodeTypes}
|
|
@@ -271,6 +309,8 @@ function CalcFlowInner({
|
|
|
271
309
|
onModeChange={onModeChange}
|
|
272
310
|
farCards={farCards}
|
|
273
311
|
onFarCardsChange={onFarCardsChange}
|
|
312
|
+
recipeIds={recipeIds}
|
|
313
|
+
onRecipeIdsChange={onRecipeIdsChange}
|
|
274
314
|
/>
|
|
275
315
|
{schemeNodes.length ? (
|
|
276
316
|
ready ? null : (
|
|
@@ -298,6 +338,7 @@ function CalcFlowInner({
|
|
|
298
338
|
onCloseDemand={closeDemand}
|
|
299
339
|
/>
|
|
300
340
|
</CalcTierProvider>
|
|
341
|
+
</CalcRecipeIdsProvider>
|
|
301
342
|
</CalcFarProvider>
|
|
302
343
|
</CalcSessionProvider>
|
|
303
344
|
);
|
|
@@ -9,6 +9,10 @@ import { CalcRecipePicker } from '@terrafirmagreg-team/recipe/components/views/c
|
|
|
9
9
|
import { CalcMemberPicker } from '@terrafirmagreg-team/recipe/components/views/calc/member-picker';
|
|
10
10
|
import { usesForInput } from '@terrafirmagreg-team/recipe/lib/browser/lookup';
|
|
11
11
|
import type { CalcFlowData } from '@terrafirmagreg-team/recipe/lib/calc/flow';
|
|
12
|
+
import {
|
|
13
|
+
memberTarget,
|
|
14
|
+
type MemberRequest,
|
|
15
|
+
} from '@terrafirmagreg-team/recipe/lib/calc/member';
|
|
12
16
|
import type {
|
|
13
17
|
DemandRequest,
|
|
14
18
|
SupplyRequest,
|
|
@@ -50,8 +54,8 @@ function SupplyPicker({
|
|
|
50
54
|
kind: slot.kind,
|
|
51
55
|
recipe: null,
|
|
52
56
|
availableRecipes: recipes,
|
|
53
|
-
tagId:
|
|
54
|
-
members:
|
|
57
|
+
tagId: slot.tagId,
|
|
58
|
+
members: slot.members,
|
|
55
59
|
inputs: [],
|
|
56
60
|
};
|
|
57
61
|
return (
|
|
@@ -188,7 +192,7 @@ export function CalcPickers({
|
|
|
188
192
|
onCloseDemand,
|
|
189
193
|
}: {
|
|
190
194
|
pickerNode: CalcNode | null;
|
|
191
|
-
memberNode:
|
|
195
|
+
memberNode: MemberRequest | null;
|
|
192
196
|
supply: SupplyRequest | null;
|
|
193
197
|
demand: DemandRequest | null;
|
|
194
198
|
session: RecipeSession;
|
|
@@ -207,6 +211,9 @@ export function CalcPickers({
|
|
|
207
211
|
onCloseSupply: () => void;
|
|
208
212
|
onCloseDemand: () => void;
|
|
209
213
|
}) {
|
|
214
|
+
const member = memberNode
|
|
215
|
+
? memberTarget(memberNode, data.tagSelections)
|
|
216
|
+
: undefined;
|
|
210
217
|
return (
|
|
211
218
|
<>
|
|
212
219
|
{pickerNode ? (
|
|
@@ -225,16 +232,16 @@ export function CalcPickers({
|
|
|
225
232
|
onSetRecipeDefault={data.onSetRecipeDefault}
|
|
226
233
|
/>
|
|
227
234
|
) : null}
|
|
228
|
-
{
|
|
235
|
+
{member ? (
|
|
229
236
|
<CalcMemberPicker
|
|
230
237
|
open
|
|
231
238
|
onOpenChange={(open) => {
|
|
232
239
|
if (!open) onCloseMember();
|
|
233
240
|
}}
|
|
234
|
-
tagId={
|
|
235
|
-
members={
|
|
236
|
-
selected={
|
|
237
|
-
memberKind={
|
|
241
|
+
tagId={member.tagId}
|
|
242
|
+
members={member.members}
|
|
243
|
+
selected={member.selected}
|
|
244
|
+
memberKind={member.kind}
|
|
238
245
|
dataset={dataset}
|
|
239
246
|
lang={session.lang}
|
|
240
247
|
langMap={session.langMap}
|
|
@@ -31,6 +31,8 @@ export function CalcToolbar({
|
|
|
31
31
|
onModeChange: (mode: CalcViewMode) => void;
|
|
32
32
|
farCards: CalcFarMode;
|
|
33
33
|
onFarCardsChange: (mode: CalcFarMode) => void;
|
|
34
|
+
recipeIds: boolean;
|
|
35
|
+
onRecipeIdsChange: (show: boolean) => void;
|
|
34
36
|
}) {
|
|
35
37
|
const t = useTranslations();
|
|
36
38
|
return (
|
|
@@ -10,6 +10,7 @@ import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-transl
|
|
|
10
10
|
import { IconButton } from '@terrafirmagreg-team/ui/components/blocks/button/icon-button';
|
|
11
11
|
import {
|
|
12
12
|
DropdownMenu,
|
|
13
|
+
DropdownMenuCheckboxItem,
|
|
13
14
|
DropdownMenuContent,
|
|
14
15
|
DropdownMenuLabel,
|
|
15
16
|
DropdownMenuRadioGroup,
|
|
@@ -35,11 +36,15 @@ export function CalcViewMenu({
|
|
|
35
36
|
onModeChange,
|
|
36
37
|
farCards,
|
|
37
38
|
onFarCardsChange,
|
|
39
|
+
recipeIds,
|
|
40
|
+
onRecipeIdsChange,
|
|
38
41
|
}: {
|
|
39
42
|
mode: CalcViewMode;
|
|
40
43
|
onModeChange: (mode: CalcViewMode) => void;
|
|
41
44
|
farCards: CalcFarMode;
|
|
42
45
|
onFarCardsChange: (mode: CalcFarMode) => void;
|
|
46
|
+
recipeIds: boolean;
|
|
47
|
+
onRecipeIdsChange: (show: boolean) => void;
|
|
43
48
|
}) {
|
|
44
49
|
const t = useTranslations();
|
|
45
50
|
const modeLabels: Record<CalcViewMode, string> = {
|
|
@@ -110,6 +115,14 @@ export function CalcViewMenu({
|
|
|
110
115
|
</DropdownMenuRadioGroup>
|
|
111
116
|
</>
|
|
112
117
|
) : null}
|
|
118
|
+
<DropdownMenuSeparator />
|
|
119
|
+
<DropdownMenuCheckboxItem
|
|
120
|
+
className="whitespace-nowrap"
|
|
121
|
+
checked={recipeIds}
|
|
122
|
+
onCheckedChange={(checked) => onRecipeIdsChange(checked === true)}
|
|
123
|
+
>
|
|
124
|
+
{t('Show recipe IDs', { note: 'recipe.calc.ids' })}
|
|
125
|
+
</DropdownMenuCheckboxItem>
|
|
113
126
|
</DropdownMenuContent>
|
|
114
127
|
</DropdownMenu>
|
|
115
128
|
);
|
|
@@ -13,7 +13,10 @@ import {
|
|
|
13
13
|
} from '@terrafirmagreg-team/ui/components/ui/command';
|
|
14
14
|
import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
|
|
15
15
|
import { stackDisplayName } from '@terrafirmagreg-team/game/lib/entry/display';
|
|
16
|
-
import
|
|
16
|
+
import {
|
|
17
|
+
stackIdBase,
|
|
18
|
+
type ReferenceKind,
|
|
19
|
+
} from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
17
20
|
|
|
18
21
|
export function CalcMemberList({
|
|
19
22
|
tagId,
|
|
@@ -46,7 +49,9 @@ export function CalcMemberList({
|
|
|
46
49
|
key={id}
|
|
47
50
|
value={id}
|
|
48
51
|
keywords={[stackDisplayName(langMap, id), id]}
|
|
49
|
-
data-checked={
|
|
52
|
+
data-checked={
|
|
53
|
+
selected != null && stackIdBase(id) === stackIdBase(selected)
|
|
54
|
+
}
|
|
50
55
|
onSelect={() => onSelect(tagId, id)}
|
|
51
56
|
>
|
|
52
57
|
<Entry
|