BsCmdDeleteSO.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. Deletes a scene object
  10. * and restores it as an undo operation.
  11. */
  12. class BS_ED_EXPORT CmdDeleteSO : public EditorCommand
  13. {
  14. public:
  15. ~CmdDeleteSO();
  16. /**
  17. * @brief Creates and executes the command on the provided scene object.
  18. * Automatically registers the command with undo/redo system.
  19. *
  20. * @param sceneObject Scene object to delete.
  21. * @param description Optional description of what exactly the command does.
  22. */
  23. static void execute(const HSceneObject& sceneObject, const WString& description = StringUtil::WBLANK);
  24. /**
  25. * @copydoc EditorCommand::commit
  26. */
  27. void commit() override;
  28. /**
  29. * @copydoc EditorCommand::revert
  30. */
  31. void revert() override;
  32. private:
  33. friend class UndoRedo;
  34. CmdDeleteSO(const WString& description, const HSceneObject& sceneObject);
  35. /**
  36. * @brief Saves the state of the specified object, all of its children
  37. * and components. Make sure to call "clear" when you no longer need
  38. * the data, or wish to call this method again.
  39. */
  40. void recordSO(const HSceneObject& sceneObject);
  41. /**
  42. * @brief Clears all the stored data and frees memory.
  43. */
  44. void clear();
  45. HSceneObject mSceneObject;
  46. CmdUtility::SceneObjProxy mSceneObjectProxy;
  47. UINT8* mSerializedObject;
  48. UINT32 mSerializedObjectSize;
  49. UINT64 mSerializedObjectParentId;
  50. };
  51. }