Plants vs. Zombies: Replanted - v1.0.3
    Preparing search index...

    Interface IExtensionApi

    interface for convenience functions made available to extensions

    IExtensionApi

    interface IExtensionApi {
        addMetaServer: (id: string, server: IServer) => void;
        awaitUI: () => Bluebird<void>;
        clearStylesheet: () => void;
        closeDialog?: (id: string, actionKey?: string, input?: any) => void;
        deregisterProtocol: (protocol: string) => void;
        dismissAllNotifications?: () => void;
        dismissNotification?: (id: string) => void;
        emitAndAwait: <T = any>(eventName: string, ...args: any[]) => Bluebird<T>;
        events: EventEmitter;
        ext: IExtensionApiExtension;
        extension?: IRegisteredExtension;
        genMd5Hash: (
            data: string | Buffer<ArrayBufferLike>,
            progressFunc?: (progress: number, total: number) => void,
        ) => Bluebird<IHashResult>;
        getI18n: () => i18n;
        getLoadedExtensions: () => IRegisteredExtension[];
        getPath: (name: string) => string;
        getState: <T extends IState = IState>() => T;
        highlightControl: (
            selector: string,
            durationMS: number,
            text?: string,
            altStyle?: boolean,
        ) => void;
        isOutdated: () => boolean;
        laterT: any;
        locale: () => string;
        lookupModMeta: (
            details: ILookupDetails,
            ignoreCache?: boolean,
        ) => Bluebird<ILookupResult[]>;
        lookupModReference: (
            ref: IModReference,
            options?: ILookupOptions,
        ) => Bluebird<IModLookupResult[]>;
        NAMESPACE: string;
        onAsync: (
            eventName: string,
            listener: (...args: any[]) => PromiseLike<any>,
        ) => void;
        onStateChange?: <T = any>(
            path: string[],
            callback: StateChangeCallback<T>,
        ) => void;
        openArchive: (
            archivePath: string,
            options?: IArchiveOptions,
            extension?: string,
        ) => Bluebird<Archive>;
        registerProtocol: IRegisterProtocol;
        registerRepositoryLookup: IRegisterRepositoryLookup;
        runExecutable: (
            executable: string,
            args: string[],
            options: IRunOptions,
        ) => Bluebird<void>;
        saveFile: (options: ISaveOptions) => Bluebird<string>;
        saveModMeta: (modInfo: IModInfo) => Bluebird<void>;
        selectDir: (options: IOpenOptions) => Bluebird<string>;
        selectExecutable: (options: IOpenOptions) => Bluebird<string>;
        selectFile: (options: IOpenOptions) => Bluebird<string>;
        sendNotification?: (notification: INotification) => string;
        setStylesheet: (key: string, filePath: string) => void;
        showDialog?: (
            type: DialogType,
            title: string,
            content: IDialogContent,
            actions: DialogActions,
            id?: string,
        ) => Bluebird<IDialogResult>;
        showErrorNotification?: (
            message: string,
            detail: any,
            options?: IErrorOptions,
        ) => void;
        store?: ThunkStore<any>;
        suppressNotification?: (id: string, suppress?: boolean) => void;
        translate: any;
        withPrePost: <T>(
            eventName: string,
            callback: (...args: any[]) => Bluebird<T>,
        ) => (...args: any[]) => Bluebird<T>;
    }
    Index

    Properties

    addMetaServer: (id: string, server: IServer) => void

    add a meta server Please note that setting a server with the same id again will replace the existing one with that id and setting it to undefined removes it

    awaitUI: () => Bluebird<void>

    returns a promise that resolves once the ui has been displayed. This is useful if you have a callback that may be triggered before the ui is displayed but may require the UI to be processed. Specifically events can only be sent once this event has been triggered

    clearStylesheet: () => void

    clear the stylesheet cache to ensure it gets rebuilt even if the list of files hasn't changed

    closeDialog?: (id: string, actionKey?: string, input?: any) => void

    close a dialog

    deregisterProtocol: (protocol: string) => void

    deregister an uri protocol currently being handled by us

    IExtensionApi

    dismissAllNotifications?: () => void
    dismissNotification?: (id: string) => void

    hides a notification by its id

    IExtensionApi

    emitAndAwait: <T = any>(eventName: string, ...args: any[]) => Bluebird<T>

    emit an event and allow every receiver to return a Promise. This call will only return after all these Promises are resolved. If the event handlers return a value, this returns an array of results

    events: EventEmitter

    event emitter

    IExtensionApi

    functions made available from extension to extension. Callers have to make sure they handle gracefully the case where a function doesn't exist

    name of the extension to use this api with

    genMd5Hash: (
        data: string | Buffer<ArrayBufferLike>,
        progressFunc?: (progress: number, total: number) => void,
    ) => Bluebird<IHashResult>

    generate an md5 hash for the specified file

    Type Declaration

      • (
            data: string | Buffer<ArrayBufferLike>,
            progressFunc?: (progress: number, total: number) => void,
        ): Bluebird<IHashResult>
      • Parameters

        • data: string | Buffer<ArrayBufferLike>

          Either a string containing the file path or a Buffer containing the data to hash

        • OptionalprogressFunc: (progress: number, total: number) => void

          optional function to report progress

        Returns Bluebird<IHashResult>

        a promise resolving to the md5 hash result

    getI18n: () => i18n

    get direct access to the i18next object managing localisation. This is only needed to influence how localisation works in general, to just translate a text, use "translate"

    getLoadedExtensions: () => IRegisteredExtension[]

    get a list of extensions currently loaded into Vortex

    getPath: (name: string) => string

    retrieve path for a known directory location.

    Note: This uses electrons ids for known folder locations. Please write your extensions to always use the appropriate folder location returned from this function, especially 'userData' should be used for all settings/state/temporary data if you don't want to/can't use the store. If Vortex introduces a way for users to customise storage locations then getPath will return the customised path so you don't have to adjust your extension.

    IExtensionApi

    getState: <T extends IState = IState>() => T

    wrapper for api.store.getState() with the benefit that it automatically assigns a type

    highlightControl: (
        selector: string,
        durationMS: number,
        text?: string,
        altStyle?: boolean,
    ) => void

    highlight a control for a short time to direct the users attention to it. The control (or controls) is identified by a css selector. A text can be added, but no promise that it actually looks good in practice

    Usually the css style used to draw the outline contains a bit of hackery to offset the padding and border width it adds so that the contents doesn't get moved around. If altStyle is set we use absolute positioning to get the same effect. This requires us to make the target item "position: relative" though which is more intrusive and can break the styling of the contents more severely.

    isOutdated: () => boolean

    returns true if the running version of Vortex is considered outdated. This is mostly used to determine if feedback should be sent to Nexus Mods.

    laterT: any

    prepare a string to be translated further down the line.

    locale: () => string

    active locale

    lookupModMeta: (
        details: ILookupDetails,
        ignoreCache?: boolean,
    ) => Bluebird<ILookupResult[]>

    find meta information about a mod this will calculate a hash and the file size of the specified file for the lookup unless those details are already provided. Please note that it's still possible for the file to get multiple matches, i.e. if it has been re-uploaded, potentially for a different game.

    IExtensionApi

    lookupModReference: (
        ref: IModReference,
        options?: ILookupOptions,
    ) => Bluebird<IModLookupResult[]>

    find meta information about a mod

    IExtensionApi

    NAMESPACE: string
    onAsync: (
        eventName: string,
        listener: (...args: any[]) => PromiseLike<any>,
    ) => void

    handle an event emitted with emitAndAwait. The listener can return a promise and the emitter will only return after all promises from handlers are returned. Note that listeners should report all errors themselves, it is considered a bug if the listener returns a rejected promise. If errors do need to be reported they have to be part of the resolved valued

    onStateChange?: <T = any>(
        path: string[],
        callback: StateChangeCallback<T>,
    ) => void

    register a callback for changes to the state

    Type Declaration

      • <T = any>(path: string[], callback: StateChangeCallback<T>): void
      • Type Parameters

        • T = any

        Parameters

        • path: string[]

          path in the state-tree to watch for changes, i.e. ['settings', 'interface', 'language'] would call the callback for all changes to the interface language

        • callback: StateChangeCallback<T>

        Returns void

    IExtensionApi

    openArchive: (
        archivePath: string,
        options?: IArchiveOptions,
        extension?: string,
    ) => Bluebird<Archive>

    opens an archive

    registerProtocol: IRegisterProtocol

    registers an uri protocol to be handled by this application. If the "def"ault parameter is set to true, this application will also be inserted as the system wide default handler for the protocol. Use with caution, as this will overwrite the previous value, which can't be undone automatically

    IExtensionContext

    registerRepositoryLookup: IRegisterRepositoryLookup

    registers a lookup mechanism that can be used to look up information about a mod based on ids. This will either work as a fallback or as a replacement to the md5 based lookup for applicable mods. The "repositoryId" should be the same as the "source" used. It's possible to return multiple results if the input data doesn't definitively identify a single item but this might be a bit of a mess to figure out later.

    runExecutable: (
        executable: string,
        args: string[],
        options: IRunOptions,
    ) => Bluebird<void>

    run an executable. This is comparable to node.js child_process.spawn but it allows us to add extensions, like support interpreters and hooks. It will also automatically ask the user to authorize elevation if the executable requires it The returned promise is resolved when the started process has run to completion. IRunOptions.onSpawned can be used to react to when the process has been started.

    saveFile: (options: ISaveOptions) => Bluebird<string>

    show a system dialog to save a single file

    IExtensionApi

    saveModMeta: (modInfo: IModInfo) => Bluebird<void>

    save meta information about a mod

    IExtensionApi

    selectDir: (options: IOpenOptions) => Bluebird<string>

    show a system dialog to open a single directory

    IExtensionApi

    selectExecutable: (options: IOpenOptions) => Bluebird<string>

    show a system dialog to select an executable file

    IExtensionApi

    selectFile: (options: IOpenOptions) => Bluebird<string>

    show a system dialog to open a single file

    IExtensionApi

    sendNotification?: (notification: INotification) => string

    show a notification to the user. This is not available in the call to registerReducer

    Type Declaration

    IExtensionApi

    setStylesheet: (key: string, filePath: string) => void

    insert or replace a sass-stylesheet. It gets integrated into the existing sheets based on the key: By default, the sheets "variables", "details" and "style" are intended to customize the look of the application.

    • "variables" is a set of variables representing colors, sizes and margins that will be used throughout the application.
    • "details" applies these variables to different generic controls (like tabs, lists, ...)
    • "style" is where you should customize individual controls with css rules

    If your extension sets a sheet that didn't exist before then that sheet will be inserted before the "style" sheet but after everything else. This allows themes to affect extension styles.

    Type Declaration

      • (key: string, filePath: string): void
      • Parameters

        • key: string

          identify the key to set. If this is an existing sheet, that sheet will be replaced

        • filePath: string

          path of the corresponding stylesheet file

        Returns void

    Important: As usual with css, rules you add affect the entire application, without severely restricting themes and extensions we can not automatically restrict your stylesheets to the controls added by your extension. This means it's your responsibility to make sure your stylesheet doesn't modify foreign controls.

    IExtensionContext

    showDialog?: (
        type: DialogType,
        title: string,
        content: IDialogContent,
        actions: DialogActions,
        id?: string,
    ) => Bluebird<IDialogResult>

    show a dialog

    showErrorNotification?: (
        message: string,
        detail: any,
        options?: IErrorOptions,
    ) => void

    show an error message to the user. This is a convenience wrapper for sendNotification. This is not available in the call to registerReducer

    IExtensionApi

    store?: ThunkStore<any>

    the redux store containing all application state & data

    Please note: this store object will remain valid for the whole application runtime so you can store it, bind it to functions and so on. The state object (store.getState()) is immutable and will be a different object whenever the state is changed. Thus you should not store/bind the state directly unless you actually want a "snapshot" of the state.

    IExtensionApi

    suppressNotification?: (id: string, suppress?: boolean) => void

    hides a notification and don't show it again if this is called with the second parameter set to false, it re-enables the notification instead

    translate: any

    translation function

    withPrePost: <T>(
        eventName: string,
        callback: (...args: any[]) => Bluebird<T>,
    ) => (...args: any[]) => Bluebird<T>

    wraps a function such that it will emitAndAwait will-eventName and did-eventName events before and after invoking the actual callback. both these events receive the arguments passed to the callback, the did-event also receives the result of the callback if any (the result is the first argument because the number of arguments may be variable)