| 1 | #ifndef GAME_EDITOR_EDITOR_HISTORY_H |
|---|---|
| 2 | #define GAME_EDITOR_EDITOR_HISTORY_H |
| 3 | |
| 4 | #include "editor_action.h" |
| 5 | |
| 6 | #include <game/client/ui_listbox.h> |
| 7 | #include <game/editor/map_object.h> |
| 8 | |
| 9 | #include <deque> |
| 10 | #include <memory> |
| 11 | #include <vector> |
| 12 | |
| 13 | class CEditorHistory : public CMapObject |
| 14 | { |
| 15 | public: |
| 16 | explicit CEditorHistory(CEditorMap *pMap) : |
| 17 | CMapObject(pMap) |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | ~CEditorHistory() override |
| 22 | { |
| 23 | Clear(); |
| 24 | } |
| 25 | |
| 26 | void RecordAction(const std::shared_ptr<IEditorAction> &pAction); |
| 27 | void RecordAction(const std::shared_ptr<IEditorAction> &pAction, const char *pDisplay); |
| 28 | void Execute(const std::shared_ptr<IEditorAction> &pAction, const char *pDisplay = nullptr); |
| 29 | |
| 30 | bool Undo(); |
| 31 | bool Redo(); |
| 32 | |
| 33 | void Clear(); |
| 34 | bool CanUndo() const { return !m_vpUndoActions.empty(); } |
| 35 | bool CanRedo() const { return !m_vpRedoActions.empty(); } |
| 36 | |
| 37 | void BeginBulk(); |
| 38 | void EndBulk(const char *pDisplay = nullptr); |
| 39 | void EndBulk(int DisplayToUse); |
| 40 | |
| 41 | std::deque<std::shared_ptr<IEditorAction>> m_vpUndoActions; |
| 42 | std::deque<std::shared_ptr<IEditorAction>> m_vpRedoActions; |
| 43 | |
| 44 | private: |
| 45 | std::vector<std::shared_ptr<IEditorAction>> m_vpBulkActions; |
| 46 | bool m_IsBulk = false; |
| 47 | }; |
| 48 | |
| 49 | enum class EHistoryType |
| 50 | { |
| 51 | EDITOR, |
| 52 | ENVELOPE, |
| 53 | SERVER_SETTINGS, |
| 54 | }; |
| 55 | |
| 56 | class CEditorHistoryUiState |
| 57 | { |
| 58 | public: |
| 59 | EHistoryType m_HistoryType = EHistoryType::EDITOR; |
| 60 | CListBox m_aListBoxes[(int)EHistoryType::SERVER_SETTINGS + 1]; |
| 61 | int m_aSelectedActionIndices[(int)EHistoryType::SERVER_SETTINGS + 1] = {0}; |
| 62 | const char m_aHistoryTypeButtonIds[(int)EHistoryType::SERVER_SETTINGS + 1] = {0}; |
| 63 | const char m_DeleteButtonId = 0; |
| 64 | const char m_BaseActionButtonId = 0; |
| 65 | }; |
| 66 | |
| 67 | #endif |
| 68 |