feat(wip): implementing edit history and un-re-do
This commit is contained in:
parent
b875c2089b
commit
e2926f7c3f
6 changed files with 90 additions and 3 deletions
27
modules/terrain_editor/edit_history.h
Normal file
27
modules/terrain_editor/edit_history.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include "core/object/class_db.h"
|
||||
#include "core/object/object.h"
|
||||
#include "core/variant/callable.h"
|
||||
#include "terrain_editor/register_types.h"
|
||||
|
||||
class EditHistory : public Object {
|
||||
GDCLASS(EditHistory, Object);
|
||||
static void _bind_methods();
|
||||
static EditHistory *singleton_instance;
|
||||
friend void initialize_terrain_editor_module(ModuleInitializationLevel p_level);
|
||||
struct EditAction {
|
||||
Callable do_action;
|
||||
Callable undo_action;
|
||||
};
|
||||
|
||||
public:
|
||||
static EditHistory *get_singleton() { return singleton_instance; }
|
||||
void push_action(Callable do_action, Callable undo_action);
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
private:
|
||||
size_t undo_count{ 0 };
|
||||
Vector<EditAction> history{};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue