SExtDependencyViewer.cpp 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898
  1. // Copyright 2017-2021 marynate. All Rights Reserved.
  2. #include "SExtDependencyViewer.h"
  3. #include "EdGraph_ExtDependencyViewer.h"
  4. #include "EdGraphNode_ExtDependency.h"
  5. #include "ExtDependencyViewerSchema.h"
  6. #include "ExtContentBrowserSingleton.h"
  7. #include "ExtAssetData.h"
  8. #include "ExtContentBrowserSettings.h"
  9. #include "ExtDependencyViewerCommands.h"
  10. #include "Widgets/SOverlay.h"
  11. #include "Engine/GameViewportClient.h"
  12. #include "Dialogs/Dialogs.h"
  13. #include "Misc/MessageDialog.h"
  14. #include "Misc/ScopedSlowTask.h"
  15. #include "Modules/ModuleManager.h"
  16. #include "Widgets/SBoxPanel.h"
  17. #include "Widgets/Layout/SBorder.h"
  18. #include "Widgets/Images/SImage.h"
  19. #include "Widgets/Text/STextBlock.h"
  20. #include "Widgets/Layout/SBox.h"
  21. #include "Widgets/Input/SEditableTextBox.h"
  22. #include "Widgets/Input/SButton.h"
  23. #include "Widgets/Input/SCheckBox.h"
  24. #include "Widgets/Input/SSearchBox.h"
  25. #include "Widgets/Input/SSpinBox.h"
  26. #include "Widgets/Input/SComboButton.h"
  27. #include "Widgets/Input/SSlider.h"
  28. #include "EditorStyleSet.h"
  29. #include "Engine/Selection.h"
  30. #include "AssetRegistry/AssetRegistryModule.h"
  31. #include "ICollectionManager.h"
  32. #include "CollectionManagerModule.h"
  33. #include "Editor.h"
  34. #include "EditorWidgetsModule.h"
  35. #include "Toolkits/GlobalEditorCommonCommands.h"
  36. #include "Engine/AssetManager.h"
  37. #include "Widgets/Input/SComboBox.h"
  38. #include "HAL/PlatformApplicationMisc.h"
  39. #include "Framework/Application/SlateApplication.h"
  40. #include "Framework/MultiBox/MultiBoxBuilder.h"
  41. #include "ObjectTools.h"
  42. #define LOCTEXT_NAMESPACE "ExtDependencyViewer"
  43. SExtDependencyViewer::~SExtDependencyViewer()
  44. {
  45. if (!GExitPurge)
  46. {
  47. if ( ensure(GraphObj) )
  48. {
  49. GraphObj->RemoveFromRoot();
  50. }
  51. }
  52. }
  53. void SExtDependencyViewer::Construct(const FArguments& InArgs)
  54. {
  55. // Create an action list and register commands
  56. RegisterActions();
  57. // Set up the history manager
  58. HistoryManager.SetOnApplyHistoryData(FOnApplyExtRefHistoryData::CreateSP(this, &SExtDependencyViewer::OnApplyHistoryData));
  59. HistoryManager.SetOnUpdateHistoryData(FOnUpdateExtRefHistoryData::CreateSP(this, &SExtDependencyViewer::OnUpdateHistoryData));
  60. // Fill out CollectionsComboList
  61. {
  62. TArray<FName> CollectionNames;
  63. FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
  64. CollectionManagerModule.Get().GetCollectionNames(ECollectionShareType::CST_All, CollectionNames);
  65. CollectionNames.Sort([](const FName& A, const FName& B) { return A.Compare(B) < 0; });
  66. CollectionsComboList.Add(MakeShareable(new FName(NAME_None)));
  67. for (FName CollectionName : CollectionNames)
  68. {
  69. CollectionsComboList.Add(MakeShareable(new FName(CollectionName)));
  70. }
  71. }
  72. // Create the graph
  73. GraphObj = NewObject<UEdGraph_ExtDependencyViewer>();
  74. GraphObj->Schema = UExtDependencyViewerSchema::StaticClass();
  75. GraphObj->AddToRoot();
  76. GraphObj->SetReferenceViewer(StaticCastSharedRef<SExtDependencyViewer>(AsShared()));
  77. SGraphEditor::FGraphEditorEvents GraphEvents;
  78. GraphEvents.OnNodeDoubleClicked = FSingleNodeEvent::CreateSP(this, &SExtDependencyViewer::OnNodeDoubleClicked);
  79. GraphEvents.OnCreateActionMenu = SGraphEditor::FOnCreateActionMenu::CreateSP(this, &SExtDependencyViewer::OnCreateGraphActionMenu);
  80. // Create the graph editor
  81. GraphEditorPtr = SNew(SGraphEditor)
  82. .AdditionalCommands(ReferenceViewerActions)
  83. .GraphToEdit(GraphObj)
  84. .GraphEvents(GraphEvents)
  85. .OnNavigateHistoryBack(FSimpleDelegate::CreateSP(this, &SExtDependencyViewer::GraphNavigateHistoryBack))
  86. .OnNavigateHistoryForward(FSimpleDelegate::CreateSP(this, &SExtDependencyViewer::GraphNavigateHistoryForward));
  87. FEditorWidgetsModule& EditorWidgetsModule = FModuleManager::LoadModuleChecked<FEditorWidgetsModule>("EditorWidgets");
  88. TSharedRef<SWidget> AssetDiscoveryIndicator = EditorWidgetsModule.CreateAssetDiscoveryIndicator(EAssetDiscoveryIndicatorScaleMode::Scale_None, FMargin(16, 8), false);
  89. static const FName DefaultForegroundName("DefaultForeground");
  90. ChildSlot
  91. [
  92. SNew(SVerticalBox)
  93. #if ECB_TODO
  94. // Title Bar>>
  95. + SVerticalBox::Slot()
  96. .AutoHeight()
  97. .Padding(0, 2, 0, 1)
  98. [
  99. SNew(SBorder)
  100. .BorderImage(FAppStyle::GetBrush(TEXT("Graph.TitleBackground")))
  101. .HAlign(HAlign_Fill)
  102. [
  103. SNew(SHorizontalBox)
  104. + SHorizontalBox::Slot()
  105. .HAlign(HAlign_Center)
  106. .FillWidth(1.f)
  107. [
  108. SNew(STextBlock)
  109. .Text(LOCTEXT("DepencencyViewerGraphLabel", "Dependency Viewer"))
  110. .TextStyle(FAppStyle::Get(), TEXT("GraphBreadcrumbButtonText"))
  111. ]
  112. ]
  113. ]
  114. // Title Bar <<
  115. #endif
  116. #if ECB_WIP_REF_VIEWER_HISTORY
  117. // Path and history
  118. +SVerticalBox::Slot()
  119. .AutoHeight()
  120. .Padding( 0, 0, 0, 4 )
  121. [
  122. SNew(SHorizontalBox)
  123. // History Back Button
  124. +SHorizontalBox::Slot()
  125. .AutoWidth()
  126. .VAlign(VAlign_Center)
  127. .Padding(1,0)
  128. [
  129. SNew(SButton)
  130. .ButtonStyle( FAppStyle::Get(), "HoverHintOnly" )
  131. .ForegroundColor( FAppStyle::GetSlateColor(DefaultForegroundName) )
  132. .ToolTipText( this, &SExtDependencyViewer::GetHistoryBackTooltip )
  133. .ContentPadding( 0 )
  134. .OnClicked(this, &SExtDependencyViewer::BackClicked)
  135. .IsEnabled(this, &SExtDependencyViewer::IsBackEnabled)
  136. [
  137. SNew(SImage) .Image(FAppStyle::GetBrush("ContentBrowser.HistoryBack"))
  138. ]
  139. ]
  140. // History Forward Button
  141. +SHorizontalBox::Slot()
  142. .AutoWidth()
  143. .Padding(1,0,3,0)
  144. .VAlign(VAlign_Center)
  145. [
  146. SNew(SButton)
  147. .ButtonStyle( FAppStyle::Get(), "HoverHintOnly" )
  148. .ForegroundColor( FAppStyle::GetSlateColor(DefaultForegroundName) )
  149. .ToolTipText( this, &SExtDependencyViewer::GetHistoryForwardTooltip )
  150. .ContentPadding( 0 )
  151. .OnClicked(this, &SExtDependencyViewer::ForwardClicked)
  152. .IsEnabled(this, &SExtDependencyViewer::IsForwardEnabled)
  153. [
  154. SNew(SImage) .Image(FAppStyle::GetBrush("ContentBrowser.HistoryForward"))
  155. ]
  156. ]
  157. // Path
  158. +SHorizontalBox::Slot()
  159. .VAlign(VAlign_Fill)
  160. .FillWidth(1.f)
  161. [
  162. SNew(SBorder)
  163. .BorderImage( FAppStyle::GetBrush("ToolPanel.GroupBorder") )
  164. [
  165. SNew(SEditableTextBox)
  166. .Text(this, &SExtDependencyViewer::GetAddressBarText)
  167. .OnTextCommitted(this, &SExtDependencyViewer::OnAddressBarTextCommitted)
  168. .OnTextChanged(this, &SExtDependencyViewer::OnAddressBarTextChanged)
  169. .SelectAllTextWhenFocused(true)
  170. .SelectAllTextOnCommit(true)
  171. .Style(FAppStyle::Get(), "ReferenceViewer.PathText")
  172. ]
  173. ]
  174. ]
  175. #endif
  176. // Graph
  177. #if ECB_FOLD
  178. +SVerticalBox::Slot()
  179. .FillHeight(1.f)
  180. [
  181. SNew(SOverlay)
  182. +SOverlay::Slot()
  183. [
  184. GraphEditorPtr.ToSharedRef()
  185. ]
  186. // Float Panel >>
  187. #if ECB_TODO
  188. +SOverlay::Slot()
  189. .HAlign(HAlign_Left)
  190. .VAlign(VAlign_Top)
  191. .Padding(8)
  192. [
  193. SNew(SBorder)
  194. .BorderImage( FAppStyle::GetBrush("ToolPanel.GroupBorder") )
  195. [
  196. SNew(SVerticalBox)
  197. +SVerticalBox::Slot()
  198. .HAlign(HAlign_Fill)
  199. .VAlign(VAlign_Center)
  200. .Padding(2.f)
  201. .AutoHeight()
  202. [
  203. SAssignNew(SearchBox, SSearchBox)
  204. .HintText(LOCTEXT("Search", "Search..."))
  205. .ToolTipText(LOCTEXT("SearchTooltip", "Type here to search (pressing Enter zooms to the results)"))
  206. .OnTextChanged(this, &SExtDependencyViewer::HandleOnSearchTextChanged)
  207. .OnTextCommitted(this, &SExtDependencyViewer::HandleOnSearchTextCommitted)
  208. ]
  209. #if ECB_LEGACY
  210. +SVerticalBox::Slot()
  211. .AutoHeight()
  212. [
  213. SNew(SHorizontalBox)
  214. +SHorizontalBox::Slot()
  215. .VAlign(VAlign_Center)
  216. .Padding(2.f)
  217. [
  218. SNew(STextBlock)
  219. .Text(LOCTEXT("SearchDepthLabelText", "Search Depth Limit"))
  220. ]
  221. +SHorizontalBox::Slot()
  222. .AutoWidth()
  223. .VAlign(VAlign_Center)
  224. .Padding(2.f)
  225. [
  226. SNew(SCheckBox)
  227. .OnCheckStateChanged( this, &SExtDependencyViewer::OnSearchDepthEnabledChanged )
  228. .IsChecked( this, &SExtDependencyViewer::IsSearchDepthEnabledChecked )
  229. ]
  230. +SHorizontalBox::Slot()
  231. .AutoWidth()
  232. .VAlign(VAlign_Center)
  233. .Padding(2.f)
  234. [
  235. SNew(SBox)
  236. .WidthOverride(100)
  237. [
  238. SNew(SSpinBox<int32>)
  239. .Value(this, &SExtDependencyViewer::GetSearchDepthCount)
  240. .OnValueChanged(this, &SExtDependencyViewer::OnSearchDepthCommitted)
  241. .MinValue(1)
  242. .MaxValue(50)
  243. .MaxSliderValue(12)
  244. ]
  245. ]
  246. ]
  247. +SVerticalBox::Slot()
  248. .AutoHeight()
  249. [
  250. SNew(SHorizontalBox)
  251. +SHorizontalBox::Slot()
  252. .VAlign(VAlign_Center)
  253. .Padding(2.f)
  254. [
  255. SNew(STextBlock)
  256. .Text(LOCTEXT("SearchBreadthLabelText", "Search Breadth Limit"))
  257. ]
  258. +SHorizontalBox::Slot()
  259. .AutoWidth()
  260. .VAlign(VAlign_Center)
  261. .Padding(2.f)
  262. [
  263. SNew(SCheckBox)
  264. .OnCheckStateChanged( this, &SExtDependencyViewer::OnSearchBreadthEnabledChanged )
  265. .IsChecked( this, &SExtDependencyViewer::IsSearchBreadthEnabledChecked )
  266. ]
  267. +SHorizontalBox::Slot()
  268. .AutoWidth()
  269. .VAlign(VAlign_Center)
  270. .Padding(2.f)
  271. [
  272. SNew(SBox)
  273. .WidthOverride(100)
  274. [
  275. SNew(SSpinBox<int32>)
  276. .Value(this, &SExtDependencyViewer::GetSearchBreadthCount)
  277. .OnValueChanged(this, &SExtDependencyViewer::OnSearchBreadthCommitted)
  278. .MinValue(1)
  279. .MaxValue(1000)
  280. .MaxSliderValue(50)
  281. ]
  282. ]
  283. ]
  284. +SVerticalBox::Slot()
  285. .AutoHeight()
  286. [
  287. SNew(SHorizontalBox)
  288. +SHorizontalBox::Slot()
  289. .VAlign(VAlign_Center)
  290. .Padding(2.f)
  291. [
  292. SNew(STextBlock)
  293. .Text(LOCTEXT("CollectionFilter", "Collection Filter"))
  294. ]
  295. +SHorizontalBox::Slot()
  296. .AutoWidth()
  297. .VAlign(VAlign_Center)
  298. .Padding(2.f)
  299. [
  300. SNew(SCheckBox)
  301. .OnCheckStateChanged( this, &SExtDependencyViewer::OnEnableCollectionFilterChanged )
  302. .IsChecked( this, &SExtDependencyViewer::IsEnableCollectionFilterChecked )
  303. ]
  304. +SHorizontalBox::Slot()
  305. .AutoWidth()
  306. .VAlign(VAlign_Center)
  307. .Padding(2.f)
  308. [
  309. SNew(SBox)
  310. .WidthOverride(100)
  311. [
  312. SNew(SComboBox<TSharedPtr<FName>>)
  313. .OptionsSource(&CollectionsComboList)
  314. .OnGenerateWidget(this, &SExtDependencyViewer::GenerateCollectionFilterItem)
  315. .OnSelectionChanged(this, &SExtDependencyViewer::HandleCollectionFilterChanged)
  316. .ToolTipText(this, &SExtDependencyViewer::GetCollectionFilterText)
  317. [
  318. SNew(STextBlock)
  319. .Text(this, &SExtDependencyViewer::GetCollectionFilterText)
  320. ]
  321. ]
  322. ]
  323. ]
  324. +SVerticalBox::Slot()
  325. .AutoHeight()
  326. [
  327. SNew(SHorizontalBox)
  328. +SHorizontalBox::Slot()
  329. .VAlign(VAlign_Center)
  330. .Padding(2.f)
  331. [
  332. SNew(STextBlock)
  333. .Text(LOCTEXT("ShowHideSoftReferences", "Show Soft References"))
  334. ]
  335. +SHorizontalBox::Slot()
  336. .AutoWidth()
  337. .VAlign(VAlign_Center)
  338. .Padding(2.f)
  339. [
  340. SNew(SCheckBox)
  341. .OnCheckStateChanged( this, &SExtDependencyViewer::OnShowSoftReferencesChanged )
  342. .IsChecked( this, &SExtDependencyViewer::IsShowSoftReferencesChecked )
  343. ]
  344. ]
  345. + SVerticalBox::Slot()
  346. .AutoHeight()
  347. [
  348. SNew(SHorizontalBox)
  349. + SHorizontalBox::Slot()
  350. .VAlign(VAlign_Center)
  351. .Padding(2.f)
  352. [
  353. SNew(STextBlock)
  354. .Text(LOCTEXT("ShowHideHardReferences", "Show Hard References"))
  355. ]
  356. +SHorizontalBox::Slot()
  357. .AutoWidth()
  358. .VAlign(VAlign_Center)
  359. .Padding(2.f)
  360. [
  361. SNew(SCheckBox)
  362. .OnCheckStateChanged(this, &SExtDependencyViewer::OnShowHardReferencesChanged)
  363. .IsChecked(this, &SExtDependencyViewer::IsShowHardReferencesChecked)
  364. ]
  365. ]
  366. + SVerticalBox::Slot()
  367. .AutoHeight()
  368. [
  369. SNew(SHorizontalBox)
  370. .Visibility(this, &SExtDependencyViewer::GetManagementReferencesVisibility)
  371. + SHorizontalBox::Slot()
  372. .VAlign(VAlign_Center)
  373. .Padding(2.f)
  374. [
  375. SNew(STextBlock)
  376. .Text(LOCTEXT("ShowHideManagementReferences", "Show Management References"))
  377. ]
  378. +SHorizontalBox::Slot()
  379. .AutoWidth()
  380. .VAlign(VAlign_Center)
  381. .Padding(2.f)
  382. [
  383. SNew(SCheckBox)
  384. .OnCheckStateChanged(this, &SExtDependencyViewer::OnShowManagementReferencesChanged)
  385. .IsChecked(this, &SExtDependencyViewer::IsShowManagementReferencesChecked)
  386. ]
  387. ]
  388. + SVerticalBox::Slot()
  389. .AutoHeight()
  390. [
  391. SNew(SHorizontalBox)
  392. + SHorizontalBox::Slot()
  393. .VAlign(VAlign_Center)
  394. .Padding(2.f)
  395. [
  396. SNew(STextBlock)
  397. .Text(LOCTEXT("ShowHideSearchableNames", "Show Searchable Names"))
  398. ]
  399. +SHorizontalBox::Slot()
  400. .AutoWidth()
  401. .VAlign(VAlign_Center)
  402. .Padding(2.f)
  403. [
  404. SNew(SCheckBox)
  405. .OnCheckStateChanged(this, &SExtDependencyViewer::OnShowSearchableNamesChanged)
  406. .IsChecked(this, &SExtDependencyViewer::IsShowSearchableNamesChecked)
  407. ]
  408. ]
  409. + SVerticalBox::Slot()
  410. .AutoHeight()
  411. [
  412. SNew(SHorizontalBox)
  413. + SHorizontalBox::Slot()
  414. .VAlign(VAlign_Center)
  415. .Padding(2.f)
  416. [
  417. SNew(STextBlock)
  418. .Text(LOCTEXT("ShowHideNativePackages", "Show Native Packages"))
  419. ]
  420. +SHorizontalBox::Slot()
  421. .AutoWidth()
  422. .VAlign(VAlign_Center)
  423. .Padding(2.f)
  424. [
  425. SNew(SCheckBox)
  426. .OnCheckStateChanged(this, &SExtDependencyViewer::OnShowNativePackagesChanged)
  427. .IsChecked(this, &SExtDependencyViewer::IsShowNativePackagesChecked)
  428. ]
  429. ]
  430. #endif
  431. ]
  432. ]
  433. #endif // Float Panel <<
  434. +SOverlay::Slot()
  435. .HAlign(HAlign_Center)
  436. .VAlign(VAlign_Center)
  437. .Padding(FMargin(24, 0, 24, 0))
  438. [
  439. AssetDiscoveryIndicator
  440. ]
  441. ]
  442. #endif
  443. // Bottom panel
  444. #if ECB_FEA_REF_VIEWER_OPTIONS
  445. + SVerticalBox::Slot()
  446. .AutoHeight()
  447. [
  448. SNew(SHorizontalBox)
  449. + SHorizontalBox::Slot().FillWidth(1.0f).HAlign(HAlign_Right)
  450. [
  451. SNew(SHorizontalBox)
  452. #if ECB_FEA_REF_VIEWER_NODE_SPACING
  453. // Node Spacing
  454. + SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center).Padding(4, 0)
  455. [
  456. SAssignNew(NodeSpacingSliderContainer, SHorizontalBox)
  457. + SHorizontalBox::Slot().AutoWidth().Padding(0, 0, 2, 0)
  458. .VAlign(VAlign_Center)
  459. [
  460. SNew(STextBlock).Text(LOCTEXT("NodeSpacing", "Node Spacing"))
  461. ]
  462. + SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center)
  463. [
  464. SNew(SBox)
  465. .WidthOverride(120.0f)
  466. [
  467. SNew(SSlider)
  468. .ToolTipText(LOCTEXT("NodeSpacingToolTip", "Adjust the x spacing between nodes"))
  469. .Value(this, &SExtDependencyViewer::GetNodeSpacingScale)
  470. .OnValueChanged(this, &SExtDependencyViewer::SetNodeSpacingScale)
  471. .Locked(this, &SExtDependencyViewer::IsNodeSpacingScaleLocked)
  472. ]
  473. ]
  474. ]
  475. #endif
  476. // View options
  477. + SHorizontalBox::Slot().AutoWidth().HAlign(HAlign_Right)
  478. [
  479. SAssignNew(ViewOptionsComboButton, SComboButton)
  480. .ContentPadding(0)
  481. .ForegroundColor(this, &SExtDependencyViewer::GetViewButtonForegroundColor)
  482. .ButtonStyle(FAppStyle::Get(), "ToggleButton")
  483. .OnGetMenuContent(this, &SExtDependencyViewer::GetViewButtonContent)
  484. .ButtonContent()
  485. [
  486. SNew(SHorizontalBox)
  487. + SHorizontalBox::Slot()
  488. .AutoWidth()
  489. .VAlign(VAlign_Center)
  490. [
  491. SNew(SImage).Image(FAppStyle::GetBrush("GenericViewButton"))
  492. ]
  493. + SHorizontalBox::Slot()
  494. .AutoWidth()
  495. .Padding(2, 0, 0, 0)
  496. .VAlign(VAlign_Center)
  497. [
  498. SNew(STextBlock).Text(LOCTEXT("OptionsButton", "Options"))
  499. ]
  500. ]
  501. ]
  502. ]
  503. ]
  504. #endif
  505. ];
  506. }
  507. void SExtDependencyViewer::SetGraphRootIdentifiers(const TArray<FExtAssetIdentifier>& NewGraphRootIdentifiers)
  508. {
  509. GraphObj->SetGraphRoot(NewGraphRootIdentifiers);
  510. RebuildGraph();
  511. // Zoom once this frame to make sure widgets are visible, then zoom again so size is correct
  512. TriggerZoomToFit(0, 0);
  513. RegisterActiveTimer(0.1f, FWidgetActiveTimerDelegate::CreateSP(this, &SExtDependencyViewer::TriggerZoomToFit));
  514. // Set the initial history data
  515. HistoryManager.AddHistoryData();
  516. }
  517. EActiveTimerReturnType SExtDependencyViewer::TriggerZoomToFit(double InCurrentTime, float InDeltaTime)
  518. {
  519. if (GraphEditorPtr.IsValid())
  520. {
  521. GraphEditorPtr->ZoomToFit(false);
  522. }
  523. return EActiveTimerReturnType::Stop;
  524. }
  525. void SExtDependencyViewer::SaveSettings(const FString& IniFilename, const FString& IniSection, const FString& SettingsString) const
  526. {
  527. GConfig->SetFloat(*IniSection, TEXT(".DependencyViewerNodeXSpacingScale"), NodeSpacingScale, IniFilename);
  528. }
  529. void SExtDependencyViewer::LoadSettings(const FString& IniFilename, const FString& IniSection, const FString& SettingsString)
  530. {
  531. float Scale = 0.f;
  532. if (GConfig->GetFloat(*IniSection, TEXT(".DependencyViewerNodeXSpacingScale"), Scale, IniFilename))
  533. {
  534. SetNodeSpacingScale(Scale);
  535. }
  536. }
  537. float SExtDependencyViewer::GetNodeSpacingScale() const
  538. {
  539. return NodeSpacingScale;
  540. }
  541. void SExtDependencyViewer::SetNodeSpacingScale(float NewValue)
  542. {
  543. NodeSpacingScale = FMath::Clamp<float>(NewValue, 0.f, 1.f);;
  544. const float Min = 200.f;
  545. const float Max = 1200.f;
  546. float NewNodeXSpacing = Min + (Max - Min) * NodeSpacingScale;
  547. if (GraphObj)
  548. {
  549. GraphObj->SetNodeXSpacing(NewNodeXSpacing);
  550. }
  551. RebuildGraph();
  552. }
  553. bool SExtDependencyViewer::IsNodeSpacingScaleLocked() const
  554. {
  555. return GraphObj == NULL;
  556. }
  557. FSlateColor SExtDependencyViewer::GetViewButtonForegroundColor() const
  558. {
  559. static const FName InvertedForegroundName("InvertedForeground");
  560. static const FName DefaultForegroundName("DefaultForeground");
  561. return ViewOptionsComboButton->IsHovered() ? FAppStyle::GetSlateColor(InvertedForegroundName) : FAppStyle::GetSlateColor(DefaultForegroundName);
  562. }
  563. TSharedRef<SWidget> SExtDependencyViewer::GetViewButtonContent()
  564. {
  565. UExtContentBrowserSettings* ExtContentBrowserSetting = GetMutableDefault<UExtContentBrowserSettings>();
  566. FMenuBuilder MenuBuilder(/*bInShouldCloseWindowAfterMenuSelection=*/false, NULL, TSharedPtr<FExtender>(), /*bCloseSelfOnly=*/ true);
  567. MenuBuilder.BeginSection("Show", LOCTEXT("ShowHeading", "Show"));
  568. {
  569. MenuBuilder.AddMenuEntry(
  570. LOCTEXT("ShowDirectDependenciesOnly", "Direct Dependencies Only"),
  571. LOCTEXT("ShowDirectDependenciesOnlyTooltip", "Only showing direct dependencies, un-check to show dependencies recursively"),
  572. FSlateIcon(),
  573. FUIAction(
  574. FExecuteAction::CreateLambda([this] { OnSearchDepthEnabledChanged(IsSearchDepthEnabledChecked() == ECheckBoxState::Checked ? ECheckBoxState::Unchecked : ECheckBoxState::Checked); }),
  575. FCanExecuteAction(),
  576. FIsActionChecked::CreateLambda([this] { return IsSearchDepthEnabledChecked() == ECheckBoxState::Checked; })
  577. ),
  578. NAME_None,
  579. EUserInterfaceActionType::ToggleButton
  580. );
  581. MenuBuilder.AddMenuEntry(
  582. LOCTEXT("ShowHardReferences", "Hard References"),
  583. LOCTEXT("ShowHardReferencesTooltip", "Show hard referenced dependencies"),
  584. FSlateIcon(),
  585. FUIAction(
  586. FExecuteAction::CreateLambda([this] { OnShowHardReferencesChanged(IsShowHardReferencesChecked() == ECheckBoxState::Checked ? ECheckBoxState::Unchecked : ECheckBoxState::Checked); }),
  587. FCanExecuteAction(),
  588. FIsActionChecked::CreateLambda([this] { return IsShowHardReferencesChecked() == ECheckBoxState::Checked; })
  589. ),
  590. NAME_None,
  591. EUserInterfaceActionType::ToggleButton
  592. );
  593. MenuBuilder.AddMenuEntry(
  594. LOCTEXT("ShowSoftReferences", "Soft References"),
  595. LOCTEXT("ShowSoftReferencesTooltip", "Show soft referenced dependencies"),
  596. FSlateIcon(),
  597. FUIAction(
  598. FExecuteAction::CreateLambda([this] { OnShowSoftReferencesChanged(IsShowSoftReferencesChecked() == ECheckBoxState::Checked ? ECheckBoxState::Unchecked : ECheckBoxState::Checked); }),
  599. FCanExecuteAction(),
  600. FIsActionChecked::CreateLambda([this] { return IsShowSoftReferencesChecked() == ECheckBoxState::Checked; })
  601. ),
  602. NAME_None,
  603. EUserInterfaceActionType::ToggleButton
  604. );
  605. MenuBuilder.AddMenuEntry(
  606. LOCTEXT("ShowHideNativePackages", "Native Packages"),
  607. LOCTEXT("ShowHideNativePackagesTooltip", "Show or hide native packages"),
  608. FSlateIcon(),
  609. FUIAction(
  610. FExecuteAction::CreateLambda([this] { OnShowNativePackagesChanged(IsShowNativePackagesChecked() == ECheckBoxState::Checked ? ECheckBoxState::Unchecked : ECheckBoxState::Checked); }),
  611. FCanExecuteAction(),
  612. FIsActionChecked::CreateLambda([this] { return IsShowNativePackagesChecked() == ECheckBoxState::Checked; })
  613. ),
  614. NAME_None,
  615. EUserInterfaceActionType::ToggleButton
  616. );
  617. }
  618. MenuBuilder.EndSection();
  619. MenuBuilder.BeginSection("Zoom", LOCTEXT("ZoomHeading", "Zoom"));
  620. {
  621. MenuBuilder.AddMenuEntry(
  622. LOCTEXT("FitAll", "Fit All"),
  623. LOCTEXT("FitAllTooltip", "Zooms out to fit all nodes"),
  624. FSlateIcon(),
  625. FUIAction(
  626. FExecuteAction::CreateLambda([this] { ZoomToFitAll(); })
  627. ),
  628. NAME_None,
  629. EUserInterfaceActionType::Button
  630. );
  631. MenuBuilder.AddMenuEntry(
  632. LOCTEXT("FitSelected", "Fit Selected"),
  633. LOCTEXT("FitSelectedTooltip", "Zooms out to fit selected nodes"),
  634. FSlateIcon(),
  635. FUIAction(
  636. FExecuteAction::CreateLambda([this] { ZoomToFitSelected();})
  637. ),
  638. NAME_None,
  639. EUserInterfaceActionType::Button
  640. );
  641. MenuBuilder.AddMenuEntry(
  642. LOCTEXT("FitError", "Select and Fit Error Nodes"),
  643. LOCTEXT("FitErrorTooltip", "Select and zoom to error nodes"),
  644. FSlateIcon(),
  645. FUIAction(
  646. FExecuteAction::CreateLambda([this]
  647. {
  648. if (GraphObj == nullptr || !GraphEditorPtr.IsValid())
  649. {
  650. return;
  651. }
  652. GraphEditorPtr->ClearSelectionSet();
  653. TArray<UEdGraphNode_ExtDependency*> AllNodes;
  654. GraphObj->GetNodesOfClass<UEdGraphNode_ExtDependency>(AllNodes);
  655. for (const auto Node : AllNodes)
  656. {
  657. if (Node->IsMissingOrInvalid())
  658. {
  659. GraphEditorPtr->SetNodeSelection(Node, true);
  660. }
  661. }
  662. ZoomToFitSelected();
  663. })
  664. ),
  665. NAME_None,
  666. EUserInterfaceActionType::Button
  667. );
  668. }
  669. MenuBuilder.EndSection();
  670. MenuBuilder.BeginSection("Style", LOCTEXT("StyleHeading", "Style"));
  671. {
  672. #if ECB_WIP_REF_VIEWER_HIGHLIGHT_ERROR
  673. MenuBuilder.AddMenuEntry(
  674. LOCTEXT("HighlightErrorNodes", "Highlight Error Nodes"),
  675. LOCTEXT("HighlightErrorNodesTooltip", "Whether to highlight error nodes"),
  676. FSlateIcon(),
  677. FUIAction(
  678. FExecuteAction::CreateLambda([this, ExtContentBrowserSetting] { ExtContentBrowserSetting->HighlightErrorNodesInDependencyViewer = !ExtContentBrowserSetting->HighlightErrorNodesInDependencyViewer; ExtContentBrowserSetting->PostEditChange(); }),
  679. FCanExecuteAction(),
  680. FIsActionChecked::CreateLambda([this, ExtContentBrowserSetting] { return ExtContentBrowserSetting->HighlightErrorNodesInDependencyViewer; })
  681. ),
  682. NAME_None,
  683. EUserInterfaceActionType::ToggleButton
  684. );
  685. #endif
  686. MenuBuilder.AddMenuEntry(
  687. LOCTEXT("StraightConnectLine", "Straight Connect Line"),
  688. LOCTEXT("StraightConnectLineTooltip", "Whether use straight or spline connect line between nodes"),
  689. FSlateIcon(),
  690. FUIAction(
  691. FExecuteAction::CreateLambda([this, ExtContentBrowserSetting] { ExtContentBrowserSetting->UseStraightLineInDependencyViewer = !ExtContentBrowserSetting->UseStraightLineInDependencyViewer; ExtContentBrowserSetting->PostEditChange(); }),
  692. FCanExecuteAction(),
  693. FIsActionChecked::CreateLambda([this, ExtContentBrowserSetting] { return ExtContentBrowserSetting->UseStraightLineInDependencyViewer; })
  694. ),
  695. NAME_None,
  696. EUserInterfaceActionType::ToggleButton
  697. );
  698. }
  699. MenuBuilder.EndSection();
  700. MenuBuilder.BeginSection("Layout", LOCTEXT("LayoutHeading", "Layout"));
  701. {
  702. MenuBuilder.AddMenuEntry(
  703. LOCTEXT("ShowUnderAssetView", "Show Under Asset View"),
  704. LOCTEXT("ShowUnderAssetViewTooltip", "Show dependency viewer under asset view or on right of asset view"),
  705. FSlateIcon(),
  706. FUIAction(
  707. FExecuteAction::CreateLambda([this, ExtContentBrowserSetting] { ExtContentBrowserSetting->ShowDependencyViewerUnderAssetView = !ExtContentBrowserSetting->ShowDependencyViewerUnderAssetView; ExtContentBrowserSetting->PostEditChange(); }),
  708. FCanExecuteAction(),
  709. FIsActionChecked::CreateLambda([this, ExtContentBrowserSetting] { return ExtContentBrowserSetting->ShowDependencyViewerUnderAssetView; })
  710. ),
  711. NAME_None,
  712. EUserInterfaceActionType::ToggleButton
  713. );
  714. }
  715. MenuBuilder.EndSection();
  716. return MenuBuilder.MakeWidget();
  717. }
  718. void SExtDependencyViewer::SetCurrentRegistrySource(/*const FAssetManagerEditorRegistrySource* RegistrySource*/)
  719. {
  720. RebuildGraph();
  721. }
  722. void SExtDependencyViewer::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
  723. {
  724. static float WidthLastFrame = 0.f;
  725. if (WidthLastFrame != AllottedGeometry.Size.X)
  726. {
  727. WidthLastFrame = AllottedGeometry.Size.X;
  728. NodeSpacingSliderContainer->SetVisibility(WidthLastFrame < 290.f ? EVisibility::Collapsed : EVisibility::Visible);
  729. ViewOptionsComboButton->SetVisibility(WidthLastFrame < 80.f ? EVisibility::Collapsed : EVisibility::Visible);
  730. }
  731. }
  732. void SExtDependencyViewer::OnNodeDoubleClicked(UEdGraphNode* Node)
  733. {
  734. #if ECB_WIP_REF_VIEWER_JUMP
  735. TSet<UObject*> Nodes;
  736. Nodes.Add(Node);
  737. ReCenterGraphOnNodes( Nodes );
  738. #endif
  739. }
  740. void SExtDependencyViewer::RebuildGraph()
  741. {
  742. #if ECB_FEA_ASYNC_ASSET_DISCOVERY
  743. FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
  744. if (AssetRegistryModule.Get().IsLoadingAssets())
  745. {
  746. // We are still discovering assets, listen for the completion delegate before building the graph
  747. if (!AssetRegistryModule.Get().OnFilesLoaded().IsBoundToObject(this))
  748. {
  749. AssetRegistryModule.Get().OnFilesLoaded().AddSP(this, &SExtDependencyViewer::OnInitialAssetRegistrySearchComplete);
  750. }
  751. }
  752. else
  753. #endif
  754. {
  755. // All assets are already discovered, build the graph now, if we have one
  756. if (GraphObj)
  757. {
  758. GraphObj->RebuildGraph();
  759. }
  760. }
  761. }
  762. FActionMenuContent SExtDependencyViewer::OnCreateGraphActionMenu(UEdGraph* InGraph, const FVector2D& InNodePosition, const TArray<UEdGraphPin*>& InDraggedPins, bool bAutoExpand, SGraphEditor::FActionMenuClosed InOnMenuClosed)
  763. {
  764. // no context menu when not over a node
  765. return FActionMenuContent();
  766. }
  767. bool SExtDependencyViewer::IsBackEnabled() const
  768. {
  769. return HistoryManager.CanGoBack();
  770. }
  771. bool SExtDependencyViewer::IsForwardEnabled() const
  772. {
  773. return HistoryManager.CanGoForward();
  774. }
  775. FReply SExtDependencyViewer::BackClicked()
  776. {
  777. HistoryManager.GoBack();
  778. return FReply::Handled();
  779. }
  780. FReply SExtDependencyViewer::ForwardClicked()
  781. {
  782. HistoryManager.GoForward();
  783. return FReply::Handled();
  784. }
  785. void SExtDependencyViewer::GraphNavigateHistoryBack()
  786. {
  787. BackClicked();
  788. }
  789. void SExtDependencyViewer::GraphNavigateHistoryForward()
  790. {
  791. ForwardClicked();
  792. }
  793. FText SExtDependencyViewer::GetHistoryBackTooltip() const
  794. {
  795. if ( HistoryManager.CanGoBack() )
  796. {
  797. return FText::Format( LOCTEXT("HistoryBackTooltip", "Back to {0}"), HistoryManager.GetBackDesc() );
  798. }
  799. return FText::GetEmpty();
  800. }
  801. FText SExtDependencyViewer::GetHistoryForwardTooltip() const
  802. {
  803. if ( HistoryManager.CanGoForward() )
  804. {
  805. return FText::Format( LOCTEXT("HistoryForwardTooltip", "Forward to {0}"), HistoryManager.GetForwardDesc() );
  806. }
  807. return FText::GetEmpty();
  808. }
  809. FText SExtDependencyViewer::GetAddressBarText() const
  810. {
  811. if ( GraphObj )
  812. {
  813. if (TemporaryPathBeingEdited.IsEmpty())
  814. {
  815. const TArray<FExtAssetIdentifier>& CurrentGraphRootPackageNames = GraphObj->GetCurrentGraphRootIdentifiers();
  816. if (CurrentGraphRootPackageNames.Num() == 1)
  817. {
  818. return FText::FromString(CurrentGraphRootPackageNames[0].ToString());
  819. }
  820. else if (CurrentGraphRootPackageNames.Num() > 1)
  821. {
  822. return FText::Format(LOCTEXT("AddressBarMultiplePackagesText", "{0} and {1} others"), FText::FromString(CurrentGraphRootPackageNames[0].ToString()), FText::AsNumber(CurrentGraphRootPackageNames.Num()));
  823. }
  824. }
  825. else
  826. {
  827. return TemporaryPathBeingEdited;
  828. }
  829. }
  830. return FText();
  831. }
  832. void SExtDependencyViewer::OnAddressBarTextCommitted(const FText& NewText, ETextCommit::Type CommitInfo)
  833. {
  834. if (CommitInfo == ETextCommit::OnEnter)
  835. {
  836. TArray<FExtAssetIdentifier> NewPaths;
  837. NewPaths.Add(FExtAssetIdentifier::FromString(NewText.ToString()));
  838. SetGraphRootIdentifiers(NewPaths);
  839. }
  840. TemporaryPathBeingEdited = FText();
  841. }
  842. void SExtDependencyViewer::OnAddressBarTextChanged(const FText& NewText)
  843. {
  844. TemporaryPathBeingEdited = NewText;
  845. }
  846. void SExtDependencyViewer::OnApplyHistoryData(const FExtDependencyViewerHistoryData& History)
  847. {
  848. if ( GraphObj )
  849. {
  850. GraphObj->SetGraphRoot(History.Identifiers);
  851. UEdGraphNode_ExtDependency* NewRootNode = GraphObj->RebuildGraph();
  852. if ( NewRootNode && ensure(GraphEditorPtr.IsValid()) )
  853. {
  854. GraphEditorPtr->SetNodeSelection(NewRootNode, true);
  855. }
  856. }
  857. }
  858. void SExtDependencyViewer::OnUpdateHistoryData(FExtDependencyViewerHistoryData& HistoryData) const
  859. {
  860. if ( GraphObj )
  861. {
  862. const TArray<FExtAssetIdentifier>& CurrentGraphRootIdentifiers = GraphObj->GetCurrentGraphRootIdentifiers();
  863. HistoryData.HistoryDesc = GetAddressBarText();
  864. HistoryData.Identifiers = CurrentGraphRootIdentifiers;
  865. }
  866. else
  867. {
  868. HistoryData.HistoryDesc = FText::GetEmpty();
  869. HistoryData.Identifiers.Empty();
  870. }
  871. }
  872. void SExtDependencyViewer::OnSearchDepthEnabledChanged( ECheckBoxState NewState )
  873. {
  874. if ( GraphObj )
  875. {
  876. GraphObj->SetSearchDepthLimitEnabled(NewState == ECheckBoxState::Checked);
  877. RebuildGraph();
  878. ZoomToFitAll();
  879. }
  880. }
  881. ECheckBoxState SExtDependencyViewer::IsSearchDepthEnabledChecked() const
  882. {
  883. if ( GraphObj )
  884. {
  885. return GraphObj->IsSearchDepthLimited() ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
  886. }
  887. else
  888. {
  889. return ECheckBoxState::Unchecked;
  890. }
  891. }
  892. int32 SExtDependencyViewer::GetSearchDepthCount() const
  893. {
  894. if ( GraphObj )
  895. {
  896. return GraphObj->GetSearchDepthLimit();
  897. }
  898. else
  899. {
  900. return 0;
  901. }
  902. }
  903. void SExtDependencyViewer::OnSearchDepthCommitted(int32 NewValue)
  904. {
  905. if ( GraphObj )
  906. {
  907. GraphObj->SetSearchDepthLimit(NewValue);
  908. RebuildGraph();
  909. }
  910. }
  911. void SExtDependencyViewer::OnSearchBreadthEnabledChanged( ECheckBoxState NewState )
  912. {
  913. if ( GraphObj )
  914. {
  915. GraphObj->SetSearchBreadthLimitEnabled(NewState == ECheckBoxState::Checked);
  916. RebuildGraph();
  917. }
  918. }
  919. ECheckBoxState SExtDependencyViewer::IsSearchBreadthEnabledChecked() const
  920. {
  921. if ( GraphObj )
  922. {
  923. return GraphObj->IsSearchBreadthLimited() ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
  924. }
  925. else
  926. {
  927. return ECheckBoxState::Unchecked;
  928. }
  929. }
  930. TSharedRef<SWidget> SExtDependencyViewer::GenerateCollectionFilterItem(TSharedPtr<FName> InItem)
  931. {
  932. FText ItemAsText = FText::FromName(*InItem);
  933. return
  934. SNew(SBox)
  935. .WidthOverride(300)
  936. [
  937. SNew(STextBlock)
  938. .Text(ItemAsText)
  939. .ToolTipText(ItemAsText)
  940. ];
  941. }
  942. void SExtDependencyViewer::OnEnableCollectionFilterChanged(ECheckBoxState NewState)
  943. {
  944. if (GraphObj)
  945. {
  946. const bool bNewValue = NewState == ECheckBoxState::Checked;
  947. const bool bCurrentValue = GraphObj->GetEnableCollectionFilter();
  948. if (bCurrentValue != bNewValue)
  949. {
  950. GraphObj->SetEnableCollectionFilter(NewState == ECheckBoxState::Checked);
  951. RebuildGraph();
  952. }
  953. }
  954. }
  955. ECheckBoxState SExtDependencyViewer::IsEnableCollectionFilterChecked() const
  956. {
  957. if (GraphObj)
  958. {
  959. return GraphObj->GetEnableCollectionFilter() ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
  960. }
  961. else
  962. {
  963. return ECheckBoxState::Unchecked;
  964. }
  965. }
  966. void SExtDependencyViewer::HandleCollectionFilterChanged(TSharedPtr<FName> Item, ESelectInfo::Type SelectInfo)
  967. {
  968. if (GraphObj)
  969. {
  970. const FName NewFilter = *Item;
  971. const FName CurrentFilter = GraphObj->GetCurrentCollectionFilter();
  972. if (CurrentFilter != NewFilter)
  973. {
  974. if (CurrentFilter == NAME_None)
  975. {
  976. // Automatically check the box to enable the filter if the previous filter was None
  977. GraphObj->SetEnableCollectionFilter(true);
  978. }
  979. GraphObj->SetCurrentCollectionFilter(NewFilter);
  980. RebuildGraph();
  981. }
  982. }
  983. }
  984. FText SExtDependencyViewer::GetCollectionFilterText() const
  985. {
  986. return FText::FromName(GraphObj->GetCurrentCollectionFilter());
  987. }
  988. void SExtDependencyViewer::OnShowSoftReferencesChanged(ECheckBoxState NewState)
  989. {
  990. if (GraphObj)
  991. {
  992. GraphObj->SetShowSoftReferencesEnabled(NewState == ECheckBoxState::Checked);
  993. RebuildGraph();
  994. }
  995. }
  996. ECheckBoxState SExtDependencyViewer::IsShowSoftReferencesChecked() const
  997. {
  998. if (GraphObj)
  999. {
  1000. return GraphObj->IsShowSoftReferences()? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
  1001. }
  1002. else
  1003. {
  1004. return ECheckBoxState::Unchecked;
  1005. }
  1006. }
  1007. void SExtDependencyViewer::OnShowHardReferencesChanged(ECheckBoxState NewState)
  1008. {
  1009. if (GraphObj)
  1010. {
  1011. GraphObj->SetShowHardReferencesEnabled(NewState == ECheckBoxState::Checked);
  1012. RebuildGraph();
  1013. }
  1014. }
  1015. ECheckBoxState SExtDependencyViewer::IsShowHardReferencesChecked() const
  1016. {
  1017. if (GraphObj)
  1018. {
  1019. return GraphObj->IsShowHardReferences() ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
  1020. }
  1021. else
  1022. {
  1023. return ECheckBoxState::Unchecked;
  1024. }
  1025. }
  1026. EVisibility SExtDependencyViewer::GetManagementReferencesVisibility() const
  1027. {
  1028. if (UAssetManager::IsInitialized())
  1029. {
  1030. return EVisibility::SelfHitTestInvisible;
  1031. }
  1032. return EVisibility::Collapsed;
  1033. }
  1034. void SExtDependencyViewer::OnShowManagementReferencesChanged(ECheckBoxState NewState)
  1035. {
  1036. if (GraphObj)
  1037. {
  1038. // This can take a few seconds if it isn't ready
  1039. UAssetManager::Get().UpdateManagementDatabase();
  1040. GraphObj->SetShowManagementReferencesEnabled(NewState == ECheckBoxState::Checked);
  1041. RebuildGraph();
  1042. }
  1043. }
  1044. ECheckBoxState SExtDependencyViewer::IsShowManagementReferencesChecked() const
  1045. {
  1046. if (GraphObj)
  1047. {
  1048. return GraphObj->IsShowManagementReferences() ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
  1049. }
  1050. else
  1051. {
  1052. return ECheckBoxState::Unchecked;
  1053. }
  1054. }
  1055. void SExtDependencyViewer::OnShowSearchableNamesChanged(ECheckBoxState NewState)
  1056. {
  1057. if (GraphObj)
  1058. {
  1059. GraphObj->SetShowSearchableNames(NewState == ECheckBoxState::Checked);
  1060. RebuildGraph();
  1061. }
  1062. }
  1063. ECheckBoxState SExtDependencyViewer::IsShowSearchableNamesChecked() const
  1064. {
  1065. if (GraphObj)
  1066. {
  1067. return GraphObj->IsShowSearchableNames() ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
  1068. }
  1069. else
  1070. {
  1071. return ECheckBoxState::Unchecked;
  1072. }
  1073. }
  1074. void SExtDependencyViewer::OnShowNativePackagesChanged(ECheckBoxState NewState)
  1075. {
  1076. if (GraphObj)
  1077. {
  1078. GraphObj->SetShowNativePackages(NewState == ECheckBoxState::Checked);
  1079. RebuildGraph();
  1080. }
  1081. }
  1082. ECheckBoxState SExtDependencyViewer::IsShowNativePackagesChecked() const
  1083. {
  1084. if (GraphObj)
  1085. {
  1086. return GraphObj->IsShowNativePackages() ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
  1087. }
  1088. else
  1089. {
  1090. return ECheckBoxState::Unchecked;
  1091. }
  1092. }
  1093. int32 SExtDependencyViewer::GetSearchBreadthCount() const
  1094. {
  1095. if ( GraphObj )
  1096. {
  1097. return GraphObj->GetSearchBreadthLimit();
  1098. }
  1099. else
  1100. {
  1101. return 0;
  1102. }
  1103. }
  1104. void SExtDependencyViewer::OnSearchBreadthCommitted(int32 NewValue)
  1105. {
  1106. if ( GraphObj )
  1107. {
  1108. GraphObj->SetSearchBreadthLimit(NewValue);
  1109. RebuildGraph();
  1110. }
  1111. }
  1112. void SExtDependencyViewer::RegisterActions()
  1113. {
  1114. ReferenceViewerActions = MakeShareable(new FUICommandList);
  1115. FExtDependencyViewerCommands::Register();
  1116. ReferenceViewerActions->MapAction(
  1117. FExtDependencyViewerCommands::Get().ZoomToFitSelected,
  1118. FExecuteAction::CreateSP(this, &SExtDependencyViewer::ZoomToFitSelected),
  1119. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::CanZoomToFit));
  1120. #if ECB_LEGACY
  1121. ReferenceViewerActions->MapAction(
  1122. FAssetManagerEditorCommands::Get().Find,
  1123. FExecuteAction::CreateSP(this, &SExtDependencyViewer::OnFind));
  1124. ReferenceViewerActions->MapAction(
  1125. FGlobalEditorCommonCommands::Get().FindInContentBrowser,
  1126. FExecuteAction::CreateSP(this, &SExtDependencyViewer::ShowSelectionInContentBrowser),
  1127. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasAtLeastOnePackageNodeSelected));
  1128. ReferenceViewerActions->MapAction(
  1129. FAssetManagerEditorCommands::Get().OpenSelectedInAssetEditor,
  1130. FExecuteAction::CreateSP(this, &SExtDependencyViewer::OpenSelectedInAssetEditor),
  1131. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasAtLeastOneRealNodeSelected));
  1132. ReferenceViewerActions->MapAction(
  1133. FAssetManagerEditorCommands::Get().ReCenterGraph,
  1134. FExecuteAction::CreateSP(this, &SExtDependencyViewer::ReCenterGraph),
  1135. FCanExecuteAction());
  1136. ReferenceViewerActions->MapAction(
  1137. FAssetManagerEditorCommands::Get().CopyReferencedObjects,
  1138. FExecuteAction::CreateSP(this, &SExtDependencyViewer::CopyReferencedObjects),
  1139. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasAtLeastOnePackageNodeSelected));
  1140. ReferenceViewerActions->MapAction(
  1141. FAssetManagerEditorCommands::Get().CopyReferencingObjects,
  1142. FExecuteAction::CreateSP(this, &SExtDependencyViewer::CopyReferencingObjects),
  1143. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasAtLeastOnePackageNodeSelected));
  1144. ReferenceViewerActions->MapAction(
  1145. FAssetManagerEditorCommands::Get().ShowReferencedObjects,
  1146. FExecuteAction::CreateSP(this, &SExtDependencyViewer::ShowReferencedObjects),
  1147. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasAtLeastOnePackageNodeSelected));
  1148. ReferenceViewerActions->MapAction(
  1149. FAssetManagerEditorCommands::Get().ShowReferencingObjects,
  1150. FExecuteAction::CreateSP(this, &SExtDependencyViewer::ShowReferencingObjects),
  1151. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasAtLeastOnePackageNodeSelected));
  1152. ReferenceViewerActions->MapAction(
  1153. FAssetManagerEditorCommands::Get().MakeLocalCollectionWithReferencers,
  1154. FExecuteAction::CreateSP(this, &SExtDependencyViewer::MakeCollectionWithReferencersOrDependencies, ECollectionShareType::CST_Local, true),
  1155. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasExactlyOnePackageNodeSelected));
  1156. ReferenceViewerActions->MapAction(
  1157. FAssetManagerEditorCommands::Get().MakePrivateCollectionWithReferencers,
  1158. FExecuteAction::CreateSP(this, &SExtDependencyViewer::MakeCollectionWithReferencersOrDependencies, ECollectionShareType::CST_Private, true),
  1159. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasExactlyOnePackageNodeSelected));
  1160. ReferenceViewerActions->MapAction(
  1161. FAssetManagerEditorCommands::Get().MakeSharedCollectionWithReferencers,
  1162. FExecuteAction::CreateSP(this, &SExtDependencyViewer::MakeCollectionWithReferencersOrDependencies, ECollectionShareType::CST_Shared, true),
  1163. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasExactlyOnePackageNodeSelected));
  1164. ReferenceViewerActions->MapAction(
  1165. FAssetManagerEditorCommands::Get().MakeLocalCollectionWithDependencies,
  1166. FExecuteAction::CreateSP(this, &SExtDependencyViewer::MakeCollectionWithReferencersOrDependencies, ECollectionShareType::CST_Local, false),
  1167. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasExactlyOnePackageNodeSelected));
  1168. ReferenceViewerActions->MapAction(
  1169. FAssetManagerEditorCommands::Get().MakePrivateCollectionWithDependencies,
  1170. FExecuteAction::CreateSP(this, &SExtDependencyViewer::MakeCollectionWithReferencersOrDependencies, ECollectionShareType::CST_Private, false),
  1171. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasExactlyOnePackageNodeSelected));
  1172. ReferenceViewerActions->MapAction(
  1173. FAssetManagerEditorCommands::Get().MakeSharedCollectionWithDependencies,
  1174. FExecuteAction::CreateSP(this, &SExtDependencyViewer::MakeCollectionWithReferencersOrDependencies, ECollectionShareType::CST_Shared, false),
  1175. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasExactlyOnePackageNodeSelected));
  1176. ReferenceViewerActions->MapAction(
  1177. FAssetManagerEditorCommands::Get().ShowReferenceTree,
  1178. FExecuteAction::CreateSP(this, &SExtDependencyViewer::ShowReferenceTree),
  1179. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasExactlyOnePackageNodeSelected));
  1180. ReferenceViewerActions->MapAction(
  1181. FAssetManagerEditorCommands::Get().ViewSizeMap,
  1182. FExecuteAction::CreateSP(this, &SExtDependencyViewer::ViewSizeMap),
  1183. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasAtLeastOneRealNodeSelected));
  1184. ReferenceViewerActions->MapAction(
  1185. FAssetManagerEditorCommands::Get().ViewAssetAudit,
  1186. FExecuteAction::CreateSP(this, &SExtDependencyViewer::ViewAssetAudit),
  1187. FCanExecuteAction::CreateSP(this, &SExtDependencyViewer::HasAtLeastOneRealNodeSelected));
  1188. #endif
  1189. }
  1190. void SExtDependencyViewer::ShowSelectionInContentBrowser()
  1191. {
  1192. TArray<FExtAssetData> AssetList;
  1193. // Build up a list of selected assets from the graph selection set
  1194. TSet<UObject*> SelectedNodes = GraphEditorPtr->GetSelectedNodes();
  1195. for (FGraphPanelSelectionSet::TConstIterator It(SelectedNodes); It; ++It)
  1196. {
  1197. if (UEdGraphNode_ExtDependency* ReferenceNode = Cast<UEdGraphNode_ExtDependency>(*It))
  1198. {
  1199. if (ReferenceNode->GetAssetData().IsValid())
  1200. {
  1201. AssetList.Add(ReferenceNode->GetAssetData());
  1202. }
  1203. }
  1204. }
  1205. if (AssetList.Num() > 0)
  1206. {
  1207. //GEditor->SyncBrowserToObjects(AssetList);
  1208. }
  1209. }
  1210. void SExtDependencyViewer::OpenSelectedInAssetEditor()
  1211. {
  1212. TArray<FExtAssetIdentifier> IdentifiersToEdit;
  1213. FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
  1214. TSet<UObject*> SelectedNodes = GraphEditorPtr->GetSelectedNodes();
  1215. for (FGraphPanelSelectionSet::TConstIterator It(SelectedNodes); It; ++It)
  1216. {
  1217. if (UEdGraphNode_ExtDependency* ReferenceNode = Cast<UEdGraphNode_ExtDependency>(*It))
  1218. {
  1219. if (!ReferenceNode->IsCollapsed())
  1220. {
  1221. ReferenceNode->GetAllIdentifiers(IdentifiersToEdit);
  1222. }
  1223. }
  1224. }
  1225. // This will handle packages as well as searchable names if other systems register
  1226. //FEditorDelegates::OnEditAssetIdentifiers.Broadcast(IdentifiersToEdit);
  1227. }
  1228. void SExtDependencyViewer::ReCenterGraph()
  1229. {
  1230. ReCenterGraphOnNodes( GraphEditorPtr->GetSelectedNodes() );
  1231. }
  1232. FString SExtDependencyViewer::GetReferencedObjectsList() const
  1233. {
  1234. using namespace UE::AssetRegistry;
  1235. FString ReferencedObjectsList;
  1236. TSet<FName> AllSelectedPackageNames;
  1237. GetPackageNamesFromSelectedNodes(AllSelectedPackageNames);
  1238. if (AllSelectedPackageNames.Num() > 0)
  1239. {
  1240. FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
  1241. for (const FName SelectedPackageName : AllSelectedPackageNames)
  1242. {
  1243. TArray<FName> HardDependencies;
  1244. FExtContentBrowserSingleton::GetAssetRegistry().GetDependencies(SelectedPackageName, HardDependencies, EDependencyCategory::Package, FDependencyQuery(EDependencyQuery::Hard));
  1245. TArray<FName> SoftDependencies;
  1246. FExtContentBrowserSingleton::GetAssetRegistry().GetDependencies(SelectedPackageName, SoftDependencies, EDependencyCategory::Package, FDependencyQuery(EDependencyQuery::Soft));
  1247. ReferencedObjectsList += FString::Printf(TEXT("[%s - Dependencies]\n"), *SelectedPackageName.ToString());
  1248. if (HardDependencies.Num() > 0)
  1249. {
  1250. ReferencedObjectsList += TEXT(" [HARD]\n");
  1251. for (const FName HardDependency : HardDependencies)
  1252. {
  1253. const FString PackageString = HardDependency.ToString();
  1254. ReferencedObjectsList += FString::Printf(TEXT(" %s.%s\n"), *PackageString, *FPackageName::GetLongPackageAssetName(PackageString));
  1255. }
  1256. }
  1257. if (SoftDependencies.Num() > 0)
  1258. {
  1259. ReferencedObjectsList += TEXT(" [SOFT]\n");
  1260. for (const FName SoftDependency : SoftDependencies)
  1261. {
  1262. const FString PackageString = SoftDependency.ToString();
  1263. ReferencedObjectsList += FString::Printf(TEXT(" %s.%s\n"), *PackageString, *FPackageName::GetLongPackageAssetName(PackageString));
  1264. }
  1265. }
  1266. }
  1267. }
  1268. return ReferencedObjectsList;
  1269. }
  1270. FString SExtDependencyViewer::GetReferencingObjectsList() const
  1271. {
  1272. FString ReferencingObjectsList;
  1273. TSet<FName> AllSelectedPackageNames;
  1274. GetPackageNamesFromSelectedNodes(AllSelectedPackageNames);
  1275. if (AllSelectedPackageNames.Num() > 0)
  1276. {
  1277. FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
  1278. for (const FName SelectedPackageName : AllSelectedPackageNames)
  1279. {
  1280. TArray<FName> HardDependencies;
  1281. FExtContentBrowserSingleton::GetAssetRegistry().GetReferencers(SelectedPackageName, HardDependencies, UE::AssetRegistry::EDependencyCategory::Package, UE::AssetRegistry::EDependencyQuery::Hard);
  1282. TArray<FName> SoftDependencies;
  1283. AssetRegistryModule.Get().GetReferencers(SelectedPackageName, SoftDependencies, UE::AssetRegistry::EDependencyCategory::Package, UE::AssetRegistry::EDependencyQuery::Soft);
  1284. ReferencingObjectsList += FString::Printf(TEXT("[%s - Referencers]\n"), *SelectedPackageName.ToString());
  1285. if (HardDependencies.Num() > 0)
  1286. {
  1287. ReferencingObjectsList += TEXT(" [HARD]\n");
  1288. for (const FName HardDependency : HardDependencies)
  1289. {
  1290. const FString PackageString = HardDependency.ToString();
  1291. ReferencingObjectsList += FString::Printf(TEXT(" %s.%s\n"), *PackageString, *FPackageName::GetLongPackageAssetName(PackageString));
  1292. }
  1293. }
  1294. if (SoftDependencies.Num() > 0)
  1295. {
  1296. ReferencingObjectsList += TEXT(" [SOFT]\n");
  1297. for (const FName SoftDependency : SoftDependencies)
  1298. {
  1299. const FString PackageString = SoftDependency.ToString();
  1300. ReferencingObjectsList += FString::Printf(TEXT(" %s.%s\n"), *PackageString, *FPackageName::GetLongPackageAssetName(PackageString));
  1301. }
  1302. }
  1303. }
  1304. }
  1305. return ReferencingObjectsList;
  1306. }
  1307. void SExtDependencyViewer::CopyReferencedObjects()
  1308. {
  1309. const FString ReferencedObjectsList = GetReferencedObjectsList();
  1310. FPlatformApplicationMisc::ClipboardCopy(*ReferencedObjectsList);
  1311. }
  1312. void SExtDependencyViewer::CopyReferencingObjects()
  1313. {
  1314. const FString ReferencingObjectsList = GetReferencingObjectsList();
  1315. FPlatformApplicationMisc::ClipboardCopy(*ReferencingObjectsList);
  1316. }
  1317. void SExtDependencyViewer::ShowReferencedObjects()
  1318. {
  1319. const FString ReferencedObjectsList = GetReferencedObjectsList();
  1320. SGenericDialogWidget::OpenDialog(LOCTEXT("ReferencedObjectsDlgTitle", "Referenced Objects"), SNew(STextBlock).Text(FText::FromString(ReferencedObjectsList)));
  1321. }
  1322. void SExtDependencyViewer::ShowReferencingObjects()
  1323. {
  1324. const FString ReferencingObjectsList = GetReferencingObjectsList();
  1325. SGenericDialogWidget::OpenDialog(LOCTEXT("ReferencingObjectsDlgTitle", "Referencing Objects"), SNew(STextBlock).Text(FText::FromString(ReferencingObjectsList)));
  1326. }
  1327. void SExtDependencyViewer::MakeCollectionWithReferencersOrDependencies(ECollectionShareType::Type ShareType, bool bReferencers)
  1328. {
  1329. TSet<FName> AllSelectedPackageNames;
  1330. GetPackageNamesFromSelectedNodes(AllSelectedPackageNames);
  1331. if (AllSelectedPackageNames.Num() > 0)
  1332. {
  1333. if (ensure(ShareType != ECollectionShareType::CST_All))
  1334. {
  1335. FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
  1336. FText CollectionNameAsText;
  1337. FString FirstAssetName = FPackageName::GetLongPackageAssetName(AllSelectedPackageNames.Array()[0].ToString());
  1338. if (bReferencers)
  1339. {
  1340. if (AllSelectedPackageNames.Num() > 1)
  1341. {
  1342. CollectionNameAsText = FText::Format(LOCTEXT("ReferencersForMultipleAssetNames", "{0}AndOthers_Referencers"), FText::FromString(FirstAssetName));
  1343. }
  1344. else
  1345. {
  1346. CollectionNameAsText = FText::Format(LOCTEXT("ReferencersForSingleAsset", "{0}_Referencers"), FText::FromString(FirstAssetName));
  1347. }
  1348. }
  1349. else
  1350. {
  1351. if (AllSelectedPackageNames.Num() > 1)
  1352. {
  1353. CollectionNameAsText = FText::Format(LOCTEXT("DependenciesForMultipleAssetNames", "{0}AndOthers_Dependencies"), FText::FromString(FirstAssetName));
  1354. }
  1355. else
  1356. {
  1357. CollectionNameAsText = FText::Format(LOCTEXT("DependenciesForSingleAsset", "{0}_Dependencies"), FText::FromString(FirstAssetName));
  1358. }
  1359. }
  1360. FName CollectionName;
  1361. CollectionManagerModule.Get().CreateUniqueCollectionName(*CollectionNameAsText.ToString(), ShareType, CollectionName);
  1362. FText ResultsMessage;
  1363. FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
  1364. TArray<FName> PackageNamesToAddToCollection;
  1365. if (bReferencers)
  1366. {
  1367. for (FName SelectedPackage : AllSelectedPackageNames)
  1368. {
  1369. FExtContentBrowserSingleton::GetAssetRegistry().GetReferencers(SelectedPackage, PackageNamesToAddToCollection);
  1370. }
  1371. }
  1372. else
  1373. {
  1374. for (FName SelectedPackage : AllSelectedPackageNames)
  1375. {
  1376. FExtContentBrowserSingleton::GetAssetRegistry().GetDependencies(SelectedPackage, PackageNamesToAddToCollection);
  1377. }
  1378. }
  1379. TSet<FName> PackageNameSet;
  1380. for (FName PackageToAdd : PackageNamesToAddToCollection)
  1381. {
  1382. if (!AllSelectedPackageNames.Contains(PackageToAdd))
  1383. {
  1384. PackageNameSet.Add(PackageToAdd);
  1385. }
  1386. }
  1387. //IAssetManagerEditorModule::Get().WriteCollection(CollectionName, ShareType, PackageNameSet.Array(), true);
  1388. }
  1389. }
  1390. }
  1391. void SExtDependencyViewer::ShowReferenceTree()
  1392. {
  1393. UObject* SelectedObject = GetObjectFromSingleSelectedNode();
  1394. if ( SelectedObject )
  1395. {
  1396. bool bObjectWasSelected = false;
  1397. for (FSelectionIterator It(*GEditor->GetSelectedObjects()) ; It; ++It)
  1398. {
  1399. if ( (*It) == SelectedObject )
  1400. {
  1401. GEditor->GetSelectedObjects()->Deselect( SelectedObject );
  1402. bObjectWasSelected = true;
  1403. }
  1404. }
  1405. ObjectTools::ShowReferenceGraph( SelectedObject );
  1406. if ( bObjectWasSelected )
  1407. {
  1408. GEditor->GetSelectedObjects()->Select( SelectedObject );
  1409. }
  1410. }
  1411. }
  1412. void SExtDependencyViewer::ViewSizeMap()
  1413. {
  1414. TArray<FExtAssetIdentifier> AssetIdentifiers;
  1415. TSet<UObject*> SelectedNodes = GraphEditorPtr->GetSelectedNodes();
  1416. for (UObject* Node : SelectedNodes)
  1417. {
  1418. UEdGraphNode_ExtDependency* ReferenceNode = Cast<UEdGraphNode_ExtDependency>(Node);
  1419. if (ReferenceNode)
  1420. {
  1421. ReferenceNode->GetAllIdentifiers(AssetIdentifiers);
  1422. }
  1423. }
  1424. #if ECB_LEGACY
  1425. if (AssetIdentifiers.Num() > 0)
  1426. {
  1427. IAssetManagerEditorModule::Get().OpenSizeMapUI(AssetIdentifiers);
  1428. }
  1429. #endif
  1430. }
  1431. void SExtDependencyViewer::ViewAssetAudit()
  1432. {
  1433. TSet<FName> SelectedAssetPackageNames;
  1434. GetPackageNamesFromSelectedNodes(SelectedAssetPackageNames);
  1435. #if ECB_LEGACY
  1436. if (SelectedAssetPackageNames.Num() > 0)
  1437. {
  1438. IAssetManagerEditorModule::Get().OpenAssetAuditUI(SelectedAssetPackageNames.Array());
  1439. }
  1440. #endif
  1441. }
  1442. void SExtDependencyViewer::ReCenterGraphOnNodes(const TSet<UObject*>& Nodes)
  1443. {
  1444. TArray<FExtAssetIdentifier> NewGraphRootNames;
  1445. FIntPoint TotalNodePos(ForceInitToZero);
  1446. for ( auto NodeIt = Nodes.CreateConstIterator(); NodeIt; ++NodeIt )
  1447. {
  1448. UEdGraphNode_ExtDependency* ReferenceNode = Cast<UEdGraphNode_ExtDependency>(*NodeIt);
  1449. if ( ReferenceNode )
  1450. {
  1451. ReferenceNode->GetAllIdentifiers(NewGraphRootNames);
  1452. TotalNodePos.X += ReferenceNode->NodePosX;
  1453. TotalNodePos.Y += ReferenceNode->NodePosY;
  1454. }
  1455. }
  1456. if ( NewGraphRootNames.Num() > 0 )
  1457. {
  1458. const FIntPoint AverageNodePos = TotalNodePos / NewGraphRootNames.Num();
  1459. GraphObj->SetGraphRoot(NewGraphRootNames, AverageNodePos);
  1460. UEdGraphNode_ExtDependency* NewRootNode = GraphObj->RebuildGraph();
  1461. if ( NewRootNode && ensure(GraphEditorPtr.IsValid()) )
  1462. {
  1463. GraphEditorPtr->ClearSelectionSet();
  1464. GraphEditorPtr->SetNodeSelection(NewRootNode, true);
  1465. }
  1466. // Set the initial history data
  1467. HistoryManager.AddHistoryData();
  1468. }
  1469. }
  1470. UObject* SExtDependencyViewer::GetObjectFromSingleSelectedNode() const
  1471. {
  1472. UObject* ReturnObject = nullptr;
  1473. TSet<UObject*> SelectedNodes = GraphEditorPtr->GetSelectedNodes();
  1474. if ( ensure(SelectedNodes.Num()) == 1 )
  1475. {
  1476. UEdGraphNode_ExtDependency* ReferenceNode = Cast<UEdGraphNode_ExtDependency>(SelectedNodes.Array()[0]);
  1477. if ( ReferenceNode )
  1478. {
  1479. const FExtAssetData& AssetData = ReferenceNode->GetAssetData();
  1480. if (AssetData.IsAssetLoaded())
  1481. {
  1482. ReturnObject = AssetData.GetAsset();
  1483. }
  1484. else
  1485. {
  1486. FScopedSlowTask SlowTask(0, LOCTEXT("LoadingSelectedObject", "Loading selection..."));
  1487. SlowTask.MakeDialog();
  1488. ReturnObject = AssetData.GetAsset();
  1489. }
  1490. }
  1491. }
  1492. return ReturnObject;
  1493. }
  1494. void SExtDependencyViewer::GetPackageNamesFromSelectedNodes(TSet<FName>& OutNames) const
  1495. {
  1496. TSet<UObject*> SelectedNodes = GraphEditorPtr->GetSelectedNodes();
  1497. for (UObject* Node : SelectedNodes)
  1498. {
  1499. UEdGraphNode_ExtDependency* ReferenceNode = Cast<UEdGraphNode_ExtDependency>(Node);
  1500. if (ReferenceNode)
  1501. {
  1502. TArray<FName> NodePackageNames;
  1503. ReferenceNode->GetAllPackageNames(NodePackageNames);
  1504. OutNames.Append(NodePackageNames);
  1505. }
  1506. }
  1507. }
  1508. bool SExtDependencyViewer::HasExactlyOneNodeSelected() const
  1509. {
  1510. if ( GraphEditorPtr.IsValid() )
  1511. {
  1512. return GraphEditorPtr->GetSelectedNodes().Num() == 1;
  1513. }
  1514. return false;
  1515. }
  1516. bool SExtDependencyViewer::HasExactlyOnePackageNodeSelected() const
  1517. {
  1518. if (GraphEditorPtr.IsValid())
  1519. {
  1520. if (GraphEditorPtr->GetSelectedNodes().Num() != 1)
  1521. {
  1522. return false;
  1523. }
  1524. TSet<UObject*> SelectedNodes = GraphEditorPtr->GetSelectedNodes();
  1525. for (UObject* Node : SelectedNodes)
  1526. {
  1527. UEdGraphNode_ExtDependency* ReferenceNode = Cast<UEdGraphNode_ExtDependency>(Node);
  1528. if (ReferenceNode)
  1529. {
  1530. if (ReferenceNode->IsPackage())
  1531. {
  1532. return true;
  1533. }
  1534. }
  1535. return false;
  1536. }
  1537. }
  1538. return false;
  1539. }
  1540. bool SExtDependencyViewer::HasAtLeastOnePackageNodeSelected() const
  1541. {
  1542. if ( GraphEditorPtr.IsValid() )
  1543. {
  1544. TSet<UObject*> SelectedNodes = GraphEditorPtr->GetSelectedNodes();
  1545. for (UObject* Node : SelectedNodes)
  1546. {
  1547. UEdGraphNode_ExtDependency* ReferenceNode = Cast<UEdGraphNode_ExtDependency>(Node);
  1548. if (ReferenceNode)
  1549. {
  1550. if (ReferenceNode->IsPackage())
  1551. {
  1552. return true;
  1553. }
  1554. }
  1555. }
  1556. }
  1557. return false;
  1558. }
  1559. bool SExtDependencyViewer::HasAtLeastOneRealNodeSelected() const
  1560. {
  1561. if (GraphEditorPtr.IsValid())
  1562. {
  1563. TSet<UObject*> SelectedNodes = GraphEditorPtr->GetSelectedNodes();
  1564. for (UObject* Node : SelectedNodes)
  1565. {
  1566. UEdGraphNode_ExtDependency* ReferenceNode = Cast<UEdGraphNode_ExtDependency>(Node);
  1567. if (ReferenceNode)
  1568. {
  1569. if (!ReferenceNode->IsCollapsed())
  1570. {
  1571. return true;
  1572. }
  1573. }
  1574. }
  1575. }
  1576. return false;
  1577. }
  1578. void SExtDependencyViewer::OnInitialAssetRegistrySearchComplete()
  1579. {
  1580. if ( GraphObj )
  1581. {
  1582. GraphObj->RebuildGraph();
  1583. }
  1584. }
  1585. void SExtDependencyViewer::ZoomToFitSelected()
  1586. {
  1587. if (GraphEditorPtr.IsValid())
  1588. {
  1589. GraphEditorPtr->ZoomToFit(/*bSelectedOnly*/true);
  1590. }
  1591. }
  1592. void SExtDependencyViewer::ZoomToFitAll()
  1593. {
  1594. if (GraphEditorPtr.IsValid())
  1595. {
  1596. GraphEditorPtr->ZoomToFit(/*bSelectedOnly*/false);
  1597. }
  1598. }
  1599. bool SExtDependencyViewer::CanZoomToFit() const
  1600. {
  1601. if (GraphEditorPtr.IsValid())
  1602. {
  1603. return true;
  1604. }
  1605. return false;
  1606. }
  1607. void SExtDependencyViewer::OnFind()
  1608. {
  1609. FSlateApplication::Get().SetKeyboardFocus(SearchBox, EFocusCause::SetDirectly);
  1610. }
  1611. void SExtDependencyViewer::HandleOnSearchTextChanged(const FText& SearchText)
  1612. {
  1613. if (GraphObj == nullptr || !GraphEditorPtr.IsValid())
  1614. {
  1615. return;
  1616. }
  1617. GraphEditorPtr->ClearSelectionSet();
  1618. if (SearchText.IsEmpty())
  1619. {
  1620. return;
  1621. }
  1622. FString SearchString = SearchText.ToString();
  1623. TArray<FString> SearchWords;
  1624. SearchString.ParseIntoArrayWS( SearchWords );
  1625. TArray<UEdGraphNode_ExtDependency*> AllNodes;
  1626. GraphObj->GetNodesOfClass<UEdGraphNode_ExtDependency>( AllNodes );
  1627. TArray<FName> NodePackageNames;
  1628. for (UEdGraphNode_ExtDependency* Node : AllNodes)
  1629. {
  1630. NodePackageNames.Empty();
  1631. Node->GetAllPackageNames(NodePackageNames);
  1632. for (const FName& PackageName : NodePackageNames)
  1633. {
  1634. // package name must match all words
  1635. bool bMatch = true;
  1636. for (const FString& Word : SearchWords)
  1637. {
  1638. if (!PackageName.ToString().Contains(Word))
  1639. {
  1640. bMatch = false;
  1641. break;
  1642. }
  1643. }
  1644. if (bMatch)
  1645. {
  1646. GraphEditorPtr->SetNodeSelection(Node, true);
  1647. break;
  1648. }
  1649. }
  1650. }
  1651. }
  1652. void SExtDependencyViewer::HandleOnSearchTextCommitted(const FText& SearchText, ETextCommit::Type CommitType)
  1653. {
  1654. if (!GraphEditorPtr.IsValid())
  1655. {
  1656. return;
  1657. }
  1658. if (CommitType == ETextCommit::OnCleared)
  1659. {
  1660. GraphEditorPtr->ClearSelectionSet();
  1661. }
  1662. GraphEditorPtr->ZoomToFit(true);
  1663. }
  1664. #undef LOCTEXT_NAMESPACE