@terrafirmagreg-team/game 1.2.2 → 1.2.3
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/game",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Game-data components and catalogs",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@terrafirmagreg-team/data": "1.2.1",
|
|
29
29
|
"@terrafirmagreg-team/dump": "1.2.1",
|
|
30
|
-
"@terrafirmagreg-team/kit": "1.2.
|
|
30
|
+
"@terrafirmagreg-team/kit": "1.2.3",
|
|
31
31
|
"@terrafirmagreg-team/search": "1.2.2",
|
|
32
32
|
"@terrafirmagreg-team/sites": "1.2.1",
|
|
33
33
|
"@terrafirmagreg-team/translate": "1.2.3",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
3
3
|
|
|
4
4
|
import { useState, type ReactElement, type ReactNode } from 'react';
|
|
5
|
+
import type { ReferenceKind } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
5
6
|
import { useModifierKeys } from '@terrafirmagreg-team/ui/hooks/use-modifier-keys';
|
|
6
7
|
import { LazyTooltip } from '@terrafirmagreg-team/ui/components/blocks/tooltip/lazy';
|
|
7
8
|
import { stackTooltip } from '@terrafirmagreg-team/game/lib/entry/tooltip';
|
|
@@ -50,7 +51,7 @@ export function EntryTooltip({
|
|
|
50
51
|
dataset: DatasetRef;
|
|
51
52
|
id: string;
|
|
52
53
|
name: string;
|
|
53
|
-
kind?:
|
|
54
|
+
kind?: ReferenceKind;
|
|
54
55
|
|
|
55
56
|
lang?: string;
|
|
56
57
|
langMap?: Record<string, string>;
|
package/src/lib/entry/entry.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
2
2
|
import { entryHref } from '@terrafirmagreg-team/game/lib/entry/href';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
isTagKind,
|
|
5
|
+
tagKindOf,
|
|
6
|
+
} from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
4
7
|
import type { ReferenceKind } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
5
8
|
import type { EntryProps } from '@terrafirmagreg-team/game/types/entry';
|
|
6
9
|
|
|
@@ -20,7 +23,8 @@ export function usesStackTooltip(kind: ReferenceKind | undefined): boolean {
|
|
|
20
23
|
|
|
21
24
|
export function tooltipLoadKind(
|
|
22
25
|
kind: ReferenceKind | undefined,
|
|
23
|
-
):
|
|
26
|
+
): ReferenceKind | undefined {
|
|
27
|
+
if (isTagKind(kind)) return kind;
|
|
24
28
|
const member = tagKindOf(kind) ?? kind;
|
|
25
29
|
if (member === 'fluid') return 'fluid';
|
|
26
30
|
if (member === 'entity') return 'entity';
|
package/src/lib/entry/tooltip.ts
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
2
2
|
import { displayOf } from '@terrafirmagreg-team/dump/lib/dump/data/registry/parse';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
parseStackId,
|
|
5
|
+
tagKindOf,
|
|
6
|
+
type ReferenceKind,
|
|
7
|
+
} from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
4
8
|
import { clientDumpLang } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
5
9
|
import {
|
|
6
10
|
clientRegistryKindFor,
|
|
7
11
|
loadClientRegistry,
|
|
8
12
|
} from '@terrafirmagreg-team/dump/lib/dump/client/registry';
|
|
9
13
|
import type { DumpDisplay } from '@terrafirmagreg-team/dump/lib/dump/contract/text';
|
|
10
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
dumpTextLines,
|
|
16
|
+
stackDisplayName,
|
|
17
|
+
} from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
11
18
|
import { createDatasetCache } from '@terrafirmagreg-team/dump/lib/dump/reader';
|
|
19
|
+
import { fetchTagMembers } from '@terrafirmagreg-team/game/lib/entry/icon-load';
|
|
12
20
|
|
|
13
21
|
export const loadStackDisplay = createDatasetCache(
|
|
14
22
|
async (
|
|
@@ -43,11 +51,28 @@ export async function stackTooltip(
|
|
|
43
51
|
id: string,
|
|
44
52
|
lang: string | undefined,
|
|
45
53
|
langMap: Record<string, string> | undefined,
|
|
46
|
-
kind:
|
|
54
|
+
kind: ReferenceKind | undefined,
|
|
47
55
|
): Promise<StackTooltip> {
|
|
48
|
-
const display = await loadStackDisplay(dataset, id, kind);
|
|
49
56
|
const map =
|
|
50
57
|
langMap ?? (lang ? await clientDumpLang(dataset, lang) : undefined);
|
|
58
|
+
if (id.startsWith('#')) {
|
|
59
|
+
if (!map) return { lines: [], mods: {} };
|
|
60
|
+
const members = await fetchTagMembers(
|
|
61
|
+
dataset,
|
|
62
|
+
id.slice(1),
|
|
63
|
+
tagKindOf(kind) ?? 'item',
|
|
64
|
+
);
|
|
65
|
+
return {
|
|
66
|
+
lines: members.map((member) => stackDisplayName(map, member)),
|
|
67
|
+
mods: {},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const memberKind = tagKindOf(kind) ?? kind;
|
|
71
|
+
const loadKind =
|
|
72
|
+
memberKind === 'fluid' || memberKind === 'entity'
|
|
73
|
+
? memberKind
|
|
74
|
+
: 'item';
|
|
75
|
+
const display = await loadStackDisplay(dataset, id, loadKind);
|
|
51
76
|
if (!display || !map) return { lines: [], mods: {} };
|
|
52
77
|
const mods: Record<string, string[]> = {};
|
|
53
78
|
for (const [mod, raw] of Object.entries(display.tooltipMods ?? {})) {
|