mwg API
    Preparing search index...

    Class Settings

    Persisted player settings: music and sound-effect levels, master mute, zoom preference, and key bindings, read back on the next launch.

    The values live in core so they stay renderer-free; the wiring stays with the game, which assigns them onto its own Music/Sound/Camera (see the example). Bindings are the exception: they are applied to Input on load and on every bindings mutation, since persisted keys that a game must remember to apply would silently do nothing.

    Corrupt storage reads as defaults rather than throwing: a settings screen should show the defaults, not a crash.

    import { Settings, effectiveMusicVolume, effectiveSfxVolume } from '@datamoc/mwg/core';

    const settings = new Settings({ namespace: 'my-game' });
    settings.update({ musicVolume: 0.7, zoom: 2 });
    settings.setCustom('hints', true);

    const music = { volume: 1 };
    const camera = { zoom: 1 };
    music.volume = effectiveMusicVolume(settings.current);
    camera.zoom = settings.current.zoom;
    console.log(effectiveSfxVolume(settings.current), settings.getCustom('hints', false));
    Index
    • re-applies the stored bindings to Input, for a game that installed its own after this was built

      Returns void

    • back to full volume, unmuted, zoom 1 and the default bindings, persisted

      Returns void

    • Parameters

      • bindings: Readonly<Record<Action, readonly string[]>>

      Returns void

    • Parameters

      • patch: {
            bindings?: Readonly<Record<string, readonly string[]>>;
            custom?: Readonly<Record<string, CustomSettingValue>>;
            musicVolume?: number;
            muted?: boolean;
            sfxVolume?: number;
            zoom?: number;
        }

      Returns void