@scm-js/plugin-api 1.53.0 → 1.55.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 +66 -7
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -2518,7 +2518,7 @@ export interface PluginApi {
|
|
|
2518
2518
|
readonly menu: MenuApi;
|
|
2519
2519
|
/** Items in the right-click menus of the map and the terrain palette. */
|
|
2520
2520
|
readonly contextMenu: ContextMenuApi;
|
|
2521
|
-
/** Key combinations, tried before the editor's own and never while a text field has focus. */
|
|
2521
|
+
/** Key combinations, tried before the editor's own, and never while a text field has focus or a dialog is open. */
|
|
2522
2522
|
readonly hotkeys: HotkeyApi;
|
|
2523
2523
|
readonly commands: CommandsApi;
|
|
2524
2524
|
/** Live objects one plugin holds out for others to use, found by name and watched for arriving. */
|
|
@@ -2535,7 +2535,7 @@ export interface PluginApi {
|
|
|
2535
2535
|
readonly sync: SyncApi;
|
|
2536
2536
|
/**
|
|
2537
2537
|
* A small key-value store of the plugin's own, kept in the browser's local storage under
|
|
2538
|
-
* the plugin's id and listed with everything else in Preferences ▸
|
|
2538
|
+
* the plugin's id and listed with everything else in Preferences ▸ Storage.
|
|
2539
2539
|
*/
|
|
2540
2540
|
readonly storage: StorageApi;
|
|
2541
2541
|
/** `console.log` with the plugin's name in front. */
|
|
@@ -4591,6 +4591,20 @@ export interface TilesetApi {
|
|
|
4591
4591
|
load(tileset?: TilesetId): Promise<boolean>;
|
|
4592
4592
|
raw(): LoadedTileset | null;
|
|
4593
4593
|
}
|
|
4594
|
+
/**
|
|
4595
|
+
* What is selected on each object layer, by index into the scenario's lists, with a
|
|
4596
|
+
* setter for each; the Clipboard layer's marked area; the active layer; and the Layers
|
|
4597
|
+
* panel's locks.
|
|
4598
|
+
*
|
|
4599
|
+
* @example
|
|
4600
|
+
* // Select Player 1's units inside the marked area.
|
|
4601
|
+
* const area = api.selection.markedArea();
|
|
4602
|
+
* if (area) {
|
|
4603
|
+
* const mine = new Set(api.query.unitsOf(0));
|
|
4604
|
+
* api.selection.setLayer("units");
|
|
4605
|
+
* api.selection.setUnits(api.query.unitsIn(area).filter((i) => mine.has(i)));
|
|
4606
|
+
* }
|
|
4607
|
+
*/
|
|
4594
4608
|
export interface SelectionApi {
|
|
4595
4609
|
/** The Cut / Copy / Paste layer's marked rectangle, in tiles. */
|
|
4596
4610
|
markedArea(): Rect | null;
|
|
@@ -4950,6 +4964,7 @@ export interface DialogTransfer {
|
|
|
4950
4964
|
export interface DialogSpec {
|
|
4951
4965
|
title: string;
|
|
4952
4966
|
size?: DialogSize;
|
|
4967
|
+
/** A fixed height (720 CSS pixels, less on a small screen) instead of the content's own, for a body that scrolls or fills. */
|
|
4953
4968
|
tall?: boolean;
|
|
4954
4969
|
/** Fill `body` (an empty `<div>` inside the dialog); return a cleanup if you need one. */
|
|
4955
4970
|
mount(body: HTMLElement, dialog: DialogHandle): void | (() => void);
|
|
@@ -5112,6 +5127,24 @@ export interface MapViewSpec {
|
|
|
5112
5127
|
* its box and presses are the map's own view's (hidden behind this one).
|
|
5113
5128
|
*/
|
|
5114
5129
|
minimap?: MapViewMinimapSpec;
|
|
5130
|
+
/**
|
|
5131
|
+
* View ▸ Fog of War, the toolbar's button and its key, while the view is shown: turn the view's
|
|
5132
|
+
* own fog on or off. The toggle then shows the view's fog, as you last said it
|
|
5133
|
+
* (`MapViewHandle.setFog`), not the map's. Without `onFog` the toggle is off while the view is shown.
|
|
5134
|
+
*/
|
|
5135
|
+
onFog?(on: boolean): void;
|
|
5136
|
+
/**
|
|
5137
|
+
* What `MapViewHandle.paintOver` draws changed — View ▸ Grid or Locations turned on or off, the
|
|
5138
|
+
* grid's settings, the map's locations, another plugin's overlay: draw over the view again. With
|
|
5139
|
+
* it the editor's Grid, Locations and Location Names toggles, and the other plugins' overlays,
|
|
5140
|
+
* stay on offer while the view is shown; without it they are off, as the view cannot show them.
|
|
5141
|
+
*/
|
|
5142
|
+
onRepaint?(): void;
|
|
5143
|
+
}
|
|
5144
|
+
/** Where the pointer is over a map view (`MapViewHandle.setPointer`), in map pixels. */
|
|
5145
|
+
export interface MapViewPointer {
|
|
5146
|
+
x: number;
|
|
5147
|
+
y: number;
|
|
5115
5148
|
}
|
|
5116
5149
|
/**
|
|
5117
5150
|
* Where a view looks, in map pixels (32 to a tile): the point in the middle of what it shows,
|
|
@@ -5214,6 +5247,31 @@ export interface MapViewHandle extends Disposable {
|
|
|
5214
5247
|
wheel(wheel: MapViewWheel): boolean;
|
|
5215
5248
|
/** Make the minimap's picture again (`minimap.draw`), at most once a frame. Cheap: call it as the view's contents move. */
|
|
5216
5249
|
redrawMinimap(): void;
|
|
5250
|
+
/**
|
|
5251
|
+
* Whether the view shows its fog now, for View ▸ Fog of War and the toolbar's button while it
|
|
5252
|
+
* is shown (`onFog`); null when it has none to show at the moment, which greys the toggle. Say
|
|
5253
|
+
* it whenever it changes, by the person's hand or yours.
|
|
5254
|
+
*/
|
|
5255
|
+
setFog(on: boolean | null): void;
|
|
5256
|
+
/**
|
|
5257
|
+
* Where the pointer is over the view, in map pixels, for the status bar's tile and position;
|
|
5258
|
+
* null once it leaves. A view in an iframe hears the pointer and the editor does not.
|
|
5259
|
+
*/
|
|
5260
|
+
setPointer(at: MapViewPointer | null): void;
|
|
5261
|
+
/**
|
|
5262
|
+
* Draw what the editor draws over a map onto your canvas over the view, mapped by `view` as a
|
|
5263
|
+
* map tool's or an overlay's `draw` is: the grid and the locations as View ▸ Grid, Locations and
|
|
5264
|
+
* Location Names have them, then the other plugins' visible overlays (yours are your own to draw).
|
|
5265
|
+
* Call it from your own drawing, above the view's picture and below your marks, each time you
|
|
5266
|
+
* draw; `onRepaint` says when it would draw something else. Nothing while the view is not shown.
|
|
5267
|
+
*
|
|
5268
|
+
* @example
|
|
5269
|
+
* function drawOver(ctx: CanvasRenderingContext2D, v: MapView) {
|
|
5270
|
+
* handle.paintOver(ctx, v);
|
|
5271
|
+
* drawMyMarks(ctx, v);
|
|
5272
|
+
* }
|
|
5273
|
+
*/
|
|
5274
|
+
paintOver(ctx: CanvasRenderingContext2D, view: MapView): void;
|
|
5217
5275
|
}
|
|
5218
5276
|
export interface PanelHandle {
|
|
5219
5277
|
close(): void;
|
|
@@ -5481,14 +5539,14 @@ export type OverlayAbove =
|
|
|
5481
5539
|
| "everything";
|
|
5482
5540
|
/**
|
|
5483
5541
|
* An overlay is a picture drawn over the map that the user can turn on and off: it
|
|
5484
|
-
* is
|
|
5542
|
+
* is a tick in the View menu and a row in the Layers panel, stays while the user works
|
|
5485
5543
|
* on any layer, and never takes the pointer — clicks go to the active layer's tools
|
|
5486
5544
|
* as usual. It hears the pointer through `onHover`, which is how a readout follows the
|
|
5487
5545
|
* mouse while the user places units. Register one at activation and keep the handle;
|
|
5488
5546
|
* it goes away with the plugin.
|
|
5489
5547
|
*
|
|
5490
5548
|
* @example
|
|
5491
|
-
* // A ring twelve tiles wide round every start location,
|
|
5549
|
+
* // A ring twelve tiles wide round every start location, a tick in the View menu.
|
|
5492
5550
|
* const overlay = api.ui.overlay({
|
|
5493
5551
|
* name: "Start rings",
|
|
5494
5552
|
* above: "objects",
|
|
@@ -5505,7 +5563,7 @@ export type OverlayAbove =
|
|
|
5505
5563
|
* api.events.on("units", () => overlay.redraw());
|
|
5506
5564
|
*/
|
|
5507
5565
|
export interface OverlaySpec {
|
|
5508
|
-
/** Shown in View
|
|
5566
|
+
/** Shown in the View menu and the Layers panel. Unique per plugin. In English, like a menu label: shown through the plugin's registered catalogues. */
|
|
5509
5567
|
name: string;
|
|
5510
5568
|
/** Start visible; true by default. What the user last set for this name wins for the session. */
|
|
5511
5569
|
visible?: boolean;
|
|
@@ -5654,7 +5712,7 @@ export interface UiApi {
|
|
|
5654
5712
|
*/
|
|
5655
5713
|
mapTool(spec: MapToolSpec): MapToolHandle;
|
|
5656
5714
|
/**
|
|
5657
|
-
* A picture over the map the user can switch on and off (View
|
|
5715
|
+
* A picture over the map the user can switch on and off (a tick in the View menu, the Layers
|
|
5658
5716
|
* panel) and that stays while they work on any layer. It draws at every repaint and
|
|
5659
5717
|
* hears the pointer, but never takes it. As many as you like; they go with the plugin.
|
|
5660
5718
|
*/
|
|
@@ -6256,7 +6314,8 @@ export interface ContextMenuApi {
|
|
|
6256
6314
|
}
|
|
6257
6315
|
export interface HotkeyApi {
|
|
6258
6316
|
/**
|
|
6259
|
-
* `"Ctrl+Shift+I"`, `"Alt+F9"`, `"F8"` — modifiers in any order, then a key name.
|
|
6317
|
+
* `"Ctrl+Shift+I"`, `"Alt+F9"`, `"F8"` — modifiers in any order, then a key name. Tried
|
|
6318
|
+
* before the editor's own keys, and never while a text field has focus or a dialog is open.
|
|
6260
6319
|
*
|
|
6261
6320
|
* @example
|
|
6262
6321
|
* api.hotkeys.add("Ctrl+Alt+G", () => api.view.setFlags({ grid: !api.view.flags().grid }));
|