]> git.lizzy.rs Git - nothing.git/blobdiff - src/game/level/level_editor/undo_history.h
(#1050) Replace system clipboard with internal one
[nothing.git] / src / game / level / level_editor / undo_history.h
index 801059e10838df49689f33b3941c2c3999226250..f9623f38f9c7f9bbc06608a49847ec81f94f8f22 100644 (file)
@@ -1,32 +1,21 @@
 #ifndef UNDO_HISTORY_H_
 #define UNDO_HISTORY_H_
 
-#include "layer.h"
+#include "stack.h"
 
-#define CONTEXT_SIZE 256
-
-#define ASSERT_CONTEXT_SIZE(context)               \
-    trace_assert(sizeof(context) <= CONTEXT_SIZE)
-
-typedef enum {
-    UNDO_ADD,
-    UNDO_DELETE,
-    UNDO_UPDATE
-} UndoType;
+typedef void (*RevertAction)(void *context, size_t context_size);
 
 typedef struct {
-    char data[CONTEXT_SIZE];
-} Context;
-
-typedef void (*RevertAction)(void *layer, Context context);
-
-typedef struct UndoHistory UndoHistory;
+    Stack actions;
+} UndoHistory;
 
-UndoHistory *create_undo_history(void);
-void destroy_undo_history(UndoHistory *undo_history);
+static inline
+void destroy_undo_history(UndoHistory undo_history)
+{
+    destroy_stack(undo_history.actions);
+}
 
 void undo_history_push(UndoHistory *undo_history,
-                       void *layer,
                        RevertAction revert,
                        void *context_data,
                        size_t context_data_size);