BsCmdDeleteSO.h 1.7 KB

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