SaveDirtyFilesCallbacks.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/SaveChangedFilesManager.h>
  10. namespace EMStudio
  11. {
  12. class SaveDirtyActorFilesCallback
  13. : public SaveDirtyFilesCallback
  14. {
  15. MCORE_MEMORYOBJECTCATEGORY(SaveDirtyActorFilesCallback, MCore::MCORE_DEFAULT_ALIGNMENT, MEMCATEGORY_EMSTUDIOSDK)
  16. public:
  17. enum
  18. {
  19. TYPE_ID = 0x00000001
  20. };
  21. public:
  22. SaveDirtyActorFilesCallback() = default;
  23. ~SaveDirtyActorFilesCallback() = default;
  24. uint32 GetType() const override { return TYPE_ID; }
  25. uint32 GetPriority() const override { return 4; }
  26. bool GetIsPostProcessed() const override { return false; }
  27. const char* GetExtension() const override { return "actor"; }
  28. const char* GetFileType() const override { return "actor"; }
  29. const AZ::Uuid GetFileRttiType() const override { return azrtti_typeid<EMotionFX::Actor>(); }
  30. void GetDirtyFileNames(AZStd::vector<AZStd::string>* outFileNames, AZStd::vector<ObjectPointer>* outObjects) override;
  31. int SaveDirtyFiles(const AZStd::vector<AZStd::string>& filenamesToSave, const AZStd::vector<ObjectPointer>& objects, MCore::CommandGroup* commandGroup) override;
  32. static int SaveDirtyActor(EMotionFX::Actor* actor, MCore::CommandGroup* commandGroup, bool askBeforeSaving, bool showCancelButton = true);
  33. };
  34. class SaveDirtyMotionFilesCallback
  35. : public SaveDirtyFilesCallback
  36. {
  37. MCORE_MEMORYOBJECTCATEGORY(SaveDirtyMotionFilesCallback, MCore::MCORE_DEFAULT_ALIGNMENT, MEMCATEGORY_EMSTUDIOSDK)
  38. public:
  39. SaveDirtyMotionFilesCallback() = default;
  40. virtual ~SaveDirtyMotionFilesCallback() = default;
  41. enum
  42. {
  43. TYPE_ID = 0x00000002
  44. };
  45. uint32 GetType() const override { return TYPE_ID; }
  46. uint32 GetPriority() const override { return 3; }
  47. bool GetIsPostProcessed() const override { return false; }
  48. const char* GetExtension() const override { return "motion"; }
  49. const char* GetFileType() const override { return "motion"; }
  50. const AZ::Uuid GetFileRttiType() const override { return azrtti_typeid<EMotionFX::Motion>(); }
  51. void GetDirtyFileNames(AZStd::vector<AZStd::string>* outFileNames, AZStd::vector<ObjectPointer>* outObjects) override;
  52. int SaveDirtyFiles(const AZStd::vector<AZStd::string>& filenamesToSave, const AZStd::vector<ObjectPointer>& objects, MCore::CommandGroup* commandGroup) override;
  53. static int SaveDirtyMotion(EMotionFX::Motion* motion, [[maybe_unused]] MCore::CommandGroup* commandGroup, bool askBeforeSaving, bool showCancelButton = true);
  54. };
  55. class SaveDirtyMotionSetFilesCallback
  56. : public SaveDirtyFilesCallback
  57. {
  58. MCORE_MEMORYOBJECTCATEGORY(SaveDirtyMotionSetFilesCallback, MCore::MCORE_DEFAULT_ALIGNMENT, MEMCATEGORY_EMSTUDIOSDK)
  59. public:
  60. SaveDirtyMotionSetFilesCallback() = default;
  61. virtual ~SaveDirtyMotionSetFilesCallback() = default;
  62. enum
  63. {
  64. TYPE_ID = 0x00000003
  65. };
  66. uint32 GetType() const override { return TYPE_ID; }
  67. uint32 GetPriority() const override { return 2; }
  68. bool GetIsPostProcessed() const override { return false; }
  69. const char* GetExtension() const override { return "motionset"; }
  70. const char* GetFileType() const override { return "motion set"; }
  71. const AZ::Uuid GetFileRttiType() const override { return azrtti_typeid<EMotionFX::MotionSet>(); }
  72. void GetDirtyFileNames(AZStd::vector<AZStd::string>* outFileNames, AZStd::vector<ObjectPointer>* outObjects) override;
  73. int SaveDirtyFiles(const AZStd::vector<AZStd::string>& filenamesToSave, const AZStd::vector<ObjectPointer>& objects, MCore::CommandGroup* commandGroup) override;
  74. static int SaveDirtyMotionSet(EMotionFX::MotionSet* motionSet, MCore::CommandGroup* commandGroup, bool askBeforeSaving, bool showCancelButton = true);
  75. };
  76. class SaveDirtyAnimGraphFilesCallback
  77. : public SaveDirtyFilesCallback
  78. {
  79. MCORE_MEMORYOBJECTCATEGORY(SaveDirtyFilesCallback, MCore::MCORE_DEFAULT_ALIGNMENT, MEMCATEGORY_EMSTUDIOSDK)
  80. public:
  81. SaveDirtyAnimGraphFilesCallback() = default;
  82. ~SaveDirtyAnimGraphFilesCallback() = default;
  83. enum
  84. {
  85. TYPE_ID = 0x00000004
  86. };
  87. uint32 GetType() const override { return TYPE_ID; }
  88. uint32 GetPriority() const override { return 1; }
  89. bool GetIsPostProcessed() const override { return false; }
  90. const char* GetExtension() const override { return "animgraph"; }
  91. const char* GetFileType() const override { return "anim graph"; }
  92. const AZ::Uuid GetFileRttiType() const override { return azrtti_typeid<EMotionFX::AnimGraph>(); }
  93. void GetDirtyFileNames(AZStd::vector<AZStd::string>* outFileNames, AZStd::vector<ObjectPointer>* outObjects) override;
  94. int SaveDirtyFiles(const AZStd::vector<AZStd::string>& filenamesToSave, const AZStd::vector<ObjectPointer>& objects, MCore::CommandGroup* commandGroup) override;
  95. int SaveDirtyAnimGraph(EMotionFX::AnimGraph* animGraph, MCore::CommandGroup* commandGroup, bool askBeforeSaving, bool showCancelButton = true);
  96. };
  97. class SaveDirtyWorkspaceCallback
  98. : public SaveDirtyFilesCallback
  99. {
  100. MCORE_MEMORYOBJECTCATEGORY(SaveDirtyWorkspaceCallback, MCore::MCORE_DEFAULT_ALIGNMENT, MEMCATEGORY_EMSTUDIOSDK)
  101. public:
  102. SaveDirtyWorkspaceCallback() = default;
  103. ~SaveDirtyWorkspaceCallback() = default;
  104. enum
  105. {
  106. TYPE_ID = 0x00000005
  107. };
  108. uint32 GetType() const override { return TYPE_ID; }
  109. uint32 GetPriority() const override { return 0; }
  110. bool GetIsPostProcessed() const override { return false; }
  111. const char* GetExtension() const override { return "emfxworkspace"; }
  112. const char* GetFileType() const override { return "workspace"; }
  113. const AZ::Uuid GetFileRttiType() const override { return azrtti_typeid<EMStudio::Workspace>(); }
  114. void GetDirtyFileNames(AZStd::vector<AZStd::string>* outFileNames, AZStd::vector<ObjectPointer>* outObjects) override;
  115. int SaveDirtyFiles(const AZStd::vector<AZStd::string>& filenamesToSave, const AZStd::vector<ObjectPointer>& objects, MCore::CommandGroup* commandGroup) override;
  116. };
  117. } // namespace EMStudio