3
0

EditorLevelSettingsComponent.cpp 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 "EditorLevelSettingsComponent.h"
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include <AzCore/Serialization/EditContext.h>
  11. namespace Vegetation
  12. {
  13. void EditorLevelSettingsComponent::Reflect(AZ::ReflectContext* context)
  14. {
  15. BaseClassType::Reflect(context);
  16. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  17. if (serializeContext)
  18. {
  19. serializeContext->Class<EditorLevelSettingsComponent, BaseClassType>()
  20. ->Version(1, &LmbrCentral::EditorWrappedComponentBaseVersionConverter<typename BaseClassType::WrappedComponentType, typename BaseClassType::WrappedConfigType, 1>)
  21. ->Field("UseEditorMaxInstanceProcessTimeMicroseconds", &EditorLevelSettingsComponent::m_useEditorMaxInstanceProcessTimeMicroseconds)
  22. ->Field("EditorMaxInstanceProcessTimeMicroseconds", &EditorLevelSettingsComponent::m_editorMaxInstanceProcessTimeMicroseconds)
  23. ;
  24. AZ::EditContext* editContext = serializeContext->GetEditContext();
  25. if (editContext)
  26. {
  27. editContext->Class<EditorLevelSettingsComponent>(s_componentName, s_componentDescription)
  28. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  29. ->Attribute(AZ::Edit::Attributes::Category, s_categoryName)
  30. ->Attribute(AZ::Edit::Attributes::Icon, s_icon)
  31. ->Attribute(AZ::Edit::Attributes::ViewportIcon, s_viewportIcon)
  32. ->Attribute(AZ::Edit::Attributes::HelpPageURL, s_helpUrl)
  33. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  34. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Level", 0x9aeacc13))
  35. ->DataElement(AZ::Edit::UIHandlers::CheckBox, &EditorLevelSettingsComponent::m_useEditorMaxInstanceProcessTimeMicroseconds, "Override Instance Time Slicing", "Use a max instance process time (in microseconds) for the Editor")
  36. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorLevelSettingsComponent::ConfigurationChanged)
  37. ->DataElement(0, &EditorLevelSettingsComponent::m_editorMaxInstanceProcessTimeMicroseconds, "Editor Instance Time Slicing", "The timeout maximum number of microseconds to process the vegetation instance construction & removal operations while in the Editor.")
  38. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorLevelSettingsComponent::ConfigurationChanged)
  39. ->Attribute(AZ::Edit::Attributes::Min, 0)
  40. ->Attribute(AZ::Edit::Attributes::Max, 33000)
  41. ;
  42. }
  43. }
  44. }
  45. AZ::u32 EditorLevelSettingsComponent::ConfigurationChanged()
  46. {
  47. m_component.Deactivate();
  48. if (m_useEditorMaxInstanceProcessTimeMicroseconds)
  49. {
  50. LevelSettingsConfig editorConfig = m_configuration;
  51. editorConfig.m_instanceSystemConfig.m_maxInstanceProcessTimeMicroseconds = m_editorMaxInstanceProcessTimeMicroseconds;
  52. m_component.ReadInConfig(&editorConfig);
  53. }
  54. else
  55. {
  56. m_component.ReadInConfig(&m_configuration);
  57. }
  58. if (m_visible && m_component.GetEntity())
  59. {
  60. m_component.Activate();
  61. }
  62. return AZ::Edit::PropertyRefreshLevels::None;
  63. }
  64. } // namespace Vegetation