BsCmdCloneSO.h 1.8 KB

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