3
0

EditorDebugComponent.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 "EditorDebugComponent.h"
  9. #include <AzCore/Serialization/Utils.h>
  10. #include <AzCore/base.h>
  11. #include <AzToolsFramework/API/ToolsApplicationAPI.h>
  12. #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
  13. #include <Vegetation/Ebuses/AreaSystemRequestBus.h>
  14. #include <Vegetation/Ebuses/InstanceSystemRequestBus.h>
  15. #include <VegetationSystemComponent.h>
  16. #include <ISystem.h>
  17. #include <IConsole.h>
  18. namespace Vegetation
  19. {
  20. namespace EditorDebugComponentVersionUtility
  21. {
  22. bool VersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement)
  23. {
  24. EditorVegetationComponentBaseVersionConverter<DebugComponent, DebugConfig>(context, classElement);
  25. if (classElement.GetVersion() < 2)
  26. {
  27. classElement.RemoveElementByName(AZ_CRC("FilerTypeLevel", 0x246c4e16));
  28. classElement.RemoveElementByName(AZ_CRC("SortType", 0xdd2117e6));
  29. }
  30. return true;
  31. }
  32. }
  33. void EditorDebugComponent::Reflect(AZ::ReflectContext* context)
  34. {
  35. BaseClassType::Reflect(context);
  36. AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
  37. if (serialize)
  38. {
  39. serialize->Class<EditorDebugComponent, BaseClassType>()
  40. ->Version(2, &EditorDebugComponentVersionUtility::VersionConverter)
  41. ;
  42. AZ::EditContext* edit = serialize->GetEditContext();
  43. if (edit)
  44. {
  45. edit->Class<EditorDebugComponent>(
  46. s_componentName, s_componentDescription)
  47. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  48. ->Attribute(AZ::Edit::Attributes::Icon, s_icon)
  49. ->Attribute(AZ::Edit::Attributes::ViewportIcon, s_viewportIcon)
  50. ->Attribute(AZ::Edit::Attributes::HelpPageURL, s_helpUrl)
  51. ->Attribute(AZ::Edit::Attributes::Category, s_categoryName)
  52. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Level", 0x9aeacc13))
  53. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  54. ->UIElement(AZ::Edit::UIHandlers::Button, "")
  55. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugComponent::OnDumpDataToFile)
  56. ->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
  57. ->Attribute(AZ::Edit::Attributes::ButtonText, "Dump Performance Log")
  58. ->UIElement(AZ::Edit::UIHandlers::Button, "")
  59. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugComponent::OnClearReport)
  60. ->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
  61. ->Attribute(AZ::Edit::Attributes::ButtonText, "Clear Performance Log")
  62. ->UIElement(AZ::Edit::UIHandlers::Button, "")
  63. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugComponent::OnRefreshAllAreas)
  64. ->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
  65. ->Attribute(AZ::Edit::Attributes::ButtonText, "Refresh All Areas")
  66. ->UIElement(AZ::Edit::UIHandlers::Button, "")
  67. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugComponent::OnClearAllAreas)
  68. ->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
  69. ->Attribute(AZ::Edit::Attributes::ButtonText, "Clear All Areas")
  70. ;
  71. }
  72. }
  73. }
  74. void EditorDebugComponent::Activate()
  75. {
  76. BaseClassType::Activate();
  77. }
  78. void EditorDebugComponent::OnDumpDataToFile()
  79. {
  80. m_component.ExportCurrentReport();
  81. }
  82. void EditorDebugComponent::OnClearReport()
  83. {
  84. m_component.ClearPerformanceReport();
  85. }
  86. void EditorDebugComponent::OnRefreshAllAreas()
  87. {
  88. AreaSystemRequestBus::Broadcast(&AreaSystemRequestBus::Events::RefreshAllAreas);
  89. }
  90. void EditorDebugComponent::OnClearAllAreas()
  91. {
  92. AreaSystemRequestBus::Broadcast(&AreaSystemRequestBus::Events::ClearAllAreas);
  93. AreaSystemRequestBus::Broadcast(&AreaSystemRequestBus::Events::RefreshAllAreas);
  94. }
  95. }