WwiseResourceCookerModule.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 "Misc/ConfigCacheIni.h"
  17. #include "Modules/ModuleManager.h"
  18. #include "UObject/Class.h"
  19. struct FWwiseSharedPlatformId;
  20. class FWwiseResourceCooker;
  21. UENUM()
  22. enum class EWwiseExportDebugNameRule
  23. {
  24. Release,
  25. Name,
  26. ObjectPath
  27. };
  28. class IWwiseResourceCookerModule : public IModuleInterface
  29. {
  30. public:
  31. void WWISERESOURCECOOKER_API StartupModule() override;
  32. void WWISERESOURCECOOKER_API ShutdownModule() override;
  33. static FName GetModuleName()
  34. {
  35. static const FName ModuleName = GetModuleNameFromConfig();
  36. return ModuleName;
  37. }
  38. /**
  39. * Checks to see if this module is loaded and ready.
  40. *
  41. * @return True if the module is loaded and ready to use
  42. */
  43. static bool IsAvailable()
  44. {
  45. return FModuleManager::Get().IsModuleLoaded(GetModuleName());
  46. }
  47. static IWwiseResourceCookerModule* GetModule()
  48. {
  49. const auto ModuleName = GetModuleName();
  50. if (ModuleName.IsNone())
  51. {
  52. return nullptr;
  53. }
  54. #if UE_SERVER
  55. return nullptr;
  56. #else
  57. FModuleManager& ModuleManager = FModuleManager::Get();
  58. IWwiseResourceCookerModule* Result = ModuleManager.GetModulePtr<IWwiseResourceCookerModule>(ModuleName);
  59. if (UNLIKELY(!Result))
  60. {
  61. if (UNLIKELY(IsEngineExitRequested()))
  62. {
  63. UE_LOG(LogLoad, Verbose, TEXT("Skipping reloading missing WwiseResourceCooker module: Exiting."));
  64. }
  65. else if (UNLIKELY(!IsInGameThread()))
  66. {
  67. UE_LOG(LogLoad, Warning, TEXT("Skipping loading missing WwiseResourceCooker module: Not in game thread"));
  68. }
  69. else
  70. {
  71. UE_LOG(LogLoad, Log, TEXT("Loading WwiseResourceCooker module: %s"), *ModuleName.GetPlainNameString());
  72. Result = ModuleManager.LoadModulePtr<IWwiseResourceCookerModule>(ModuleName);
  73. if (UNLIKELY(!Result))
  74. {
  75. UE_LOG(LogLoad, Fatal, TEXT("Could not load WwiseResourceCooker module: %s not found"), *ModuleName.GetPlainNameString());
  76. }
  77. }
  78. }
  79. return Result;
  80. #endif
  81. }
  82. virtual FWwiseResourceCooker* GetResourceCooker()
  83. {
  84. return nullptr;
  85. }
  86. virtual FWwiseResourceCooker* InstantiateResourceCooker()
  87. {
  88. return nullptr;
  89. }
  90. virtual FWwiseResourceCooker* CreateCookerForPlatform(
  91. const ITargetPlatform* TargetPlatform,
  92. const FWwiseSharedPlatformId& InPlatform,
  93. EWwiseExportDebugNameRule InExportDebugNameRule = EWwiseExportDebugNameRule::Release)
  94. {
  95. return nullptr;
  96. }
  97. virtual void DestroyCookerForPlatform(const ITargetPlatform* TargetPlatform)
  98. {
  99. }
  100. virtual FWwiseResourceCooker* GetCookerForPlatform(const ITargetPlatform* TargetPlatform)
  101. {
  102. return nullptr;
  103. }
  104. FWwiseResourceCooker* GetCookerForArchive(const FArchive& InArchive)
  105. {
  106. if (!InArchive.IsCooking() || !InArchive.IsSaving())
  107. {
  108. return nullptr;
  109. }
  110. return GetCookerForPlatform(InArchive.CookingTarget());
  111. }
  112. virtual void DestroyAllCookerPlatforms()
  113. {
  114. }
  115. protected:
  116. static WWISERESOURCECOOKER_API FDelegateHandle ModifyCookDelegateHandle;
  117. virtual void OnModifyCook(TConstArrayView<const ITargetPlatform*> InTargetPlatforms, TArray<FName>& InOutPackagesToCook, TArray<FName>& InOutPackagesToNeverCook)
  118. {
  119. }
  120. private:
  121. static inline FName GetModuleNameFromConfig()
  122. {
  123. FString ModuleName = TEXT("WwiseResourceCooker");
  124. GConfig->GetString(TEXT("Audio"), TEXT("WwiseResourceCookerModuleName"), ModuleName, GEngineIni);
  125. return FName(ModuleName);
  126. }
  127. };