@team-antioch/sc2-adjutant 0.1.0 → 0.1.1
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/README.md +2 -0
- package/data/blizzard-baseline.json +3061 -0
- package/data/button-hotkeys.json +5722 -0
- package/data/game-assets.json +50909 -0
- package/data/package-entries.json +32361 -2
- package/dist/capture/bank-fixtures.d.ts +13 -0
- package/dist/capture/bank-fixtures.js +35 -0
- package/dist/capture/bank-snapshots.d.ts +95 -0
- package/dist/capture/bank-snapshots.js +302 -0
- package/dist/capture/editor-broker-client.d.ts +27 -4
- package/dist/capture/editor-broker-client.js +3 -3
- package/dist/capture/editor-broker.js +154 -9
- package/dist/capture/effect-tour.d.ts +113 -0
- package/dist/capture/effect-tour.js +283 -0
- package/dist/capture/effect-video.d.ts +74 -0
- package/dist/capture/effect-video.js +173 -0
- package/dist/capture/exemplar-capture.d.ts +4 -0
- package/dist/capture/exemplar-capture.js +4 -1
- package/dist/capture/shots.d.ts +6 -1
- package/dist/capture/shots.js +1 -1
- package/dist/capture/stop-tour.d.ts +3 -1
- package/dist/capture/stop-tour.js +1 -1
- package/dist/capture/style-pack-captures.d.ts +67 -0
- package/dist/capture/style-pack-captures.js +172 -0
- package/dist/catalog/stock-catalog.d.ts +8 -0
- package/dist/catalog/stock-catalog.js +13 -0
- package/dist/cli/capture-exemplars.js +18 -32
- package/dist/cli/effect-tour.d.ts +2 -0
- package/dist/cli/effect-tour.js +378 -0
- package/dist/cli/make-frames.d.ts +1 -0
- package/dist/cli/make-frames.js +21 -0
- package/dist/cli/sound-mix.d.ts +1 -0
- package/dist/cli/sound-mix.js +75 -0
- package/dist/cli/study.js +6 -26
- package/dist/domain/blueprint-trigger.d.ts +355 -3
- package/dist/domain/blueprint-trigger.js +149 -8
- package/dist/domain/library-interface.d.ts +50 -29
- package/dist/domain/library-interface.js +54 -41
- package/dist/domain/mission-blueprint.d.ts +13 -6
- package/dist/domain/mission-blueprint.js +6 -0
- package/dist/domain/mod-blueprint.d.ts +4 -4
- package/dist/host/game-logs.d.ts +63 -0
- package/dist/host/game-logs.js +178 -0
- package/dist/host/game-ownership.d.ts +37 -0
- package/dist/host/game-ownership.js +84 -0
- package/dist/host/game-run-report.d.ts +63 -0
- package/dist/host/game-run-report.js +119 -0
- package/dist/host/known-errors.d.ts +34 -0
- package/dist/host/known-errors.js +73 -0
- package/dist/init/init-workspace.d.ts +3 -1
- package/dist/init/init-workspace.js +10 -1
- package/dist/map/convert-mission-triggers.d.ts +115 -7
- package/dist/map/convert-mission-triggers.js +527 -47
- package/dist/map/editor-changes.d.ts +1 -1
- package/dist/map/editor-form.d.ts +5 -0
- package/dist/map/editor-form.js +72 -0
- package/dist/map/game-packages.d.ts +3 -2
- package/dist/map/game-packages.js +5 -2
- package/dist/map/kept-references.js +47 -1
- package/dist/map/kept-session.js +3 -1
- package/dist/map/outline-diff.d.ts +24 -0
- package/dist/map/outline-diff.js +95 -0
- package/dist/map/outline-trigger.d.ts +7 -0
- package/dist/map/outline-trigger.js +29 -20
- package/dist/map/ownership-plan.d.ts +6 -2
- package/dist/map/ownership-plan.js +1 -1
- package/dist/map/package-output.js +13 -8
- package/dist/map/tune-kept-triggers.d.ts +7 -0
- package/dist/map/tune-kept-triggers.js +33 -6
- package/dist/map/write-blueprint-trigger.d.ts +9 -4
- package/dist/map/write-blueprint-trigger.js +46 -13
- package/dist/map/write-map-package.js +20 -9
- package/dist/mcp/capture-jobs.d.ts +2 -0
- package/dist/mcp/capture-jobs.js +2 -0
- package/dist/mcp/server.d.ts +11 -2
- package/dist/mcp/server.js +17 -4
- package/dist/mcp/tools/bank-report.d.ts +19 -0
- package/dist/mcp/tools/bank-report.js +51 -0
- package/dist/mcp/tools/blueprint.js +18 -14
- package/dist/mcp/tools/capture.d.ts +4 -0
- package/dist/mcp/tools/capture.js +22 -5
- package/dist/mcp/tools/catalog.d.ts +1 -1
- package/dist/mcp/tools/catalog.js +30 -1
- package/dist/mcp/tools/compile.d.ts +1 -1
- package/dist/mcp/tools/compile.js +100 -9
- package/dist/mcp/tools/editor-handoff.d.ts +4 -1
- package/dist/mcp/tools/editor-handoff.js +6 -3
- package/dist/mcp/tools/style-pack.d.ts +11 -0
- package/dist/mcp/tools/style-pack.js +245 -0
- package/dist/mcp/tools/tool-group.d.ts +9 -0
- package/dist/mods/button-hotkeys.d.ts +45 -0
- package/dist/mods/button-hotkeys.js +185 -0
- package/dist/mods/compile-mod.js +19 -5
- package/dist/mods/custom-doodads.d.ts +21 -1
- package/dist/mods/custom-doodads.js +53 -7
- package/dist/mods/data-rules.js +8 -1
- package/dist/mods/effective-entry.d.ts +18 -0
- package/dist/mods/effective-entry.js +52 -0
- package/dist/mods/function-search.js +12 -0
- package/dist/mods/library-xml.d.ts +34 -5
- package/dist/mods/library-xml.js +94 -22
- package/dist/mods/sound-mix.d.ts +92 -0
- package/dist/mods/sound-mix.js +195 -0
- package/dist/plugins/check-workspace.js +22 -3
- package/dist/plugins/plugin-api.d.ts +59 -5
- package/dist/plugins/plugin-api.js +6 -0
- package/dist/plugins/plugin-sdk.d.ts +13 -1
- package/dist/plugins/plugin-sdk.js +16 -1
- package/dist/plugins/plugin-sources.js +1 -0
- package/dist/plugins/registry.d.ts +4 -0
- package/dist/plugins/registry.js +6 -2
- package/dist/plugins/workspace.d.ts +5 -0
- package/dist/plugins/workspace.js +10 -2
- package/dist/study/blizzard-baseline.d.ts +76 -0
- package/dist/study/blizzard-baseline.js +137 -0
- package/dist/study/exemplar-report.d.ts +71 -0
- package/dist/study/exemplar-report.js +163 -0
- package/dist/study/find-places.d.ts +127 -0
- package/dist/study/find-places.js +306 -0
- package/dist/study/load-map-package.d.ts +3 -0
- package/dist/study/load-map-package.js +11 -0
- package/dist/study/map-study.d.ts +1 -0
- package/dist/study/map-study.js +3 -0
- package/dist/study/measure-lighting.d.ts +6 -0
- package/dist/study/measure-lighting.js +1 -1
- package/dist/study/measures.d.ts +225 -0
- package/dist/study/measures.js +366 -0
- package/dist/study/scaffold-style-pack.d.ts +58 -0
- package/dist/study/scaffold-style-pack.js +261 -0
- package/dist/study/study-exemplars.d.ts +67 -0
- package/dist/study/study-exemplars.js +133 -0
- package/dist/triggers/blueprint-triggers.d.ts +71 -11
- package/dist/triggers/blueprint-triggers.js +403 -48
- package/dist/triggers/kept-trigger-galaxy.d.ts +29 -0
- package/dist/triggers/kept-trigger-galaxy.js +103 -7
- package/dist/triggers/splice-map-script.d.ts +2 -0
- package/dist/triggers/splice-map-script.js +309 -8
- package/dist/triggers/write-triggers-xml.js +20 -5
- package/dist/ui/frame-path-check.d.ts +43 -4
- package/dist/ui/frame-path-check.js +121 -13
- package/dist/ui/frame-paths.d.ts +21 -1
- package/dist/ui/frame-paths.js +26 -6
- package/dist/ui/toast.d.ts +4 -5
- package/dist/ui/toast.js +6 -10
- package/examples/example-campaign/README.md +27 -0
- package/examples/example-campaign/missions/ashfall-relay/blueprint.json +11 -1
- package/examples/example-campaign/missions/ashfall-relay/triggers/ash-tremors.json +69 -0
- package/examples/example-campaign/missions/ashfall-relay/triggers/start-ash-tremors.json +31 -0
- package/package.json +3 -3
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
// id refused when it is a game doodad's or unit's: the entries would replace the game's
|
|
18
18
|
// (a unit's actor and model are mostly of its id). A model at a game doodad model's
|
|
19
19
|
// path is warned about: its file replaces the game's for everything that draws it.
|
|
20
|
+
// entries a Blueprint Generic Entry's fields that name an `Assets\` model or image (genericEntryAssetWarnings)
|
|
21
|
+
// are warned about when no mod package, the Blueprint or the game's lists hold the file
|
|
20
22
|
// swaps checked against the .m3 the game draws (texture-swaps.ts): its own file, or a
|
|
21
23
|
// gameModel's read from the game through the Host Adapter's model.export, refused
|
|
22
24
|
// on a machine without it; each `with` found as the model's textures are (a
|
|
@@ -25,7 +27,7 @@ import { readFileSync } from "node:fs";
|
|
|
25
27
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
26
28
|
import { tmpdir } from "node:os";
|
|
27
29
|
import path from "node:path";
|
|
28
|
-
import { gameDoodadModels, isGameModel, listDoodads } from "../catalog/stock-catalog.js";
|
|
30
|
+
import { gameDoodadModels, isGameAsset, isGameModel, listDoodads } from "../catalog/stock-catalog.js";
|
|
29
31
|
import { findPackageFile } from "../catalog/package-files.js";
|
|
30
32
|
import { readM3Footprint, readM3MeshExtent } from "../catalog/m3-footprint.js";
|
|
31
33
|
import { readM3Sequences } from "../catalog/m3-sequences.js";
|
|
@@ -34,6 +36,7 @@ import { gameUnitIds } from "../catalog/tech-catalog.js";
|
|
|
34
36
|
import { OBJECT_STRINGS } from "../domain/entry-strings.js";
|
|
35
37
|
import { isLfsPointer } from "./asset-sources.js";
|
|
36
38
|
import { CatalogSchemaError, catalogSchema, schemaProblems } from "./catalog-schema.js";
|
|
39
|
+
import { genericEntryKey } from "./generic-entries.js";
|
|
37
40
|
import { isInside } from "../util/inside.js";
|
|
38
41
|
import { baseName, checkDoodadSwaps } from "./texture-swaps.js";
|
|
39
42
|
import { modPackagesUnder, readWorkspaceMod } from "./workspace-mods.js";
|
|
@@ -177,6 +180,54 @@ export function checkCustomDoodadFiles(doodad, label, find, lookedIn) {
|
|
|
177
180
|
}
|
|
178
181
|
return warnings;
|
|
179
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Finds a file by its storage path in the mod packages the game loads under the mod `id`, the mod's
|
|
185
|
+
* own among them (its Asset Mod's too, once compiled): `lookedIn` says where, for messages.
|
|
186
|
+
*/
|
|
187
|
+
export async function modFileFinder(workspace, id) {
|
|
188
|
+
const packages = await modPackagesUnder(workspace, await readWorkspaceMod(workspace, id));
|
|
189
|
+
const lookedIn = `the mod packages it loads from the Workspace (${packages.map((pkg) => fromRoot(workspace.root, pkg)).join(", ")}), where an Asset Mod's assets put its files once it's compiled`;
|
|
190
|
+
const find = (storagePath) => {
|
|
191
|
+
const found = findPackageFile(packages, storagePath);
|
|
192
|
+
return found ? { data: readFileSync(found.file), where: fromRoot(workspace.root, found.file) } : undefined;
|
|
193
|
+
};
|
|
194
|
+
return { find, lookedIn };
|
|
195
|
+
}
|
|
196
|
+
/** An asset path a Generic Entry's field names: a model, or an image (an icon, a texture). */
|
|
197
|
+
const ASSET_PATH = /^Assets[\\/][^#*]*\.(m3|dds|tga|png|jpg)$/i;
|
|
198
|
+
/** The asset paths `entry`'s fields name, each with its field's name (a nested one dotted, as `TextureDeclares.Prefix`). */
|
|
199
|
+
export function entryAssetPaths(entry) {
|
|
200
|
+
const found = [];
|
|
201
|
+
const walk = (value, field) => {
|
|
202
|
+
if (typeof value === "string") {
|
|
203
|
+
if (ASSET_PATH.test(value))
|
|
204
|
+
found.push({ field, path: value });
|
|
205
|
+
}
|
|
206
|
+
else if (Array.isArray(value))
|
|
207
|
+
for (const item of value)
|
|
208
|
+
walk(item, field);
|
|
209
|
+
else if (typeof value === "object")
|
|
210
|
+
for (const [key, each] of Object.entries(value))
|
|
211
|
+
if (!key.startsWith("$"))
|
|
212
|
+
walk(each, field === "" ? key : `${field}.${key}`);
|
|
213
|
+
};
|
|
214
|
+
for (const [name, value] of Object.entries(entry.fields))
|
|
215
|
+
walk(value, name);
|
|
216
|
+
return found;
|
|
217
|
+
}
|
|
218
|
+
/** A model with variations is its numbered files (`<name>_00.m3` and on), as the game names them: the first one, for a path without a number. */
|
|
219
|
+
const numbered = (file) => (/\.m3$/i.test(file) ? [file.replace(/\.m3$/i, "_00.m3")] : []);
|
|
220
|
+
/**
|
|
221
|
+
* Warns about each asset path `entries`' fields name (entryAssetPaths) that is no file the game
|
|
222
|
+
* loads under the mod: not found by `find` (as checkCustomDoodadFiles finds a model or texture), not
|
|
223
|
+
* a model core knows of (isGameModel), and for an image not one the game's data names (isGameAsset, every stock mod).
|
|
224
|
+
* The game may still have a file those lists lack, so it is advice. Names the entry, field and path.
|
|
225
|
+
*/
|
|
226
|
+
export function genericEntryAssetWarnings(entries, find, lookedIn) {
|
|
227
|
+
return entries.flatMap((entry) => entryAssetPaths(entry)
|
|
228
|
+
.filter(({ path: file }) => ![file, ...numbered(file)].some((each) => find(each) || isGameModel(each) || isGameAsset(each)))
|
|
229
|
+
.map(({ field, path: file }) => `${genericEntryKey(entry)}'s ${field} names ${file}, which isn't in ${lookedIn}, and no ${/\.m3$/i.test(file) ? "game model" : "game image"} core knows of is at that path: the game shows a placeholder or nothing. Add the file there (and compile it), or fix the path. If it is a game file core's list lacks (data/game-models.json or data/game-assets.json), report it on sc2-adjutant`));
|
|
230
|
+
}
|
|
180
231
|
/**
|
|
181
232
|
* Checks the files of a Campaign Mod's doodads (its Blueprint `doodads`, its folder's id `id`) in
|
|
182
233
|
* the Workspace's mod packages the game loads under it (its Asset Mod among them), as
|
|
@@ -189,12 +240,7 @@ export async function modDoodadWarnings(doodads, workspace, id, gameModels = asy
|
|
|
189
240
|
const swaps = new Map();
|
|
190
241
|
if (doodads.length === 0)
|
|
191
242
|
return { warnings: [], swaps };
|
|
192
|
-
const
|
|
193
|
-
const lookedIn = `the mod packages it loads from the Workspace (${packages.map((pkg) => fromRoot(workspace.root, pkg)).join(", ")}), where an Asset Mod's assets put its files once it's compiled`;
|
|
194
|
-
const find = (storagePath) => {
|
|
195
|
-
const found = findPackageFile(packages, storagePath);
|
|
196
|
-
return found ? { data: readFileSync(found.file), where: fromRoot(workspace.root, found.file) } : undefined;
|
|
197
|
-
};
|
|
243
|
+
const { find, lookedIn } = await modFileFinder(workspace, id);
|
|
198
244
|
const warnings = [];
|
|
199
245
|
for (const [index, doodad] of doodads.entries()) {
|
|
200
246
|
const label = `doodads.${index} (${doodad.id})`;
|
package/dist/mods/data-rules.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// one (the reference lists the evidence), but none is confirmed in the Editor yet, so none
|
|
4
4
|
// refuses a compile.
|
|
5
5
|
import { isCommentItem, isCommentKey } from "../domain/catalog-fields.js";
|
|
6
|
-
import {
|
|
6
|
+
import { repeatedFields } from "./effective-entry.js";
|
|
7
|
+
import { entryXml, genericEntryKey } from "./generic-entries.js";
|
|
7
8
|
/** The fields that hold one item per level, so an item with no index leaves the parent's level 0 as it was. */
|
|
8
9
|
const LEVEL_ARRAYS = ["VeterancyLevelArray", "LevelScalingArray", "LevelUpgradeArray"];
|
|
9
10
|
/** The AbilSetId Blizzard's class default gives every ability of that class, which a copy inherits. */
|
|
@@ -21,6 +22,8 @@ export function dataRuleWarnings(sources) {
|
|
|
21
22
|
if (entry.id !== undefined)
|
|
22
23
|
byId.set(`${entry.catalog}:${entry.id}`, entry);
|
|
23
24
|
const out = [];
|
|
25
|
+
// The Blueprint's own entries only, as the effective-entry merge reads them: Kept and imported data aren't here.
|
|
26
|
+
const repeats = repeatedFields(sources.map(({ from, entries }) => ({ label: from, files: [`<Catalog>\n${entries.map(entryXml).join("\n")}\n</Catalog>`] })));
|
|
24
27
|
for (const { from, entries } of sources) {
|
|
25
28
|
for (const entry of entries) {
|
|
26
29
|
const name = `${from}: ${genericEntryKey(entry)}`;
|
|
@@ -41,6 +44,10 @@ export function dataRuleWarnings(sources) {
|
|
|
41
44
|
}
|
|
42
45
|
if (entry.catalog === "Actor" && parent && parent.class !== entry.class && !entry.class.startsWith(parent.class))
|
|
43
46
|
out.push(`${name}: its parent ${entry.parent} is a ${parent.class}, not a ${entry.class}: parent an actor on one of its own class (Blizzard parents a subclass on its base class, such as CActorRegionQuad on CActorRegion, but the safe pairing is the same class)`);
|
|
47
|
+
for (const repeat of repeats.filter((one) => one.class === entry.class && one.id === entry.id)) {
|
|
48
|
+
const field = repeat.index === undefined ? repeat.field : `${repeat.field}[${repeat.index}]`;
|
|
49
|
+
out.push(`${name}: ${field} repeats the value its parent ${repeat.parent} sets: delete it here, so a later change to ${repeat.parent} reaches this entry (or change it, if it should differ)`);
|
|
50
|
+
}
|
|
44
51
|
if (entry.catalog === "Weapon" && entry.class === "CWeapon" && entry.id !== undefined)
|
|
45
52
|
out.push(`${name}: a named weapon is a CWeaponLegacy in Blizzard's data (none of its 3,000-odd named weapons is a CWeapon), and the Editor may refuse a named CWeapon: change its class to CWeaponLegacy`);
|
|
46
53
|
}
|
|
@@ -58,6 +58,24 @@ export type EntryQuery = {
|
|
|
58
58
|
export declare function effectiveEntry(layers: readonly DataLayer[], query: EntryQuery): EntryReport | {
|
|
59
59
|
readonly refused: string;
|
|
60
60
|
};
|
|
61
|
+
/** A field an entry writes that its parent chain already sets to the same value: `field`, or `field[index]` for one indexed element, and the entry whose definition sets it. */
|
|
62
|
+
export type RepeatedField = {
|
|
63
|
+
readonly class: string;
|
|
64
|
+
readonly id: string;
|
|
65
|
+
readonly field: string;
|
|
66
|
+
readonly index?: string;
|
|
67
|
+
readonly parent: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The fields each entry of the layers writes whose value its parent chain already gives it, read
|
|
71
|
+
* from the same merge as `effectiveEntry` (the chain from the root down, the entry's own fields
|
|
72
|
+
* not among them; the class default is left out, since it isn't a value the parent sets). A field
|
|
73
|
+
* given only by index is compared element by element; any other as a whole. An element removed
|
|
74
|
+
* with `removed="1"`, or one that names a ##token##, is never a repeat: the first is a decision
|
|
75
|
+
* and the second may mean something else under the child's tokens. An entry whose parent no layer
|
|
76
|
+
* defines has none.
|
|
77
|
+
*/
|
|
78
|
+
export declare function repeatedFields(layers: readonly DataLayer[]): RepeatedField[];
|
|
61
79
|
/** The report as plain lines for a reply. */
|
|
62
80
|
export declare function formatEntryReport(report: EntryReport): string;
|
|
63
81
|
/** Blizzard's data layers from an SC2GameData folder (its `mods/` and `campaigns/` packages), in load order, skipping a package it lacks; none when it has none. */
|
|
@@ -223,6 +223,58 @@ export function effectiveEntry(layers, query) {
|
|
|
223
223
|
notes,
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* The fields each entry of the layers writes whose value its parent chain already gives it, read
|
|
228
|
+
* from the same merge as `effectiveEntry` (the chain from the root down, the entry's own fields
|
|
229
|
+
* not among them; the class default is left out, since it isn't a value the parent sets). A field
|
|
230
|
+
* given only by index is compared element by element; any other as a whole. An element removed
|
|
231
|
+
* with `removed="1"`, or one that names a ##token##, is never a repeat: the first is a decision
|
|
232
|
+
* and the second may mean something else under the child's tokens. An entry whose parent no layer
|
|
233
|
+
* defines has none.
|
|
234
|
+
*/
|
|
235
|
+
export function repeatedFields(layers) {
|
|
236
|
+
const index = new DataIndex(layers);
|
|
237
|
+
const text = (element) => render(element.node, new Map(), new Set());
|
|
238
|
+
const kept = (field) => field.elements.filter((element) => !element.removed);
|
|
239
|
+
const out = [];
|
|
240
|
+
for (const entry of index.entries.values()) {
|
|
241
|
+
if (entry.parent === undefined || entry.id === "")
|
|
242
|
+
continue;
|
|
243
|
+
const chain = [entry];
|
|
244
|
+
for (let current = entry; current.parent !== undefined;) {
|
|
245
|
+
const parent = index.resolveParent(current.cls, current.parent);
|
|
246
|
+
if (!parent || chain.includes(parent))
|
|
247
|
+
break;
|
|
248
|
+
chain.push(parent);
|
|
249
|
+
current = parent;
|
|
250
|
+
}
|
|
251
|
+
const inherited = new Map();
|
|
252
|
+
for (const source of [...chain.slice(1)].reverse()) {
|
|
253
|
+
mergeFields(inherited, [...source.fields.values()].flatMap((field) => field.elements.map((element) => ({ node: element.node, from: nameOf(source) }))));
|
|
254
|
+
}
|
|
255
|
+
for (const [name, own] of entry.fields) {
|
|
256
|
+
const given = inherited.get(name);
|
|
257
|
+
if (!given)
|
|
258
|
+
continue;
|
|
259
|
+
const mine = kept(own);
|
|
260
|
+
const theirs = kept(given);
|
|
261
|
+
if (mine.length === 0 || mine.some((element) => text(element).includes("##")))
|
|
262
|
+
continue;
|
|
263
|
+
const base = { class: entry.cls, id: entry.id, field: name };
|
|
264
|
+
if (own.over) {
|
|
265
|
+
for (const element of mine) {
|
|
266
|
+
const same = theirs.find((other) => other.index === element.index);
|
|
267
|
+
if (same && text(same) === text(element))
|
|
268
|
+
out.push({ ...base, index: element.index, parent: same.from });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
else if (mine.length === theirs.length && mine.every((element, place) => text(element) === text(theirs[place]))) {
|
|
272
|
+
out.push({ ...base, parent: theirs[0].from });
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return out;
|
|
277
|
+
}
|
|
226
278
|
/** The report as plain lines for a reply. */
|
|
227
279
|
export function formatEntryReport(report) {
|
|
228
280
|
const lines = [`${report.class}:${report.id}, defined in ${report.layers.join(", ")}`];
|
|
@@ -37,8 +37,20 @@ export function editorTypeName(libraries, spec) {
|
|
|
37
37
|
return `${types["gamelink"] ?? "Game Link"} - ${spec.gameType}`;
|
|
38
38
|
return types[type] ?? type;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The index of each record of libraries in reach, built the first time it is searched: the authoring
|
|
42
|
+
* tool resolves a name for every call it writes, and an outline resolves each again. A record isn't
|
|
43
|
+
* changed once searched (missionLibraries and librariesInReach fill theirs before they return it).
|
|
44
|
+
*/
|
|
45
|
+
const INDEXES = new WeakMap();
|
|
40
46
|
/** Every function in reach, indexed for search, library by library in reach order. */
|
|
41
47
|
function indexed(libraries) {
|
|
48
|
+
let index = INDEXES.get(libraries);
|
|
49
|
+
if (index === undefined)
|
|
50
|
+
INDEXES.set(libraries, (index = buildIndex(libraries)));
|
|
51
|
+
return index;
|
|
52
|
+
}
|
|
53
|
+
function buildIndex(libraries) {
|
|
42
54
|
const typeName = (spec) => editorTypeName(libraries, spec);
|
|
43
55
|
// A type answers to the name the Editor shows and to its own (unitgroup), folded.
|
|
44
56
|
const answers = (spec) => (spec === undefined ? [] : [...new Set([folded(typeName(spec)), ...(spec.type ? [folded(spec.type)] : [])])]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArrayBound, GuiBody, GuiStatement, GuiVariable, HeldValue, LibraryCategory, LibraryComment, LibraryCustomScript, LibraryFunction, LibraryParameter, LibraryPreset, LibraryStructure } from "../domain/library-interface.js";
|
|
2
|
-
import type { BlueprintTrigger } from "../domain/blueprint-trigger.js";
|
|
2
|
+
import type { BlueprintPreset, BlueprintTrigger } from "../domain/blueprint-trigger.js";
|
|
3
3
|
import { type LibraryStructureKind } from "../domain/library-interface.js";
|
|
4
4
|
import { type XmlNode } from "../util/xml.js";
|
|
5
5
|
/** `text` as XML text or an attribute's value: `&`, `<`, `>` and `"` escaped. */
|
|
@@ -24,6 +24,8 @@ export declare function expressionFormProblem(tags: readonly string[], type: str
|
|
|
24
24
|
export declare function expressionSlotProblem(tags: readonly string[], code: string | undefined): string | undefined;
|
|
25
25
|
/** A map element's icon line, a Label as `<library>/<id>`, at `indent`. */
|
|
26
26
|
export declare const mapLabelLine: (ref: string, indent: string) => string;
|
|
27
|
+
/** A `<ScriptCode>` block: its text's lines under the tag, a blank line left empty. */
|
|
28
|
+
export declare const scriptCodeLines: (text: string, child?: string, grandchild?: string) => string[];
|
|
27
29
|
/**
|
|
28
30
|
* Writes elements in the order the Editor reaches them: a library's (each reference naming the
|
|
29
31
|
* library, its elements indented in its `<Library>` block) or, with no library, a map's own (its
|
|
@@ -57,13 +59,17 @@ export declare class ElementWriter {
|
|
|
57
59
|
variable(variable: GuiVariable): void;
|
|
58
60
|
subFunction(slot: LibraryFunction["subFunctions"][number]): void;
|
|
59
61
|
}
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
+
/**
|
|
63
|
+
* The function's item line (filed in Root) and its elements, as the Editor writes them: a library's
|
|
64
|
+
* (`library`), its elements in its `<Library>` block, or, with no library, a map's own (a Mission
|
|
65
|
+
* Blueprint's, ADR-0026), its own references bare and its elements at the top of `<TriggerData>`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function functionXml(library: string | undefined, fn: LibraryFunction, body?: GuiBody): {
|
|
62
68
|
readonly itemLine: string;
|
|
63
69
|
readonly elements: readonly string[];
|
|
64
70
|
};
|
|
65
|
-
/** The function's TriggerStrings: its name, grammar and hint, its parameters', block slots' and variables' names
|
|
66
|
-
export declare function functionStrings(library: string, fn: LibraryFunction, body?: GuiBody): Record<string, string>;
|
|
71
|
+
/** The function's TriggerStrings: its name, grammar and hint, its parameters', block slots' and variables' names; a map's own (no library) keyed `<Type>/<Field>/<id>`. */
|
|
72
|
+
export declare function functionStrings(library: string | undefined, fn: LibraryFunction, body?: GuiBody): Record<string, string>;
|
|
67
73
|
/** An item line, as Root or a category files it. */
|
|
68
74
|
export declare const itemLine: (library: string, ref: string) => string;
|
|
69
75
|
/** One of the library's items other than a function, written: its elements, in the order the Editor reaches them, and its TriggerStrings. */
|
|
@@ -155,10 +161,33 @@ export declare function readLibraryFunction(xml: string | LibraryElements, strin
|
|
|
155
161
|
export declare function readLibraryParameterDefault(elements: LibraryElements, strings: ReadonlyMap<string, string>, library: string, paramDef: string): HeldValue | undefined;
|
|
156
162
|
/** A map's own function's interface (mapElements), its own references bare: what a call to it needs. A form this file doesn't read is refused (UnconvertibleFunctionError). */
|
|
157
163
|
export declare function readMapFunction(elements: LibraryElements, strings: ReadonlyMap<string, string>, id: string): LibraryFunction;
|
|
164
|
+
/** A map's own function (mapElements) whole, as functionXml writes it with no library: its interface and its GUI body. A form this file doesn't write is refused (UnconvertibleFunctionError). */
|
|
165
|
+
export declare function readMapFunctionWhole(elements: LibraryElements, strings: ReadonlyMap<string, string>, id: string): {
|
|
166
|
+
readonly fn: LibraryFunction;
|
|
167
|
+
readonly body?: GuiBody;
|
|
168
|
+
};
|
|
158
169
|
/** The elements of a map's own trigger list, outside every library it embeds, by type and Id (LibraryElements). */
|
|
159
170
|
export declare function mapElements(xml: string): Map<string, XmlNode>;
|
|
160
171
|
/** A map's trigger as a Mission Blueprint holds it (ADR-0026), less its `kind` and its text values' words. */
|
|
161
172
|
export type MapTrigger = Omit<BlueprintTrigger, "kind" | "strings">;
|
|
173
|
+
/** One of a map's own items other than a function (mapElements): a folder, preset type, record, comment or custom script, as a library's is read, its own references bare. A form this file doesn't write is refused (UnconvertibleFunctionError). */
|
|
174
|
+
export declare function readMapItem(elements: LibraryElements, strings: ReadonlyMap<string, string>, type: string, id: string): LibraryItem;
|
|
175
|
+
/** A map's preset type as a Mission Blueprint holds it (ADR-0026), less its `kind`: its values in order, a comment filed among them in its place. */
|
|
176
|
+
export type MapPreset = Omit<BlueprintPreset, "kind">;
|
|
177
|
+
/**
|
|
178
|
+
* A map's own preset type (mapElements) with its values and the comments filed among them, as
|
|
179
|
+
* blueprintPresetXml writes it, its name and each value's from TriggerStrings. A form this file
|
|
180
|
+
* doesn't write (a value of its own, a default value, a preset type extending another) is refused
|
|
181
|
+
* (UnconvertibleFunctionError), saying what it is.
|
|
182
|
+
*/
|
|
183
|
+
export declare function readMapPreset(elements: LibraryElements, strings: ReadonlyMap<string, string>, id: string): MapPreset;
|
|
184
|
+
/** A map's own global (mapElements) with its initial value, as ElementWriter.variable writes it with no library; a form this file doesn't write is refused (UnconvertibleFunctionError). */
|
|
185
|
+
export declare function readMapGlobal(elements: LibraryElements, strings: ReadonlyMap<string, string>, id: string): GuiVariable;
|
|
186
|
+
/** A map's own comment filed in Root or a folder (mapElements), as ElementWriter.statement writes it with no library; refused (UnconvertibleFunctionError) where it holds what a comment among statements doesn't. */
|
|
187
|
+
export declare function readMapComment(elements: LibraryElements, strings: ReadonlyMap<string, string>, id: string): {
|
|
188
|
+
readonly id: string;
|
|
189
|
+
readonly comment: string;
|
|
190
|
+
};
|
|
162
191
|
/**
|
|
163
192
|
* Reads one trigger of a map's own list (mapElements) with its names (TriggerStrings'
|
|
164
193
|
* `<Type>/Name/<id>`), as blueprintTriggerXml writes it, its own references bare; a form this file
|
package/dist/mods/library-xml.js
CHANGED
|
@@ -77,12 +77,18 @@ function typeLines(indent, tag, type, library) {
|
|
|
77
77
|
...(type.assetType ? [`${indent} <AssetType Value="${escapeXml(type.assetType)}"/>`] : []),
|
|
78
78
|
...(type.userType ? [`${indent} <UserType Value="${escapeXml(type.userType)}"/>`] : []),
|
|
79
79
|
...(type.constant ? [`${indent} <Constant/>`] : []),
|
|
80
|
-
...(type.array ?? []).map((bound, dim) =>
|
|
80
|
+
...(type.array ?? []).map((bound, dim) => {
|
|
81
|
+
if ("size" in bound)
|
|
82
|
+
return `${indent} <ArraySize Dim="${dim}" Value="${bound.size}"/>`;
|
|
83
|
+
// A map's own constant names no Library.
|
|
84
|
+
const [lib, id] = refParts(bound.variable, library);
|
|
85
|
+
return `${indent} <ArraySize Dim="${dim}" Type="Variable"${lib === undefined ? "" : ` Library="${lib}"`} Id="${id}"/>`;
|
|
86
|
+
}),
|
|
81
87
|
`${indent}</${tag}>`,
|
|
82
88
|
];
|
|
83
89
|
}
|
|
84
90
|
/** A `<ScriptCode>` block: its text's lines under the tag, a blank line left empty. */
|
|
85
|
-
const scriptCodeLines = (text, child = CHILD, grandchild = GRANDCHILD) => [`${child}<ScriptCode>`, ...text.split("\n").map((line) => (line === "" ? "" : `${grandchild}${escapeXml(line)}`)), `${child}</ScriptCode>`];
|
|
91
|
+
export const scriptCodeLines = (text, child = CHILD, grandchild = GRANDCHILD) => [`${child}<ScriptCode>`, ...text.split("\n").map((line) => (line === "" ? "" : `${grandchild}${escapeXml(line)}`)), `${child}</ScriptCode>`];
|
|
86
92
|
/** What a type's TypeElement names: a structure's Structure, a user instance's parameter giving its user type (ParamDef), else a Preset. */
|
|
87
93
|
const typeElementKind = (type) => (type === "struct" ? "Structure" : type === "userinstance" ? "ParamDef" : "Preset");
|
|
88
94
|
/**
|
|
@@ -237,27 +243,32 @@ export class ElementWriter {
|
|
|
237
243
|
]);
|
|
238
244
|
}
|
|
239
245
|
}
|
|
240
|
-
/**
|
|
246
|
+
/**
|
|
247
|
+
* The function's item line (filed in Root) and its elements, as the Editor writes them: a library's
|
|
248
|
+
* (`library`), its elements in its `<Library>` block, or, with no library, a map's own (a Mission
|
|
249
|
+
* Blueprint's, ADR-0026), its own references bare and its elements at the top of `<TriggerData>`.
|
|
250
|
+
*/
|
|
241
251
|
export function functionXml(library, fn, body) {
|
|
242
|
-
const
|
|
252
|
+
const [element, child, grandchild] = library === undefined ? [" ", ELEMENT, CHILD] : [ELEMENT, CHILD, GRANDCHILD];
|
|
253
|
+
const writer = new ElementWriter(library, element);
|
|
243
254
|
const lib = library;
|
|
244
255
|
const def = [
|
|
245
|
-
...(fn.identifier ? [`${
|
|
246
|
-
...(fn.label ? [labelRefLine(fn.label, lib)] : []),
|
|
247
|
-
...(fn.section !== undefined ? [`${
|
|
248
|
-
...(fn.disabled ? [`${
|
|
249
|
-
...(fn.deprecated ? [`${
|
|
250
|
-
...(fn.internal ? [`${
|
|
251
|
-
`${
|
|
252
|
-
...fn.flags.map((flag) => `${
|
|
253
|
-
...(fn.returns ? typeLines(
|
|
254
|
-
...fn.parameters.map((parameter) => refLine(
|
|
255
|
-
...fn.subFunctions.map((slot) => refLine(
|
|
256
|
-
...(body?.variables ?? []).map((variable) => refLine(
|
|
257
|
-
...(body?.actions ?? []).map((statement) => refLine(
|
|
258
|
-
...(fn.script !== undefined ? scriptCodeLines(fn.script) : []),
|
|
256
|
+
...(fn.identifier ? [`${child}<Identifier>${escapeXml(fn.identifier)}</Identifier>`] : []),
|
|
257
|
+
...(fn.label ? [lib === undefined ? mapLabelLine(fn.label, child) : labelRefLine(fn.label, lib)] : []),
|
|
258
|
+
...(fn.section !== undefined ? [`${child}<Section Value="${escapeXml(fn.section)}"/>`] : []),
|
|
259
|
+
...(fn.disabled ? [`${child}<Disabled/>`] : []),
|
|
260
|
+
...(fn.deprecated ? [`${child}<Deprecated/>`] : []),
|
|
261
|
+
...(fn.internal ? [`${child}<Internal/>`] : []),
|
|
262
|
+
`${child}<${KIND_FLAGS[fn.kind]}/>`,
|
|
263
|
+
...fn.flags.map((flag) => `${child}<${flagTag(flag)}/>`),
|
|
264
|
+
...(fn.returns ? typeLines(child, "ReturnType", fn.returns, lib) : []),
|
|
265
|
+
...fn.parameters.map((parameter) => refLine(child, "Parameter", "ParamDef", parameter.id, lib)),
|
|
266
|
+
...fn.subFunctions.map((slot) => refLine(child, "SubFunctionType", "SubFuncType", slot.id, lib)),
|
|
267
|
+
...(body?.variables ?? []).map((variable) => refLine(child, "Variable", "Variable", variable.id, lib)),
|
|
268
|
+
...(body?.actions ?? []).map((statement) => refLine(child, "FunctionCall", isComment(statement) ? "Comment" : "FunctionCall", statement.id, lib)),
|
|
269
|
+
...(fn.script !== undefined ? scriptCodeLines(fn.script, child, grandchild) : []),
|
|
259
270
|
];
|
|
260
|
-
writer.elements.push([`${
|
|
271
|
+
writer.elements.push([`${element}<Element Type="FunctionDef" Id="${fn.id}">`, ...def, `${element}</Element>`].join("\n"));
|
|
261
272
|
for (const parameter of fn.parameters)
|
|
262
273
|
writer.parameter(parameter);
|
|
263
274
|
for (const slot of fn.subFunctions)
|
|
@@ -266,12 +277,12 @@ export function functionXml(library, fn, body) {
|
|
|
266
277
|
writer.variable(variable);
|
|
267
278
|
for (const statement of body?.actions ?? [])
|
|
268
279
|
writer.statement(statement);
|
|
269
|
-
return { itemLine:
|
|
280
|
+
return { itemLine: library === undefined ? `${ELEMENT}<Item Type="FunctionDef" Id="${fn.id}"/>` : `${CHILD}<Item Type="FunctionDef" Library="${library}" Id="${fn.id}"/>`, elements: writer.elements };
|
|
270
281
|
}
|
|
271
|
-
/** The function's TriggerStrings: its name, grammar and hint, its parameters', block slots' and variables' names
|
|
282
|
+
/** The function's TriggerStrings: its name, grammar and hint, its parameters', block slots' and variables' names; a map's own (no library) keyed `<Type>/<Field>/<id>`. */
|
|
272
283
|
export function functionStrings(library, fn, body) {
|
|
273
284
|
const out = {};
|
|
274
|
-
const key = (type, field, id) => libraryStringKey(library, type, field, id);
|
|
285
|
+
const key = (type, field, id) => (library === undefined ? `${type}/${field}/${id}` : libraryStringKey(library, type, field, id));
|
|
275
286
|
out[key("FunctionDef", "Name", fn.id)] = fn.name;
|
|
276
287
|
if (fn.grammar !== undefined)
|
|
277
288
|
out[key("FunctionDef", "Grammar", fn.id)] = fn.grammar;
|
|
@@ -434,11 +445,39 @@ export function readLibraryParameterDefault(elements, strings, library, paramDef
|
|
|
434
445
|
export function readMapFunction(elements, strings, id) {
|
|
435
446
|
return new Reader(elements, strings, undefined, id, true).read().fn;
|
|
436
447
|
}
|
|
448
|
+
/** A map's own function (mapElements) whole, as functionXml writes it with no library: its interface and its GUI body. A form this file doesn't write is refused (UnconvertibleFunctionError). */
|
|
449
|
+
export function readMapFunctionWhole(elements, strings, id) {
|
|
450
|
+
return new Reader(elements, strings, undefined, id).read();
|
|
451
|
+
}
|
|
437
452
|
/** The elements of a map's own trigger list, outside every library it embeds, by type and Id (LibraryElements). */
|
|
438
453
|
export function mapElements(xml) {
|
|
439
454
|
const data = xmlTree(xml).find((node) => node.name === "TriggerData");
|
|
440
455
|
return new Map((data?.children ?? []).filter((node) => node.name === "Element").map((node) => [elementKey(attr(node, "Type") ?? "", attr(node, "Id") ?? ""), node]));
|
|
441
456
|
}
|
|
457
|
+
/** One of a map's own items other than a function (mapElements): a folder, preset type, record, comment or custom script, as a library's is read, its own references bare. A form this file doesn't write is refused (UnconvertibleFunctionError). */
|
|
458
|
+
export function readMapItem(elements, strings, type, id) {
|
|
459
|
+
return new Reader(elements, strings, undefined, id).readItem(type);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* A map's own preset type (mapElements) with its values and the comments filed among them, as
|
|
463
|
+
* blueprintPresetXml writes it, its name and each value's from TriggerStrings. A form this file
|
|
464
|
+
* doesn't write (a value of its own, a default value, a preset type extending another) is refused
|
|
465
|
+
* (UnconvertibleFunctionError), saying what it is.
|
|
466
|
+
*/
|
|
467
|
+
export function readMapPreset(elements, strings, id) {
|
|
468
|
+
return new Reader(elements, strings, undefined, id).mapPreset();
|
|
469
|
+
}
|
|
470
|
+
/** A map's own global (mapElements) with its initial value, as ElementWriter.variable writes it with no library; a form this file doesn't write is refused (UnconvertibleFunctionError). */
|
|
471
|
+
export function readMapGlobal(elements, strings, id) {
|
|
472
|
+
return new Reader(elements, strings, undefined, id).variable(id);
|
|
473
|
+
}
|
|
474
|
+
/** A map's own comment filed in Root or a folder (mapElements), as ElementWriter.statement writes it with no library; refused (UnconvertibleFunctionError) where it holds what a comment among statements doesn't. */
|
|
475
|
+
export function readMapComment(elements, strings, id) {
|
|
476
|
+
const comment = new Reader(elements, strings, undefined, id).comment(id);
|
|
477
|
+
if (!("comment" in comment) || comment.disabled || comment.sub !== undefined)
|
|
478
|
+
throw new UnconvertibleFunctionError(id, "it is a disabled comment or one in a block slot, which no item of Root or a folder is");
|
|
479
|
+
return { id: comment.id, comment: comment.comment };
|
|
480
|
+
}
|
|
442
481
|
/**
|
|
443
482
|
* Reads one trigger of a map's own list (mapElements) with its names (TriggerStrings'
|
|
444
483
|
* `<Type>/Name/<id>`), as blueprintTriggerXml writes it, its own references bare; a form this file
|
|
@@ -810,6 +849,39 @@ class Reader {
|
|
|
810
849
|
}
|
|
811
850
|
}
|
|
812
851
|
}
|
|
852
|
+
/** A map's preset type, as readMapPreset reads it. */
|
|
853
|
+
mapPreset() {
|
|
854
|
+
const id = this.functionId;
|
|
855
|
+
const node = this.element(id, "Preset");
|
|
856
|
+
this.only(node, ["PresetInteger", "BaseType", "PresetGenConstVar", "Item"]);
|
|
857
|
+
const name = this.name("Preset", id);
|
|
858
|
+
if (name === undefined)
|
|
859
|
+
this.fail("it has no name in TriggerStrings.txt");
|
|
860
|
+
const base = node.children.find((c) => c.name === "BaseType");
|
|
861
|
+
const baseType = base && attr(base, "Value");
|
|
862
|
+
if (!baseType)
|
|
863
|
+
this.fail(`its preset type ${id} has no BaseType`);
|
|
864
|
+
const values = node.children
|
|
865
|
+
.filter((c) => c.name === "Item")
|
|
866
|
+
.map((c) => {
|
|
867
|
+
const itemId = this.ref(c, true);
|
|
868
|
+
if (attr(c, "Type") === "Comment") {
|
|
869
|
+
const comment = this.comment(itemId);
|
|
870
|
+
if (!("comment" in comment) || comment.disabled || comment.sub !== undefined)
|
|
871
|
+
this.fail(`its comment ${itemId} is disabled or in a block slot, which no preset type's is`);
|
|
872
|
+
return { id: itemId, comment: comment.comment };
|
|
873
|
+
}
|
|
874
|
+
if (attr(c, "Type") !== "PresetValue")
|
|
875
|
+
this.fail(`its preset type ${id} holds a ${attr(c, "Type")}`);
|
|
876
|
+
this.only(this.element(itemId, "PresetValue"), []);
|
|
877
|
+
const valueName = this.name("PresetValue", itemId);
|
|
878
|
+
if (valueName === undefined)
|
|
879
|
+
this.fail(`its value ${itemId} has no name in TriggerStrings.txt`);
|
|
880
|
+
return { id: itemId, name: valueName };
|
|
881
|
+
});
|
|
882
|
+
const has = (tag) => node.children.some((c) => c.name === tag);
|
|
883
|
+
return { id, name, baseType, ...(has("PresetInteger") ? { integer: true } : {}), ...(has("PresetGenConstVar") ? { constants: true } : {}), values };
|
|
884
|
+
}
|
|
813
885
|
/** A map's trigger: its flags, local variables, events, conditions and actions, as blueprintTriggerXml writes them. */
|
|
814
886
|
readTrigger() {
|
|
815
887
|
const id = this.functionId;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Workspace } from "../plugins/workspace.js";
|
|
3
|
+
import { type GenericEntry } from "./generic-entries.js";
|
|
4
|
+
/** Blizzard's silent CSound for a layered actor sound with nothing at 0 (in void.sc2mod). */
|
|
5
|
+
export declare const SILENT_SOUND = "Nova_SniperRifleTail_Dummy";
|
|
6
|
+
export declare const SoundMixLayerSchema: z.ZodObject<{
|
|
7
|
+
sound: z.ZodString;
|
|
8
|
+
at: z.ZodNumber;
|
|
9
|
+
stop: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
fade: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export declare const SoundMixSchema: z.ZodObject<{
|
|
13
|
+
id: z.ZodString;
|
|
14
|
+
layers: z.ZodArray<z.ZodObject<{
|
|
15
|
+
sound: z.ZodString;
|
|
16
|
+
at: z.ZodNumber;
|
|
17
|
+
stop: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
fade: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
}, z.core.$strict>>;
|
|
20
|
+
silent: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
export type SoundMixLayer = z.infer<typeof SoundMixLayerSchema>;
|
|
23
|
+
export type SoundMix = z.infer<typeof SoundMixSchema>;
|
|
24
|
+
/** One mix or a list of them, as a mix file holds them. */
|
|
25
|
+
export declare const SoundMixFileSchema: z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
layers: z.ZodArray<z.ZodObject<{
|
|
28
|
+
sound: z.ZodString;
|
|
29
|
+
at: z.ZodNumber;
|
|
30
|
+
stop: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
fade: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
}, z.core.$strict>>;
|
|
33
|
+
silent: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strict>, z.ZodArray<z.ZodObject<{
|
|
35
|
+
id: z.ZodString;
|
|
36
|
+
layers: z.ZodArray<z.ZodObject<{
|
|
37
|
+
sound: z.ZodString;
|
|
38
|
+
at: z.ZodNumber;
|
|
39
|
+
stop: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
fade: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
}, z.core.$strict>>;
|
|
42
|
+
silent: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.core.$strict>>]>, z.ZodTransform<{
|
|
44
|
+
id: string;
|
|
45
|
+
layers: {
|
|
46
|
+
sound: string;
|
|
47
|
+
at: number;
|
|
48
|
+
stop?: number | undefined;
|
|
49
|
+
fade?: number | undefined;
|
|
50
|
+
}[];
|
|
51
|
+
silent?: string | undefined;
|
|
52
|
+
}[], {
|
|
53
|
+
id: string;
|
|
54
|
+
layers: {
|
|
55
|
+
sound: string;
|
|
56
|
+
at: number;
|
|
57
|
+
stop?: number | undefined;
|
|
58
|
+
fade?: number | undefined;
|
|
59
|
+
}[];
|
|
60
|
+
silent?: string | undefined;
|
|
61
|
+
} | {
|
|
62
|
+
id: string;
|
|
63
|
+
layers: {
|
|
64
|
+
sound: string;
|
|
65
|
+
at: number;
|
|
66
|
+
stop?: number | undefined;
|
|
67
|
+
fade?: number | undefined;
|
|
68
|
+
}[];
|
|
69
|
+
silent?: string | undefined;
|
|
70
|
+
}[]>>;
|
|
71
|
+
/** The actor entries that play `mix`: its actor, then one for each layer with a stop. */
|
|
72
|
+
export declare function soundMixEntries(mix: SoundMix): GenericEntry[];
|
|
73
|
+
/** `entries` as the elements of an ActorData.xml, for a map's own data. */
|
|
74
|
+
export declare const soundMixXml: (entries: readonly GenericEntry[]) => string;
|
|
75
|
+
/** The CSound ids defined in a file or folder: a GameData XML file, a JSON file of Generic Entries, or every such file in a folder (a .SC2Map, a .SC2Mod, a Mod Blueprint's entries). */
|
|
76
|
+
export declare function definedSounds(where: string): Promise<Set<string>>;
|
|
77
|
+
/** The CSounds a Workspace's own mods define: in each mod's package, and in its Blueprint's Generic Entries. */
|
|
78
|
+
export declare function workspaceSounds(workspace: Pick<Workspace, "root" | "mods">): Promise<Set<string>>;
|
|
79
|
+
export type SoundCheck = {
|
|
80
|
+
/** Each CSound the mixes play, and where it's defined: the game's packages that define it, or "own" for one of `own`. */
|
|
81
|
+
readonly found: ReadonlyMap<string, readonly string[]>;
|
|
82
|
+
/** The problems: a CSound defined nowhere (it would play nothing, silently), an entry the game's schema refuses. */
|
|
83
|
+
readonly problems: readonly string[];
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Checks `mixes`: every CSound a layer plays (and the silent one where it's used) is the game's
|
|
87
|
+
* (data/package-entries.json) or one of `own` (the map's or mod's own), and every entry they make
|
|
88
|
+
* passes the game's data schema.
|
|
89
|
+
*/
|
|
90
|
+
export declare function checkSoundMixes(mixes: readonly SoundMix[], own: ReadonlySet<string>): SoundCheck;
|
|
91
|
+
/** The line to add to the actor of the unit a mix is for: it creates the mix on `terms` (an actor event such as UnitDeath). */
|
|
92
|
+
export declare const soundMixWiring: (mix: Pick<SoundMix, "id">, terms?: string) => string;
|