BsCmdRecordSO.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsEditorCommand.h"
  4. #include "BsUndoRedo.h"
  5. #include "BsCmdUtility.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief A command used for undo/redo purposes. It records a state of the entire
  10. * scene object at a specific point and allows you to restore it to its
  11. * original values as needed.
  12. */
  13. class BS_ED_EXPORT CmdRecordSO : public EditorCommand
  14. {
  15. public:
  16. ~CmdRecordSO();
  17. /**
  18. * @brief Creates and executes the command on the provided scene object.
  19. * Automatically registers the command with undo/redo system.
  20. *
  21. * @param sceneObject Scene object to record.
  22. * @param description Optional description of what exactly the command does.
  23. */
  24. static void execute(const HSceneObject& sceneObject, const WString& description = StringUtil::WBLANK);
  25. /**
  26. * @copydoc EditorCommand::commit
  27. */
  28. void commit() override;
  29. /**
  30. * @copydoc EditorCommand::revert
  31. */
  32. void revert() override;
  33. private:
  34. friend class UndoRedo;
  35. CmdRecordSO(const WString& description, const HSceneObject& sceneObject);
  36. /**
  37. * @brief Saves the state of the specified object, all of its children
  38. * and components. Make sure to call "clear" when you no longer need
  39. * the data, or wish to call this method again.
  40. */
  41. void recordSO(const HSceneObject& sceneObject);
  42. /**
  43. * @brief Clears all the stored data and frees memory.
  44. */
  45. void clear();
  46. HSceneObject mSceneObject;
  47. CmdUtility::SceneObjProxy mSceneObjectProxy;
  48. UINT8* mSerializedObject;
  49. UINT32 mSerializedObjectSize;
  50. UINT64 mSerializedObjectParentId;
  51. };
  52. }