WwiseBrowserDataSource.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 "CoreMinimal.h"
  17. #include "UAssetDataSource.h"
  18. #include "WaapiDataSource.h"
  19. #include "../WwiseBrowserForwards.h"
  20. #include "WwiseItemType.h"
  21. #include "WwiseProjectDatabaseSource.h"
  22. #include "WwiseBrowser/WwiseAssetDragDropOp.h"
  23. struct FWwiseTreeItem;
  24. enum ESoundBankStatusFilter
  25. {
  26. NewInWwise,
  27. DeletedInWwise,
  28. RenamedInWwise,
  29. NotInWwise,
  30. MovedInWwise,
  31. UpToDate,
  32. NumberOfSoundBankStatus
  33. };
  34. enum EUAssetStatusFilter
  35. {
  36. UAssetMissing,
  37. NotInSoundBankOrUnreal,
  38. UAssetOrphaned,
  39. RenamedInSoundBank,
  40. MultipleUAssets,
  41. UAssetNeedsUpdate,
  42. UAssetUpToDate,
  43. NumberOfUAssetStatus
  44. };
  45. enum EWwiseTypeFilter
  46. {
  47. AcousticTexture,
  48. Effects,
  49. Events,
  50. GameParameters,
  51. MasterMixerHierarchy,
  52. State,
  53. Switch,
  54. Trigger,
  55. NumberOfWwiseTypes
  56. };
  57. struct FSoundBankStatusFilter
  58. {
  59. bool bFilters[NumberOfSoundBankStatus] = { false };
  60. bool IsKeptInBrowser(FWwiseTreeItemPtr& Item) const;
  61. bool AreFiltersOff() const;
  62. };
  63. struct FUAssetStatusFilter
  64. {
  65. bool bFilters[NumberOfUAssetStatus] = { false };
  66. bool IsKeptInBrowser(FWwiseTreeItemPtr& Item) const;
  67. bool AreFiltersOff() const;
  68. };
  69. struct FWwiseTypeFilter
  70. {
  71. bool bFilters[NumberOfWwiseTypes] = { false };
  72. bool IsKeptInBrowser(FWwiseTreeItemPtr& Item) const;
  73. bool AreFiltersOff() const;
  74. private:
  75. EWwiseItemType::Type GetExpectedType(EWwiseTypeFilter Filter) const;
  76. };
  77. class FWwiseBrowserDataSource
  78. {
  79. public:
  80. DECLARE_DELEGATE(FOnWwiseBrowserDataSourceRefreshed)
  81. FWwiseBrowserDataSource();
  82. ~FWwiseBrowserDataSource();
  83. void ConstructTree();
  84. bool AreFiltersOff();
  85. void ApplyTextFilter(TSharedPtr<StringFilter> FilterText);
  86. void ApplyFilter(FSoundBankStatusFilter SoundBankStatusFilter,
  87. FUAssetStatusFilter UAssetStatusFilter,
  88. FWwiseTypeFilter WwiseTypeFilter);
  89. void ApplyFilter(FWwiseTreeItemPtr Item, FWwiseTreeItemPtr& OutItem);
  90. void ClearFilter();
  91. bool IsKeptInBrowser(FWwiseTreeItemPtr Item);
  92. FWwiseTreeItemPtr GetTreeRootForType(EWwiseItemType::Type ItemType, const FString& FilterText={});
  93. FText GetProjectName();
  94. FText GetConnectedWwiseProjectName();
  95. int32 LoadChildren(FWwiseTreeItemPtr TreeItem, TArray<FWwiseTreeItemPtr>& OutChildren);
  96. // Clean placeholder children
  97. void ClearEmptyChildren(FWwiseTreeItemPtr TreeItem);
  98. EWwiseConnectionStatus GetWaapiConnectionStatus() const;
  99. FString GetItemWorkUnitPath(FWwiseTreeItemPtr InTreeItem);
  100. void SelectInWwiseProjectExplorer(TArray<FWwiseTreeItemPtr>& InTreeItem);
  101. FOnWwiseBrowserDataSourceRefreshed WwiseBrowserDataSourceRefreshed;
  102. FOnWaapiSelectionChange WwiseSelectionChange;
  103. FOnWaapiSelectionChange WwiseExpansionChange;
  104. FDelegateHandle PostEditorTickHandle;
  105. void HandleFindWwiseItemInProjectExplorerCommandExecute(const TArray<FWwiseTreeItemPtr>& SelectedItems) const;
  106. void CreateProjectDBItem(const FWwiseTreeItemPtr& TreeItemRootSoundBank, FWwiseTreeItemPtr& TreeItemRootDst);
  107. void CreateWaapiExclusiveItem(const FWwiseTreeItemPtr& WaapiItem, FWwiseTreeItemPtr& TreeItemRootDst);
  108. void CreateWaapiItem(const FWwiseTreeItemPtr& TreeItemRootWwise, FWwiseTreeItemPtr& TreeItemRootDst);
  109. private:
  110. void MergeDataSources(bool bGenerateUAssetsInfo = true);
  111. bool bIsDirty = false;
  112. float AssetUpdateTimer = 0.f;
  113. const float AssetTimerRefresh = 0.1f;
  114. TUniquePtr<FWaapiDataSource> WaapiDataSource;
  115. TUniquePtr<FWwiseProjectDatabaseDataSource> ProjectDBDataSource;
  116. TUniquePtr<FUAssetDataSource> UAssetDataSource;
  117. /** Root items, one for each type of Wwise object */
  118. FCriticalSection RootItemsLock;
  119. TArray< FWwiseTreeItemPtr > RootItems;
  120. TArray< FWwiseTreeItemPtr > RootItemsUnfiltered;
  121. TSharedPtr<StringFilter> CurrentFilterText;
  122. FSoundBankStatusFilter SoundBankStatusFilter;
  123. FUAssetStatusFilter UAssetStatusFilter;
  124. FWwiseTypeFilter WwiseTypeFilter;
  125. // Merges TreeItemRootSrc and TreeItemRootDst, with the resulting tree in TreeItemRootDst. New TreeItems will be created if they do not exist in TreeItemRootDst
  126. void CreateUnifiedTree(const FWwiseTreeItemPtr& TreeItemRootSoundBank, const FWwiseTreeItemPtr& TreeItemRootWaapi, FWwiseTreeItemPtr& TreeItemRootDst);
  127. void OnWaapiDataSourceRefreshed();
  128. void OnProjectDBDataSourceRefreshed();
  129. void SetupAssetCallbacks();
  130. void OnFilesFullyLoaded();
  131. void OnTimerTick(float DeltaSeconds);
  132. void OnUAssetSourceRefresh(const FAssetData& RemovedAssetData);
  133. void OnUAssetSourceRefresh(const FAssetData& RemovedAssetData, const FString& OldPath);
  134. void OnWwiseSelectionChange(const TArray<TSharedPtr<FWwiseTreeItem>>& Items);
  135. void OnWwiseExpansionChange(const TArray<TSharedPtr<FWwiseTreeItem>>& Items);
  136. FDelegateHandle OnAssetAdded;
  137. FDelegateHandle OnAssetRemoved;
  138. FDelegateHandle OnAssetRenamed;
  139. FDelegateHandle OnAssetUpdated;
  140. FDelegateHandle OnFilesLoaded;
  141. };