#pragma once #include "IUndoManager.h" #include #include #include namespace XCEngine { namespace Editor { class ISelectionManager; class SceneManager; class UndoManager : public IUndoManager { public: UndoManager(SceneManager& sceneManager, ISelectionManager& selectionManager); void ClearHistory() override; bool CanUndo() const override; bool CanRedo() const override; const std::string& GetUndoLabel() const override; const std::string& GetRedoLabel() const override; void Undo() override; void Redo() override; UndoStateSnapshot CaptureCurrentState() const override; void PushCommand(const std::string& label, UndoStateSnapshot before, UndoStateSnapshot after) override; void BeginInteractiveChange(const std::string& label) override; bool HasPendingInteractiveChange() const override; void FinalizeInteractiveChange() override; void CancelInteractiveChange() override; private: struct CommandEntry { std::string label; UndoStateSnapshot before; UndoStateSnapshot after; }; struct PendingInteractiveChange { std::string label; UndoStateSnapshot before; }; bool ApplyState(const UndoStateSnapshot& state); static bool AreStatesEqual(const UndoStateSnapshot& lhs, const UndoStateSnapshot& rhs); SceneManager& m_sceneManager; ISelectionManager& m_selectionManager; std::vector m_history; size_t m_nextIndex = 0; std::optional m_pendingInteractiveChange; std::string m_emptyLabel; }; } // namespace Editor } // namespace XCEngine