BsCmdCreateSO.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. Creates a scene object and removes it as an undo operation. */
  13. class BS_ED_EXPORT CmdCreateSO final : public EditorCommand
  14. {
  15. public:
  16. /**
  17. * Creates a new scene object. Automatically registers the command with undo/redo system.
  18. *
  19. * @param[in] name Name of the scene object.
  20. * @param[in] flags Optional creation flags for the scene object.
  21. * @param[in] description Optional description of what exactly the command does.
  22. * @return Newly created scene object.
  23. */
  24. static HSceneObject execute(const String& name, UINT32 flags, const String& description = StringUtil::BLANK);
  25. /**
  26. * Creates a new scene object with an initial set of components. Automatically registers the command with undo/redo
  27. * system.
  28. *
  29. * @param[in] name Name of the scene object.
  30. * @param[in] flags Optional creation flags for the scene object.
  31. * @param[in] componentTypeIds A list of type ID's of the components to add to the scene object.
  32. * @param[in] description Optional description of what exactly the command does.
  33. * @return Newly created scene object.
  34. */
  35. static HSceneObject execute(const String& name, UINT32 flags, const Vector<UINT32>& componentTypeIds,
  36. const String& description = StringUtil::BLANK);
  37. /** @copydoc EditorCommand::commit */
  38. void commit() override;
  39. /** @copydoc EditorCommand::revert */
  40. void revert() override;
  41. private:
  42. friend class UndoRedo;
  43. CmdCreateSO(const String& description, const String& name, UINT32 flags);
  44. CmdCreateSO(const String& description, const String& name, const Vector<UINT32>& componentTypeIds, UINT32 flags);
  45. String mName;
  46. UINT32 mFlags;
  47. HSceneObject mSceneObject;
  48. Vector<UINT32> mComponentTypeIds;
  49. };
  50. /** @} */
  51. }