SampleComponentManagerBus.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 <AzCore/EBus/EBus.h>
  10. #include <AzCore/std/string/string.h>
  11. namespace AZ
  12. {
  13. class ComponentDescriptor;
  14. }
  15. namespace AtomSampleViewer
  16. {
  17. enum class SamplePipelineType : uint32_t
  18. {
  19. RHI = 0,
  20. RPI
  21. };
  22. class SampleEntry
  23. {
  24. public:
  25. AZStd::string m_parentMenuName;
  26. AZStd::string m_sampleName;
  27. // m_parentMenuName/m_sampleName
  28. AZStd::string m_fullName;
  29. AZ::Uuid m_sampleUuid;
  30. AZStd::function<bool()> m_isSupportedFunc;
  31. SamplePipelineType m_pipelineType = SamplePipelineType::RHI;
  32. AZ::ComponentDescriptor* m_componentDescriptor;
  33. AZStd::string m_contentWarning;
  34. AZStd::string m_contentWarningTitle;
  35. bool operator==(const SampleEntry& other)
  36. {
  37. return other.m_sampleName == m_sampleName && other.m_parentMenuName == m_parentMenuName;
  38. }
  39. };
  40. template <typename T>
  41. static SampleEntry NewSample(SamplePipelineType type, const char* menuName, const AZStd::string& name)
  42. {
  43. SampleEntry entry;
  44. entry.m_sampleName = name;
  45. entry.m_sampleUuid = azrtti_typeid<T>();
  46. entry.m_pipelineType = type;
  47. entry.m_componentDescriptor = T::CreateDescriptor();
  48. entry.m_parentMenuName = menuName;
  49. entry.m_fullName = entry.m_parentMenuName + '/' + entry.m_sampleName;
  50. entry.m_contentWarning = T::ContentWarning;
  51. entry.m_contentWarningTitle = T::ContentWarningTitle;
  52. return entry;
  53. }
  54. template <typename T>
  55. static SampleEntry NewSample(SamplePipelineType type, const char* menuName, const AZStd::string& name, AZStd::function<bool()> isSupportedFunction)
  56. {
  57. SampleEntry entry = NewSample<T>(type, menuName, name);
  58. entry.m_isSupportedFunc = isSupportedFunction;
  59. return entry;
  60. }
  61. class SampleComponentManagerRequests
  62. : public AZ::EBusTraits
  63. {
  64. public:
  65. //! Close any open sample and return to the home screen
  66. virtual void Reset() = 0;
  67. //! Open a sample with the given name. Return false if the sample wasn't found.
  68. virtual bool OpenSample(const AZStd::string& sampleName) = 0;
  69. //! Show or hide a debug tool with the given name. Return false if the tool wasn't found.
  70. virtual bool ShowTool(const AZStd::string& toolName, bool enable) = 0;
  71. //! Take a screenshot and save to the indicated file path.
  72. //! @param filePath where to save the screenshot file. The screenshot type is indicated by the extension.
  73. //! @param hideImGui hide ImGui while taking the screenshot.
  74. virtual void RequestFrameCapture(const AZStd::string& filePath, bool hideImGui) = 0;
  75. //! Returns true if a frame capture has been requested and not yet fulfilled
  76. virtual bool IsFrameCapturePending() = 0;
  77. //! Runs the main test suite, in an automated mode and closes AtomSampleViewer when the suite finished running
  78. //! @param suiteFilePath path to the compiled luac test script
  79. //! @param exitOnTestEnd if true, exits AtomSampleViewerStandalone when the script finishes, used in jenkins
  80. //! @param randomSeed the seed for the random generator, frequently used inside lua tests to shuffle the order of the test execution
  81. virtual void RunMainTestSuite(const AZStd::string& suiteFilePath, bool exitOnTestEnd, int randomSeed) = 0;
  82. //! Set the number of MSAA samples
  83. //! @param numMSAASamples the number of MSAA samples
  84. virtual void SetNumMSAASamples(int16_t numMsaaSamples) = 0;
  85. //! Gets the number of MSAA samples
  86. virtual int16_t GetNumMSAASamples() = 0;
  87. //! Sets the default number of MSAA samples
  88. virtual void SetDefaultNumMSAASamples(int16_t defaultNumMsaaSamples) = 0;
  89. //! Gets the default number of MSAA samples
  90. virtual int16_t GetDefaultNumMSAASamples() = 0;
  91. //! Set the number of MSAA samples to the platform default
  92. virtual void ResetNumMSAASamples() = 0;
  93. //! Reset the RPI scene while keeping the current sample running
  94. virtual void ResetRPIScene() = 0;
  95. //! Clear the RPI scene
  96. virtual void ClearRPIScene() = 0;
  97. //! Enables or disables the default render pipeline.
  98. virtual void EnableRenderPipeline(bool value) = 0;
  99. //! Enables or disables the XR pipelines.
  100. virtual void EnableXrPipelines(bool value) = 0;
  101. };
  102. using SampleComponentManagerRequestBus = AZ::EBus<SampleComponentManagerRequests>;
  103. class ScriptManager;
  104. class ScriptableImGui;
  105. class SampleComponentSingletonRequests
  106. : public AZ::EBusTraits
  107. {
  108. public:
  109. virtual ScriptManager* GetScriptManagerInstance() = 0;
  110. virtual ScriptableImGui* GetScriptableImGuiInstance() = 0;
  111. virtual void RegisterSampleComponent(const SampleEntry& sample) = 0;
  112. };
  113. using SampleComponentSingletonRequestBus = AZ::EBus<SampleComponentSingletonRequests>;
  114. class SampleComponentManagerNotifications
  115. : public AZ::EBusTraits
  116. {
  117. public:
  118. //! Called when SampleComponentManager has been activated
  119. virtual void OnSampleManagerActivated() {}
  120. };
  121. using SampleComponentManagerNotificationBus = AZ::EBus<SampleComponentManagerNotifications>;
  122. } // namespace AtomSampleViewer