BsCmdDeleteSO.h 1.8 KB

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