BsCmdReparentSO.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /**
  13. * A command used for undo/redo purposes. It records a scene object parent change operations. It allows you to apply
  14. * the parent change or revert the object to its original parent as needed.
  15. */
  16. class BS_ED_EXPORT CmdReparentSO final : public EditorCommand
  17. {
  18. public:
  19. /**
  20. * Creates and executes the command on the provided scene object(s). Automatically registers the command with
  21. * undo/redo system.
  22. *
  23. * @param[in] sceneObjects Object(s) to change the parent for.
  24. * @param[in] newParent New parent for the provided objects.
  25. * @param[in] description Optional description of what exactly the command does.
  26. */
  27. static void execute(const Vector<HSceneObject>& sceneObjects, const HSceneObject& newParent,
  28. const String& description = StringUtil::BLANK);
  29. /**
  30. * Creates and executes the command on the provided scene object. Automatically registers the command with
  31. * undo/redo system.
  32. *
  33. * @param[in] sceneObject Object to change the parent for.
  34. * @param[in] newParent New parent for the provided objects.
  35. * @param[in] description Optional description of what exactly the command does.
  36. */
  37. static void execute(HSceneObject& sceneObject, const HSceneObject& newParent,
  38. const String& description = StringUtil::BLANK);
  39. /** @copydoc EditorCommand::commit */
  40. void commit() override;
  41. /** @copydoc EditorCommand::revert */
  42. void revert() override;
  43. private:
  44. friend class UndoRedo;
  45. CmdReparentSO(const String& description, const Vector<HSceneObject>& sceneObjects, const HSceneObject& newParent);
  46. Vector<HSceneObject> mSceneObjects;
  47. Vector<HSceneObject> mOldParents;
  48. HSceneObject mNewParent;
  49. };
  50. /** @} */
  51. }