123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653 |
- // Copyright 2017-2021 marynate. All Rights Reserved.
- #include "EdGraph_ExtDependencyViewer.h"
- #include "EdGraphNode_ExtDependency.h"
- #include "ExtContentBrowserSingleton.h"
- #include "ExtAssetData.h"
- #include "ExtAssetThumbnail.h"
- #include "EdGraph/EdGraphPin.h"
- #include "AssetRegistry/ARFilter.h"
- #include "AssetRegistry/AssetRegistryModule.h"
- #include "AssetThumbnail.h"
- #include "SExtDependencyViewer.h"
- #include "SExtDependencyNode.h"
- #include "GraphEditor.h"
- #include "ICollectionManager.h"
- #include "CollectionManagerModule.h"
- #include "Engine/AssetManager.h"
- #include "AssetManagerEditorModule.h"
- #include "Logging/TokenizedMessage.h"
- UEdGraph_ExtDependencyViewer::UEdGraph_ExtDependencyViewer(const FObjectInitializer& ObjectInitializer)
- : Super(ObjectInitializer)
- {
- AssetThumbnailPool = MakeShareable( new FExtAssetThumbnailPool(1024) );
- MaxSearchDepth = 1;
- MaxSearchBreadth = 15;
- bLimitSearchDepth = true;
- bLimitSearchBreadth = false;
- bIsShowSoftReferences = true;
- bIsShowHardReferences = true;
- bIsShowManagementReferences = false;
- bIsShowSearchableNames = false;
- bIsShowNativePackages = true;
- NodeXSpacing = 400.f;
- }
- void UEdGraph_ExtDependencyViewer::BeginDestroy()
- {
- AssetThumbnailPool.Reset();
- Super::BeginDestroy();
- }
- void UEdGraph_ExtDependencyViewer::SetGraphRoot(const TArray<FExtAssetIdentifier>& GraphRootIdentifiers, const FIntPoint& GraphRootOrigin)
- {
- CurrentGraphRootIdentifiers = GraphRootIdentifiers;
- CurrentGraphRootOrigin = GraphRootOrigin;
- // If we're focused on a searchable name, enable that flag
- for (const FExtAssetIdentifier& AssetId : GraphRootIdentifiers)
- {
- if (AssetId.IsValue())
- {
- bIsShowSearchableNames = true;
- }
- else if (AssetId.GetPrimaryAssetId().IsValid())
- {
- if (UAssetManager::IsInitialized())
- {
- UAssetManager::Get().UpdateManagementDatabase();
- }
-
- bIsShowManagementReferences = true;
- }
- }
- }
- const TArray<FExtAssetIdentifier>& UEdGraph_ExtDependencyViewer::GetCurrentGraphRootIdentifiers() const
- {
- return CurrentGraphRootIdentifiers;
- }
- void UEdGraph_ExtDependencyViewer::SetReferenceViewer(TSharedPtr<SExtDependencyViewer> InViewer)
- {
- ReferenceViewer = InViewer;
- }
- bool UEdGraph_ExtDependencyViewer::GetSelectedAssetsForMenuExtender(const class UEdGraphNode* Node, TArray<FExtAssetIdentifier>& SelectedAssets) const
- {
- if (!ReferenceViewer.IsValid())
- {
- return false;
- }
- TSharedPtr<SGraphEditor> GraphEditor = ReferenceViewer.Pin()->GetGraphEditor();
- if (!GraphEditor.IsValid())
- {
- return false;
- }
- TSet<UObject*> SelectedNodes = GraphEditor->GetSelectedNodes();
- for (FGraphPanelSelectionSet::TConstIterator It(SelectedNodes); It; ++It)
- {
- if (UEdGraphNode_ExtDependency* ReferenceNode = Cast<UEdGraphNode_ExtDependency>(*It))
- {
- if (!ReferenceNode->IsCollapsed())
- {
- SelectedAssets.Add(ReferenceNode->GetIdentifier());
- }
- }
- }
- return true;
- }
- UEdGraphNode_ExtDependency* UEdGraph_ExtDependencyViewer::RebuildGraph()
- {
- RemoveAllNodes();
- UEdGraphNode_ExtDependency* NewRootNode = ConstructNodes(CurrentGraphRootIdentifiers, CurrentGraphRootOrigin);
- NotifyGraphChanged();
- return NewRootNode;
- }
- bool UEdGraph_ExtDependencyViewer::IsSearchDepthLimited() const
- {
- return bLimitSearchDepth;
- }
- bool UEdGraph_ExtDependencyViewer::IsSearchBreadthLimited() const
- {
- return bLimitSearchBreadth;
- }
- bool UEdGraph_ExtDependencyViewer::IsShowSoftReferences() const
- {
- return bIsShowSoftReferences;
- }
- bool UEdGraph_ExtDependencyViewer::IsShowHardReferences() const
- {
- return bIsShowHardReferences;
- }
- bool UEdGraph_ExtDependencyViewer::IsShowManagementReferences() const
- {
- return bIsShowManagementReferences;
- }
- bool UEdGraph_ExtDependencyViewer::IsShowSearchableNames() const
- {
- return bIsShowSearchableNames;
- }
- bool UEdGraph_ExtDependencyViewer::IsShowNativePackages() const
- {
- return bIsShowNativePackages;
- }
- void UEdGraph_ExtDependencyViewer::SetSearchDepthLimitEnabled(bool newEnabled)
- {
- bLimitSearchDepth = newEnabled;
- }
- void UEdGraph_ExtDependencyViewer::SetSearchBreadthLimitEnabled(bool newEnabled)
- {
- bLimitSearchBreadth = newEnabled;
- }
- void UEdGraph_ExtDependencyViewer::SetShowSoftReferencesEnabled(bool newEnabled)
- {
- bIsShowSoftReferences = newEnabled;
- }
- void UEdGraph_ExtDependencyViewer::SetShowHardReferencesEnabled(bool newEnabled)
- {
- bIsShowHardReferences = newEnabled;
- }
- void UEdGraph_ExtDependencyViewer::SetShowManagementReferencesEnabled(bool newEnabled)
- {
- bIsShowManagementReferences = newEnabled;
- }
- void UEdGraph_ExtDependencyViewer::SetShowSearchableNames(bool newEnabled)
- {
- bIsShowSearchableNames = newEnabled;
- }
- void UEdGraph_ExtDependencyViewer::SetShowNativePackages(bool newEnabled)
- {
- bIsShowNativePackages = newEnabled;
- }
- int32 UEdGraph_ExtDependencyViewer::GetSearchDepthLimit() const
- {
- return MaxSearchDepth;
- }
- int32 UEdGraph_ExtDependencyViewer::GetSearchBreadthLimit() const
- {
- return MaxSearchBreadth;
- }
- void UEdGraph_ExtDependencyViewer::SetSearchDepthLimit(int32 NewDepthLimit)
- {
- MaxSearchDepth = NewDepthLimit;
- }
- void UEdGraph_ExtDependencyViewer::SetSearchBreadthLimit(int32 NewBreadthLimit)
- {
- MaxSearchBreadth = NewBreadthLimit;
- }
- FName UEdGraph_ExtDependencyViewer::GetCurrentCollectionFilter() const
- {
- return CurrentCollectionFilter;
- }
- void UEdGraph_ExtDependencyViewer::SetCurrentCollectionFilter(FName NewFilter)
- {
- CurrentCollectionFilter = NewFilter;
- }
- bool UEdGraph_ExtDependencyViewer::GetEnableCollectionFilter() const
- {
- return bEnableCollectionFilter;
- }
- void UEdGraph_ExtDependencyViewer::SetEnableCollectionFilter(bool bEnabled)
- {
- bEnableCollectionFilter = bEnabled;
- }
- float UEdGraph_ExtDependencyViewer::GetNodeXSpacing() const
- {
- return NodeXSpacing;
- }
- void UEdGraph_ExtDependencyViewer::SetNodeXSpacing(float NewNodeXSpacing)
- {
- #if ECB_FEA_REF_VIEWER_NODE_SPACING
- NodeXSpacing = FMath::Clamp<float>(NewNodeXSpacing, 200.f, 10000.f);
- #endif
- }
- FAssetManagerDependencyQuery UEdGraph_ExtDependencyViewer::GetReferenceSearchFlags(bool bHardOnly) const
- {
- using namespace UE::AssetRegistry;
- FAssetManagerDependencyQuery Query;
- Query.Categories = EDependencyCategory::None;
- Query.Flags = EDependencyQuery::NoRequirements;
- bool bLocalIsShowSoftReferences = bIsShowSoftReferences && !bHardOnly;
- if (bLocalIsShowSoftReferences || bIsShowHardReferences)
- {
- Query.Categories |= EDependencyCategory::Package;
- Query.Flags |= bLocalIsShowSoftReferences ? EDependencyQuery::NoRequirements : EDependencyQuery::Hard;
- Query.Flags |= bIsShowHardReferences ? EDependencyQuery::NoRequirements : EDependencyQuery::Soft;
- //Query.Flags |= Settings->IsShowEditorOnlyReferences() ? EDependencyQuery::NoRequirements : EDependencyQuery::Game;
- }
- if (bIsShowSearchableNames && !bHardOnly)
- {
- Query.Categories |= EDependencyCategory::SearchableName;
- }
- if (bIsShowManagementReferences)
- {
- Query.Categories |= EDependencyCategory::Manage;
- Query.Flags |= bHardOnly ? EDependencyQuery::Direct : EDependencyQuery::NoRequirements;
- }
- return Query;
- }
- UEdGraphNode_ExtDependency* UEdGraph_ExtDependencyViewer::ConstructNodes(const TArray<FExtAssetIdentifier>& GraphRootIdentifiers, const FIntPoint& GraphRootOrigin )
- {
- UEdGraphNode_ExtDependency* RootNode = NULL;
- if (GraphRootIdentifiers.Num() > 0 )
- {
- TSet<FName> AllowedPackageNames;
- if (ShouldFilterByCollection())
- {
- FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
- TArray<FSoftObjectPath> AssetPaths;
- CollectionManagerModule.Get().GetAssetsInCollection(CurrentCollectionFilter, ECollectionShareType::CST_All, AssetPaths);
- AllowedPackageNames.Reserve(AssetPaths.Num());
- for (FSoftObjectPath& AssetPath : AssetPaths)
- {
- AllowedPackageNames.Add(FName(*FPackageName::ObjectPathToPackageName(AssetPath.ToString())));
- }
- }
- TMap<FExtAssetIdentifier, int32> ReferencerNodeSizes;
- TSet<FExtAssetIdentifier> VisitedReferencerSizeNames;
- int32 ReferencerDepth = 1;
- RecursivelyGatherSizes(/*bReferencers=*/true, GraphRootIdentifiers, AllowedPackageNames, ReferencerDepth, VisitedReferencerSizeNames, ReferencerNodeSizes);
- TMap<FExtAssetIdentifier, int32> DependencyNodeSizes;
- TSet<FExtAssetIdentifier> VisitedDependencySizeNames;
- int32 DependencyDepth = 1;
- RecursivelyGatherSizes(/*bReferencers=*/false, GraphRootIdentifiers, AllowedPackageNames, DependencyDepth, VisitedDependencySizeNames, DependencyNodeSizes);
- TSet<FName> AllPackageNames;
- auto AddPackage = [](const FExtAssetIdentifier& AssetId, TSet<FName>& PackageNames)
- {
- // Only look for asset data if this is a package
- if (!AssetId.IsValue())
- {
- PackageNames.Add(AssetId.PackageName);
- }
- };
- for (const FExtAssetIdentifier& AssetId : VisitedReferencerSizeNames)
- {
- AddPackage(AssetId, AllPackageNames);
- }
- for (const FExtAssetIdentifier& AssetId : VisitedDependencySizeNames)
- {
- AddPackage(AssetId, AllPackageNames);
- }
- TMap<FName, FExtAssetData> PackagesToAssetDataMap;
- GatherAssetData(AllPackageNames, PackagesToAssetDataMap);
- // Create the root node
- RootNode = CreateReferenceNode();
- RootNode->SetupReferenceNode(GraphRootOrigin, GraphRootIdentifiers, PackagesToAssetDataMap.FindRef(GraphRootIdentifiers[0].PackageName));
- TSet<FExtAssetIdentifier> VisitedReferencerNames;
- int32 VisitedReferencerDepth = 1;
- RecursivelyConstructNodes(/*bReferencers=*/true, RootNode, GraphRootIdentifiers, GraphRootOrigin, ReferencerNodeSizes, PackagesToAssetDataMap, AllowedPackageNames, VisitedReferencerDepth, VisitedReferencerNames);
- TSet<FExtAssetIdentifier> VisitedDependencyNames;
- int32 VisitedDependencyDepth = 1;
- RecursivelyConstructNodes(/*bReferencers=*/false, RootNode, GraphRootIdentifiers, GraphRootOrigin, DependencyNodeSizes, PackagesToAssetDataMap, AllowedPackageNames, VisitedDependencyDepth, VisitedDependencyNames);
- }
- return RootNode;
- }
- int32 UEdGraph_ExtDependencyViewer::RecursivelyGatherSizes(bool bReferencers, const TArray<FExtAssetIdentifier>& Identifiers, const TSet<FName>& AllowedPackageNames, int32 CurrentDepth, TSet<FExtAssetIdentifier>& VisitedNames, TMap<FExtAssetIdentifier, int32>& OutNodeSizes) const
- {
- check(Identifiers.Num() > 0);
- VisitedNames.Append(Identifiers);
- FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
- TArray<FExtAssetIdentifier> ReferenceNames;
- const FAssetManagerDependencyQuery DependencyQuery = GetReferenceSearchFlags(false);
- if ( bReferencers )
- {
- for (const FExtAssetIdentifier& AssetId : Identifiers)
- {
- FExtContentBrowserSingleton::GetAssetRegistry().GetReferencers(AssetId, ReferenceNames, DependencyQuery.Categories);
- }
- }
- else
- {
- for (const FExtAssetIdentifier& AssetId : Identifiers)
- {
- FExtContentBrowserSingleton::GetAssetRegistry().GetDependencies(AssetId, ReferenceNames, DependencyQuery.Categories);
- }
- }
- if (!bIsShowNativePackages)
- {
- auto RemoveNativePackage = [](const FExtAssetIdentifier& InAsset) { return InAsset.PackageName.ToString().StartsWith(TEXT("/Script")) && !InAsset.IsValue(); };
- ReferenceNames.RemoveAll(RemoveNativePackage);
- }
- int32 NodeSize = 0;
- if ( ReferenceNames.Num() > 0 && !ExceedsMaxSearchDepth(CurrentDepth) )
- {
- int32 NumReferencesMade = 0;
- int32 NumReferencesExceedingMax = 0;
- #if ECB_LEGACY
- // Filter for our registry source
- IAssetManagerEditorModule::Get().FilterAssetIdentifiersForCurrentRegistrySource(ReferenceNames, GetReferenceSearchFlags(false), !bReferencers);
- #endif
- // Since there are referencers, use the size of all your combined referencers.
- // Do not count your own size since there could just be a horizontal line of nodes
- for (FExtAssetIdentifier& AssetId : ReferenceNames)
- {
- if ( !VisitedNames.Contains(AssetId) && (!AssetId.IsPackage() || !ShouldFilterByCollection() || AllowedPackageNames.Contains(AssetId.PackageName)) )
- {
- if ( !ExceedsMaxSearchBreadth(NumReferencesMade) )
- {
- TArray<FExtAssetIdentifier> NewPackageNames;
- NewPackageNames.Add(AssetId);
- NodeSize += RecursivelyGatherSizes(bReferencers, NewPackageNames, AllowedPackageNames, CurrentDepth + 1, VisitedNames, OutNodeSizes);
- NumReferencesMade++;
- }
- else
- {
- NumReferencesExceedingMax++;
- }
- }
- }
- if ( NumReferencesExceedingMax > 0 )
- {
- // Add one size for the collapsed node
- NodeSize++;
- }
- }
- if ( NodeSize == 0 )
- {
- // If you have no valid children, the node size is just 1 (counting only self to make a straight line)
- NodeSize = 1;
- }
- OutNodeSizes.Add(Identifiers[0], NodeSize);
- return NodeSize;
- }
- void UEdGraph_ExtDependencyViewer::GatherAssetData(const TSet<FName>& AllPackageNames, TMap<FName, FExtAssetData>& OutPackageToAssetDataMap) const
- {
- FARFilter Filter;
- for ( auto PackageIt = AllPackageNames.CreateConstIterator(); PackageIt; ++PackageIt )
- {
- const FString& PackageName = (*PackageIt).ToString();
- //const FString& PackagePath = PackageName + TEXT(".") + FPackageName::GetLongPackageAssetName(PackageName);
- //Filter.ObjectPaths.Add( FName(*PackagePath) );
- Filter.PackageNames.Add(FName(*PackageName));
- }
- TArray<FExtAssetData> AssetDataList;
- FExtContentBrowserSingleton::GetAssetRegistry().GetAssets(Filter, AssetDataList);
- for ( auto AssetIt = AssetDataList.CreateConstIterator(); AssetIt; ++AssetIt )
- {
- OutPackageToAssetDataMap.Add((*AssetIt).PackageName, *AssetIt);
- }
- }
- UEdGraphNode_ExtDependency* UEdGraph_ExtDependencyViewer::RecursivelyConstructNodes(bool bReferencers, UEdGraphNode_ExtDependency* RootNode, const TArray<FExtAssetIdentifier>& Identifiers, const FIntPoint& NodeLoc, const TMap<FExtAssetIdentifier, int32>& NodeSizes, const TMap<FName, FExtAssetData>& PackagesToAssetDataMap, const TSet<FName>& AllowedPackageNames, int32 CurrentDepth, TSet<FExtAssetIdentifier>& VisitedNames)
- {
- check(Identifiers.Num() > 0);
- VisitedNames.Append(Identifiers);
- UEdGraphNode_ExtDependency* NewNode = NULL;
- if ( RootNode->GetIdentifier() == Identifiers[0] )
- {
- // Don't create the root node. It is already created!
- NewNode = RootNode;
- }
- else
- {
- NewNode = CreateReferenceNode();
- NewNode->SetupReferenceNode(NodeLoc, Identifiers, PackagesToAssetDataMap.FindRef(Identifiers[0].PackageName));
- }
- FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
- TArray<FExtAssetIdentifier> ReferenceNames;
- TArray<FExtAssetIdentifier> HardReferenceNames;
- const FAssetManagerDependencyQuery HardOnlyDependencyQuery = GetReferenceSearchFlags(true);
- const FAssetManagerDependencyQuery DependencyQuery = GetReferenceSearchFlags(false);
- if ( bReferencers )
- {
- for (const FExtAssetIdentifier& AssetId : Identifiers)
- {
- FExtContentBrowserSingleton::GetAssetRegistry().GetReferencers(AssetId, HardReferenceNames, HardOnlyDependencyQuery.Categories);
- FExtContentBrowserSingleton::GetAssetRegistry().GetReferencers(AssetId, ReferenceNames, DependencyQuery.Categories);
- }
- }
- else
- {
- for (const FExtAssetIdentifier& AssetId : Identifiers)
- {
- FExtContentBrowserSingleton::GetAssetRegistry().GetDependencies(AssetId, HardReferenceNames, HardOnlyDependencyQuery.Categories);
- FExtContentBrowserSingleton::GetAssetRegistry().GetDependencies(AssetId, ReferenceNames, DependencyQuery.Categories);
- }
- }
- if (!bIsShowNativePackages)
- {
- auto RemoveNativePackage = [](const FExtAssetIdentifier& InAsset) { return InAsset.PackageName.ToString().StartsWith(TEXT("/Script")) && !InAsset.IsValue(); };
- HardReferenceNames.RemoveAll(RemoveNativePackage);
- ReferenceNames.RemoveAll(RemoveNativePackage);
- }
- if ( ReferenceNames.Num() > 0 && !ExceedsMaxSearchDepth(CurrentDepth) )
- {
- FIntPoint ReferenceNodeLoc = NodeLoc;
- if ( bReferencers )
- {
- // Referencers go left
- ReferenceNodeLoc.X -= NodeXSpacing;
- }
- else
- {
- // Dependencies go right
- ReferenceNodeLoc.X += NodeXSpacing;
- }
- const int32 NodeSizeY = 200;
- const int32 TotalReferenceSizeY = NodeSizes.FindChecked(Identifiers[0]) * NodeSizeY;
- ReferenceNodeLoc.Y -= TotalReferenceSizeY * 0.5f;
- ReferenceNodeLoc.Y += NodeSizeY * 0.5f;
- int32 NumReferencesMade = 0;
- int32 NumReferencesExceedingMax = 0;
- #if ECB_LEGACY
- // Filter for our registry source
- IAssetManagerEditorModule::Get().FilterAssetIdentifiersForCurrentRegistrySource(ReferenceNames, GetReferenceSearchFlags(false), !bReferencers);
- IAssetManagerEditorModule::Get().FilterAssetIdentifiersForCurrentRegistrySource(HardReferenceNames, GetReferenceSearchFlags(false), !bReferencers);
- #endif
- for ( int32 RefIdx = 0; RefIdx < ReferenceNames.Num(); ++RefIdx )
- {
- FExtAssetIdentifier ReferenceName = ReferenceNames[RefIdx];
- if ( !VisitedNames.Contains(ReferenceName) && (!ReferenceName.IsPackage() || !ShouldFilterByCollection() || AllowedPackageNames.Contains(ReferenceName.PackageName)) )
- {
- bool bIsHardReference = HardReferenceNames.Contains(ReferenceName);
- if ( !ExceedsMaxSearchBreadth(NumReferencesMade) )
- {
- int32 ThisNodeSizeY = ReferenceName.IsValue() ? 100 : NodeSizeY;
- const int32 RefSizeY = NodeSizes.FindChecked(ReferenceName);
- FIntPoint RefNodeLoc;
- RefNodeLoc.X = ReferenceNodeLoc.X;
- RefNodeLoc.Y = ReferenceNodeLoc.Y + RefSizeY * ThisNodeSizeY * 0.5 - ThisNodeSizeY * 0.5;
-
- TArray<FExtAssetIdentifier> NewIdentifiers;
- NewIdentifiers.Add(ReferenceName);
-
- UEdGraphNode_ExtDependency* ReferenceNode = RecursivelyConstructNodes(bReferencers, RootNode, NewIdentifiers, RefNodeLoc, NodeSizes, PackagesToAssetDataMap, AllowedPackageNames, CurrentDepth + 1, VisitedNames);
- if (bIsHardReference)
- {
- if (bReferencers)
- {
- ReferenceNode->GetDependencyPin()->PinType.PinCategory = TEXT("hard");
- }
- else
- {
- ReferenceNode->GetReferencerPin()->PinType.PinCategory = TEXT("hard"); //-V595
- }
- }
- bool bIsMissingOrInvalid = ReferenceNode->IsMissingOrInvalid();
- if (bIsMissingOrInvalid)
- {
- if (bReferencers)
- {
- ReferenceNode->GetDependencyPin()->PinType.PinSubCategory = TEXT("invalid");
- }
- else
- {
- ReferenceNode->GetReferencerPin()->PinType.PinSubCategory = TEXT("invalid");
- }
- ReferenceNode->bHasCompilerMessage = true;
- if (!bIsHardReference)
- {
- ReferenceNode->ErrorType = EMessageSeverity::Warning;
- }
- else
- {
- ReferenceNode->ErrorType = EMessageSeverity::Error;
- }
- }
-
- if ( ensure(ReferenceNode) )
- {
- if ( bReferencers )
- {
- NewNode->AddReferencer( ReferenceNode );
- }
- else
- {
- ReferenceNode->AddReferencer( NewNode );
- }
- ReferenceNodeLoc.Y += RefSizeY * ThisNodeSizeY;
- }
- NumReferencesMade++;
- }
- else
- {
- NumReferencesExceedingMax++;
- }
- }
- }
- if ( NumReferencesExceedingMax > 0 )
- {
- // There are more references than allowed to be displayed. Make a collapsed node.
- UEdGraphNode_ExtDependency* ReferenceNode = CreateReferenceNode();
- FIntPoint RefNodeLoc;
- RefNodeLoc.X = ReferenceNodeLoc.X;
- RefNodeLoc.Y = ReferenceNodeLoc.Y;
- if ( ensure(ReferenceNode) )
- {
- ReferenceNode->SetReferenceNodeCollapsed(RefNodeLoc, NumReferencesExceedingMax);
- if ( bReferencers )
- {
- NewNode->AddReferencer( ReferenceNode );
- }
- else
- {
- ReferenceNode->AddReferencer( NewNode );
- }
- }
- }
- }
- return NewNode;
- }
- const TSharedPtr<FExtAssetThumbnailPool>& UEdGraph_ExtDependencyViewer::GetAssetThumbnailPool() const
- {
- return AssetThumbnailPool;
- }
- bool UEdGraph_ExtDependencyViewer::ExceedsMaxSearchDepth(int32 Depth) const
- {
- return bLimitSearchDepth && Depth > MaxSearchDepth;
- }
- bool UEdGraph_ExtDependencyViewer::ExceedsMaxSearchBreadth(int32 Breadth) const
- {
- return bLimitSearchBreadth && Breadth > MaxSearchBreadth;
- }
- UEdGraphNode_ExtDependency* UEdGraph_ExtDependencyViewer::CreateReferenceNode()
- {
- const bool bSelectNewNode = false;
- return Cast<UEdGraphNode_ExtDependency>(CreateNode(UEdGraphNode_ExtDependency::StaticClass(), bSelectNewNode));
- }
- void UEdGraph_ExtDependencyViewer::RemoveAllNodes()
- {
- TArray<UEdGraphNode*> NodesToRemove = Nodes;
- for (int32 NodeIndex = 0; NodeIndex < NodesToRemove.Num(); ++NodeIndex)
- {
- RemoveNode(NodesToRemove[NodeIndex]);
- }
- }
- bool UEdGraph_ExtDependencyViewer::ShouldFilterByCollection() const
- {
- return bEnableCollectionFilter && CurrentCollectionFilter != NAME_None;
- }
|