EditorVignetteComponent.cpp 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #include <PostProcess/Vignette/EditorVignetteComponent.h>
  9. #include <AzCore/RTTI/BehaviorContext.h>
  10. namespace AZ
  11. {
  12. namespace Render
  13. {
  14. void EditorVignetteComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. BaseClass::Reflect(context);
  17. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serializeContext->Class<EditorVignetteComponent, BaseClass>()->Version(0);
  20. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  21. {
  22. editContext->Class<EditorVignetteComponent>("Vignette", "Controls the Vignette")
  23. ->ClassElement(Edit::ClassElements::EditorData, "")
  24. ->Attribute(Edit::Attributes::Category, "Graphics/PostFX")
  25. ->Attribute(
  26. AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg") // Create better icons for this effect
  27. ->Attribute(
  28. AZ::Edit::Attributes::ViewportIcon,
  29. "Icons/Components/Viewport/Component_Placeholder.svg") // Create better icons for this effect
  30. ->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  31. ->Attribute(Edit::Attributes::AutoExpand, true)
  32. ->Attribute(
  33. Edit::Attributes::HelpPageURL,
  34. "https://o3de.org/docs/user-guide/components/reference/atom/Vignette/") // Create documentation page for this effect
  35. ;
  36. editContext->Class<VignetteComponentController>("VignetteComponentController", "")
  37. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  38. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  39. ->DataElement(AZ::Edit::UIHandlers::Default, &VignetteComponentController::m_configuration, "Configuration", "")
  40. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly);
  41. editContext->Class<VignetteComponentConfig>("VignetteComponentConfig", "")
  42. ->DataElement(
  43. Edit::UIHandlers::CheckBox, &VignetteComponentConfig::m_enabled, "Enable Vignette", "Enable Vignette.")
  44. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  45. ->DataElement(AZ::Edit::UIHandlers::Slider, &VignetteComponentConfig::m_intensity, "Intensity", "Intensity of effect")
  46. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  47. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  48. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  49. ->Attribute(Edit::Attributes::ReadOnly, &VignetteComponentConfig::ArePropertiesReadOnly)
  50. // Overrides
  51. ->ClassElement(AZ::Edit::ClassElements::Group, "Overrides")
  52. ->Attribute(AZ::Edit::Attributes::AutoExpand, false)
  53. // Auto-gen editor context settings for overrides
  54. #define EDITOR_CLASS VignetteComponentConfig
  55. #include <Atom/Feature/ParamMacros/StartOverrideEditorContext.inl>
  56. #include <Atom/Feature/PostProcess/Vignette/VignetteParams.inl>
  57. #include <Atom/Feature/ParamMacros/EndParams.inl>
  58. #undef EDITOR_CLASS
  59. ;
  60. }
  61. }
  62. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  63. {
  64. behaviorContext->Class<EditorVignetteComponent>()->RequestBus("VignetteRequestBus");
  65. behaviorContext
  66. ->ConstantProperty("EditorVignetteComponentTypeId", BehaviorConstant(Uuid(Vignette::EditorVignetteComponentTypeId)))
  67. ->Attribute(AZ::Script::Attributes::Module, "render")
  68. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  69. }
  70. }
  71. EditorVignetteComponent::EditorVignetteComponent(const VignetteComponentConfig& config)
  72. : BaseClass(config)
  73. {
  74. }
  75. u32 EditorVignetteComponent::OnConfigurationChanged()
  76. {
  77. m_controller.OnConfigChanged();
  78. return Edit::PropertyRefreshLevels::AttributesAndValues;
  79. }
  80. } // namespace Render
  81. } // namespace AZ