@terrafirmagreg-team/recipe 1.2.32 → 1.2.33

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.32",
3
+ "version": "1.2.33",
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.14",
29
- "@terrafirmagreg-team/kit": "^1.2.31",
29
+ "@terrafirmagreg-team/kit": "^1.2.32",
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.23",
34
+ "@terrafirmagreg-team/ui": "^1.2.24",
35
35
  "@types/pathfinding": "^0.1.0",
36
36
  "comlink": "^4.4.2",
37
37
  "fflate": "0.8.3",
@@ -27,8 +27,6 @@ export function CardText({
27
27
  if (!content) return null;
28
28
  const wrap = widget.type === 'paragraph';
29
29
  const rgb = widget.color === undefined ? 0xffffff : widget.color & 0xffffff;
30
- const shadowRgb = ((rgb & 0xfcfcfc) >> 2) & 0xffffff;
31
- const shadowed = widget.shadow === true;
32
30
  return (
33
31
  <span
34
32
  className={`font-mc pointer-events-none absolute leading-none ${wrap ? 'whitespace-pre-wrap' : 'whitespace-pre'}`}
@@ -47,11 +45,6 @@ export function CardText({
47
45
  }),
48
46
  fontSize: size ?? 8 * scale,
49
47
  color: `#${rgb.toString(16).padStart(6, '0')}`,
50
- ...(shadowed
51
- ? {
52
- textShadow: `${scale}px ${scale}px 0 #${shadowRgb.toString(16).padStart(6, '0')}`,
53
- }
54
- : {}),
55
48
  }}
56
49
  >
57
50
  <McText text={content} surface="dark" />
@@ -315,7 +315,6 @@ export function ScrollCard(props: Props) {
315
315
 
316
316
  const renderText = (el: ScrollElement, index: number, moving: boolean) => {
317
317
  const rgb = (el.color ?? 0xffffff) & 0xffffff;
318
- const shadowRgb = ((rgb & 0xfcfcfc) >> 2) & 0xffffff;
319
318
  const x = (el.x - viewport.x) * scale;
320
319
  const y = (el.y - viewport.y) * scale;
321
320
  const shifted = (horizontal ? x : y) - (moving ? offset * scale : 0);
@@ -328,11 +327,6 @@ export function ScrollCard(props: Props) {
328
327
  top: horizontal ? y : shifted,
329
328
  fontSize: 8 * scale,
330
329
  color: `#${rgb.toString(16).padStart(6, '0')}`,
331
- ...(shadowRgb !== rgb
332
- ? {
333
- textShadow: `${scale}px ${scale}px 0 #${shadowRgb.toString(16).padStart(6, '0')}`,
334
- }
335
- : {}),
336
330
  }}
337
331
  >
338
332
  <McText text={el.text ?? ''} surface="dark" />
@@ -417,7 +411,7 @@ export function ScrollCard(props: Props) {
417
411
  ) : null}
418
412
  {el.label ? (
419
413
  <span
420
- className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-white [text-shadow:1px_1px_0_var(--color-mc-arrow)]"
414
+ className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-white"
421
415
  style={{ fontSize: (el.w / 16) * 7 * scale }}
422
416
  >
423
417
  {el.label}
@@ -146,7 +146,6 @@ export function SlotHitbox({
146
146
  style={{
147
147
  paddingLeft: scale / 2,
148
148
  fontSize: (Math.min(widget.w, widget.h) / 16) * 7 * scale,
149
- textShadow: `${scale}px ${scale}px 0 var(--color-mc-arrow)`,
150
149
  }}
151
150
  >
152
151
  #
@@ -172,7 +171,6 @@ export function SlotHitbox({
172
171
  (Math.min(widget.w, widget.h) / 16) *
173
172
  (widget.kind === 'fluid' ? 4 : 7) *
174
173
  scale,
175
- textShadow: `${scale}px ${scale}px 0 var(--color-mc-arrow)`,
176
174
  }}
177
175
  >
178
176
  {widget.kind === 'fluid'
@@ -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-white [text-shadow:1px_1px_0_var(--color-mc-arrow)]"
112
+ className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-white"
113
113
  style={{ fontSize: (pitch / 16) * (kind === 'fluid' ? 4 : 7) }}
114
114
  >
115
115
  {badges.join(' ')}
@@ -4,6 +4,7 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
4
4
  import { useMemo } from 'react';
5
5
  import { Shapes } from 'lucide-react';
6
6
  import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
7
+ import { creativeTabName } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
7
8
  import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
8
9
  import { IconPager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
9
10
  import type { RecipeCategory, RecipeSession } from '@terrafirmagreg-team/recipe/types';
@@ -37,13 +38,16 @@ export function RecipeTypeTabs({
37
38
  onChange,
38
39
  className,
39
40
  }: {
40
- session: Pick<RecipeSession, 'lang' | 'names' | 'index' | 'dataset'>;
41
+ session: Pick<
42
+ RecipeSession,
43
+ 'lang' | 'names' | 'index' | 'dataset' | 'langMap'
44
+ >;
41
45
  ids: string[];
42
46
  value?: string;
43
47
  onChange?: (id: string) => void;
44
48
  className?: string;
45
49
  }) {
46
- const { lang, names, index, dataset } = session;
50
+ const { lang, names, index, dataset, langMap } = session;
47
51
 
48
52
  const options = useMemo(() => {
49
53
  const byId = new Map(
@@ -54,10 +58,12 @@ export function RecipeTypeTabs({
54
58
  return {
55
59
  id,
56
60
  icon: <CategoryGlyph category={category} dataset={dataset} />,
57
- help: recipeItemName(names, lang, id),
61
+ help: category?.display?.name
62
+ ? creativeTabName(langMap ?? {}, category.display.name)
63
+ : recipeItemName(names, lang, id),
58
64
  };
59
65
  });
60
- }, [index, ids, lang, names, dataset]);
66
+ }, [index, ids, lang, names, dataset, langMap]);
61
67
 
62
68
  return (
63
69
  <IconPager
@@ -84,6 +84,7 @@ export function Calculator({ session }: { session: RecipeSession }) {
84
84
  nodes: deferredNodes,
85
85
  tagMembers,
86
86
  ensureMaterial,
87
+ fluids: session.index?.fluids,
87
88
  });
88
89
 
89
90
  const iconItems = useMemo(
@@ -214,12 +214,27 @@ export const CalcNodeCardFull = memo(function CalcNodeCardFull({
214
214
  >
215
215
  <Minus className="size-2.5" />
216
216
  </button>
217
- <span
218
- className="min-w-6 text-center tabular-nums"
217
+ <input
218
+ key={node.crafts}
219
+ type="number"
220
+ min={1}
221
+ defaultValue={node.crafts}
219
222
  title={t('Crafts', { note: 'recipe.calc.crafts.title' })}
220
- >
221
- {node.crafts}
222
- </span>
223
+ aria-label={t('Crafts', { note: 'recipe.calc.crafts.title' })}
224
+ className="w-9 rounded border border-transparent bg-transparent text-center tabular-nums hover:border-border focus:border-border focus:outline-none"
225
+ onClick={(e) => e.stopPropagation()}
226
+ onKeyDown={(e) => {
227
+ if (e.key === 'Enter') e.currentTarget.blur();
228
+ }}
229
+ onBlur={(e) => {
230
+ const next = Math.max(
231
+ 1,
232
+ Math.round(Number(e.target.value) || 1),
233
+ );
234
+ if (next !== node.crafts) onCrafts(id, next);
235
+ else e.target.value = String(node.crafts);
236
+ }}
237
+ />
223
238
  <button
224
239
  type="button"
225
240
  aria-label={t('More crafts', { note: 'recipe.calc.crafts.up' })}
@@ -12,7 +12,10 @@ import { recipeCalcHref, recipeStackHref } from '@terrafirmagreg-team/recipe/lib
12
12
  import type { Recipe } from '@terrafirmagreg-team/recipe/lib/data/dto';
13
13
  import { loadClientRecipe } from '@terrafirmagreg-team/recipe/lib/client/recipe';
14
14
  import { resolveClientTag } from '@terrafirmagreg-team/dump/lib/dump/client/tags';
15
- import { toCalcRecipe } from '@terrafirmagreg-team/recipe/lib/calc/tree';
15
+ import {
16
+ recipeDivisor,
17
+ toCalcRecipe,
18
+ } from '@terrafirmagreg-team/recipe/lib/calc/tree';
16
19
  import { CALC_NODE_W } from '@terrafirmagreg-team/recipe/lib/calc/flow';
17
20
  import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
18
21
  import type {
@@ -47,6 +50,7 @@ export function useCalcActions({
47
50
  nodes,
48
51
  tagMembers,
49
52
  ensureMaterial,
53
+ fluids,
50
54
  }: {
51
55
  dataset: DatasetRef;
52
56
  lang: Lang;
@@ -64,7 +68,9 @@ export function useCalcActions({
64
68
  nodes: CalcNode[];
65
69
  tagMembers?: (tagId: string) => TagResolution | undefined;
66
70
  ensureMaterial?: (materialId: string) => void;
71
+ fluids?: readonly string[];
67
72
  }) {
73
+ const fluidIds = useMemo(() => new Set(fluids ?? []), [fluids]);
68
74
  const { checked: shared, onClick: onShare } = useCopyButton(async () => {
69
75
  const tree = encodeShare();
70
76
  const { id: datasetId, version } = dataset;
@@ -127,6 +133,13 @@ export function useCalcActions({
127
133
 
128
134
  const onAddCard = useCallback(
129
135
  (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
+ }
130
143
  const id = newCardId();
131
144
  persist({
132
145
  cards: [
@@ -139,7 +152,7 @@ export function useCalcActions({
139
152
  setFocusNodeId(id);
140
153
  return id;
141
154
  },
142
- [flushAmounts, persist, wires, tagSelections, setFocusNodeId],
155
+ [flushAmounts, persist, wires, tagSelections, setFocusNodeId, fluidIds],
143
156
  );
144
157
 
145
158
  const onSupplyInput = useCallback(
@@ -149,8 +162,13 @@ export function useCalcActions({
149
162
  const input = consumerNode?.inputs[inputIndex];
150
163
  if (!consumerNode || !consumerCard || !input?.id) return null;
151
164
  const need = Math.max(1, input.amount - input.covered);
152
- const crafts = recipeId && outputAmount
153
- ? Math.max(1, Math.ceil(need / outputAmount))
165
+ const per = outputAmount ?? (() => {
166
+ const body = recipeId ? recipeBody(recipeId) : undefined;
167
+ const calc = body ? toCalcRecipe(body) : undefined;
168
+ return calc ? recipeDivisor(calc, input.id!, input.kind) : 0;
169
+ })();
170
+ const crafts = recipeId && per > 0
171
+ ? Math.max(1, Math.ceil(need / per))
154
172
  : need;
155
173
  const base = consumerCard.pos;
156
174
  const id = newCardId();
@@ -179,7 +197,7 @@ export function useCalcActions({
179
197
  });
180
198
  return id;
181
199
  },
182
- [nodes, cards, wires, flushAmounts, persist, tagSelections],
200
+ [nodes, cards, wires, flushAmounts, persist, tagSelections, recipeBody],
183
201
  );
184
202
 
185
203
  const onDemandOutput = useCallback(
@@ -112,7 +112,10 @@ export async function usesForInput(
112
112
  ? [...new Set([...refs, ...ioRefs])]
113
113
  : refs;
114
114
  return uniqueRows([
115
- ...(await resolveRecipeRows(dataset, index, [...allRefs, ...tagRefs], opts)),
115
+ ...(await resolveRecipeRows(dataset, index, [...allRefs, ...tagRefs], {
116
+ includeTagRows: false,
117
+ ...opts,
118
+ })),
116
119
  ...stationRows.flat(),
117
120
  ]);
118
121
  }
package/styles/calc.css CHANGED
@@ -178,12 +178,6 @@
178
178
  line-height: 1;
179
179
  padding-bottom: 0.5px;
180
180
  color: var(--color-foreground);
181
- text-shadow:
182
- 0 0 2px var(--color-card),
183
- 0 1px 1px var(--color-card),
184
- 1px 0 1px var(--color-card),
185
- -1px 0 1px var(--color-card),
186
- 0 -1px 1px var(--color-card);
187
181
  }
188
182
 
189
183
  .calc-port-count[data-len='l'] {