-
Notifications
You must be signed in to change notification settings - Fork 348
Expand file tree
/
Copy pathFlowActorDetails.cpp
More file actions
57 lines (48 loc) · 2 KB
/
FlowActorDetails.cpp
File metadata and controls
57 lines (48 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Fill out your copyright notice in the Description page of Project Settings.
#include "DetailCustomizations/FlowActorDetails.h"
#include "ActorDetailsDelegates.h"
#include "DetailCategoryBuilder.h"
#include "DetailLayoutBuilder.h"
#include "FlowComponent.h"
#include "Graph/FlowGraphSettings.h"
FFlowActorDetails::~FFlowActorDetails()
{
OnExtendActorDetails.RemoveAll(this);
}
void FFlowActorDetails::Register()
{
if (GetDefault<UFlowGraphSettings>()->bShowFlowTagsInActorDetails)
{
OnExtendActorDetails.AddSP(this, &FFlowActorDetails::AddFlowCategory);
}
}
void FFlowActorDetails::AddFlowCategory(class IDetailLayoutBuilder& Details, const FGetSelectedActors& GetSelectedActors)
{
if (GetSelectedActors.IsBound())
{
TArray<UObject*> Components;
const TArray<TWeakObjectPtr<AActor>>& SelectedActors = GetSelectedActors.Execute();
for (auto& WeakActor : SelectedActors)
{
if (const AActor* Actor = WeakActor.Get())
{
TInlineComponentArray<UFlowComponent*> FlowComps(Actor);
Components.Append(FlowComps);
}
}
if (!Components.IsEmpty())
{
const ECategoryPriority::Type Priority = GetDefault<UFlowGraphSettings>()->bMarkFlowCategoryImportant ? ECategoryPriority::Important : ECategoryPriority::Default;
const FText CategoryName = FText::Format(NSLOCTEXT("FlowDetails", "FlowCategoryFormat", "Flow Components: {0} "), FText::AsNumber(Components.Num()));
const FString Tooltip = FString::JoinBy(Components, LINE_TERMINATOR, [](const UObject* Object)
{
const UActorComponent* Component = CastChecked<UActorComponent>(Object);
const FString Actor = Component->GetOwner() ? Component->GetOwner()->GetActorNameOrLabel() : TEXT("None");
return FString(Actor + TEXT(".") + Object->GetName());
});
IDetailCategoryBuilder& Category = Details.EditCategory(TEXT("_FlowDetails"), CategoryName, Priority);
Category.SetToolTip(FText::FromString(Tooltip));
Category.AddExternalObjectProperty(Components, GET_MEMBER_NAME_CHECKED(UFlowComponent, IdentityTags));
}
}
}