WwiseResourceLoaderModule.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 "Misc/ConfigCacheIni.h"
  19. class FWwiseResourceLoaderImpl;
  20. class FWwiseResourceLoader;
  21. class IWwiseResourceLoaderModule : public IModuleInterface
  22. {
  23. public:
  24. static FName GetModuleName()
  25. {
  26. static const FName ModuleName = GetModuleNameFromConfig();
  27. return ModuleName;
  28. }
  29. /**
  30. * Checks to see if this module is loaded and ready.
  31. *
  32. * @return True if the module is loaded and ready to use
  33. */
  34. static bool IsAvailable()
  35. {
  36. return FModuleManager::Get().IsModuleLoaded(GetModuleName());
  37. }
  38. static IWwiseResourceLoaderModule* GetModule()
  39. {
  40. const auto ModuleName = GetModuleName();
  41. if (ModuleName.IsNone())
  42. {
  43. return nullptr;
  44. }
  45. #if UE_SERVER
  46. return nullptr;
  47. #else
  48. FModuleManager& ModuleManager = FModuleManager::Get();
  49. IWwiseResourceLoaderModule* Result = ModuleManager.GetModulePtr<IWwiseResourceLoaderModule>(ModuleName);
  50. if (UNLIKELY(!Result))
  51. {
  52. if (UNLIKELY(IsEngineExitRequested()))
  53. {
  54. UE_LOG(LogLoad, Verbose, TEXT("Skipping reloading missing WwiseResourceLoaderImpl module: Exiting."));
  55. }
  56. else if (UNLIKELY(!IsInGameThread()))
  57. {
  58. UE_LOG(LogLoad, Warning, TEXT("Skipping loading missing WwiseResourceLoaderImpl module: Not in game thread"));
  59. }
  60. else
  61. {
  62. UE_LOG(LogLoad, Log, TEXT("Loading WwiseResourceLoaderImpl module: %s"), *ModuleName.GetPlainNameString());
  63. Result = ModuleManager.LoadModulePtr<IWwiseResourceLoaderModule>(ModuleName);
  64. if (UNLIKELY(!Result))
  65. {
  66. UE_LOG(LogLoad, Fatal, TEXT("Could not load WwiseResourceLoaderImpl module: %s not found"), *ModuleName.GetPlainNameString());
  67. }
  68. }
  69. }
  70. return Result;
  71. #endif
  72. }
  73. virtual FWwiseResourceLoader* GetResourceLoader() { return nullptr; }
  74. virtual FWwiseResourceLoaderImpl* InstantiateResourceLoaderImpl() { return nullptr; }
  75. virtual FWwiseResourceLoader* InstantiateResourceLoader() { return nullptr; }
  76. private:
  77. static inline FName GetModuleNameFromConfig()
  78. {
  79. FString ModuleName = TEXT("WwiseResourceLoader");
  80. GConfig->GetString(TEXT("Audio"), TEXT("WwiseResourceLoaderModuleName"), ModuleName, GEngineIni);
  81. return FName(ModuleName);
  82. }
  83. };