BsCmdRecordSO.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 recordHierarchy If true, all children of the provided scene object will be recorded as well.
  23. * @param description Optional description of what exactly the command does.
  24. */
  25. static void execute(const HSceneObject& sceneObject, bool recordHierarchy = false,
  26. const WString& description = StringUtil::WBLANK);
  27. /**
  28. * @copydoc EditorCommand::commit
  29. */
  30. void commit() override;
  31. /**
  32. * @copydoc EditorCommand::revert
  33. */
  34. void revert() override;
  35. private:
  36. friend class UndoRedo;
  37. CmdRecordSO(const WString& description, const HSceneObject& sceneObject, bool recordHierarchy);
  38. /**
  39. * @brief Saves the state of the specified object, all of its children
  40. * and components. Make sure to call "clear" when you no longer need
  41. * the data, or wish to call this method again.
  42. */
  43. void recordSO(const HSceneObject& sceneObject);
  44. /**
  45. * @brief Clears all the stored data and frees memory.
  46. */
  47. void clear();
  48. HSceneObject mSceneObject;
  49. CmdUtility::SceneObjProxy mSceneObjectProxy;
  50. bool mRecordHierarchy;
  51. UINT8* mSerializedObject;
  52. UINT32 mSerializedObjectSize;
  53. };
  54. }