AkSettingsPerUser.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #include "AkSettingsPerUser.h"
  16. #include "AkAudioDevice.h"
  17. #include "Misc/Paths.h"
  18. #include "WwiseUnrealDefines.h"
  19. #if WITH_EDITOR
  20. #include "AkUnrealEditorHelper.h"
  21. #endif
  22. //////////////////////////////////////////////////////////////////////////
  23. // UAkSettingsPerUser
  24. UAkSettingsPerUser::UAkSettingsPerUser(const FObjectInitializer& ObjectInitializer)
  25. : Super(ObjectInitializer)
  26. {
  27. #if WITH_EDITOR
  28. WwiseWindowsInstallationPath.Path = FPlatformMisc::GetEnvironmentVariable(TEXT("WWISEROOT"));
  29. VisualizeRoomsAndPortals = false;
  30. bShowReverbInfo = true;
  31. #endif
  32. }
  33. #if WITH_EDITOR
  34. void UAkSettingsPerUser::PreEditChange(FProperty* PropertyAboutToChange)
  35. {
  36. PreviousWwiseWindowsInstallationPath = WwiseWindowsInstallationPath.Path;
  37. PreviousWwiseMacInstallationPath = WwiseMacInstallationPath.FilePath;
  38. PreviousGeneratedSoundBanksFolder = RootOutputPathOverride.Path;
  39. }
  40. void UAkSettingsPerUser::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
  41. {
  42. const FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
  43. const FName MemberPropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.MemberProperty->GetFName() : NAME_None;
  44. if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, WwiseWindowsInstallationPath))
  45. {
  46. AkUnrealEditorHelper::SanitizePath(WwiseWindowsInstallationPath.Path, PreviousWwiseWindowsInstallationPath, FText::FromString("Please enter a valid Wwise Installation path"));
  47. }
  48. else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, WwiseMacInstallationPath))
  49. {
  50. AkUnrealEditorHelper::SanitizePath(WwiseMacInstallationPath.FilePath, PreviousWwiseMacInstallationPath, FText::FromString("Please enter a valid Wwise Authoring Mac executable path"));
  51. }
  52. else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, bAutoConnectToWAAPI))
  53. {
  54. OnAutoConnectToWaapiChanged.Broadcast();
  55. }
  56. else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, WaapiTranslatorTimeout))
  57. {
  58. FAkAudioDevice* AkAudioDevice = FAkAudioDevice::Get();
  59. if (AkAudioDevice)
  60. {
  61. AkAudioDevice->SetLocalOutput();
  62. }
  63. }
  64. else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, RootOutputPathOverride))
  65. {
  66. bool bPathChanged = AkUnrealEditorHelper::SanitizeFolderPathAndMakeRelativeToContentDir(
  67. RootOutputPathOverride.Path, PreviousGeneratedSoundBanksFolder,
  68. FText::FromString("Please enter a valid directory path"));
  69. if (bPathChanged)
  70. {
  71. OnGeneratedSoundBanksPathChanged.Broadcast();
  72. }
  73. OnGeneratedSoundBanksPathChanged.Broadcast();
  74. }
  75. else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, VisualizeRoomsAndPortals))
  76. {
  77. OnShowRoomsPortalsChanged.Broadcast();
  78. }
  79. else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, bShowReverbInfo))
  80. {
  81. OnShowReverbInfoChanged.Broadcast();
  82. }
  83. if(RootOutputPathOverride.Path.IsEmpty())
  84. {
  85. RootOutputPathOverride = GeneratedSoundBanksFolderOverride_DEPRECATED;
  86. }
  87. Super::PostEditChangeProperty(PropertyChangedEvent);
  88. }
  89. void UAkSettingsPerUser::ToggleVisualizeRoomsAndPortals()
  90. {
  91. VisualizeRoomsAndPortals = !VisualizeRoomsAndPortals;
  92. OnShowRoomsPortalsChanged.Broadcast();
  93. }
  94. void UAkSettingsPerUser::ToggleShowReverbInfo()
  95. {
  96. bShowReverbInfo = !bShowReverbInfo;
  97. OnShowReverbInfoChanged.Broadcast();
  98. }
  99. #endif