BsCmdRecordSO.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /**
  11. * @brief A command used for undo/redo purposes. It records a state of the entire
  12. * scene object at a specific point and allows you to restore it to its
  13. * original values as needed.
  14. */
  15. class BS_ED_EXPORT CmdRecordSO : public EditorCommand
  16. {
  17. public:
  18. ~CmdRecordSO();
  19. /**
  20. * @brief Creates and executes the command on the provided scene object.
  21. * Automatically registers the command with undo/redo system.
  22. *
  23. * @param sceneObject Scene object to record.
  24. * @param recordHierarchy If true, all children of the provided scene object will be recorded as well.
  25. * @param description Optional description of what exactly the command does.
  26. */
  27. static void execute(const HSceneObject& sceneObject, bool recordHierarchy = false,
  28. const WString& description = StringUtil::WBLANK);
  29. /**
  30. * @copydoc EditorCommand::commit
  31. */
  32. void commit() override;
  33. /**
  34. * @copydoc EditorCommand::revert
  35. */
  36. void revert() override;
  37. private:
  38. friend class UndoRedo;
  39. CmdRecordSO(const WString& description, const HSceneObject& sceneObject, bool recordHierarchy);
  40. /**
  41. * @brief Saves the state of the specified object, all of its children
  42. * and components. Make sure to call "clear" when you no longer need
  43. * the data, or wish to call this method again.
  44. */
  45. void recordSO(const HSceneObject& sceneObject);
  46. /**
  47. * @brief Clears all the stored data and frees memory.
  48. */
  49. void clear();
  50. HSceneObject mSceneObject;
  51. CmdUtility::SceneObjProxy mSceneObjectProxy;
  52. bool mRecordHierarchy;
  53. UINT8* mSerializedObject;
  54. UINT32 mSerializedObjectSize;
  55. };
  56. }