]> git.lizzy.rs Git - nothing.git/blob - src/game/level/level_editor/undo_history.h
(#824) Integrate UndoHistory with the LevelEditor
[nothing.git] / src / game / level / level_editor / undo_history.h
1 #ifndef UNDO_HISTORY_H_
2 #define UNDO_HISTORY_H_
3
4 #include "layer.h"
5
6 #define CONTEXT_SIZE 32
7
8 typedef struct {
9     char data[CONTEXT_SIZE];
10 } Context;
11
12 typedef void (*RevertAction)(void *layer, Context context);
13
14 typedef struct {
15     void *layer;
16     Context context;
17     RevertAction revert;
18 } Action;
19
20 typedef struct UndoHistory UndoHistory;
21
22 UndoHistory *create_undo_history(void);
23 void destroy_undo_history(UndoHistory *undo_history);
24
25 void undo_history_push(UndoHistory *undo_history, Action action);
26 void undo_history_pop(UndoHistory *undo_history);
27
28 #endif  // UNDO_HISTORY_H_