@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
|
@@ -63,7 +63,7 @@ export declare function regionsAsCompiled(regionsXml: string, record: CompileRec
|
|
|
63
63
|
*/
|
|
64
64
|
export declare function editorObjectForm(text: string): string;
|
|
65
65
|
/** The name of a trigger or variable in the package's TriggerStrings, by element Id. */
|
|
66
|
-
export declare function triggerStringName(strings: string | undefined, type: "Trigger" | "Variable", id: string): string | undefined;
|
|
66
|
+
export declare function triggerStringName(strings: string | undefined, type: "Trigger" | "Variable" | "FunctionDef", id: string): string | undefined;
|
|
67
67
|
/**
|
|
68
68
|
* Each entry of `record` that the package at `root` no longer matches, where the compile would
|
|
69
69
|
* write something else there (`fresh` gives what it queued for a file) or remove it.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AuthoringTrigger, AuthoringValue } from "../triggers/author-trigger.js";
|
|
2
|
+
/** A value as the Editor shows it: a call as `Name (Parameter = value, ...)`, a variable by its name, a text in quotes. */
|
|
3
|
+
export declare function valueText(value: AuthoringValue | readonly AuthoringValue[]): string;
|
|
4
|
+
/** The trigger as text in the Editor's terms, as above. */
|
|
5
|
+
export declare function editorForm(trigger: AuthoringTrigger): string;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// A trigger as text in the Editor's terms, one line to a call (#46): its events, conditions and
|
|
2
|
+
// actions with each function by the name the Editor shows it and every argument written out by
|
|
3
|
+
// parameter name, a block's statements nested under its slot's name. Written from the authoring
|
|
4
|
+
// outline (triggers/authoring-outline.ts), which already names everything as the Editor does.
|
|
5
|
+
//
|
|
6
|
+
// The Editor's own line for a call is its function's grammar ("Set Variable (~Variable~ = ~Value~)"),
|
|
7
|
+
// but the game's library data (data/trigger-libraries.json) holds no grammars, only names, so this is
|
|
8
|
+
// the plain form: `Set Variable (Variable = Mode, Value = true)`. It exists to be compared line by
|
|
9
|
+
// line (outline-diff.ts); it is not read back.
|
|
10
|
+
const INDENT = " ";
|
|
11
|
+
const isCall = (statement) => "function" in statement;
|
|
12
|
+
/** A value as the Editor shows it: a call as `Name (Parameter = value, ...)`, a variable by its name, a text in quotes. */
|
|
13
|
+
export function valueText(value) {
|
|
14
|
+
if (Array.isArray(value))
|
|
15
|
+
return `[${value.map((each) => valueText(each)).join(", ")}]`;
|
|
16
|
+
const single = value;
|
|
17
|
+
if (typeof single !== "object")
|
|
18
|
+
return String(single);
|
|
19
|
+
if ("function" in single)
|
|
20
|
+
return callText(single);
|
|
21
|
+
if ("preset" in single)
|
|
22
|
+
return single.preset;
|
|
23
|
+
if ("bits" in single)
|
|
24
|
+
return `{${single.bits.join(", ")}}`;
|
|
25
|
+
if ("variable" in single) {
|
|
26
|
+
const indexes = (single.index ?? []).map((each) => `[${valueText(each)}]`).join("");
|
|
27
|
+
const members = [];
|
|
28
|
+
for (let member = single.member; member; member = member.member)
|
|
29
|
+
members.push(`.${member.variable}${(member.index ?? []).map((each) => `[${valueText(each)}]`).join("")}`);
|
|
30
|
+
return `${single.variable}${indexes}${members.join("")}`;
|
|
31
|
+
}
|
|
32
|
+
if ("trigger" in single)
|
|
33
|
+
return single.trigger;
|
|
34
|
+
if ("text" in single)
|
|
35
|
+
return `"${single.text}"`;
|
|
36
|
+
if ("expression" in single)
|
|
37
|
+
return single.expression.replace(/~(\w+)~/g, (whole, code) => (single.slots?.[code] !== undefined ? `(${valueText(single.slots[code])})` : whole));
|
|
38
|
+
if ("customScript" in single)
|
|
39
|
+
return `custom script ${single.customScript}`;
|
|
40
|
+
return single.value ?? single.type;
|
|
41
|
+
}
|
|
42
|
+
/** A call as one line: its function and each parameter set, by name. */
|
|
43
|
+
function callText(call) {
|
|
44
|
+
const params = Object.entries(call.params ?? {}).map(([name, value]) => `${name} = ${value === null ? "(unset)" : valueText(value)}`);
|
|
45
|
+
return `${call.function}${params.length > 0 ? ` (${params.join(", ")})` : ""}${call.disabled ? " (disabled)" : ""}`;
|
|
46
|
+
}
|
|
47
|
+
/** The statements as lines at `indent`: a call's line, then each of its blocks' slot names with their statements under it. */
|
|
48
|
+
function statementLines(statements, indent) {
|
|
49
|
+
return statements.flatMap((statement) => {
|
|
50
|
+
if (!isCall(statement)) {
|
|
51
|
+
const text = "comment" in statement ? `// ${statement.comment}` : `Custom Script: ${statement.customScript}`;
|
|
52
|
+
return [`${indent}${text}${statement.disabled ? " (disabled)" : ""}`];
|
|
53
|
+
}
|
|
54
|
+
return [`${indent}${callText(statement)}`, ...Object.entries(statement.blocks ?? {}).flatMap(([slot, body]) => [`${indent}${INDENT}${slot}`, ...statementLines(body, `${indent}${INDENT}${INDENT}`)])];
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const variableText = (variable) => {
|
|
58
|
+
const type = typeof variable.type === "string" ? variable.type : variable.type.type;
|
|
59
|
+
return `${variable.name} (${type}${variable.array ? `, array ${variable.array.join("x")}` : ""}${variable.constant ? ", constant" : ""})${variable.value !== undefined ? ` = ${valueText(variable.value)}` : ""}`;
|
|
60
|
+
};
|
|
61
|
+
/** The trigger as text in the Editor's terms, as above. */
|
|
62
|
+
export function editorForm(trigger) {
|
|
63
|
+
const flags = [trigger.disabled ? "disabled" : undefined, trigger.initiallyOff ? "initially off" : undefined].filter((flag) => flag !== undefined);
|
|
64
|
+
const part = (heading, lines) => (lines.length > 0 ? [heading, ...lines] : []);
|
|
65
|
+
return [
|
|
66
|
+
`Trigger ${trigger.name}${flags.length > 0 ? ` (${flags.join(", ")})` : ""}`,
|
|
67
|
+
...part("Local Variables", (trigger.variables ?? []).map((variable) => `${INDENT}${variableText(variable)}`)),
|
|
68
|
+
...part("Events", statementLines(trigger.events ?? [], INDENT)),
|
|
69
|
+
...part("Conditions", statementLines(trigger.conditions ?? [], INDENT)),
|
|
70
|
+
...part("Actions", statementLines(trigger.actions ?? [], INDENT)),
|
|
71
|
+
].join("\n");
|
|
72
|
+
}
|
|
@@ -27,13 +27,14 @@ export declare function packageReach(workspace: Pick<Workspace, "root" | "mods">
|
|
|
27
27
|
export declare function dependencyToAdd(packages: readonly string[]): string;
|
|
28
28
|
/** A game package's name as a mapper knows it: `NovaStoryAssets.SC2Mod`, as its dependency's file names it, else its path. */
|
|
29
29
|
export declare function packageName(pkg: string): string;
|
|
30
|
-
/** Which of the game's packages define each CModel and
|
|
30
|
+
/** Which of the game's packages define each CModel, CLight and CSound id (data/package-entries.json), by id: each id's packages, in the file's order. */
|
|
31
31
|
export type PackageEntries = {
|
|
32
32
|
readonly models: ReadonlyMap<string, readonly string[]>;
|
|
33
33
|
readonly lights: ReadonlyMap<string, readonly string[]>;
|
|
34
|
+
readonly sounds: ReadonlyMap<string, readonly string[]>;
|
|
34
35
|
};
|
|
35
36
|
export declare const PACKAGE_ENTRIES_PATH: string;
|
|
36
|
-
/** The game's packages' models and
|
|
37
|
+
/** The game's packages' models, Lights and sounds, read once; a missing or damaged file is refused, naming how to make it again. */
|
|
37
38
|
export declare function packageEntries(): PackageEntries;
|
|
38
39
|
/** The package one of the game's files is in, by its path in the game's data (`mods/novastoryassets.sc2mod/base.sc2data/…`): `mods/novastoryassets.sc2mod`. */
|
|
39
40
|
export declare function filePackage(file: string): string | undefined;
|
|
@@ -107,7 +107,7 @@ export function packageName(pkg) {
|
|
|
107
107
|
}
|
|
108
108
|
export const PACKAGE_ENTRIES_PATH = path.join(CORE_DATA_DIR, "package-entries.json");
|
|
109
109
|
let entries;
|
|
110
|
-
/** The game's packages' models and
|
|
110
|
+
/** The game's packages' models, Lights and sounds, read once; a missing or damaged file is refused, naming how to make it again. */
|
|
111
111
|
export function packageEntries() {
|
|
112
112
|
entries ??= (() => {
|
|
113
113
|
let stored;
|
|
@@ -119,13 +119,16 @@ export function packageEntries() {
|
|
|
119
119
|
}
|
|
120
120
|
const models = new Map();
|
|
121
121
|
const lights = new Map();
|
|
122
|
+
const sounds = new Map();
|
|
122
123
|
for (const [pkg, held] of Object.entries(stored.packages)) {
|
|
123
124
|
for (const id of held.models)
|
|
124
125
|
models.set(id, [...(models.get(id) ?? []), pkg]);
|
|
125
126
|
for (const id of held.lights)
|
|
126
127
|
lights.set(id, [...(lights.get(id) ?? []), pkg]);
|
|
128
|
+
for (const id of held.sounds)
|
|
129
|
+
sounds.set(id, [...(sounds.get(id) ?? []), pkg]);
|
|
127
130
|
}
|
|
128
|
-
return { models, lights };
|
|
131
|
+
return { models, lights, sounds };
|
|
129
132
|
})();
|
|
130
133
|
return entries;
|
|
131
134
|
}
|
|
@@ -6,7 +6,7 @@ import path from "node:path";
|
|
|
6
6
|
import { bindLikeOriginal } from "../plugins/plugin-api.js";
|
|
7
7
|
import { editorForm } from "../triggers/splice-map-script.js";
|
|
8
8
|
import { ITEM_LINE, recordedItemKey } from "../triggers/splice-triggers.js";
|
|
9
|
-
import { editorGlobalName, editorTriggerName } from "../triggers/trigger-model.js";
|
|
9
|
+
import { editorGlobalName, editorTriggerName, galaxyIdentifier } from "../triggers/trigger-model.js";
|
|
10
10
|
import { elementIdentifier, gameDataEntries, packageFiles, readPackageText as read, triggerStringNames } from "./kept-package.js";
|
|
11
11
|
const OBJECT_KINDS = { ObjectUnit: "unit", ObjectPoint: "point", ObjectCamera: "camera" };
|
|
12
12
|
const unescape = (text) => text.replace(/"/g, '"').replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/&/g, "&");
|
|
@@ -57,6 +57,49 @@ export function triggerTreeScriptNames(triggers, strings) {
|
|
|
57
57
|
// A name only an Identifier gives is the same in every locale.
|
|
58
58
|
for (const element of triggerElementsIn(triggers, ""))
|
|
59
59
|
add(element);
|
|
60
|
+
// A function (gf_ and its Identifier, else its name's), which a Mission Blueprint may convert (ADR-0026).
|
|
61
|
+
const tables = strings.map(triggerStringNames);
|
|
62
|
+
// The map's own, outside every library it embeds.
|
|
63
|
+
const libraries = [...triggers.matchAll(/<Library Id="[^"]*">[\s\S]*?<\/Library>/g)].map((match) => [match.index, match.index + match[0].length]);
|
|
64
|
+
for (const match of triggers.matchAll(/<Element Type="FunctionDef" Id="([0-9A-F]{8})"(\/?)>/g)) {
|
|
65
|
+
if (libraries.some(([start, end]) => match.index >= start && match.index < end))
|
|
66
|
+
continue;
|
|
67
|
+
const close = match[2] ? match.index : triggers.indexOf("</Element>", match.index);
|
|
68
|
+
const identifier = elementIdentifier(triggers.slice(match.index, close < 0 ? undefined : close));
|
|
69
|
+
const names = [...new Set([...tables.map((table) => table.get(`FunctionDef:${match[1]}`)).filter((name) => name !== undefined), ...(identifier === undefined ? [] : [""])])];
|
|
70
|
+
const scriptNames = [...new Set(names.map((name) => `gf_${identifier ?? galaxyIdentifier(name)}`))];
|
|
71
|
+
if (scriptNames.length > 0)
|
|
72
|
+
named.set(`FunctionDef:${match[1]}`, scriptNames);
|
|
73
|
+
}
|
|
74
|
+
// A record (gs_ and its name's identifier), each of a preset type's values (its constant, ge_<preset>_<value>, an item of its own, since
|
|
75
|
+
// each is a block), and custom script (its section's heading, its name, and the init function InitCustomScript calls), which a Mission
|
|
76
|
+
// Blueprint may convert (ADR-0026).
|
|
77
|
+
const nameIn = (type, id) => [...new Set(tables.flatMap((table) => table.get(`${type}:${id}`) ?? []))];
|
|
78
|
+
const outside = (index) => !libraries.some(([start, end]) => index >= start && index < end);
|
|
79
|
+
/** An element's Galaxy identifiers: its Identifier, else its name's in each strings file. */
|
|
80
|
+
const identifiers = (type, id) => {
|
|
81
|
+
const element = new RegExp(`<Element Type="${type}" Id="${id}">([\\s\\S]*?)</Element>`).exec(triggers)?.[1];
|
|
82
|
+
const identifier = element === undefined ? undefined : elementIdentifier(element);
|
|
83
|
+
return identifier !== undefined ? [identifier] : [...new Set(nameIn(type, id).map(galaxyIdentifier))];
|
|
84
|
+
};
|
|
85
|
+
for (const match of triggers.matchAll(/<Element Type="Structure" Id="([0-9A-F]{8})">/g)) {
|
|
86
|
+
if (outside(match.index))
|
|
87
|
+
named.set(`Structure:${match[1]}`, identifiers("Structure", match[1]).map((identifier) => `gs_${identifier}`));
|
|
88
|
+
}
|
|
89
|
+
const presetValues = new Map();
|
|
90
|
+
for (const match of triggers.matchAll(/<Element Type="Preset" Id="([0-9A-F]{8})">([\s\S]*?)<\/Element>/g)) {
|
|
91
|
+
if (!outside(match.index))
|
|
92
|
+
continue;
|
|
93
|
+
const presets = identifiers("Preset", match[1]);
|
|
94
|
+
const values = [...match[2].matchAll(/<Item Type="PresetValue" Id="([0-9A-F]{8})"\/>/g)].map((value) => presets.flatMap((preset) => identifiers("PresetValue", value[1]).map((identifier) => `ge_${preset}_${identifier}`)));
|
|
95
|
+
presetValues.set(match[1], values);
|
|
96
|
+
}
|
|
97
|
+
for (const match of triggers.matchAll(/<Element Type="CustomScript" Id="([0-9A-F]{8})">([\s\S]*?)<\/Element>/g)) {
|
|
98
|
+
if (!outside(match.index))
|
|
99
|
+
continue;
|
|
100
|
+
const init = /<InitFunc>([^<]*)<\/InitFunc>/.exec(match[2])?.[1]?.trim();
|
|
101
|
+
named.set(`CustomScript:${match[1]}`, [...nameIn("CustomScript", match[1]), ...(init ? [init] : [])]);
|
|
102
|
+
}
|
|
60
103
|
const items = (body) => [...body.matchAll(ITEM_LINE())].map((match) => [match[1], match[2]]);
|
|
61
104
|
const folders = new Map([...triggers.matchAll(/<Element Type="Category" Id="([0-9A-F]{8})">([\s\S]*?)<\/Element>/g)].map((match) => [match[1], items(match[2])]));
|
|
62
105
|
const root = /<Root>([\s\S]*?)<\/Root>/.exec(triggers);
|
|
@@ -68,6 +111,9 @@ export function triggerTreeScriptNames(triggers, strings) {
|
|
|
68
111
|
seen.add(`${type}:${id}`);
|
|
69
112
|
if (type === "Category")
|
|
70
113
|
(folders.get(id) ?? []).forEach(visit);
|
|
114
|
+
else if (type === "Preset")
|
|
115
|
+
for (const names of presetValues.get(id) ?? [])
|
|
116
|
+
out.push(names);
|
|
71
117
|
else {
|
|
72
118
|
const names = named.get(`${type}:${id}`);
|
|
73
119
|
if (names !== undefined)
|
package/dist/map/kept-session.js
CHANGED
|
@@ -72,7 +72,9 @@ export async function openKeptSession(blueprintPath, options) {
|
|
|
72
72
|
/** Refuses, writing nothing, if a file in `files` is no longer as it was when the session opened. */
|
|
73
73
|
const unchanged = async (files) => {
|
|
74
74
|
for (const [file] of files) {
|
|
75
|
-
|
|
75
|
+
// The snapshot's keys have forward slashes; a key spelled with Windows separators is the same file.
|
|
76
|
+
const key = file.split(path.sep).join("/");
|
|
77
|
+
if ((await signature(path.join(mapPackage, ...key.split("/")))) !== (before.get(key) ?? ABSENT)) {
|
|
76
78
|
throw new Error(`Not ${options.verb}: ${file} changed since it was read (another session or the Editor wrote it): nothing was written, run the edit again`);
|
|
77
79
|
}
|
|
78
80
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Workspace } from "../plugins/workspace.js";
|
|
2
|
+
import type { AuthoringTrigger } from "../triggers/author-trigger.js";
|
|
3
|
+
import { type TriggerOutline } from "./outline-trigger.js";
|
|
4
|
+
import { type WrittenBlueprintTrigger } from "./write-blueprint-trigger.js";
|
|
5
|
+
/**
|
|
6
|
+
* `after`'s text with each changed line marked against `before`'s. In a run of changes, a removed
|
|
7
|
+
* line and an added one with the same head (a call, its arguments changed) are one changed line: the
|
|
8
|
+
* new line, `← was: ` the old.
|
|
9
|
+
*/
|
|
10
|
+
export declare function markedChanges(before: string, after: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* The trigger after the change as the Editor's form (editor-form.ts) with each line it changed
|
|
13
|
+
* marked against `before`'s (every line new where there is none), then what the outline's input
|
|
14
|
+
* can't express, as the outline lists it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function outlineDiff(before: TriggerOutline | undefined, after: TriggerOutline): string;
|
|
17
|
+
/**
|
|
18
|
+
* writeBlueprintTrigger, with the change it made when it replaced a trigger: its outline before,
|
|
19
|
+
* and after it as written, as outlineDiff gives it. A new trigger has none.
|
|
20
|
+
*/
|
|
21
|
+
export declare function writeBlueprintTriggerShowingChange(workspace: Workspace, blueprintPath: string, trigger: AuthoringTrigger): Promise<{
|
|
22
|
+
readonly written: WrittenBlueprintTrigger;
|
|
23
|
+
readonly diff?: string;
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// A trigger's change in the Editor's form (#46): the trigger after the change as editor-form.ts
|
|
2
|
+
// writes it, one line to a call, each line it changed marked `← new`, `← was: <old line>` or `← remove`
|
|
3
|
+
// (a removed line stays in its place, so the reader sees where it was). No other notation.
|
|
4
|
+
import { editorForm } from "./editor-form.js";
|
|
5
|
+
import { outlineText, outlineTrigger } from "./outline-trigger.js";
|
|
6
|
+
import { writeBlueprintTrigger } from "./write-blueprint-trigger.js";
|
|
7
|
+
/** The lines of `before` and `after` as an edit script: each line kept, removed or added, in order. */
|
|
8
|
+
function lineEdits(before, after) {
|
|
9
|
+
let head = 0;
|
|
10
|
+
while (head < before.length && head < after.length && before[head] === after[head])
|
|
11
|
+
head++;
|
|
12
|
+
let tail = 0;
|
|
13
|
+
while (tail < before.length - head && tail < after.length - head && before[before.length - 1 - tail] === after[after.length - 1 - tail])
|
|
14
|
+
tail++;
|
|
15
|
+
const a = before.slice(head, before.length - tail);
|
|
16
|
+
const b = after.slice(head, after.length - tail);
|
|
17
|
+
// Longest common subsequence of the lines between the shared head and tail.
|
|
18
|
+
const width = b.length + 1;
|
|
19
|
+
const lcs = new Uint32Array((a.length + 1) * width);
|
|
20
|
+
for (let i = a.length - 1; i >= 0; i--) {
|
|
21
|
+
for (let j = b.length - 1; j >= 0; j--)
|
|
22
|
+
lcs[i * width + j] = a[i] === b[j] ? lcs[(i + 1) * width + j + 1] + 1 : Math.max(lcs[(i + 1) * width + j], lcs[i * width + j + 1]);
|
|
23
|
+
}
|
|
24
|
+
const edits = before.slice(0, head).map((line) => ({ op: "keep", line }));
|
|
25
|
+
let i = 0;
|
|
26
|
+
let j = 0;
|
|
27
|
+
while (i < a.length || j < b.length) {
|
|
28
|
+
if (i < a.length && j < b.length && a[i] === b[j])
|
|
29
|
+
edits.push({ op: "keep", line: a[i++] }), j++;
|
|
30
|
+
else if (j < b.length && (i === a.length || lcs[i * width + j + 1] >= lcs[(i + 1) * width + j]))
|
|
31
|
+
edits.push({ op: "add", line: b[j++] });
|
|
32
|
+
else
|
|
33
|
+
edits.push({ op: "del", line: a[i++] });
|
|
34
|
+
}
|
|
35
|
+
return [...edits, ...before.slice(before.length - tail).map((line) => ({ op: "keep", line }))];
|
|
36
|
+
}
|
|
37
|
+
/** A line's head, its indent and its words before the first parenthesis: two lines of one head are one call changed. */
|
|
38
|
+
const headOf = (line) => /^\s*[^(]*/.exec(line)[0].trimEnd();
|
|
39
|
+
/**
|
|
40
|
+
* `after`'s text with each changed line marked against `before`'s. In a run of changes, a removed
|
|
41
|
+
* line and an added one with the same head (a call, its arguments changed) are one changed line: the
|
|
42
|
+
* new line, `← was: ` the old.
|
|
43
|
+
*/
|
|
44
|
+
export function markedChanges(before, after) {
|
|
45
|
+
const edits = lineEdits(before.split("\n"), after.split("\n"));
|
|
46
|
+
const out = [];
|
|
47
|
+
for (let at = 0; at < edits.length;) {
|
|
48
|
+
if (edits[at].op === "keep") {
|
|
49
|
+
out.push(edits[at++].line);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// One run of changes: its removed lines and its added ones.
|
|
53
|
+
const run = [];
|
|
54
|
+
while (at < edits.length && edits[at].op !== "keep")
|
|
55
|
+
run.push(edits[at++]);
|
|
56
|
+
const removed = run.filter((edit) => edit.op === "del").map((edit) => edit.line);
|
|
57
|
+
const added = run.filter((edit) => edit.op === "add").map((edit) => edit.line);
|
|
58
|
+
const was = new Map();
|
|
59
|
+
const taken = new Set();
|
|
60
|
+
added.forEach((line, index) => {
|
|
61
|
+
const old = removed.findIndex((other, at) => !taken.has(at) && headOf(other) === headOf(line));
|
|
62
|
+
if (old !== -1) {
|
|
63
|
+
taken.add(old);
|
|
64
|
+
was.set(index, removed[old]);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
removed.forEach((line, index) => {
|
|
68
|
+
if (!taken.has(index))
|
|
69
|
+
out.push(`${line} ← remove`);
|
|
70
|
+
});
|
|
71
|
+
added.forEach((line, index) => out.push(was.has(index) ? `${line} ← was: ${was.get(index).trim()}` : `${line} ← new`));
|
|
72
|
+
}
|
|
73
|
+
return out.join("\n");
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The trigger after the change as the Editor's form (editor-form.ts) with each line it changed
|
|
77
|
+
* marked against `before`'s (every line new where there is none), then what the outline's input
|
|
78
|
+
* can't express, as the outline lists it.
|
|
79
|
+
*/
|
|
80
|
+
export function outlineDiff(before, after) {
|
|
81
|
+
const marked = before === undefined ? editorForm(after.trigger).split("\n").map((line) => `${line} ← new`).join("\n") : markedChanges(editorForm(before.trigger), editorForm(after.trigger));
|
|
82
|
+
return marked + outlineText(after.trigger, after.unwritable).slice(JSON.stringify(after.trigger, null, 2).length);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* writeBlueprintTrigger, with the change it made when it replaced a trigger: its outline before,
|
|
86
|
+
* and after it as written, as outlineDiff gives it. A new trigger has none.
|
|
87
|
+
*/
|
|
88
|
+
export async function writeBlueprintTriggerShowingChange(workspace, blueprintPath, trigger) {
|
|
89
|
+
// The trigger it replaces, outlined before it is written over (a new one has none; a Kept one of the name is refused when it is written).
|
|
90
|
+
const was = await outlineTrigger(workspace, blueprintPath, trigger.id ?? trigger.name).then((outline) => (outline.owner === "Blueprint" ? outline : undefined), () => undefined);
|
|
91
|
+
const written = await writeBlueprintTrigger(workspace, blueprintPath, trigger);
|
|
92
|
+
if (written.created || was === undefined)
|
|
93
|
+
return { written };
|
|
94
|
+
return { written, diff: outlineDiff(was, await outlineTrigger(workspace, blueprintPath, written.id)) };
|
|
95
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Workspace } from "../plugins/workspace.js";
|
|
2
2
|
import type { AuthoringTrigger } from "../triggers/author-trigger.js";
|
|
3
|
+
import { type MissionTriggerReach } from "./write-blueprint-trigger.js";
|
|
3
4
|
/** A Mission's trigger outlined: what it is and who owns it, and its outline. */
|
|
4
5
|
export type TriggerOutline = {
|
|
5
6
|
readonly name: string;
|
|
@@ -17,6 +18,12 @@ export type TriggerOutline = {
|
|
|
17
18
|
};
|
|
18
19
|
/** The outline's text: `trigger` as JSON, then each place the input can't express. */
|
|
19
20
|
export declare const outlineText: (trigger: AuthoringTrigger, unwritable: readonly string[]) => string;
|
|
21
|
+
/**
|
|
22
|
+
* The Kept trigger `id` outlined from `triggers` (Triggers' text) and `gameStrings` (each locale's by path in the
|
|
23
|
+
* package): as it will be once converted. Those are the package's own for an outline of it as it
|
|
24
|
+
* is, or an edit's, to outline it as it will be (tune_kept_triggers' dry run). Throws where it can't be read in the Editor's terms.
|
|
25
|
+
*/
|
|
26
|
+
export declare function outlineKeptTriggerFrom(reach: MissionTriggerReach, id: string, triggers: string, gameStrings: ReadonlyMap<string, string>): TriggerOutline;
|
|
20
27
|
/**
|
|
21
28
|
* The outline of the Mission's trigger `wanted` (by name or element Id): the Blueprint's own, else
|
|
22
29
|
* a Kept one in its Map Package. Refused where none has it, two Kept ones share the name, or a Kept
|
|
@@ -10,6 +10,32 @@ import { readKeptTrigger, recordConversionContext } from "./convert-mission-trig
|
|
|
10
10
|
import { missionMapReach, missionTriggerReach } from "./write-blueprint-trigger.js";
|
|
11
11
|
/** The outline's text: `trigger` as JSON, then each place the input can't express. */
|
|
12
12
|
export const outlineText = (trigger, unwritable) => [JSON.stringify(trigger, null, 2), ...(unwritable.length > 0 ? ["Not written back as it is, for what the input can't express:", ...unwritable.map((place) => `- ${place}`)] : [])].join("\n");
|
|
13
|
+
/** `trigger` outlined against the reach it will have: `others` are the Blueprint's triggers beside it. */
|
|
14
|
+
function outlineOf(reach, trigger, owner, others, file) {
|
|
15
|
+
const { trigger: input, unwritable } = outlineForAuthoring(trigger, { libraries: reach.libraries, map: missionMapReach(reach, others, trigger.id) });
|
|
16
|
+
return { name: trigger.name, id: trigger.id, owner, ...(file !== undefined ? { file } : {}), trigger: input, unwritable, text: outlineText(input, unwritable) };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The Kept trigger `id` outlined from `triggers` (Triggers' text) and `gameStrings` (each locale's by path in the
|
|
20
|
+
* package): as it will be once converted. Those are the package's own for an outline of it as it
|
|
21
|
+
* is, or an edit's, to outline it as it will be (tune_kept_triggers' dry run). Throws where it can't be read in the Editor's terms.
|
|
22
|
+
*/
|
|
23
|
+
export function outlineKeptTriggerFrom(reach, id, triggers, gameStrings) {
|
|
24
|
+
const strings = stringTable(reach.files.triggerStrings);
|
|
25
|
+
// Read as convert_triggers reads it, so it outlines as it will once converted.
|
|
26
|
+
const { held } = recordConversionContext(reach.record?.entries ?? []);
|
|
27
|
+
let trigger;
|
|
28
|
+
try {
|
|
29
|
+
trigger = readKeptTrigger(mapElements(triggers), strings, gameStrings, id, held ?? new Set()).trigger;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (!(error instanceof UnconvertibleFunctionError))
|
|
33
|
+
throw error;
|
|
34
|
+
throw new Error(`The Kept trigger "${strings.get(`Trigger/Name/${id}`) ?? id}" (${id}) can't be read in the Editor's terms: ${error.reason}`, { cause: error });
|
|
35
|
+
}
|
|
36
|
+
// Against the reach it will have once converted: not among the Kept triggers, the Blueprint's all there.
|
|
37
|
+
return outlineOf(reach, trigger, "Kept", reach.authored.triggers);
|
|
38
|
+
}
|
|
13
39
|
/**
|
|
14
40
|
* The outline of the Mission's trigger `wanted` (by name or element Id): the Blueprint's own, else
|
|
15
41
|
* a Kept one in its Map Package. Refused where none has it, two Kept ones share the name, or a Kept
|
|
@@ -17,34 +43,17 @@ export const outlineText = (trigger, unwritable) => [JSON.stringify(trigger, nul
|
|
|
17
43
|
*/
|
|
18
44
|
export async function outlineTrigger(workspace, blueprintPath, wanted) {
|
|
19
45
|
const reach = await missionTriggerReach(workspace, blueprintPath);
|
|
20
|
-
const { authored, files, gameStrings, kept
|
|
21
|
-
// A Kept trigger against the reach it will have once converted: not among the Kept triggers, the Blueprint's all there.
|
|
22
|
-
const outline = (trigger, owner, others, file) => {
|
|
23
|
-
const { trigger: input, unwritable } = outlineForAuthoring(trigger, { libraries, map: missionMapReach(reach, others, trigger.id) });
|
|
24
|
-
return { name: trigger.name, id: trigger.id, owner, ...(file !== undefined ? { file } : {}), trigger: input, unwritable, text: outlineText(input, unwritable) };
|
|
25
|
-
};
|
|
46
|
+
const { authored, files, gameStrings, kept } = reach;
|
|
26
47
|
const own = authored.triggers.find(({ trigger }) => trigger.id === wanted || trigger.name === wanted);
|
|
27
48
|
if (own)
|
|
28
|
-
return
|
|
49
|
+
return outlineOf(reach, own.trigger, "Blueprint", authored.triggers.filter((entry) => entry !== own), own.file);
|
|
29
50
|
const strings = stringTable(files.triggerStrings);
|
|
30
51
|
const named = kept.filter((item) => item.type === "Trigger" && (item.id === wanted || strings.get(`Trigger/Name/${item.id}`) === wanted));
|
|
31
52
|
if (named.length === 0)
|
|
32
53
|
throw new Error(`The Mission has no trigger "${wanted}": not one of its Blueprint's, nor a Kept one in its Map Package`);
|
|
33
54
|
if (named.length > 1)
|
|
34
55
|
throw new Error(`"${wanted}" is the name of the Kept triggers ${named.map((item) => item.id).join(", ")}: give one by its element Id`);
|
|
35
|
-
|
|
36
|
-
// Read as convert_triggers reads it, so it outlines as it will once converted.
|
|
37
|
-
const { held } = recordConversionContext(record?.entries ?? []);
|
|
38
|
-
let trigger;
|
|
39
|
-
try {
|
|
40
|
-
trigger = readKeptTrigger(mapElements(files.triggers), strings, gameStrings, item.id, held ?? new Set()).trigger;
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
if (!(error instanceof UnconvertibleFunctionError))
|
|
44
|
-
throw error;
|
|
45
|
-
throw new Error(`The Kept trigger "${strings.get(`Trigger/Name/${item.id}`) ?? item.id}" (${item.id}) can't be read in the Editor's terms: ${error.reason}`, { cause: error });
|
|
46
|
-
}
|
|
47
|
-
return outline(trigger, "Kept", authored.triggers);
|
|
56
|
+
return outlineKeptTriggerFrom(reach, named[0].id, files.triggers, gameStrings);
|
|
48
57
|
}
|
|
49
58
|
/** Where a trigger outlined lives, for its heading: Kept in the package, or its Blueprint file. */
|
|
50
59
|
export const outlineHeading = ({ name, id, owner, file }) => owner === "Kept" ? `${name} (Kept trigger ${id}: convert it with convert_triggers before rewriting it with write_blueprint_trigger)` : `${name} (Blueprint trigger ${id}, ${file}; write_blueprint_trigger rewrites it)`;
|
|
@@ -44,8 +44,12 @@ export type OwnershipPlan = {
|
|
|
44
44
|
readonly componentListKind: "components" | "kept-components";
|
|
45
45
|
/** The refusal if the package can't be compiled beside: it needs a compile record and a MapInfo. */
|
|
46
46
|
packageRefusal(hasRecord: boolean, hasMapInfo: boolean): string | undefined;
|
|
47
|
-
/**
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The refusal if Kept References are built with no compile record to keep their Kept triggers from
|
|
49
|
+
* being written over. A reference to one of the Blueprint's own triggers (`blueprintTriggers`, by
|
|
50
|
+
* element Id; ADR-0026) names nothing in the package, so it needs no record.
|
|
51
|
+
*/
|
|
52
|
+
keptReferencesRefusal(buildsMissionTriggers: boolean, hasRecord: boolean, blueprintTriggers: ReadonlySet<string>): string | undefined;
|
|
49
53
|
/** Whether the compile writes triggers: asked for, and beside Kept terrain only if it has any to splice in. */
|
|
50
54
|
writesTriggers(requested: boolean, splicesAny: boolean): boolean;
|
|
51
55
|
/** The refusal if the compile's triggers have no Kept Triggers file to go beside. */
|
|
@@ -47,7 +47,7 @@ export function planOwnership(input, table = BESIDE_KEPT) {
|
|
|
47
47
|
packageRefusal: (hasRecord, hasMapInfo) => besideKept && (!hasRecord || !hasMapInfo)
|
|
48
48
|
? `${blueprint.id} ${blueprint.zones.length === 0 ? "has no Zones, so every terrain cell is Kept Content" : "has Kept terrain beside its Zones"}, and ${outputDir} isn't a Map Package with a compile record to keep it from: compile the Mission in place, into its own package (no output folder), or import a map for it (import-map)`
|
|
49
49
|
: undefined,
|
|
50
|
-
keptReferencesRefusal: (buildsMissionTriggers, hasRecord) => buildsMissionTriggers && blueprint.kept.
|
|
50
|
+
keptReferencesRefusal: (buildsMissionTriggers, hasRecord, blueprintTriggers) => buildsMissionTriggers && !hasRecord && blueprint.kept.some((reference) => !(reference.kind === "trigger" && blueprintTriggers.has(String(reference.editorId))))
|
|
51
51
|
? `${blueprint.id} has Kept References, but ${outputDir} has no compile record, so its triggers would be written whole over the Kept Content they name: compile the Mission in place, into its own package (no output folder), once it has a record (import-map writes one)`
|
|
52
52
|
: undefined,
|
|
53
53
|
writesTriggers: (requested, splicesAny) => requested && (owner("triggers") === "compile" || splicesAny),
|
|
@@ -22,7 +22,7 @@ import { entryName, fingerprint } from "../domain/compile-record.js";
|
|
|
22
22
|
import { removalOfLine } from "../domain/mod-blueprint.js";
|
|
23
23
|
import { LIBRARY_ITEM_TYPES } from "../domain/library-interface.js";
|
|
24
24
|
import { libraryStringKey } from "../mods/library-xml.js";
|
|
25
|
-
import { editorGlobalName, editorTriggerName } from "../triggers/trigger-model.js";
|
|
25
|
+
import { editorGlobalName, editorTriggerName, galaxyIdentifier } from "../triggers/trigger-model.js";
|
|
26
26
|
import { packageModes } from "../util/package-file-mode.js";
|
|
27
27
|
import { withoutCustomScriptInMapScript } from "../triggers/custom-script.js";
|
|
28
28
|
import { editorForm, scriptBlocks, sharedBlocks, spliceMapScript } from "../triggers/splice-map-script.js";
|
|
@@ -348,9 +348,10 @@ export class PackageOutput {
|
|
|
348
348
|
if (!listed(discard, `string:${TRIGGER_STRINGS}:${key}`))
|
|
349
349
|
this.keptNames.add(`name:${key}`);
|
|
350
350
|
}
|
|
351
|
-
|
|
351
|
+
// A map's own function (a Mission Blueprint's, ADR-0026) keeps its name and Galaxy as a trigger does.
|
|
352
|
+
if (entry.kind !== "trigger" && entry.kind !== "variable" && !(entry.kind === "function" && library === undefined))
|
|
352
353
|
continue;
|
|
353
|
-
const type = entry.kind
|
|
354
|
+
const type = SCRIPT_TYPES[entry.kind];
|
|
354
355
|
const key = library === undefined ? `${type}/Name/${entry.id}` : libraryStringKey(library, type, "Name", entry.id);
|
|
355
356
|
if (!listed(discard, `string:${TRIGGER_STRINGS}:${key}`))
|
|
356
357
|
this.keptNames.add(`name:${key}`);
|
|
@@ -360,7 +361,7 @@ export class PackageOutput {
|
|
|
360
361
|
for (const source of [strings, typeof freshStrings === "string" ? freshStrings : undefined]) {
|
|
361
362
|
const name = triggerStringName(source, type, entry.id);
|
|
362
363
|
if (name !== undefined)
|
|
363
|
-
this.keptScript.add(entry.kind
|
|
364
|
+
this.keptScript.add(scriptNameOf(entry.kind, name));
|
|
364
365
|
}
|
|
365
366
|
}
|
|
366
367
|
const keptScript = new Set([...this.keptScript].map(editorForm));
|
|
@@ -377,17 +378,17 @@ export class PackageOutput {
|
|
|
377
378
|
const unknown = "0".repeat(16);
|
|
378
379
|
for (const entry of reowned) {
|
|
379
380
|
entries.push({ ...entry, fingerprint: unknown });
|
|
380
|
-
if (entry.kind !== "trigger" && entry.kind !== "variable")
|
|
381
|
+
if (entry.kind !== "trigger" && entry.kind !== "variable" && !(entry.kind === "function" && library === undefined))
|
|
381
382
|
continue;
|
|
382
|
-
const type = entry.kind
|
|
383
|
+
const type = SCRIPT_TYPES[entry.kind];
|
|
383
384
|
entries.push({ kind: "string", file: TRIGGER_STRINGS, key: library === undefined ? `${type}/Name/${entry.id}` : libraryStringKey(library, type, "Name", entry.id), fingerprint: unknown });
|
|
384
385
|
if (library !== undefined)
|
|
385
386
|
continue;
|
|
386
387
|
const name = triggerStringName(strings, type, entry.id);
|
|
387
388
|
if (name === undefined)
|
|
388
389
|
continue;
|
|
389
|
-
const blocks = entry.kind === "trigger" ? ["trigger-variable", "trigger", "trigger-init"] : ["variable", "variable-init"];
|
|
390
|
-
const script = entry.kind
|
|
390
|
+
const blocks = entry.kind === "trigger" ? ["trigger-variable", "trigger", "trigger-init"] : entry.kind === "function" ? ["function-declaration", "function"] : ["variable", "variable-init"];
|
|
391
|
+
const script = scriptNameOf(entry.kind, name);
|
|
391
392
|
for (const block of blocks)
|
|
392
393
|
entries.push({ kind: "galaxy-block", id: `${block}:${script}`, fingerprint: unknown });
|
|
393
394
|
}
|
|
@@ -899,3 +900,7 @@ function inComponent(file, component) {
|
|
|
899
900
|
return /^[a-z]{2}[A-Z]{2}\.SC2Data\/LocalizedData\//.test(file);
|
|
900
901
|
return file === component;
|
|
901
902
|
}
|
|
903
|
+
/** The Triggers element type of a record kind with a script name: a trigger, a global or a map function. */
|
|
904
|
+
const SCRIPT_TYPES = { trigger: "Trigger", variable: "Variable", function: "FunctionDef" };
|
|
905
|
+
/** The Galaxy name the Editor gives an element of `kind` named `name` (gt_, gv_, gf_). */
|
|
906
|
+
const scriptNameOf = (kind, name) => (kind === "trigger" ? editorTriggerName(name) : kind === "function" ? `gf_${galaxyIdentifier(name)}` : editorGlobalName(name));
|
|
@@ -48,10 +48,17 @@ export type KeptTriggerTuneResult = {
|
|
|
48
48
|
readonly changed: readonly string[];
|
|
49
49
|
readonly files: readonly string[];
|
|
50
50
|
readonly mapPackage: string;
|
|
51
|
+
/** A dry run's change to each trigger edited, in the Editor's form with the changed lines marked (outline-diff.ts); a function has none. */
|
|
52
|
+
readonly diffs?: readonly {
|
|
53
|
+
readonly trigger: string;
|
|
54
|
+
readonly diff: string;
|
|
55
|
+
}[];
|
|
51
56
|
};
|
|
52
57
|
export type KeptTriggerTuneOptions = {
|
|
53
58
|
/** Asked whether the Editor has the map open (`editor.checkClosed`); a host that can't tell lets the edit go ahead. */
|
|
54
59
|
readonly host?: Host;
|
|
60
|
+
/** Check and apply every edit in memory and return the change to each trigger in the Editor's form, writing nothing (so the Editor having the map open is no refusal). */
|
|
61
|
+
readonly dryRun?: boolean;
|
|
55
62
|
};
|
|
56
63
|
/** core's catalog and every Mechanic's primitives in the Workspace. */
|
|
57
64
|
export declare function keptCatalog(workspace: Workspace): KeptCatalog;
|