@terrafirmagreg-team/recipe 1.2.34 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terrafirmagreg-team/recipe",
3
- "version": "1.2.34",
3
+ "version": "1.2.35",
4
4
  "type": "module",
5
5
  "description": "Recipe viewer and calculator",
6
6
  "license": "LGPL-3.0-only",
@@ -26,12 +26,12 @@
26
26
  "@terrafirmagreg-team/data": "^1.2.14",
27
27
  "@terrafirmagreg-team/dump": "^1.2.25",
28
28
  "@terrafirmagreg-team/game": "^1.2.15",
29
- "@terrafirmagreg-team/kit": "^1.2.33",
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.25",
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",
@@ -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 = 0x000000;
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,7 +45,7 @@ export function CardText({
44
45
  ...(wrap ? { width: widget.w * scale } : {}),
45
46
  }),
46
47
  fontSize: size ?? 8 * scale,
47
- color: `#${rgb.toString(16).padStart(6, '0')}`,
48
+ color: `#${ink.toString(16).padStart(6, '0')}`,
48
49
  }}
49
50
  >
50
51
  <McText text={content} surface="light" />
@@ -79,6 +79,7 @@ export function RecipeFrame({
79
79
  {list ? (
80
80
  onPageChange ? (
81
81
  <Pager
82
+ layout="center"
82
83
  page={list.page}
83
84
  pages={list.pages}
84
85
  to={list.to}
@@ -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.expanded ? undefined : expandLabel}>
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 members={cell.members} size="lg" />
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}
@@ -82,6 +82,7 @@ export function QueryPager({
82
82
  const resolved = useResolvedLang();
83
83
  return (
84
84
  <Pager
85
+ layout="center"
85
86
  page={list.page}
86
87
  pages={list.pages}
87
88
  to={list.to}
@@ -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(
@@ -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, fluidIds],
145
+ [flushAmounts, persist, wires, tagSelections, setFocusNodeId],
156
146
  );
157
147
 
158
148
  const onSupplyInput = useCallback(
@@ -2,7 +2,7 @@ import { boolCodec, createStoredValue } from '@terrafirmagreg-team/ui/lib/utils/
2
2
 
3
3
  const useStoredHideUnused = createStoredValue(
4
4
  'wiki.recipe.hideUnused',
5
- boolCodec(false),
5
+ boolCodec(true),
6
6
  );
7
7
 
8
8
  export function useHideUnused() {
@@ -121,6 +121,14 @@ export function usePanelCells({
121
121
  );
122
122
  }, [deferredFiltered, dIndex, mode, expandedGroups, favorites.entries]);
123
123
 
124
- return { cells, filtered: deferredFiltered, favoriteIds, dIndex, dNames, dLang };
124
+ return {
125
+ cells,
126
+ filtered: deferredFiltered,
127
+ favoriteIds,
128
+ dIndex,
129
+ dNames,
130
+ dLang,
131
+ used,
132
+ };
125
133
  }
126
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 { RecipeCompactIndex } from '@terrafirmagreg-team/recipe/types';
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
 
@@ -5,11 +5,16 @@ import {
5
5
  import { registryId } from '@terrafirmagreg-team/dump/lib/dump/paths';
6
6
  import { creativeTabName } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
7
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';
8
12
  import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
9
13
  import type {
10
14
  ItemPanelCell,
11
15
  RecipeCompactIndex,
12
16
  RecipeStackGroup,
17
+ UsedItems,
13
18
  } from '@terrafirmagreg-team/recipe/types';
14
19
 
15
20
  function catalogPool(index: RecipeCompactIndex, tab?: string): string[] {
@@ -24,6 +29,7 @@ type ItemPanelTabRow = {
24
29
  icon: string;
25
30
  iconRef?: TaggedReference;
26
31
  help: string;
32
+ helpKey?: string;
27
33
  };
28
34
 
29
35
  export function panelPool(
@@ -74,12 +80,16 @@ export function buildPanelCells(
74
80
  continue;
75
81
  }
76
82
  const expanded = expandedGroups.has(group.id);
83
+ const fluid = members.every((member) =>
84
+ fluidIds?.has(registryId(member)),
85
+ );
77
86
  out.push({
78
87
  kind: 'group',
79
88
  id: group.id,
80
89
  label: group.name ?? group.id,
81
90
  members,
82
91
  expanded,
92
+ ...(fluid ? { ref: 'fluid' as const } : {}),
83
93
  });
84
94
  if (expanded)
85
95
  for (const member of members)
@@ -97,9 +107,17 @@ export function panelTabRows(
97
107
  index: RecipeCompactIndex | null,
98
108
  names: Record<string, Record<string, string>>,
99
109
  lang: Lang,
110
+ used?: UsedItems,
100
111
  ): ItemPanelTabRow[] {
112
+ const hideEmpty = used !== undefined && hasRecipeUsage(used);
101
113
  const rows: ItemPanelTabRow[] = [];
102
114
  for (const row of index?.tabs ?? []) {
115
+ if (
116
+ hideEmpty &&
117
+ filterUsedIds(index?.tabItems?.[row.id] ?? [], used).length === 0
118
+ ) {
119
+ continue;
120
+ }
103
121
  const icon =
104
122
  (row.icon ? stackIdFromRef(row.icon) : undefined) ??
105
123
  index?.tabItems?.[row.id]?.[0];
@@ -111,6 +129,7 @@ export function panelTabRows(
111
129
  help: row.display?.name
112
130
  ? creativeTabName(names[lang] ?? names.en_us ?? {}, row.display.name)
113
131
  : recipeItemName(names, lang, row.id),
132
+ helpKey: row.display?.name ?? row.id,
114
133
  });
115
134
  }
116
135
  return rows;
@@ -53,6 +53,7 @@ export type ItemPanelCell =
53
53
  label: string;
54
54
  members: string[];
55
55
  expanded: boolean;
56
+ ref?: 'item' | 'fluid';
56
57
  }
57
58
  | { kind: 'recipe'; fav: RecipeFavorite };
58
59