BsCmdCloneSO.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 "UndoRedo/BsEditorCommand.h"
  6. #include "UndoRedo/BsUndoRedo.h"
  7. namespace bs
  8. {
  9. /** @addtogroup UndoRedo
  10. * @{
  11. */
  12. /** A command used for undo/redo purposes. Clones scene object(s) and removes them as an undo operation. */
  13. class BS_ED_EXPORT CmdCloneSO final : public EditorCommand
  14. {
  15. public:
  16. /**
  17. * Creates a new scene object by cloning an existing object. Automatically registers the command with undo/redo
  18. * system.
  19. *
  20. * @param[in] sceneObject Scene object to clone.
  21. * @param[in] description Optional description of what exactly the command does.
  22. * @return Cloned object.
  23. */
  24. static HSceneObject execute(const HSceneObject& sceneObject, const String& description = StringUtil::BLANK);
  25. /**
  26. * Creates new scene object(s) by cloning existing objects. Automatically registers the command with undo/redo
  27. * system.
  28. *
  29. * @param[in] sceneObjects Scene object(s) to clone.
  30. * @param[in] description Optional description of what exactly the command does.
  31. * @return Cloned objects.
  32. */
  33. static Vector<HSceneObject> execute(const Vector<HSceneObject>& sceneObjects, const String& description = StringUtil::BLANK);
  34. /** @copydoc EditorCommand::commit */
  35. void commit() override;
  36. /** @copydoc EditorCommand::revert */
  37. void revert() override;
  38. private:
  39. friend class UndoRedo;
  40. CmdCloneSO(const String& description, const Vector<HSceneObject>& originals);
  41. Vector<HSceneObject> mOriginals;
  42. Vector<HSceneObject> mClones;
  43. };
  44. /** @} */
  45. }