EdGraph_ExtDependencyViewer.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Copyright 2017-2021 marynate. All Rights Reserved.
  2. #pragma once
  3. #include "ExtAssetData.h"
  4. #include "CoreMinimal.h"
  5. #include "UObject/ObjectMacros.h"
  6. #include "EdGraph/EdGraph.h"
  7. #include "Misc/AssetRegistryInterface.h"
  8. #include "EdGraph_ExtDependencyViewer.generated.h"
  9. struct ExtAssetData;
  10. class FExtAssetThumbnailPool;
  11. class UEdGraphNode_ExtDependency;
  12. class SExtDependencyViewer;
  13. UCLASS()
  14. class UEdGraph_ExtDependencyViewer : public UEdGraph
  15. {
  16. GENERATED_UCLASS_BODY()
  17. public:
  18. // UObject implementation
  19. virtual void BeginDestroy() override;
  20. // End UObject implementation
  21. /** Set reference viewer to focus on these assets */
  22. void SetGraphRoot(const TArray<FExtAssetIdentifier>& GraphRootIdentifiers, const FIntPoint& GraphRootOrigin = FIntPoint(ForceInitToZero));
  23. /** Returns list of currently focused assets */
  24. const TArray<FExtAssetIdentifier>& GetCurrentGraphRootIdentifiers() const;
  25. /** If you're extending the reference viewer via GetAllGraphEditorContextMenuExtender you can use this to get the list of selected assets to use in your menu extender */
  26. bool GetSelectedAssetsForMenuExtender(const class UEdGraphNode* Node, TArray<FExtAssetIdentifier>& SelectedAssets) const;
  27. /** Accessor for the thumbnail pool in this graph */
  28. const TSharedPtr<class FExtAssetThumbnailPool>& GetAssetThumbnailPool() const;
  29. /** Force the graph to rebuild */
  30. class UEdGraphNode_ExtDependency* RebuildGraph();
  31. bool IsSearchDepthLimited() const;
  32. bool IsSearchBreadthLimited() const;
  33. bool IsShowSoftReferences() const;
  34. bool IsShowHardReferences() const;
  35. bool IsShowManagementReferences() const;
  36. bool IsShowSearchableNames() const;
  37. bool IsShowNativePackages() const;
  38. void SetSearchDepthLimitEnabled(bool newEnabled);
  39. void SetSearchBreadthLimitEnabled(bool newEnabled);
  40. void SetShowSoftReferencesEnabled(bool newEnabled);
  41. void SetShowHardReferencesEnabled(bool newEnabled);
  42. void SetShowManagementReferencesEnabled(bool newEnabled);
  43. void SetShowSearchableNames(bool newEnabled);
  44. void SetShowNativePackages(bool newEnabled);
  45. int32 GetSearchDepthLimit() const;
  46. int32 GetSearchBreadthLimit() const;
  47. void SetSearchDepthLimit(int32 NewDepthLimit);
  48. void SetSearchBreadthLimit(int32 NewBreadthLimit);
  49. FName GetCurrentCollectionFilter() const;
  50. void SetCurrentCollectionFilter(FName NewFilter);
  51. bool GetEnableCollectionFilter() const;
  52. void SetEnableCollectionFilter(bool bEnabled);
  53. public:
  54. float GetNodeXSpacing() const;
  55. void SetNodeXSpacing(float NewNodeXSpacing);
  56. private:
  57. void SetReferenceViewer(TSharedPtr<SExtDependencyViewer> InViewer);
  58. UEdGraphNode_ExtDependency* ConstructNodes(const TArray<FExtAssetIdentifier>& GraphRootIdentifiers, const FIntPoint& GraphRootOrigin);
  59. int32 RecursivelyGatherSizes(bool bReferencers, const TArray<FExtAssetIdentifier>& Identifiers, const TSet<FName>& AllowedPackageNames, int32 CurrentDepth, TSet<FExtAssetIdentifier>& VisitedNames, TMap<FExtAssetIdentifier, int32>& OutNodeSizes) const;
  60. void GatherAssetData(const TSet<FName>& AllPackageNames, TMap<FName, FExtAssetData>& OutPackageToAssetDataMap) const;
  61. class UEdGraphNode_ExtDependency* 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);
  62. bool ExceedsMaxSearchDepth(int32 Depth) const;
  63. bool ExceedsMaxSearchBreadth(int32 Breadth) const;
  64. struct FAssetManagerDependencyQuery GetReferenceSearchFlags(bool bHardOnly) const;
  65. UEdGraphNode_ExtDependency* CreateReferenceNode();
  66. /** Removes all nodes from the graph */
  67. void RemoveAllNodes();
  68. /** Returns true if filtering is enabled and we have a valid collection */
  69. bool ShouldFilterByCollection() const;
  70. private:
  71. /** Pool for maintaining and rendering thumbnails */
  72. TSharedPtr<FExtAssetThumbnailPool> AssetThumbnailPool;
  73. /** Editor for this pool */
  74. TWeakPtr<SExtDependencyViewer> ReferenceViewer;
  75. TArray<FExtAssetIdentifier> CurrentGraphRootIdentifiers;
  76. FIntPoint CurrentGraphRootOrigin;
  77. int32 MaxSearchDepth;
  78. int32 MaxSearchBreadth;
  79. /** Current collection filter. NAME_None for no filter */
  80. FName CurrentCollectionFilter;
  81. bool bEnableCollectionFilter;
  82. bool bLimitSearchDepth;
  83. bool bLimitSearchBreadth;
  84. bool bIsShowSoftReferences;
  85. bool bIsShowHardReferences;
  86. bool bIsShowManagementReferences;
  87. bool bIsShowSearchableNames;
  88. bool bIsShowNativePackages;
  89. float NodeXSpacing;
  90. friend SExtDependencyViewer;
  91. };