Skip to content

EditorMapFiles beta ​

Class of @v12-engine/editor

ts
export declare class EditorMapFiles

Where the map is kept: saving it to the project or the browser, opening another, importing and exporting, the files it brings, and the drafts kept while it is edited.

A part of the editor, as it gives it (editor.mapFiles)

Members ​

constructor ​

ts
constructor(host: MapFilesHost);

Constructs a new instance of the EditorMapFiles class

addToPack ​

ts
addToPack(path: string, data: Uint8Array): void;

Puts a file in the files the map brings, at a path where its kind goes (sounds/falls.mp3), or a test point (tests/2m05s.save.json)

changed ​

ts
changed(settled?: boolean): void;

After the map changed (editor.changed()): a step made, undone or redone moves the history, which says so by itself; a change that moved nothing is one no step records, and stays a change until the map is saved, unless it was told (settled) to be the end of an operation, which left no step because it changed nothing

changedUnrecorded ​

ts
changedUnrecorded(): void;

Something changed that no step of the history records (the prefab stage's chances): a change until the map is saved

checkFile ​

ts
checkFile(): Promise<void>;

Whether the map's file changed on disk since it was opened or saved here (asked as the window gets the focus): loaded as it is, where nothing here is unsaved; said, where something is, for the save to ask

dirty ​

ts
get dirty(): boolean;

Whether the map has changes that are not saved: the history is not where it stood at the last save (a step made since, or one undone past it), or something changed that no step records. Undone back to the save, it has none

dispose ​

ts
dispose(): void;

Stops the autosave timer that keeps drafts of the map

draftKey ​

ts
get draftKey(): string;

Which map this is, for its drafts (Draft.key): its project file, its place in the browser, or a map of neither

exportFile ​

ts
exportFile(): void;

Hands the map to the browser to download: as a map file, or a .vgmap with the files it brings when it has any

importFile ​

ts
importFile(file: File): Promise<void>;

Opens a map from a file: a map file, or a .vgmap with the files the map brings

keepDraft ​

ts
keepDraft(): void;

Keeps a draft of the map as it is, when it has changes: offered again if the page goes before they are saved

keepDrafts ​

ts
keepDrafts(): void;

Keeps drafts every so often from now on, as the editor's settings say (EditorPrefs.draftEvery: none for 0): asked again as they change

keepFile ​

ts
keepFile(path: string, data: Uint8Array): Promise<boolean>;

Keeps a working file of the map's (a replay of Play here) among its files and writes them where they are kept (the project's <map>.files/, the browser's pack of the map) at once, without the map counting as changed and without saving it: a map that is kept nowhere yet has it in its pack until it is saved. Whether it was written

loadPackOf ​

ts
loadPackOf(id: string): void;

The files the browser keeps with a map, once they are read, if it is still the map open

mark ​

ts
mark(): FilesMark;

Where the map stands as for saving, to put back with restore when the map comes back after another was open

open ​

ts
open(map: GameMap, id: string | undefined, file?: string | undefined, pack?: MapPack, history?: MapHistory): boolean;

Opens a map in the place of the one open. A history given is the map's own from before (see editPrefab), its steps kept; otherwise the history starts again

opened ​

ts
opened(changed: boolean): void;

Another map was opened in this one's place, with a history of its own: changed or not, as said (back from a prefab's stage, the map has the changes it had before)

openFile ​

ts
openFile(name: string, still?: () => boolean): Promise<boolean>;

Opens a map file of the project by name, as File › Open does: read with its version, so Save writes it back. False when it was not opened (still said no once it was read, the map is not the game's); rejects when it cannot be read

ready ​

ts
ready(): Promise<boolean>;

Before a game is started on the map: what is in the project is brought up to date, and the browser has what the game will play

refusal ​

ts
refusal(map: GameMap): string | undefined;

Why a map cannot be opened here, or nothing when it can: one made for another game is that game's to edit. A map that does not say (they did not, once) becomes this game's

removeFromPack ​

ts
removeFromPack(path: string): void;

Takes a file out of the files the map brings

restore ​

ts
restore(mark: FilesMark): void;

Puts back what mark kept, for the map's own history taken up again: undone back to the save, it has no changes

save ​

ts
save(options?: {
        force?: boolean;
    }): Promise<boolean>;

Saves the map to the project file when there is a project, else in the browser; gives back whether it was saved

saved ​

ts
saved(): void;

The map is as saved: no changes from here, until a step or another change

start ​

ts
start(): void;

As the editor opens: a draft from before is offered again, and drafts are kept from now on

strangersNote ​

ts
strangersNote(): string;

What to say about a map that holds types the game does not have, or nothing

takeDraft ​

ts
takeDraft(draft: Draft, take: boolean): void;

Takes up a draft from before (one of drafts) in the place of the map open, or throws it away. Either way it is no longer kept, and the others are still offered