144 lines
5.3 KiB
C++
144 lines
5.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "LoadingProfilerCommands.h"
|
|
|
|
#include "DesktopPlatformModule.h"
|
|
#include "Framework/Application/SlateApplication.h"
|
|
#include "Framework/MultiBox/MultiBoxBuilder.h"
|
|
|
|
// TraceInsights
|
|
#include "Insights/InsightsManager.h"
|
|
#include "Insights/InsightsStyle.h"
|
|
#include "Insights/LoadingProfiler/LoadingProfilerManager.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "UE::Insights::LoadingProfiler"
|
|
|
|
namespace UE::Insights::LoadingProfiler
|
|
{
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// FLoadingProfilerMenuBuilder
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void FLoadingProfilerMenuBuilder::AddMenuEntry(FMenuBuilder& MenuBuilder, const TSharedPtr< FUICommandInfo >& UICommandInfo, const FUIAction& UIAction)
|
|
{
|
|
MenuBuilder.AddMenuEntry
|
|
(
|
|
UICommandInfo->GetLabel(),
|
|
UICommandInfo->GetDescription(),
|
|
UICommandInfo->GetIcon(),
|
|
UIAction,
|
|
NAME_None,
|
|
UICommandInfo->GetUserInterfaceType()
|
|
);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// FLoadingProfilerCommands
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
FLoadingProfilerCommands::FLoadingProfilerCommands()
|
|
: TCommands<FLoadingProfilerCommands>(
|
|
TEXT("LoadingProfilerCommands"),
|
|
NSLOCTEXT("Contexts", "LoadingProfilerCommands", "Insights - Asset Loading Insights"),
|
|
NAME_None,
|
|
FInsightsStyle::GetStyleSetName())
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// UI_COMMAND takes long for the compiler to optimize
|
|
UE_DISABLE_OPTIMIZATION_SHIP
|
|
void FLoadingProfilerCommands::RegisterCommands()
|
|
{
|
|
UI_COMMAND(ToggleTimingViewVisibility,
|
|
"Timing",
|
|
"Toggles the visibility of the main Timing view.",
|
|
EUserInterfaceActionType::ToggleButton,
|
|
FInputChord());
|
|
|
|
UI_COMMAND(ToggleEventAggregationTreeViewVisibility,
|
|
"Event Aggregation",
|
|
"Toggles the visibility of the Event Aggregation table/tree view.",
|
|
EUserInterfaceActionType::ToggleButton,
|
|
FInputChord());
|
|
|
|
UI_COMMAND(ToggleObjectTypeAggregationTreeViewVisibility,
|
|
"Object Type Aggregation",
|
|
"Toggles the visibility of the Object Type Aggregation table/tree view.",
|
|
EUserInterfaceActionType::ToggleButton,
|
|
FInputChord());
|
|
|
|
UI_COMMAND(TogglePackageDetailsTreeViewVisibility,
|
|
"Package Details",
|
|
"Toggles the visibility of the Package Details table/tree view.",
|
|
EUserInterfaceActionType::ToggleButton,
|
|
FInputChord());
|
|
|
|
UI_COMMAND(ToggleExportDetailsTreeViewVisibility,
|
|
"Export Details",
|
|
"Toggles the visibility of the Export Details table/tree view.",
|
|
EUserInterfaceActionType::ToggleButton,
|
|
FInputChord());
|
|
|
|
UI_COMMAND(ToggleRequestsTreeViewVisibility,
|
|
"Requests",
|
|
"Toggles the visibility of the Requests table/tree view.",
|
|
EUserInterfaceActionType::ToggleButton,
|
|
FInputChord());
|
|
}
|
|
UE_ENABLE_OPTIMIZATION_SHIP
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Toggle Commands
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define IMPLEMENT_TOGGLE_COMMAND(CmdName, IsEnabled, SetIsEnabled) \
|
|
\
|
|
void FLoadingProfilerActionManager::Map_##CmdName##_Global()\
|
|
{\
|
|
This->CommandList->MapAction(This->GetCommands().CmdName, CmdName##_Custom());\
|
|
}\
|
|
\
|
|
const FUIAction FLoadingProfilerActionManager::CmdName##_Custom() \
|
|
{\
|
|
FUIAction UIAction;\
|
|
UIAction.ExecuteAction = FExecuteAction::CreateRaw(this, &FLoadingProfilerActionManager::CmdName##_Execute);\
|
|
UIAction.CanExecuteAction = FCanExecuteAction::CreateRaw(this, &FLoadingProfilerActionManager::CmdName##_CanExecute);\
|
|
UIAction.GetActionCheckState = FGetActionCheckState::CreateRaw(this, &FLoadingProfilerActionManager::CmdName##_GetCheckState);\
|
|
return UIAction;\
|
|
}\
|
|
\
|
|
void FLoadingProfilerActionManager::CmdName##_Execute()\
|
|
{\
|
|
const bool b##IsEnabled = !This->IsEnabled();\
|
|
This->SetIsEnabled(b##IsEnabled);\
|
|
}\
|
|
\
|
|
bool FLoadingProfilerActionManager::CmdName##_CanExecute() const\
|
|
{\
|
|
return FInsightsManager::Get()->GetSession().IsValid();\
|
|
}\
|
|
\
|
|
ECheckBoxState FLoadingProfilerActionManager::CmdName##_GetCheckState() const\
|
|
{\
|
|
const bool b##IsEnabled = This->IsEnabled();\
|
|
return b##IsEnabled ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;\
|
|
}
|
|
|
|
IMPLEMENT_TOGGLE_COMMAND(ToggleTimingViewVisibility, IsTimingViewVisible, ShowHideTimingView)
|
|
IMPLEMENT_TOGGLE_COMMAND(ToggleEventAggregationTreeViewVisibility, IsEventAggregationTreeViewVisible, ShowHideEventAggregationTreeView)
|
|
IMPLEMENT_TOGGLE_COMMAND(ToggleObjectTypeAggregationTreeViewVisibility, IsObjectTypeAggregationTreeViewVisible, ShowHideObjectTypeAggregationTreeView)
|
|
IMPLEMENT_TOGGLE_COMMAND(TogglePackageDetailsTreeViewVisibility, IsPackageDetailsTreeViewVisible, ShowHidePackageDetailsTreeView)
|
|
IMPLEMENT_TOGGLE_COMMAND(ToggleExportDetailsTreeViewVisibility, IsExportDetailsTreeViewVisible, ShowHideExportDetailsTreeView)
|
|
IMPLEMENT_TOGGLE_COMMAND(ToggleRequestsTreeViewVisibility, IsRequestsTreeViewVisible, ShowHideRequestsTreeView)
|
|
|
|
#undef IMPLEMENT_TOGGLE_COMMAND
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
} // namespace UE::Insights::LoadingProfiler
|
|
|
|
#undef LOCTEXT_NAMESPACE
|