@scm-js/plugin-api 1.21.0 → 1.22.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 +41 -0
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1051,6 +1051,12 @@ export interface Toast {
1051
1051
  * default colour, so a string written before the remaster can render differently now —
1052
1052
  * `bleedingLines` finds exactly that case, and the Repair plugin turns it into a finding
1053
1053
  * offering to write the reset the old game supplied for free.
1054
+ *
1055
+ * `runsOf` is a modern renderer in the other way too: it takes one alignment for a whole
1056
+ * line, where 1.16.1 obeyed every alignment code on it and stacked the pieces between
1057
+ * them in one place. `stackedLines` finds the lines that were drawn that way and
1058
+ * `flattenStacks` lays them out left to right — the one rewrite here that loses something
1059
+ * (where each piece sat), which is why the Repair plugin offers it unticked.
1054
1060
  */
1055
1061
  /** What a control byte does. Colours carry an `rgb`; the rest are layout or visibility. */
1056
1062
  export type CodeEffect = "color" | "mimic" | "invisible" | "align" | "clip" | "nothing" | "space";
@@ -1095,6 +1101,23 @@ export interface BleedingLine {
1095
1101
  /** The code Remastered carries onto it — the whole entry, so a caller can name it. */
1096
1102
  carried: TextCode;
1097
1103
  }
1104
+ /**
1105
+ * A line the game draws in more than one place at once. 0x12 and 0x13 move the text that
1106
+ * follows them to the right or the centre of the line they are on, and 1.16.1 honoured
1107
+ * every one of them: `Name<12>by Author` drew `Name` at the left and `by Author` at the
1108
+ * right of the same line. Lobby names, unit names and briefings were built out of that —
1109
+ * the "stacked" text a classic map shows and a renderer that takes one alignment for the
1110
+ * whole line does not.
1111
+ *
1112
+ * `runsOf` is one of those renderers: `TextLine.align` holds a single alignment, the last
1113
+ * one the line set, so every piece before it lands somewhere its author did not choose.
1114
+ */
1115
+ export interface StackedLine {
1116
+ /** 0-based index of the line within the string. */
1117
+ line: number;
1118
+ /** How many pieces of text the line draws, each at its own alignment. */
1119
+ pieces: number;
1120
+ }
1098
1121
  /** Every built-in dialog, by the id `openDialogAtom` takes; `DialogHost` maps each to its component. */
1099
1122
  export type DialogId = "newMap" | "openMap" | "saveAs" | "exportImage" | "mapProperties" | "resizeMap" | "mapRevision" | "playerSettings" | "forceSettings" | "playerColors" | "unitSettings" | "upgradeSettings" | "techSettings" | "stringEditor" | "soundEditor" | "switches" | "locationList" | "unitProperties" | "locationProperties" | "spriteProperties" | "triggerEditor" | "missionBriefing" | "cuwpEditor" | "replaceTerrain" | "autoStarts" | "testMap" | "symmetry" | "gridSettings" | "preferences" | "shortcuts" | "validateMap" | "statistics" | "importTriggers" | "exportTriggers" | "importStrings" | "exportStrings" | "find" | "about" | "confirmClose" | "plugins" | "confirmPlugin" | "pluginDialog" | "gameData" | "update";
1100
1123
  export interface MapImageOptions {
@@ -3684,6 +3707,11 @@ export interface NamesApi {
3684
3707
  * remaster can draw in colours its author never chose — `bleedingLines` finds exactly
3685
3708
  * those lines and `fixBleeding` writes the reset the old game supplied. Pass
3686
3709
  * `resetPerLine` to `runs` to see the old rendering.
3710
+ *
3711
+ * The other thing the old game did and a modern renderer does not is honour every
3712
+ * alignment code on a line, stacking the pieces between them in one place: `stackedLines`
3713
+ * finds those lines and `flattenStacks` lays them out left to right. `runs` is one of the
3714
+ * renderers that cannot show them — `TextLine.align` is one alignment for the whole line.
3687
3715
  */
3688
3716
  export interface TextApi {
3689
3717
  /** Every byte the game gives a meaning, in order; `rgb` is set for the colours only. */
@@ -3710,6 +3738,19 @@ export interface TextApi {
3710
3738
  * games draw it alike. Idempotent, and never changes what the string says.
3711
3739
  */
3712
3740
  fixBleeding(text: string): string;
3741
+ /**
3742
+ * The lines of `text` that 1.16.1 drew at more than one alignment at once — the
3743
+ * "stacked" lobby and unit names a classic map is built with. A line whose only
3744
+ * alignment code sits at its head is not one: that code places the line.
3745
+ */
3746
+ stackedLines(text: string): StackedLine[];
3747
+ /**
3748
+ * `text` with every stacked line laid out left to right: the alignment codes that split
3749
+ * it dropped and its pieces joined in writing order, a space between two that would
3750
+ * otherwise run together. Colours and every other byte survive, so nothing the string
3751
+ * says is lost — only where each piece sat. Idempotent.
3752
+ */
3753
+ flattenStacks(text: string): string;
3713
3754
  }
3714
3755
  export type DialogSize = "sm" | "md" | "lg" | "xl" | "full";
3715
3756
  export interface DialogButton {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/plugin-api",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "description": "Type declarations for the scmJS plugin API",
5
5
  "license": "MIT",
6
6
  "types": "index.d.ts",