@scm-js/plugin-api 1.5.0 → 1.6.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.
- package/index.d.ts +127 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -2745,6 +2745,16 @@ export interface ViewApi {
|
|
|
2745
2745
|
/** Grid spacing in map pixels (32 = one tile). */
|
|
2746
2746
|
gridSize(): number;
|
|
2747
2747
|
setGridSize(size: 8 | 16 | 32 | 64 | 128): void;
|
|
2748
|
+
/**
|
|
2749
|
+
* Highlight something on the map for a moment: the rect an edit filled, the units it
|
|
2750
|
+
* placed, the location it moved. Fades by itself; several may run at once. Nothing to
|
|
2751
|
+
* clean up.
|
|
2752
|
+
*
|
|
2753
|
+
* @example
|
|
2754
|
+
* const r = api.document.edit("Fill", (tx) => tx.fillFlat(rect, terrain));
|
|
2755
|
+
* if (r.changed) api.view.flash({ rect });
|
|
2756
|
+
*/
|
|
2757
|
+
flash(target: FlashTarget): void;
|
|
2748
2758
|
}
|
|
2749
2759
|
export interface CommandSpec {
|
|
2750
2760
|
/**
|
|
@@ -3455,8 +3465,19 @@ export interface DialogHandle {
|
|
|
3455
3465
|
*/
|
|
3456
3466
|
export interface PanelSpec {
|
|
3457
3467
|
title: string;
|
|
3458
|
-
/** In CSS pixels; 260 by default. The panel is as tall as its content, up to the map's height. */
|
|
3468
|
+
/** In CSS pixels; 260 by default. The panel is as tall as its content, up to the map's height. Ignored when docked. */
|
|
3459
3469
|
width?: number;
|
|
3470
|
+
/**
|
|
3471
|
+
* Where the panel lives. `"float"` (the default) is a frame over the map the user drags
|
|
3472
|
+
* about. `"right"` puts it in the right dock as a panel of its own, under Minimap, Layers
|
|
3473
|
+
* and Properties, with the same head and hide button the built-in panels have — the
|
|
3474
|
+
* choice for anything the user keeps open while working, such as an assistant or a
|
|
3475
|
+
* readout. A docked panel shows the dock even when the user has hidden every built-in
|
|
3476
|
+
* panel in it.
|
|
3477
|
+
*/
|
|
3478
|
+
dock?: "float" | "right";
|
|
3479
|
+
/** A docked panel that takes the dock's spare height (a transcript, a long list); off by default. */
|
|
3480
|
+
grow?: boolean;
|
|
3460
3481
|
/** Fill `body` (an empty `<div>` inside the panel); return a cleanup if you need one. */
|
|
3461
3482
|
mount(body: HTMLElement, panel: PanelHandle): void | (() => void);
|
|
3462
3483
|
/** The panel closed, whichever way. */
|
|
@@ -3467,6 +3488,85 @@ export interface PanelHandle {
|
|
|
3467
3488
|
isOpen(): boolean;
|
|
3468
3489
|
setTitle(title: string): void;
|
|
3469
3490
|
}
|
|
3491
|
+
/**
|
|
3492
|
+
* One cell in the status bar (`ui.statusItem`): a line of text with the plugin's icon,
|
|
3493
|
+
* a spinner while `busy`, and a click. It is how a plugin that works in the background
|
|
3494
|
+
* stays visible without a panel — "AI · working 12 s", "3 problems", "Synced".
|
|
3495
|
+
*/
|
|
3496
|
+
export interface StatusItemSpec {
|
|
3497
|
+
text: string;
|
|
3498
|
+
/** The tooltip. */
|
|
3499
|
+
title?: string;
|
|
3500
|
+
/** Show a spinner in the cell. */
|
|
3501
|
+
busy?: boolean;
|
|
3502
|
+
/** Paint the cell as a warning. */
|
|
3503
|
+
warn?: boolean;
|
|
3504
|
+
onClick?: () => void;
|
|
3505
|
+
}
|
|
3506
|
+
export interface StatusItemHandle {
|
|
3507
|
+
/** Change any of the fields; the cell redraws. */
|
|
3508
|
+
set(patch: Partial<StatusItemSpec>): void;
|
|
3509
|
+
remove(): void;
|
|
3510
|
+
isShown(): boolean;
|
|
3511
|
+
}
|
|
3512
|
+
/**
|
|
3513
|
+
* The dialogs a plugin may add to (`ui.dialogSlot`), and the fields each one exposes to
|
|
3514
|
+
* the slot. A field is the dialog's *working copy* — what the person sees in the form,
|
|
3515
|
+
* not yet applied to the map — so a slot's button can fill it in and leave OK to them.
|
|
3516
|
+
*
|
|
3517
|
+
* - `mapProperties`: `name`, `description`.
|
|
3518
|
+
* - `textTriggerEditor`: `text` (the whole editor); `payload.briefing` says which list.
|
|
3519
|
+
* - `triggerEditor`, `stringEditor`, `playerSettings`, `missionBriefing`: no fields, a slot only.
|
|
3520
|
+
*/
|
|
3521
|
+
export type SlottedDialogId = "mapProperties" | "textTriggerEditor" | "triggerEditor" | "stringEditor" | "playerSettings" | "missionBriefing";
|
|
3522
|
+
/** A form field a dialog lends to a slot: read it, set it, hear it change. */
|
|
3523
|
+
export interface DialogField {
|
|
3524
|
+
get(): string;
|
|
3525
|
+
set(value: string): void;
|
|
3526
|
+
}
|
|
3527
|
+
/** What a slot's `mount` is handed: which dialog, its payload, its fields, and a way to close it. */
|
|
3528
|
+
export interface DialogSlotHost {
|
|
3529
|
+
readonly dialog: SlottedDialogId;
|
|
3530
|
+
readonly payload: Readonly<Record<string, unknown>>;
|
|
3531
|
+
readonly fields: Readonly<Record<string, DialogField>>;
|
|
3532
|
+
close(): void;
|
|
3533
|
+
}
|
|
3534
|
+
/**
|
|
3535
|
+
* Something a plugin mounts *inside* a built-in dialog — a button in Map Properties
|
|
3536
|
+
* that suggests a name, one in the Text Trigger Editor that explains the text. The slot
|
|
3537
|
+
* is a row at the left of the dialog's footer; fill it with the widgets, and it looks like
|
|
3538
|
+
* part of the dialog. `mount` runs every time the dialog opens, with a cleanup on close.
|
|
3539
|
+
*/
|
|
3540
|
+
export interface DialogSlotSpec {
|
|
3541
|
+
mount(body: HTMLElement, host: DialogSlotHost): void | (() => void);
|
|
3542
|
+
}
|
|
3543
|
+
/**
|
|
3544
|
+
* What `view.flash` highlights: a tile rect, or units / locations by index. The
|
|
3545
|
+
* highlight fades over `ms` (600 by default) and never blocks or takes the pointer; it is
|
|
3546
|
+
* the shared way to say "this just changed" or "look here", so every plugin's flash looks
|
|
3547
|
+
* the same. `kind` picks the colour: `"change"` (gold, the default) or `"attention"` (teal).
|
|
3548
|
+
*/
|
|
3549
|
+
export type FlashTarget = {
|
|
3550
|
+
rect: Rect;
|
|
3551
|
+
kind?: FlashKind;
|
|
3552
|
+
ms?: number;
|
|
3553
|
+
} | {
|
|
3554
|
+
units: number[];
|
|
3555
|
+
kind?: FlashKind;
|
|
3556
|
+
ms?: number;
|
|
3557
|
+
} | {
|
|
3558
|
+
locations: number[];
|
|
3559
|
+
kind?: FlashKind;
|
|
3560
|
+
ms?: number;
|
|
3561
|
+
} | {
|
|
3562
|
+
tiles: {
|
|
3563
|
+
x: number;
|
|
3564
|
+
y: number;
|
|
3565
|
+
}[];
|
|
3566
|
+
kind?: FlashKind;
|
|
3567
|
+
ms?: number;
|
|
3568
|
+
};
|
|
3569
|
+
export type FlashKind = "change" | "attention";
|
|
3470
3570
|
/** The pointer over the map, in the map's own units. A tile is 32 × 32 pixels. */
|
|
3471
3571
|
export interface MapPointer {
|
|
3472
3572
|
/** Map pixels. Kept inside the map while a button is held, as the built-in brushes do. */
|
|
@@ -3610,8 +3710,33 @@ export interface UiApi {
|
|
|
3610
3710
|
fileName: string;
|
|
3611
3711
|
} | null>;
|
|
3612
3712
|
dialog(spec: DialogSpec): DialogHandle;
|
|
3613
|
-
/**
|
|
3713
|
+
/**
|
|
3714
|
+
* Open a panel: floating over the map, or docked at the right with the built-in panels
|
|
3715
|
+
* (`spec.dock`). As many as you like; each closes with the plugin.
|
|
3716
|
+
*/
|
|
3614
3717
|
panel(spec: PanelSpec): PanelHandle;
|
|
3718
|
+
/**
|
|
3719
|
+
* A cell of your own in the status bar. One line of text beside the plugin's icon, a
|
|
3720
|
+
* spinner while `busy`, a click. Keep the handle and `set` it as things move; it
|
|
3721
|
+
* leaves with `remove()` or the plugin.
|
|
3722
|
+
*/
|
|
3723
|
+
statusItem(spec: StatusItemSpec): StatusItemHandle;
|
|
3724
|
+
/**
|
|
3725
|
+
* Add to a built-in dialog. `mount` runs in a row at the left of the dialog's footer each
|
|
3726
|
+
* time that dialog opens, with the dialog's working-copy fields to read and fill
|
|
3727
|
+
* (`SlottedDialogId` lists which dialogs and fields). Returns the registration; it
|
|
3728
|
+
* leaves with `dispose()` or the plugin.
|
|
3729
|
+
*
|
|
3730
|
+
* @example
|
|
3731
|
+
* api.ui.dialogSlot("mapProperties", {
|
|
3732
|
+
* mount(body, dlg) {
|
|
3733
|
+
* body.append(api.ui.widgets.button("Suggest a name", { onClick: async () => {
|
|
3734
|
+
* dlg.fields.name.set(await suggestName(dlg.fields.description.get()));
|
|
3735
|
+
* } }));
|
|
3736
|
+
* },
|
|
3737
|
+
* });
|
|
3738
|
+
*/
|
|
3739
|
+
dialogSlot(dialog: SlottedDialogId, spec: DialogSlotSpec): Disposable;
|
|
3615
3740
|
/**
|
|
3616
3741
|
* Take over the pointer on the map until `stop()`, Esc, a right-click, a map change
|
|
3617
3742
|
* or another tool. One tool runs at a time — starting one stops the previous — and a
|