Class TextModeThemes
Holds the active TextMode color theme and switches it. Setting a theme pushes its ANSI colors to ANSIColor and publishes a TextModeThemeChangedEvent that views and terminals act on.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public static class TextModeThemes
Remarks
The active theme is stored as a name, and the resolved palette is only kept as a memo.
That matters because ColorAssetRegistry is rebuilt on every domain reload and on
entering play mode: a cached palette object survives the reload but is no longer the one
the registry hands out, so a project that edited the asset would keep seeing the old
colors. The memo is dropped on both events and the name is re-resolved.
Once a theme has been applied, switching is idempotent by name: calling SetTheme(string, bool) with the theme that is already active does nothing and publishes nothing. The very first application is exempt, because until then the active name is only what the configuration resolved to, not something that has been pushed to ANSIColor or announced to any listener.
Because ColorPalette compares by name alone, the idempotency check cannot notice
a palette asset whose colors were edited in place; RefreshActiveTheme(bool) is
the way to pick those up.
Properties
Active
Gets the active theme's resolved colors.
Declaration
public static TextModeColorScheme Active { get; }
Property Value
| Type | Description |
|---|---|
| TextModeColorScheme |
ActivePalette
Gets the active theme's palette, which leads with the sixteen ANSI colors.
Declaration
public static ColorPalette ActivePalette { get; }
Property Value
| Type | Description |
|---|---|
| ColorPalette |
ActiveThemeName
Gets the name of the active theme.
Declaration
public static string ActiveThemeName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Inverted
Gets whether TextMode shows every color inverted. The inversion stays on when the theme changes, so every theme switched to is shown inverted as well.
Declaration
public static bool Inverted { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Inversion happens when the colors are drawn. ActivePalette, Active and the colors stored in every cell stay the theme's own; use DisplayColor(Color) for a theme color that is drawn outside a TextMode view, such as a backdrop behind the grid.
Methods
CycleTheme(bool)
Advances to the next available theme, wrapping at the end.
Declaration
public static string CycleTheme(bool remapExisting = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | remapExisting | Whether the published event should carry a color map. |
Returns
| Type | Description |
|---|---|
| string | The name of the theme that is now active. |
DisplayColor(Color)
Returns a color the way TextMode displays it: inverted while Inverted is set, unchanged otherwise.
Declaration
public static Color DisplayColor(Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | color | A color, such as a theme color. |
Returns
| Type | Description |
|---|---|
| Color | The color as it appears on screen. |
Remarks
Use it for theme colors drawn outside a TextMode view, so they match the grid while the display is inverted.
DisplayColor(Color32)
Returns a color the way TextMode displays it: inverted while Inverted is set, unchanged otherwise.
Declaration
public static Color32 DisplayColor(Color32 color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | color | A color, such as a theme color. |
Returns
| Type | Description |
|---|---|
| Color32 | The color as it appears on screen. |
GetAvailableThemeNames()
Returns every registered palette that can serve as a TextMode theme, by name.
Declaration
public static List<string> GetAvailableThemeNames()
Returns
| Type | Description |
|---|---|
| List<string> | The theme names, sorted so the order does not change between sessions. |
Remarks
Sorting is not cosmetic. Palettes are discovered through Resources.LoadAll,
whose order is not stable, so an unsorted list would make cycling land somewhere
different on the next run.
RefreshActiveTheme(bool)
Re-resolves the active theme by name, even though the name has not changed.
Declaration
public static bool RefreshActiveTheme(bool remapExisting = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | remapExisting | Whether the published event should carry a color map. |
Returns
| Type | Description |
|---|---|
| bool | True when re-resolving produced different colors. |
Remarks
This is what picks up an edit to the active theme's palette asset. ColorPalette
compares by name, so editing an asset in place is invisible to
SetTheme(string, bool)'s early-out.
ResetTheme(bool)
Returns to the classic theme.
Declaration
public static void ResetTheme(bool remapExisting = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | remapExisting | Whether the published event should carry a color map. |
SetInverted(bool)
Turns inverted display on or off. Every color TextMode draws is shown with its complement (each RGB channel becomes 255 minus its value), alpha kept.
Declaration
public static bool SetInverted(bool inverted)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | inverted | True to show every color inverted, false to show the colors as they are. |
Returns
| Type | Description |
|---|---|
| bool | True when the state changed. Setting the state that is already active does nothing. |
Remarks
The inversion is applied by the cell shaders through a global shader value, so it covers everything on screen: theme colors, indexed colors and 24-bit colors alike. Nothing stored is changed, which makes switching back exact. Recoloring the stored colors instead could not tell a 24-bit color apart from a theme color that happens to have the same value, so switching back turned such cells into the wrong color.
A TextModeThemeChangedEvent is published with no color map and Inverted set, for code that draws theme colors outside a TextMode view.
SetTheme(string, bool)
Makes the named theme active.
Declaration
public static bool SetTheme(string themeName, bool remapExisting = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | themeName | Name of the theme to apply. A name that cannot be honored falls back to the classic theme with a warning, so this never leaves the module without a complete color set. |
| bool | remapExisting | When true, the published event carries a color map so views and terminals recolor the content they already hold. When false, the theme applies only to what is written next. |
Returns
| Type | Description |
|---|---|
| bool | True when the theme was applied. That includes the first application of a theme whose name already matched the resolved one. |
Remarks
The first call always applies, even when the name matches what the configuration already resolved to. That is the call the module makes at startup, and it is the one that pushes the palette to ANSIColor and tells every view to adopt it.