BsCmdCloneSO.h 1.8 KB

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