BsCmdRenameSO.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2019 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 name change operations. It allows you to apply
  14. * the name change or revert the object to its original name as needed.
  15. */
  16. class BS_ED_EXPORT CmdRenameSO 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] sceneObject Object to rename.
  24. * @param[in] newName New name for the provided object.
  25. */
  26. static void execute(const HSceneObject& sceneObjects, const String& newName);
  27. /** @copydoc EditorCommand::commit */
  28. void commit() override;
  29. /** @copydoc EditorCommand::revert */
  30. void revert() override;
  31. private:
  32. friend class UndoRedo;
  33. CmdRenameSO(const String& description, const HSceneObject& sceneObject, const String& newName);
  34. HSceneObject mSceneObject;
  35. String mOldName;
  36. String mNewName;
  37. };
  38. /** @} */
  39. }