AkSettingsPerUser.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 "AkUnrealHelper.h"
  19. #if WITH_EDITOR
  20. #include "AkUnrealEditorHelper.h"
  21. #include "SettingsEditor/Public/ISettingsEditorModule.h"
  22. #endif
  23. //////////////////////////////////////////////////////////////////////////
  24. // UAkSettingsPerUser
  25. UAkSettingsPerUser::UAkSettingsPerUser(const FObjectInitializer& ObjectInitializer)
  26. : Super(ObjectInitializer)
  27. {
  28. #if WITH_EDITOR
  29. WwiseWindowsInstallationPath.Path = FPlatformMisc::GetEnvironmentVariable(TEXT("WWISEROOT"));
  30. #endif
  31. }
  32. #if WITH_EDITOR
  33. void UAkSettingsPerUser::PreEditChange(FProperty* PropertyAboutToChange)
  34. {
  35. PreviousWwiseWindowsInstallationPath = WwiseWindowsInstallationPath.Path;
  36. PreviousWwiseMacInstallationPath = WwiseMacInstallationPath.FilePath;
  37. PreviousGeneratedSoundBanksFolder = GeneratedSoundBanksFolderUserOverride.Path;
  38. }
  39. void UAkSettingsPerUser::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
  40. {
  41. const FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
  42. const FName MemberPropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.MemberProperty->GetFName() : NAME_None;
  43. if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, WwiseWindowsInstallationPath))
  44. {
  45. AkUnrealEditorHelper::SanitizePath(WwiseWindowsInstallationPath.Path, PreviousWwiseWindowsInstallationPath, FText::FromString("Please enter a valid Wwise Installation path"));
  46. }
  47. else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, WwiseMacInstallationPath))
  48. {
  49. AkUnrealEditorHelper::SanitizePath(WwiseMacInstallationPath.FilePath, PreviousWwiseMacInstallationPath, FText::FromString("Please enter a valid Wwise Authoring Mac executable path"));
  50. }
  51. else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, bAutoConnectToWAAPI))
  52. {
  53. OnAutoConnectToWaapiChanged.Broadcast();
  54. }
  55. else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, WaapiTranslatorTimeout))
  56. {
  57. FAkAudioDevice* AkAudioDevice = FAkAudioDevice::Get();
  58. if (AkAudioDevice)
  59. {
  60. AkAudioDevice->SetLocalOutput();
  61. }
  62. }
  63. else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettingsPerUser, GeneratedSoundBanksFolderUserOverride))
  64. {
  65. bool bPathChanged = AkUnrealEditorHelper::SanitizeFolderPathAndMakeRelativeToContentDir(
  66. GeneratedSoundBanksFolderUserOverride.Path, PreviousGeneratedSoundBanksFolder,
  67. FText::FromString("Please enter a valid directory path"));
  68. if (bPathChanged)
  69. {
  70. OnGeneratedSoundBanksPathChanged.Broadcast();
  71. }
  72. OnGeneratedSoundBanksPathChanged.Broadcast();
  73. }
  74. Super::PostEditChangeProperty(PropertyChangedEvent);
  75. }
  76. #endif