1#ifndef GAME_EDITOR_EDITOR_HISTORY_H
2#define GAME_EDITOR_EDITOR_HISTORY_H
3
4#include "editor_action.h"
5
6#include <deque>
7#include <memory>
8#include <vector>
9
10class CEditorHistory
11{
12public:
13 CEditorHistory()
14 {
15 m_pEditor = nullptr;
16 m_IsBulk = false;
17 }
18
19 ~CEditorHistory()
20 {
21 Clear();
22 }
23
24 void RecordAction(const std::shared_ptr<IEditorAction> &pAction);
25 void RecordAction(const std::shared_ptr<IEditorAction> &pAction, const char *pDisplay);
26 void Execute(const std::shared_ptr<IEditorAction> &pAction, const char *pDisplay = nullptr);
27
28 bool Undo();
29 bool Redo();
30
31 void Clear();
32 bool CanUndo() const { return !m_vpUndoActions.empty(); }
33 bool CanRedo() const { return !m_vpRedoActions.empty(); }
34
35 void BeginBulk();
36 void EndBulk(const char *pDisplay = nullptr);
37 void EndBulk(int DisplayToUse);
38
39 CEditor *m_pEditor;
40 std::deque<std::shared_ptr<IEditorAction>> m_vpUndoActions;
41 std::deque<std::shared_ptr<IEditorAction>> m_vpRedoActions;
42
43private:
44 std::vector<std::shared_ptr<IEditorAction>> m_vpBulkActions;
45 bool m_IsBulk;
46};
47
48#endif
49