Skip to content

EditorHistory beta ​

Class of @v12-engine/editor

ts
export declare class EditorHistory

The editor's history (editor.history): the map's steps and the game's own in one list, undone and redone together. step(own) makes a step of the game's own (OwnStep), done now; begin(name), commit() and cancel() make one step of everything done meanwhile, the map's changes and the game's steps alike (as editor.edit(fn, name) does around fn); undo(n) and redo(n) are the editor's; names is what there is to undo and to do again, the nearest first; watch(listener) is told of each step as it is done, undone, redone or cancelled (what map.changed on the bus is made of). It follows the map's editor as another map is opened

Members ​

constructor ​

ts
constructor(editor: () => HistoryEditor, host: HistoryHost);

Constructs a new instance of the EditorHistory class

begin ​

ts
begin(name: string): void;

Begins one step of everything done until commit or cancel

cancel ​

ts
cancel(): void;

Drops the step begun, and takes back what it did

canRedo ​

ts
get canRedo(): boolean;

Whether there is a step to do again

canUndo ​

ts
get canUndo(): boolean;

Whether there is a step to take back

changing ​

ts
get changing(): boolean;

Whether a step is being made: begun and not yet committed or cancelled

commit ​

ts
commit(name?: string): Operation | null;

Ends the step begun: one operation, or null when nothing changed

names ​

ts
get names(): {
        undo: string[];
        redo: string[];
    };

The names of the steps to take back and to do again, the nearest first

redo ​

ts
redo(steps?: number): void;

Does again the last steps steps taken back

step ​

ts
step(step: OwnStep): void;

Makes a step of the game's own, done now, and tells the editor the map changed

undo ​

ts
undo(steps?: number): void;

Takes back the last steps steps

watch ​

ts
watch(listener: (operation: Operation, how: OperationHow) => void): () => void;

Calls the listener for each step done, undone, redone or cancelled; gives back what stops it