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