@scm-js/plugin-api 1.37.0 → 1.39.0

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.
Files changed (2) hide show
  1. package/index.d.ts +143 -1
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1327,6 +1327,80 @@ export interface TextTrigger {
1327
1327
  /** 1-based line the `Trigger(` header starts on. */
1328
1328
  line: number;
1329
1329
  }
1330
+ /** Every kind of thing a condition or action can refer to. */
1331
+ export type TriggerRefKind =
1332
+ /** A switch; `id` is its 0-based number. */
1333
+ "switch"
1334
+ /** A death counter; `id` is the unit id, `players` the slots whose cell it is. */
1335
+ | "deaths"
1336
+ /** A death counter out of range — an EUD read or write; `address` is the dword it reaches, `id` the unit value as written. */
1337
+ | "memory"
1338
+ /** A location; `id` is its 0-based slot (63 is Anywhere). */
1339
+ | "location"
1340
+ /** The countdown timer; `id` is 0. */
1341
+ | "timer"
1342
+ /** A player's ore or gas; `id` is the `ResourceType`. */
1343
+ | "resources"
1344
+ /** A player's score; `id` is the `ScoreType`. */
1345
+ | "score"
1346
+ /** Units of a type; `id` is the unit id (a class id for *Any unit*, *Men*, …). */
1347
+ | "units"
1348
+ /** Victory, Defeat or Draw; `id` is the action type, `players` the trigger's owners. */
1349
+ | "outcome"
1350
+ /** A string of the map's string table; `id` is the 1-based string index. */
1351
+ | "string"
1352
+ /** A sound; `id` is the string index of its file name. */
1353
+ | "wav"
1354
+ /** A Run AI Script code (four characters as a little-endian u32). */
1355
+ | "aiScript"
1356
+ /** A Create Unit with Properties slot, 0-based. */
1357
+ | "cuwp";
1358
+ /**
1359
+ * `read`: a condition tests it. `write`: an action changes it. `use`: an action names it
1360
+ * without changing it — the location units appear at, the text a message shows.
1361
+ */
1362
+ export type TriggerRefAccess = "read" | "write" | "use";
1363
+ export interface TriggerRef {
1364
+ kind: TriggerRefKind;
1365
+ access: TriggerRefAccess;
1366
+ /** Whether a condition or an action refers to it. */
1367
+ part: "condition" | "action";
1368
+ /** The condition's or action's position in the trigger. */
1369
+ slot: number;
1370
+ /** The condition or action type. */
1371
+ type: number;
1372
+ id: number;
1373
+ /**
1374
+ * The 0-based player slots it is about, for the kinds that belong to a player
1375
+ * (`deaths`, `resources`, `score`, `units`, `outcome`); empty for the rest, and for a
1376
+ * condition such as *Command the Most* that compares every player.
1377
+ */
1378
+ players: number[];
1379
+ /** The player group as the record stores it, where the record has one. */
1380
+ group?: number;
1381
+ /**
1382
+ * The group resolves only while the game runs (*Foes*, *Allies*, *Neutral Players*,
1383
+ * *Non Allied Victory Players*), so `players` is every slot it could name.
1384
+ */
1385
+ approximate?: boolean;
1386
+ /** `memory`: the address reached (rounded down to a dword). */
1387
+ address?: number;
1388
+ /** `memory`: the bits a masked record reaches (its `location` field), when the record is masked. */
1389
+ mask?: number;
1390
+ /** The condition or action is switched off (its Disabled flag); the game skips it. */
1391
+ disabled?: boolean;
1392
+ }
1393
+ export interface TriggerRefs {
1394
+ /** The trigger's index in the list. */
1395
+ index: number;
1396
+ /** The 0-based slots the trigger runs for. */
1397
+ owners: number[];
1398
+ /** The player groups ticked in the trigger, as stored. */
1399
+ groups: number[];
1400
+ /** Set by the Disabled flag, or no player owns it: the game never runs it. */
1401
+ inert: boolean;
1402
+ refs: TriggerRef[];
1403
+ }
1330
1404
  export type IssueLevel = "error" | "warn" | "info";
1331
1405
  export type IssueTarget = {
1332
1406
  kind: "location";
@@ -1955,6 +2029,8 @@ export interface StringImport {
1955
2029
  export type Locale = "en" | "ko";
1956
2030
  /** `"auto"` follows the browser (or the desktop app's system language). */
1957
2031
  export type LanguagePreference = "auto" | Locale;
2032
+ /** What `Preferences.hotkeys` holds: the commands the user changed, each with its whole list (`[]` = no keys). */
2033
+ export type HotkeyOverrides = Record<string, string[]>;
1958
2034
  export interface Preferences {
1959
2035
  /** The editor's own language: `"auto"` follows the browser's (the system's, in the desktop app), else one of `LOCALES`. Applied live. */
1960
2036
  language: LanguagePreference;
@@ -2081,6 +2157,28 @@ export interface Preferences {
2081
2157
  plugins: {
2082
2158
  updates: PluginUpdateMode;
2083
2159
  };
2160
+ /**
2161
+ * Preferences ▸ Hotkeys: the commands whose keys the user changed, by command id
2162
+ * (`editor/commands.ts`), each with its whole list — `[]` leaves it with none. A
2163
+ * command not here has the keys it ships with.
2164
+ */
2165
+ hotkeys: HotkeyOverrides;
2166
+ /**
2167
+ * Which cells the status bar shows (Preferences ▸ View). The message, the symmetry badge
2168
+ * while a mode is on, and the plugins' items always show.
2169
+ */
2170
+ statusBar: StatusBarCells;
2171
+ }
2172
+ /** See `Preferences.statusBar`, in the order the bar draws them. */
2173
+ export interface StatusBarCells {
2174
+ tile: boolean;
2175
+ pixel: boolean;
2176
+ tileId: boolean;
2177
+ size: boolean;
2178
+ tileset: boolean;
2179
+ layer: boolean;
2180
+ zoom: boolean;
2181
+ revision: boolean;
2084
2182
  }
2085
2183
  /** See `Preferences.plugins.updates`. */
2086
2184
  export type PluginUpdateMode = "notify" | "manual" | "auto";
@@ -3161,6 +3259,39 @@ export interface TriggersApi {
3161
3259
  ][];
3162
3260
  switches: number[];
3163
3261
  };
3262
+ /**
3263
+ * What each trigger reads, writes and names — TRIG when `list` is omitted, one entry per
3264
+ * trigger in list order. A condition *reads* (a switch, a death counter, the timer, a
3265
+ * player's ore, units at a location); an action *writes* (Set Switch, Set Deaths, Create
3266
+ * Unit, Move Location's target, Victory) or *uses* something without changing it (the
3267
+ * location units appear at, the text a message shows, a sound). Player groups are
3268
+ * resolved to slots against the map's forces, *Current Player* as the trigger's owners;
3269
+ * a Deaths record past the counters is a `memory` reference with its address.
3270
+ *
3271
+ * What a plugin needs to draw how triggers depend on each other, find a switch that is
3272
+ * set and never tested, or answer "which triggers can end the game". With `briefing`,
3273
+ * MBRF, where only strings and sounds are referred to.
3274
+ *
3275
+ * @example
3276
+ * // Switches something tests that nothing ever sets.
3277
+ * const refs = api.triggers.references().flatMap((t) => t.refs).filter((r) => r.kind === "switch");
3278
+ * const set = new Set(refs.filter((r) => r.access === "write").map((r) => r.id));
3279
+ * const never = [...new Set(refs.filter((r) => r.access === "read" && !set.has(r.id)).map((r) => r.id))];
3280
+ */
3281
+ references(list?: TriggerRecord[], options?: {
3282
+ briefing?: boolean;
3283
+ }): TriggerRefs[];
3284
+ /**
3285
+ * The 0-based player slots a player group names on the open map: a slot itself, the
3286
+ * members of a force, players 1–8 for *All Players*, and for *Current Player* the slots
3287
+ * of `owners` (the groups a trigger is ticked for). `approximate` when the group is only
3288
+ * settled while the game runs (*Foes*, *Allies*, *Neutral Players*, *Non Allied Victory
3289
+ * Players*); `players` is then every slot it could name.
3290
+ */
3291
+ resolvePlayers(group: number, owners?: number[]): {
3292
+ players: number[];
3293
+ approximate: boolean;
3294
+ };
3164
3295
  /**
3165
3296
  * Tell the editor that a run of the trigger list is generated by this plugin. The
3166
3297
  * Trigger Editor badges those rows, locks them and offers the plugin's own editor in
@@ -3289,6 +3420,12 @@ export type GoTo = {
3289
3420
  } | {
3290
3421
  kind: "location";
3291
3422
  index: number;
3423
+ }
3424
+ /** Opens the Trigger Editor (or, with `briefing`, the Mission Briefing) on that trigger. */
3425
+ | {
3426
+ kind: "trigger";
3427
+ index: number;
3428
+ briefing?: boolean;
3292
3429
  };
3293
3430
  /**
3294
3431
  * The map view: where the viewport is looking, how far in, and what it draws over the
@@ -4287,7 +4424,12 @@ export interface MapButtonHandle {
4287
4424
  * not yet applied to the map — so a slot's button can fill it in and leave OK to them.
4288
4425
  *
4289
4426
  * - `mapProperties`: `name`, `description`.
4290
- * - `triggerEditor`, `stringEditor`, `playerSettings`, `missionBriefing`: no fields, a slot only.
4427
+ * - `triggerEditor`, `missionBriefing`: `selected`, the selected row's index in the list
4428
+ * as text (`""` for none). Setting it selects that row. The index is into the dialog's
4429
+ * working copy, which matches `triggers.list()` until the person inserts or removes rows.
4430
+ * And `modified`, `"1"` while that working copy has changes not yet applied (read only):
4431
+ * `close()` discards them, so ask before closing when it is set.
4432
+ * - `stringEditor`, `playerSettings`: no fields, a slot only.
4291
4433
  *
4292
4434
  * A plugin's own dialog can offer a slot too (`DialogSpec.slot`), under an id of its
4293
4435
  * choosing — `"trigedit.text"` is the Text Trigger Editor's, lending `text` with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/plugin-api",
3
- "version": "1.37.0",
3
+ "version": "1.39.0",
4
4
  "description": "Type declarations for the scmJS plugin API",
5
5
  "license": "MIT",
6
6
  "types": "index.d.ts",