AudiokineticToolsModule.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. /*=============================================================================
  17. AudiokineticToolsModule.h
  18. =============================================================================*/
  19. #include "AudiokineticToolsPrivatePCH.h"
  20. #include "AkAcousticPortal.h"
  21. #include "AkAudioBankGenerationHelpers.h"
  22. #include "AkComponent.h"
  23. #include "AkSettings.h"
  24. #include "AkSettingsPerUser.h"
  25. #include "AssetManagement/AkAssetMigrationManager.h"
  26. #include "AssetManagement/AkGenerateSoundBanksTask.h"
  27. #include "AssetManagement/GeneratedSoundBanksDirectoryWatcher.h"
  28. #include "AssetManagement/WwiseProjectInfo.h"
  29. #include "AssetToolsModule.h"
  30. #include "Factories/AkAssetTypeActions.h"
  31. #include "IAudiokineticTools.h"
  32. #include "WwiseBrowser/SWwiseBrowser.h"
  33. #include "Wwise/WwiseProjectDatabase.h"
  34. #include "GeneratedSoundBanksWarning.h"
  35. #include "ReloadPopup.h"
  36. #include "ComponentAssetBroker.h"
  37. #include "Developer/ToolMenus/Public/ToolMenu.h"
  38. #include "Editor/LevelEditor/Public/LevelEditor.h"
  39. #include "ISequencerModule.h"
  40. #include "ISettingsModule.h"
  41. #include "Internationalization/Culture.h"
  42. #include "Modules/ModuleManager.h"
  43. #include "Sequencer/MovieSceneAkAudioRTPCTrackEditor.h"
  44. #include "UnrealEd/Public/EditorBuildUtils.h"
  45. #include "Widgets/Docking/SDockTab.h"
  46. #include "Widgets/Input/SHyperlink.h"
  47. #define LOCTEXT_NAMESPACE "AkAudio"
  48. DEFINE_LOG_CATEGORY(LogAudiokineticTools);
  49. namespace
  50. {
  51. struct WwiseLanguageToUnrealCulture
  52. {
  53. const TCHAR* WwiseLanguage;
  54. const TCHAR* UnrealCulture;
  55. };
  56. // This list come from the fixed list of languages that were used before Wwise 2017.1
  57. const WwiseLanguageToUnrealCulture WwiseLanguageToUnrealCultureList[] = {
  58. {TEXT("Arabic"), TEXT("ar")},
  59. {TEXT("Bulgarian"), TEXT("bg")},
  60. {TEXT("Chinese(HK)"), TEXT("zh-HK")},
  61. {TEXT("Chinese(Malaysia)"), TEXT("zh")},
  62. {TEXT("Chinese(PRC)"), TEXT("zh-CN")},
  63. {TEXT("Chinese(Taiwan)"), TEXT("zh-TW")},
  64. {TEXT("Czech"), TEXT("cs")},
  65. {TEXT("Danish"), TEXT("da")},
  66. {TEXT("English(Australia)"), TEXT("en-AU")},
  67. {TEXT("English(Canada)"), TEXT("en-CA")},
  68. {TEXT("English(US)"), TEXT("en-US")},
  69. {TEXT("English(UK)"), TEXT("en-GB")},
  70. {TEXT("Finnish"), TEXT("fi")},
  71. {TEXT("French(Canada)"), TEXT("fr-CA")},
  72. {TEXT("French(France)"), TEXT("fr-FR")},
  73. {TEXT("German"), TEXT("de")},
  74. {TEXT("Greek"), TEXT("el")},
  75. {TEXT("Hebrew"), TEXT("he")},
  76. {TEXT("Hungarian"), TEXT("hu")},
  77. {TEXT("Indonesian"), TEXT("id")},
  78. {TEXT("Italian"), TEXT("it")},
  79. {TEXT("Japanese"), TEXT("ja")},
  80. {TEXT("Korean"), TEXT("ko")},
  81. {TEXT("Norwegian "), TEXT("no")},
  82. {TEXT("Polish"), TEXT("pl")},
  83. {TEXT("Portuguese(Brazil)"), TEXT("pt-BR")},
  84. {TEXT("Portuguese(Portugal)"), TEXT("pt-PT")},
  85. {TEXT("Romanian"), TEXT("ro")},
  86. {TEXT("Russian"), TEXT("ru")},
  87. {TEXT("Slovenian"), TEXT("sl")},
  88. {TEXT("Spanish(Mexico)"), TEXT("es-MX")},
  89. {TEXT("Spanish(Spain)"), TEXT("es-ES")},
  90. {TEXT("Swedish"), TEXT("sv")},
  91. {TEXT("Thai"), TEXT("th")},
  92. {TEXT("Turkish"), TEXT("tr")},
  93. {TEXT("Ukrainian"), TEXT("uk")},
  94. {TEXT("Vietnamese"), TEXT("vi")},
  95. };
  96. }
  97. struct SettingsRegistrationStruct
  98. {
  99. SettingsRegistrationStruct(UClass* SettingsClass, const FName& SectionName, const FText& DisplayName, const FText& Description)
  100. : SettingsClass(SettingsClass), SectionName(SectionName), DisplayName(DisplayName), Description(Description)
  101. {}
  102. void Register(ISettingsModule* SettingsModule) const
  103. {
  104. SettingsModule->RegisterSettings("Project", "Wwise", SectionName, DisplayName, Description, SettingsObject());
  105. }
  106. void Unregister(ISettingsModule* SettingsModule) const
  107. {
  108. SettingsModule->UnregisterSettings("Project", "Wwise", SectionName);
  109. }
  110. private:
  111. UClass* SettingsClass;
  112. const FName SectionName;
  113. const FText DisplayName;
  114. const FText Description;
  115. UObject* SettingsObject() const { return SettingsClass->GetDefaultObject(); }
  116. };
  117. class FAudiokineticToolsModule : public IAudiokineticTools
  118. {
  119. public:
  120. /**
  121. * Creates a new WwiseBrowser tab.
  122. *
  123. * @param SpawnTabArgs The arguments for the tab to spawn.
  124. * @return The spawned tab.
  125. */
  126. TSharedRef<SDockTab> CreateWwiseBrowserTab(const FSpawnTabArgs& SpawnTabArgs);
  127. void RefreshWwiseProject() override;
  128. void OpenOnlineHelp();
  129. static void ToggleVisualizeRoomsAndPortals();
  130. static bool IsVisualizeRoomsAndPortalsEnabled();
  131. static ECheckBoxState GetVisualizeRoomsAndPortalsCheckBoxState();
  132. static void ToggleShowReverbInfo();
  133. static bool IsReverbInfoEnabled();
  134. static ECheckBoxState GetReverbInfoCheckBoxState();
  135. void CreateAkViewportCommands();
  136. void RegisterWwiseMenus();
  137. void UpdateUnrealCultureToWwiseCultureMap(const WwiseProjectInfo& wwiseProjectInfo);
  138. void VerifyGeneratedSoundBanksPath(UAkSettings* AkSettings, UAkSettingsPerUser* AkSettingsPerUser);
  139. void OnAssetRegistryFilesLoaded();
  140. virtual void StartupModule() override;
  141. virtual void OnAkAudioInit();
  142. void OnSoundBanksFolderChanged();
  143. void BeginPIE(bool bIsSimulating);
  144. void DisplayGeneratedSoundBanksWarning();
  145. void AssetReloadPrompt();
  146. void OpenAssetReloadPopup();
  147. static void ParseGeneratedSoundBankData();
  148. virtual void ShutdownModule() override;
  149. static EEditorBuildResult BuildAkEventData(UWorld* world, FName name);
  150. static FAudiokineticToolsModule* AudiokineticToolsModuleInstance;
  151. void RefreshAndUpdateTextureParams();
  152. private:
  153. static TMap<FString, SettingsRegistrationStruct>& GetWwisePlatformNameToSettingsRegistrationMap();
  154. TSet<FString> RegisteredSettingsNames;
  155. void RegisterSettings();
  156. void UnregisterSettings();
  157. /** Ak-specific viewport actions */
  158. FUIAction ToggleVizRoomsPortalsAction;
  159. FUIAction ToggleReverbInfoAction;
  160. TArray<TSharedPtr<FAssetTypeActions_Base>> AkAssetTypeActionsArray;
  161. TSharedPtr<FExtender> MainMenuExtender;
  162. FLevelEditorModule::FLevelEditorMenuExtender LevelViewportToolbarBuildMenuExtenderAk;
  163. FDelegateHandle LevelViewportToolbarBuildMenuExtenderAkHandle;
  164. FDelegateHandle OnAssetRegistryFilesLoadedHandle;
  165. FDelegateHandle RTPCTrackEditorHandle;
  166. FDelegateHandle EventTrackEditorHandle;
  167. /** Allow to create an AkComponent when Drag & Drop of an AkEvent */
  168. TSharedPtr<IComponentAssetBroker> AkEventBroker;
  169. FDoEditorBuildDelegate buildDelegate;
  170. AkAssetMigrationManager AssetMigrationManager;
  171. GeneratedSoundBanksDirectoryWatcher SoundBanksDirectoryWatcher;
  172. FDelegateHandle OnDatabaseUpdateCompleteHandle;
  173. FDelegateHandle OnDatabaseUpdateTextureHandle;
  174. FReloadPopup ReloadPopup = FReloadPopup();
  175. FGeneratedSoundBanksWarning GeneratedSoundBanksWarning = FGeneratedSoundBanksWarning();
  176. };
  177. IMPLEMENT_MODULE(FAudiokineticToolsModule, AudiokineticTools);
  178. #undef LOCTEXT_NAMESPACE