SWwiseBrowser.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. #pragma once
  16. #include "WaapiPlaybackTransport.h"
  17. #include "DataSource/WwiseBrowserDataSource.h"
  18. #include "DataSource/WaapiDataSource.h"
  19. #include "Framework/Commands/UICommandList.h"
  20. #include "Misc/TextFilter.h"
  21. #include "Widgets/SCompoundWidget.h"
  22. #include "Styling/SlateBrush.h"
  23. #include "Framework/Views/ITypedTableView.h"
  24. #include "WwiseBrowser/IWwiseBrowserColumn.h"
  25. class FUICommandList;
  26. class STableViewBase;
  27. class ITableRow;
  28. class SHeaderRow;
  29. class FWwiseBrowserDataSource;
  30. class SWwiseBrowserTreeView;
  31. using StringFilter = TTextFilter<const FString&>;
  32. class WwiseBrowserBuilderVisitor;
  33. class FWwiseBrowserDataLoader;
  34. class SWwiseBrowser : public SCompoundWidget
  35. {
  36. public:
  37. SLATE_BEGIN_ARGS( SWwiseBrowser )
  38. : _FocusSearchBoxWhenOpened(false)
  39. , _ShowTreeTitle(true)
  40. , _ShowSearchBar(true)
  41. , _ShowSeparator(true)
  42. , _AllowContextMenu(true)
  43. , _SelectionMode( ESelectionMode::Multi )
  44. {}
  45. /** Content displayed to the left of the search bar */
  46. SLATE_NAMED_SLOT( FArguments, SearchContent )
  47. /** If true, the search box will be focus the frame after construction */
  48. SLATE_ARGUMENT( bool, FocusSearchBoxWhenOpened )
  49. /** If true, The tree title will be displayed */
  50. SLATE_ARGUMENT( bool, ShowTreeTitle )
  51. /** If true, The tree search bar will be displayed */
  52. SLATE_ARGUMENT( bool, ShowSearchBar )
  53. /** If true, The tree search bar separator be displayed */
  54. SLATE_ARGUMENT( bool, ShowSeparator )
  55. /** If false, the context menu will be suppressed */
  56. SLATE_ARGUMENT( bool, AllowContextMenu )
  57. /** The selection mode for the tree view */
  58. SLATE_ARGUMENT( ESelectionMode::Type, SelectionMode )
  59. SLATE_END_ARGS( )
  60. AUDIOKINETICTOOLS_API void Construct(const FArguments& InArgs);
  61. SWwiseBrowser(void);
  62. ~SWwiseBrowser();
  63. AUDIOKINETICTOOLS_API static const FName WwiseBrowserTabName;
  64. AUDIOKINETICTOOLS_API TSharedRef<SWidget> MakeAddFilterMenu();
  65. void SoundBankFilterExecute(ESoundBankStatusFilter Filter);
  66. bool SoundBankFilterIsChecked(ESoundBankStatusFilter Filter);
  67. void UAssetFilterExecute(EUAssetStatusFilter Filter);
  68. bool UAssetFilterIsChecked(EUAssetStatusFilter Filter);
  69. void WwiseTypeFilterExecute(EWwiseTypeFilter Filter);
  70. bool WwiseTypeFilterIsChecked(EWwiseTypeFilter Filter);
  71. void SoundBankNotUpToDateExecute();
  72. void RemoveFiltersExecute();
  73. void UAssetNotUpToDateExecute();
  74. AUDIOKINETICTOOLS_API void ForceRefresh();
  75. AUDIOKINETICTOOLS_API void InitialParse();
  76. static FReply DoDragDetected(const FPointerEvent& MouseEvent, const TArray<FWwiseTreeItemPtr>& SelectedItems);
  77. TAttribute<FText> GetFilterHighlightText() const;
  78. static void ImportWwiseAssets(const TArray<FWwiseTreeItemPtr>& SelectedItems, const FString& PackagePath);
  79. /** Get the columns to be displayed in this outliner */
  80. const TMap<FName, TSharedPtr<IWwiseBrowserColumn>>& GetColumns() const
  81. {
  82. return Columns;
  83. }
  84. virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override;
  85. EVisibility IsItemPlaying(FGuid ItemId) const;
  86. void ExpandItem(FWwiseTreeItemPtr TreeItem, bool bShouldExpand);
  87. void ExpandItem(FWwiseTreeItemPtr TreeItem);
  88. bool IsItemExpanded(FWwiseTreeItemPtr TreeItem);
  89. void UpdateWaapiSelection(const TArray<TSharedPtr<FWwiseTreeItem>>& WaapiTreeItems);
  90. EWwiseConnectionStatus IsWaapiAvailable() const;
  91. /** Prevent the selection changed callback from running when filtering */
  92. bool AllowTreeViewDelegates;
  93. private:
  94. /** The new tree view widget */
  95. TSharedPtr<SWwiseBrowserTreeView> TreeViewPtr;
  96. /** The header row of the browser tree view */
  97. TSharedPtr< SHeaderRow > HeaderRowWidget;
  98. /** Filter for the search box */
  99. TSharedPtr<StringFilter> SearchBoxFilter;
  100. /** True when the tree is current being filtered */
  101. bool bIsFilterApplied;
  102. FSoundBankStatusFilter SoundBankStatusFilter;
  103. FUAssetStatusFilter UAssetStatusFilter;
  104. FWwiseTypeFilter WwiseTypeFilter;
  105. const FSlateBrush* GetFilterBadgeIcon() const;
  106. void OnTextFilterUpdated();
  107. void OnFilterUpdated();
  108. void ApplyFilter();
  109. bool IsFiltering();
  110. FText GetFilterText();
  111. FString GetFilterString();
  112. /** Root items */
  113. TArray< FWwiseTreeItemPtr > RootItems;
  114. /** Remember the selected items. Useful when filtering to preserve selection status. */
  115. TSet< FString > LastSelectedPaths;
  116. /** Remember the expanded items. Useful when filtering to preserve expansion status. */
  117. TSet< FString > LastExpandedPaths;
  118. //Open the Wwise Integration settings
  119. FReply OnOpenSettingsClicked();
  120. /** Ran when the Refresh button is clicked. Parses the Wwise project (using the WwiseWwuParser) and populates the window. */
  121. FReply OnRefreshClicked();
  122. FReply OnGenerateSoundBanksClicked();
  123. FReply OnReconcileClicked();
  124. void OnTreeItemDoubleClicked(FWwiseTreeItemPtr TreeItem);
  125. /** Populates the browser window only (does not parse the Wwise project) */
  126. void ConstructTree();
  127. /** Generate a row in the tree view */
  128. TSharedRef<ITableRow> GenerateRow( FWwiseTreeItemPtr TreeItem, const TSharedRef<STableViewBase>& OwnerTable );
  129. /** Get the children of a specific tree element */
  130. void GetChildrenForTree( FWwiseTreeItemPtr TreeItem, TArray< FWwiseTreeItemPtr >& OutChildren );
  131. /** Commands handled by this widget */
  132. TSharedRef<FUICommandList> CommandList;
  133. /** Handle Drag & Drop */
  134. virtual FReply OnDragDetected(const FGeometry& Geometry, const FPointerEvent& MouseEvent) override;
  135. void ExpandFirstLevel();
  136. void ExpandParents(FWwiseTreeItemPtr Item);
  137. FText GetProjectName() const;
  138. FText GetConnectedWwiseProjectName() const;
  139. EVisibility IsWarningVisible() const;
  140. EVisibility IsWarningNotVisible() const;
  141. FText GetWarningText() const;
  142. FText GetConnectionStatusText() const;
  143. FText GetSoundBanksLocationText() const;
  144. FSlateColor GetSoundBanksLocationTextColor() const;
  145. /** Used by the search filter */
  146. void PopulateSearchStrings( const FString& FolderName, OUT TArray< FString >& OutSearchStrings ) const;
  147. void OnSearchBoxChanged( const FText& InSearchText );
  148. void SetItemVisibility(FWwiseTreeItemPtr Item, bool IsVisible);
  149. void SaveCurrentTreeExpansion();
  150. void RestoreTreeExpansion(const TArray< FWwiseTreeItemPtr >& Items);
  151. /** Handler for tree view selection changes */
  152. void TreeSelectionChanged( FWwiseTreeItemPtr TreeItem, ESelectInfo::Type SelectInfo );
  153. /** Handler for tree view expansion changes */
  154. void TreeExpansionChanged( FWwiseTreeItemPtr TreeItem, bool bIsExpanded );
  155. /** Builds the command list for the context menu on Wwise Browser items. */
  156. void CreateWwiseBrowserCommands();
  157. /** Callback for creating a context menu for the Wwise items list. */
  158. TSharedPtr<SWidget> MakeWwiseBrowserContextMenu();
  159. /** Callback to execute the play command from the context menu. Only available with a WAAPI connection. */
  160. void HandlePlayWwiseItemCommandExecute();
  161. bool HandlePlayOrStopWwiseItemCanExecute();
  162. /** Callback to execute the stop command from the context menu. Only available with a WAAPI connection. */
  163. void HandleStopWwiseItemCommandExecute();
  164. /** Callback to execute the stop all command from the context menu. Only available with a WAAPI connection. */
  165. void HandleStopAllWwiseItemCommandExecute();
  166. /** Finds the selected item's containing workunit in Explorer. Only available with a WAAPI connection */
  167. void HandleExploreWwiseItemCommandExecute();
  168. bool HandleExploreWwiseItemCanExecute();
  169. /** Finds the selected item in the Wwise Project Explorer. Only available with a WAAPI connection */
  170. void HandleFindInProjectExplorerWwiseItemCommandExecute();
  171. bool HandleFindInProjectExplorerWwiseItemCanExecute();
  172. /** Finds the selected item in the Content browser. */
  173. void HandleFindInContentBrowserCommandExecute();
  174. bool HandleFindInContentBrowserCanExecute();
  175. void HandleRefreshWwiseBrowserCommandExecute();
  176. /** Callback to import a Wwise item into the project's Contents*/
  177. void HandleImportWwiseItemCommandExecute() const;
  178. /** Callback to reconcile a Wwise item*/
  179. void HandleReconcileWwiseItemCommandExecute() const;
  180. /** Set up the columns required for this outliner */
  181. void SetupColumns(SHeaderRow& HeaderRow);
  182. void GetTreeItemsFromWaapi(const TArray<TSharedPtr<FWwiseTreeItem>>& WaapiTreeItems, TArray<TSharedPtr<FWwiseTreeItem>>& TreeItems);
  183. FWwiseTreeItemPtr GetTreeItemFromWaapiItem(FWwiseTreeItemPtr WaapiTreeItem);
  184. void ExpandItems(const TArray< FWwiseTreeItemPtr >& Items);
  185. void CreateReconcileTab() const;
  186. private:
  187. /** Map of columns that are shown on the Browser. */
  188. TMap<FName, TSharedPtr<IWwiseBrowserColumn>> Columns;
  189. /** DataSource responsible for loading all of the Browser's data through WAAPI, ProjectDB, Unreal assets */
  190. TUniquePtr<FWwiseBrowserDataSource> DataSource;
  191. /** Transport for handling playback of Wwise Items*/
  192. TUniquePtr<WaapiPlaybackTransport> Transport;
  193. };