mwg API
    Preparing search index...

    Class Skins

    Per-widget and per-state skins, looked up by name - the data-driven half of what GUI2 puts in data/gui/*.cfg, and the thing the one global Theme has no room for.

    A lookup walks a fixed chain so a caller never gets undefined: the widget's own state, its idle look, the wildcard widget's state, the wildcard's idle look, then an empty skin. That is what lets a game define a shared * skin once and override only the two widgets it cares about, and what makes a state a widget never defined fall back rather than disappear.

    import { Skins } from '@datamoc/mw_games/two-d/ui';

    const skins = new Skins();
    skins.define('*', 'idle', { background: 0x101018, text: 0xe8e8f0 });
    skins.define('button', 'pressed', { background: 0xffe680, text: 0x101018 });

    console.log(skins.resolve('button', 'pressed').text); // 0x101018, the override
    console.log(skins.resolve('label', 'idle').background); // 0x101018, the wildcard
    Index
    ANY: "*" = '*'

    the wildcard widget every lookup falls back to

    • Builds a registry from plain data - the shape a config file would parse into. An entry with any state key is read as one look per state; anything else is that widget's idle look.

      Parameters

      • data: Readonly<Record<string, SkinData>>

      Returns Skins