You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
4.4 KiB
C++
109 lines
4.4 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#include "EditorDebugComponent.h"
|
|
|
|
#include <AzCore/Serialization/Utils.h>
|
|
#include <AzCore/base.h>
|
|
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
|
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
|
|
|
#include <Vegetation/Ebuses/AreaSystemRequestBus.h>
|
|
#include <Vegetation/Ebuses/InstanceSystemRequestBus.h>
|
|
#include <VegetationSystemComponent.h>
|
|
|
|
#include <ISystem.h>
|
|
#include <IConsole.h>
|
|
|
|
namespace Vegetation
|
|
{
|
|
namespace EditorDebugComponentVersionUtility
|
|
{
|
|
bool VersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement)
|
|
{
|
|
EditorVegetationComponentBaseVersionConverter<DebugComponent, DebugConfig>(context, classElement);
|
|
|
|
if (classElement.GetVersion() < 2)
|
|
{
|
|
classElement.RemoveElementByName(AZ_CRC("FilerTypeLevel", 0x246c4e16));
|
|
classElement.RemoveElementByName(AZ_CRC("SortType", 0xdd2117e6));
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
void EditorDebugComponent::Reflect(AZ::ReflectContext* context)
|
|
{
|
|
BaseClassType::Reflect(context);
|
|
|
|
AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
|
|
if (serialize)
|
|
{
|
|
serialize->Class<EditorDebugComponent, BaseClassType>()
|
|
->Version(2, &EditorDebugComponentVersionUtility::VersionConverter)
|
|
;
|
|
|
|
AZ::EditContext* edit = serialize->GetEditContext();
|
|
if (edit)
|
|
{
|
|
edit->Class<EditorDebugComponent>(
|
|
s_componentName, s_componentDescription)
|
|
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
|
->Attribute(AZ::Edit::Attributes::Icon, s_icon)
|
|
->Attribute(AZ::Edit::Attributes::ViewportIcon, s_viewportIcon)
|
|
->Attribute(AZ::Edit::Attributes::HelpPageURL, s_helpUrl)
|
|
->Attribute(AZ::Edit::Attributes::Category, s_categoryName)
|
|
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Level", 0x9aeacc13))
|
|
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
|
->UIElement(AZ::Edit::UIHandlers::Button, "")
|
|
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugComponent::OnDumpDataToFile)
|
|
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
|
|
->Attribute(AZ::Edit::Attributes::ButtonText, "Dump Performance Log")
|
|
->UIElement(AZ::Edit::UIHandlers::Button, "")
|
|
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugComponent::OnClearReport)
|
|
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
|
|
->Attribute(AZ::Edit::Attributes::ButtonText, "Clear Performance Log")
|
|
->UIElement(AZ::Edit::UIHandlers::Button, "")
|
|
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugComponent::OnRefreshAllAreas)
|
|
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
|
|
->Attribute(AZ::Edit::Attributes::ButtonText, "Refresh All Areas")
|
|
->UIElement(AZ::Edit::UIHandlers::Button, "")
|
|
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorDebugComponent::OnClearAllAreas)
|
|
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
|
|
->Attribute(AZ::Edit::Attributes::ButtonText, "Clear All Areas")
|
|
;
|
|
}
|
|
}
|
|
}
|
|
|
|
void EditorDebugComponent::Activate()
|
|
{
|
|
BaseClassType::Activate();
|
|
}
|
|
|
|
void EditorDebugComponent::OnDumpDataToFile()
|
|
{
|
|
m_component.ExportCurrentReport();
|
|
}
|
|
|
|
void EditorDebugComponent::OnClearReport()
|
|
{
|
|
m_component.ClearPerformanceReport();
|
|
}
|
|
|
|
void EditorDebugComponent::OnRefreshAllAreas()
|
|
{
|
|
AreaSystemRequestBus::Broadcast(&AreaSystemRequestBus::Events::RefreshAllAreas);
|
|
}
|
|
|
|
void EditorDebugComponent::OnClearAllAreas()
|
|
{
|
|
AreaSystemRequestBus::Broadcast(&AreaSystemRequestBus::Events::ClearAllAreas);
|
|
AreaSystemRequestBus::Broadcast(&AreaSystemRequestBus::Events::RefreshAllAreas);
|
|
}
|
|
}
|