Registers game settings and creates a backing Svelte store for each setting. The Svelte store will update the Foundry game settings and vice versa when changes occur to the Foundry game settings the updated data is set to the store.

Note: It is possible to add multiple onChange callbacks on registration.

TODO: A possible future extension is to offer type checking against the setting type by creating a customized writable store that has an overloaded set method to provide type checking.

Hierarchy

Constructors

  • Creates the TJSGameSettings instance.

    Parameters

    • namespace: string

      The namespace for all settings.

    Returns TJSGameSettings

Accessors

  • get namespace(): string
  • Returns string

    Returns namespace set in constructor.

Methods

  • Type Parameters

    • T

      Returns an iterable for the game setting keys and stores.

    Parameters

    • Optionalregex: RegExp

      Optional regular expression to filter by game setting keys.

    Returns IterableIterator<[string, Writable<T>], any, any>

    Iterable iterator of keys and stores.

  • Returns a readable Game Settings store for the associated key.

    Parameters

    • key: string

      Game setting key.

    Returns Readable<any>

    The associated store for the given game setting key.

  • Returns a writable Game Settings store for the associated key.

    Parameters

    • key: string

      Game setting key.

    Returns Writable<any>

    The associated store for the given game setting key.

  • Returns a writable Game Settings store for the associated key.

    Parameters

    • key: string

      Game setting key.

    Returns Writable<any>

    The associated store for the given game setting key.

  • Returns an iterable for the game setting keys from existing stores.

    Parameters

    • Optionalregex: RegExp

      Optional regular expression to filter by game setting keys.

    Returns IterableIterator<string, any, any>

    Iterable iterator of game setting keys.

  • Registers a setting with TJSGameSettings and Foundry core.

    Note: The specific store subscription handler assigned to the passed in store or store created for the setting internally is returned from this function. In some cases when setting up custom stores particularly of object types with several child property stores (propertyStore) it is necessary to only update the setting store and not all subscribers to the custom store as the propertyStore instances are also subscribers to the custom store.

    This allows the custom store in the set implementation to mainly only trigger the TJSGameSettings subscriber handler on updates and not all the connected propertyStore instances.

    Parameters

    • setting: GameSetting

      A GameSetting instance to set to Foundry game settings.

    • OptionalcoreConfig: boolean

      When false this overrides the setting.options.config parameter when registering the setting with Foundry. This allows the settings to be displayed in the app itself, but removed from the standard Foundry configuration location.

    Returns Function

    The specific store subscription handler assigned to the passed in store.

  • Registers multiple settings.

    Please refer to the note in TJSGameSettings.register about the returned object of store subscriber handler functions.

    Parameters

    • settings: Iterable<GameSetting, any, any>

      An iterable list of game setting configurations to register.

    • coreConfig: boolean

      When false this overrides the setting.options.config parameter when registering the setting with Foundry. This allows the settings to be displayed in the app itself, but removed from the standard Foundry configuration location.

    Returns {
        [key: string]: Function;
    }

    An object containing all TJSGameSetting store subscriber handlers for each setting key added.

  • Type Parameters

    • T

      Returns an iterable for the game setting stores.

    Parameters

    • Optionalregex: RegExp

      Optional regular expression to filter by game setting keys.

    Returns IterableIterator<Writable<T>, any, any>

    Iterable iterator of stores.