api.text
TextApi
StarCraft's <XX> text control codes: what they mean, and what a string looks like drawn.
Bytes 0x01–0x1F in a string are colour and layout codes. This is the editor's own table of what each one does — the same one the String Editor's buttons and preview are drawn from — plus the reading of a string that turns those bytes into what the game shows.
A plugin that displays or rewrites map text should use this rather than carrying a copy: the numbering is easy to get wrong (the editor's own table was, from 0x12 up, until it was checked against the classic player palette).
Remastered
runs models Remastered's rule, where a colour set on one line carries onto the next.
StarCraft 1.16.1 reset the colour at every line break, so a string written before the
remaster can draw in colours its author never chose — bleedingLines finds exactly
those lines and fixBleeding writes the reset the old game supplied. Pass
resetPerLine to runs to see the old rendering.
Members
codes
codes(): TextCode[];
Every byte the game gives a meaning, in order; rgb is set for the colours only.
insertable
insertable(): TextCode[];
The codes worth offering as buttons: no tab, newlines or the do-nothing byte.
defaultColor
defaultColor(): string;
#rrggbb — what the game starts a string in, and what 1.16.1 reset to at a line break.
runs
runs(text: string, options?: RunOptions): TextLine[];
The string split into lines of coloured runs, the way the game draws it.
plain
plain(text: string): string;
The text with every control byte removed — what the string actually says.
bleedingLines
bleedingLines(text: string): BleedingLine[];
The lines of text that Remastered draws in a colour 1.16.1 did not: a line that sets
no colour of its own, after one that left a colour set. Empty for a single-line string.
fixBleeding
fixBleeding(text: string): string;
text with the default colour written at the head of every bleeding line, so both
games draw it alike. Idempotent, and never changes what the string says.
Types
Declarations only this group names.
CodeEffecttype
type CodeEffect = "color" | "mimic" | "invisible" | "align" | "clip" | "nothing" | "space";
What a control byte does. Colours carry an rgb; the rest are layout or visibility.
TextCodeinterface
interface TextCode
byte: number | |
|---|---|
code: string |
|
label: string | |
effect: CodeEffect | |
rgb: string | null |
|
player?: number | Which player's colour this is, for the ones that are a player colour (1-based). |
TextRuninterface
interface TextRun
One stretch of text in a single colour.
text: string | |
|---|---|
color: string |
|
invisible: boolean | After |
clipped: boolean | After |
RunOptionsinterface
interface RunOptions
resetPerLine?: boolean | Reset to |
|---|---|
initialColor?: string | What |
BleedingLineinterface
interface BleedingLine
line: number | 0-based index of the line that inherits a colour it did not set. |
|---|---|
carried: TextCode | The code Remastered carries onto it — the whole entry, so a caller can name it. |