EditorHistory beta
Class of @v12-engine/editor
export declare class EditorHistoryThe 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
constructor(editor: () => HistoryEditor, host: HistoryHost);Constructs a new instance of the EditorHistory class
begin
begin(name: string): void;Begins one step of everything done until commit or cancel
cancel
cancel(): void;Drops the step begun, and takes back what it did
canRedo
get canRedo(): boolean;Whether there is a step to do again
canUndo
get canUndo(): boolean;Whether there is a step to take back
changing
get changing(): boolean;Whether a step is being made: begun and not yet committed or cancelled
commit
commit(name?: string): Operation | null;Ends the step begun: one operation, or null when nothing changed
names
get names(): {
undo: string[];
redo: string[];
};The names of the steps to take back and to do again, the nearest first
redo
redo(steps?: number): void;Does again the last steps steps taken back
step
step(step: OwnStep): void;Makes a step of the game's own, done now, and tells the editor the map changed
undo
undo(steps?: number): void;Takes back the last steps steps
watch
watch(listener: (operation: Operation, how: OperationHow) => void): () => void;Calls the listener for each step done, undone, redone or cancelled; gives back what stops it