BsCmdRecordSO.h 2.0 KB

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