@scm-js/plugin-api 1.4.0 → 1.5.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 +94 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -902,6 +902,8 @@ export interface ImagesDat {
|
|
|
902
902
|
lo: Uint32Array[];
|
|
903
903
|
}
|
|
904
904
|
export interface WeaponsDat {
|
|
905
|
+
/** The weapon's name: a 1-based `stat_txt.tbl` index, 0 for none. */
|
|
906
|
+
label: Uint16Array;
|
|
905
907
|
damage: Uint16Array;
|
|
906
908
|
/** Added per upgrade level. */
|
|
907
909
|
bonus: Uint16Array;
|
|
@@ -920,6 +922,8 @@ export interface UpgradesDat {
|
|
|
920
922
|
maxRepeats: Uint8Array;
|
|
921
923
|
/** 1 for upgrades only Brood War has. */
|
|
922
924
|
broodWar: Uint8Array;
|
|
925
|
+
/** The upgrade's name: a 1-based `stat_txt.tbl` index, 0 for none. */
|
|
926
|
+
label: Uint16Array;
|
|
923
927
|
}
|
|
924
928
|
/** The columns Technology Settings shows as defaults. */
|
|
925
929
|
export interface TechdataDat {
|
|
@@ -930,6 +934,8 @@ export interface TechdataDat {
|
|
|
930
934
|
energyCost: Uint16Array;
|
|
931
935
|
/** 1 for abilities only Brood War has. */
|
|
932
936
|
broodWar: Uint8Array;
|
|
937
|
+
/** The technology's name: a 1-based `stat_txt.tbl` index, 0 for none. */
|
|
938
|
+
label: Uint16Array;
|
|
933
939
|
}
|
|
934
940
|
export interface SpriteGroup {
|
|
935
941
|
label: string;
|
|
@@ -1910,6 +1916,8 @@ export interface PluginApi {
|
|
|
1910
1916
|
readonly text: TextApi;
|
|
1911
1917
|
readonly query: QueryApi;
|
|
1912
1918
|
readonly data: DataApi;
|
|
1919
|
+
/** Which set of game files the editor draws from — the game's own or a mod's — and installing, switching and removing sets. */
|
|
1920
|
+
readonly gameData: GameDataApi;
|
|
1913
1921
|
/** Bit masks, special unit ids and the pixels-per-tile every record is written in. */
|
|
1914
1922
|
readonly consts: ConstsApi;
|
|
1915
1923
|
readonly graphics: GraphicsApi;
|
|
@@ -2844,6 +2852,89 @@ export interface DataApi {
|
|
|
2844
2852
|
/** The GRP path an image id draws from, relative to `unit\`. */
|
|
2845
2853
|
imagePath(imageId: number): string | null;
|
|
2846
2854
|
}
|
|
2855
|
+
/**
|
|
2856
|
+
* A data set: one set of game files the editor draws from. The default is the game's
|
|
2857
|
+
* own; any other is a mod's, installed under an id of its own, the same formats and
|
|
2858
|
+
* table sizes with some of the files replaced.
|
|
2859
|
+
*/
|
|
2860
|
+
export interface GameDataProfile {
|
|
2861
|
+
/** Lower-case letters, digits and hyphens, up to 40 characters. */
|
|
2862
|
+
id: string;
|
|
2863
|
+
/** What the dialog and the status line call it. */
|
|
2864
|
+
name: string;
|
|
2865
|
+
}
|
|
2866
|
+
/** Where the session's game data comes from. */
|
|
2867
|
+
export interface GameDataSource {
|
|
2868
|
+
/** `bundled` (this build's own files, or the desktop app's extraction), `stored` (a copy kept in the browser), or `none`. */
|
|
2869
|
+
kind: "bundled" | "stored" | "none";
|
|
2870
|
+
/** One line, as Help ▸ Game Data… shows it. */
|
|
2871
|
+
label: string;
|
|
2872
|
+
/** The data set the files belong to. */
|
|
2873
|
+
profile: GameDataProfile;
|
|
2874
|
+
/** Set when the desktop app extracted the files from a StarCraft installation. */
|
|
2875
|
+
desktop: boolean;
|
|
2876
|
+
}
|
|
2877
|
+
/** Bytes for an install: a `File` / `Blob`, or already an array. */
|
|
2878
|
+
export type GameDataBytes = Blob | Uint8Array;
|
|
2879
|
+
/** What a data set is installed from. */
|
|
2880
|
+
export interface GameDataFiles {
|
|
2881
|
+
/**
|
|
2882
|
+
* The archives, `StarDat.mpq` and `BrooDat.mpq` among them — a mod replaces files, it
|
|
2883
|
+
* does not bring the rest. The game's own are read first, then the others in the order
|
|
2884
|
+
* given, later ones winning as in the game.
|
|
2885
|
+
*/
|
|
2886
|
+
archives: readonly {
|
|
2887
|
+
name: string;
|
|
2888
|
+
data: GameDataBytes;
|
|
2889
|
+
}[];
|
|
2890
|
+
/** Loose files by member path (`arr/units.dat`, `unit/terran/marine.grp`), read before any archive. */
|
|
2891
|
+
files?: readonly {
|
|
2892
|
+
path: string;
|
|
2893
|
+
data: GameDataBytes;
|
|
2894
|
+
}[];
|
|
2895
|
+
}
|
|
2896
|
+
/**
|
|
2897
|
+
* The game data as a whole: which set of files the editor draws from, and installing,
|
|
2898
|
+
* switching and removing sets — the plugin side of Help ▸ Game Data…. What is *in* the
|
|
2899
|
+
* files is `data` (the tables), `tileset` (the graphics), `graphics` (the pictures) and
|
|
2900
|
+
* `names` (the labels, which follow the loaded set: a unit, weapon, upgrade or
|
|
2901
|
+
* technology a mod renamed shows its new name, and the rest keep StarEdit's).
|
|
2902
|
+
*
|
|
2903
|
+
* A data set is a name over files in the game's own formats; a mod that extends the
|
|
2904
|
+
* tables past the game's sizes is not covered. Installing needs the game's two archives
|
|
2905
|
+
* every time, since a mod's files are laid over them the way its loader lays them.
|
|
2906
|
+
*
|
|
2907
|
+
* @example
|
|
2908
|
+
* // A mod plugin: install its files once, then draw with them.
|
|
2909
|
+
* const sets = await api.gameData.profiles();
|
|
2910
|
+
* if (!sets.some((p) => p.id === "my-mod")) {
|
|
2911
|
+
* const files = await api.ui.pickFiles({ multiple: true });
|
|
2912
|
+
* if (files) await api.gameData.install({ id: "my-mod", name: "My Mod" }, { archives: files.map((f) => ({ name: f.name, data: f })) });
|
|
2913
|
+
* }
|
|
2914
|
+
* await api.gameData.select("my-mod");
|
|
2915
|
+
*/
|
|
2916
|
+
export interface GameDataApi {
|
|
2917
|
+
/** The session's source, or null while it is still being resolved at startup. */
|
|
2918
|
+
source(): GameDataSource | null;
|
|
2919
|
+
/** The data set in use — the game's own until another is selected. */
|
|
2920
|
+
profile(): GameDataProfile;
|
|
2921
|
+
/** Every data set with a copy here, the game's own first. */
|
|
2922
|
+
profiles(): Promise<GameDataProfile[]>;
|
|
2923
|
+
/**
|
|
2924
|
+
* Extract a data set from its files, store it under `profile.id` and switch to it. The
|
|
2925
|
+
* archives must include the game's own two; the promise rejects with the reason when
|
|
2926
|
+
* they do not or the extraction fails. `progress` is 0–1 with a label, as the dialog's bar.
|
|
2927
|
+
*/
|
|
2928
|
+
install(profile: GameDataProfile, files: GameDataFiles, progress?: (fraction: number, label: string) => void): Promise<GameDataSource>;
|
|
2929
|
+
/**
|
|
2930
|
+
* Switch to a data set. Everything decoded from the previous one is dropped and the
|
|
2931
|
+
* viewport redraws from the new files; a set with no copy here falls back to the game's
|
|
2932
|
+
* own. Resolves with the source in use afterwards.
|
|
2933
|
+
*/
|
|
2934
|
+
select(id: string): Promise<GameDataSource>;
|
|
2935
|
+
/** Remove a data set's copy (never the game's bundled files). True when there was one. */
|
|
2936
|
+
remove(id: string): Promise<boolean>;
|
|
2937
|
+
}
|
|
2847
2938
|
/**
|
|
2848
2939
|
* The constants a plugin needs to *write* a record rather than read one: the bit masks in
|
|
2849
2940
|
* a UNIT / THG2 / MRGN record, the condition, action and argument numbers of a TRIG /
|
|
@@ -3814,7 +3905,9 @@ export type PluginEvent =
|
|
|
3814
3905
|
/** The document's file changed: its name or handle after a Save, the save options, the archive extras, the recent list. */
|
|
3815
3906
|
| "file"
|
|
3816
3907
|
/** A plugin registered or removed a command — how a plugin learns that one it calls by id has arrived. */
|
|
3817
|
-
| "commands"
|
|
3908
|
+
| "commands"
|
|
3909
|
+
/** The game data source changed: installed, switched to another data set, or a copy removed. `gameData.source()` says what it is now. */
|
|
3910
|
+
| "gameData";
|
|
3818
3911
|
/** Why the document changed. */
|
|
3819
3912
|
export type DocumentChangeReason =
|
|
3820
3913
|
/** File ▸ Open, drag-and-drop, `document.open`: a file the user chose. */
|