Skip to content

EditorGameFiles beta ​

Class of @v12-engine/editor

ts
export declare class EditorGameFiles

The game's files as the editor has them (editor.files): a store (EditorFiles), and what was written to it that is not saved yet. read sees a change first; Ctrl+S saves the changes with the map; { now: true } writes at once

Members ​

constructor ​

ts
constructor(
    store: EditorFiles, changed: () => void);

Constructs a new instance of the EditorGameFiles class

discard ​

ts
discard(path?: string): void;

Forgets what was written to a file (or to every file) and not saved: it is the store's again

dispose ​

ts
dispose(): void;

Stops watching everything

list ​

ts
list(dir?: string): Promise<string[]>;

The files in a folder and down: the store's, and those written and not saved yet, but those taken away

onChange ​

ts
onChange(listener: (path: string, text: string | undefined) => void): () => void;

Told of every file that changes as it is told to those watching it: written or taken away here, or one watched changed elsewhere. What keeps a list of a folder (the cinematics) hears of a file made. Gives back what stops it

read ​

ts
read(path: string): Promise<string | undefined>;

What a file holds now, as text: its change not saved yet, or the store's. None for one that is not there

readJson ​

ts
readJson<T = unknown>(path: string): Promise<T | undefined>;

A file read as JSON: none for one that is not there

removable ​

ts
get removable(): boolean;

Whether a file can be taken away where the game's files are kept (EditorFiles.remove)

remove ​

ts
remove(path: string, options?: {
        now?: boolean;
        force?: boolean;
    }): Promise<void>;

Takes a file away: a change until the map is saved (Ctrl+S), as a write is, or at once with now. Throws where the store cannot take one away (EditorFiles.remove)

save ​

ts
save(options?: {
        force?: boolean;
    }): Promise<{
        saved: string[];
        failed: {
            path: string;
            error: Error;
        }[];
    }>;

Saves what was written: what the map's Ctrl+S does too. What could not be is said, and kept as a change

store ​

ts
readonly store: EditorFiles;

Where they are kept: the project's, this browser's, or the game's own

unsaved ​

ts
unsaved(): string[];

The files written and not saved yet

watch ​

ts
watch(path: string, listener: (text: string | undefined) => void): () => void;

Told what a file holds each time it changes: written here, or elsewhere (on disk, another tab). Gives back what stops it

write ​

ts
write(path: string, data: unknown, options?: {
        now?: boolean;
        force?: boolean;
    }): Promise<void>;

Writes a file: words as they are, anything else as JSON (with tabs, a line at the end). A change until the map is saved (Ctrl+S), or at once with now