BsCmdCloneSO.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. Clones scene object(s)
  10. * and removes them as an undo operation.
  11. */
  12. class BS_ED_EXPORT CmdCloneSO : public EditorCommand
  13. {
  14. public:
  15. ~CmdCloneSO();
  16. /**
  17. * @brief Creates a new scene object by cloning an existing object.
  18. * Automatically registers the command with undo/redo system.
  19. *
  20. * @param sceneObject Scene object to clone.
  21. * @param description Optional description of what exactly the command does.
  22. *
  23. * @return Cloned object.
  24. */
  25. static HSceneObject execute(const HSceneObject& sceneObject, const WString& description = StringUtil::WBLANK);
  26. /**
  27. * @brief Creates new scene object(s) by cloning existing objects.
  28. * Automatically registers the command with undo/redo system.
  29. *
  30. * @param sceneObjects Scene object(s) to clone.
  31. * @param description Optional description of what exactly the command does.
  32. *
  33. * @return Cloned objects.
  34. */
  35. static Vector<HSceneObject> execute(const Vector<HSceneObject>& sceneObjects, const WString& description = StringUtil::WBLANK);
  36. /**
  37. * @copydoc EditorCommand::commit
  38. */
  39. void commit() override;
  40. /**
  41. * @copydoc EditorCommand::revert
  42. */
  43. void revert() override;
  44. private:
  45. friend class UndoRedo;
  46. CmdCloneSO(const WString& description, const Vector<HSceneObject>& originals);
  47. Vector<HSceneObject> mOriginals;
  48. Vector<HSceneObject> mClones;
  49. };
  50. }