GeneratedSoundBanksDirectoryWatcher.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 "IDirectoryWatcher.h"
  17. #include "Widgets/Notifications/SNotificationList.h"
  18. DECLARE_MULTICAST_DELEGATE(OnSoundBankGenerationDoneDelegate);
  19. class AUDIOKINETICTOOLS_API GeneratedSoundBanksDirectoryWatcher
  20. {
  21. public:
  22. bool DoesWwiseProjectExist();
  23. void CheckIfCachePathChanged();
  24. void Initialize();
  25. void Uninitialize(const bool bIsModuleShutdown = false);
  26. void StartWatchers();
  27. //Watch the SoundBankInfoCache.dat file. Changes to this file indicate that sound data generation is done
  28. bool StartCacheWatcher(const FString& CachePath);
  29. //Watch for changes to GeneratedSoundBanks folder, triggering a countdown timer to parse once no more changes are detected after a certain delay
  30. void StartSoundBanksWatcher(const FString& GeneratedSoundBanksFolder);
  31. void StopWatchers();
  32. void StopSoundBanksWatcher();
  33. void StopCacheWatcher();
  34. void RestartWatchers();
  35. void ConditionalRestartWatchers();
  36. bool ShouldRestartWatchers();
  37. OnSoundBankGenerationDoneDelegate OnSoundBanksGenerated;
  38. private:
  39. FString CachePath;
  40. FString SoundBankDirectory;
  41. void OnCacheChanged(const TArray<FFileChangeData>& ChangedFiles);
  42. void OnGeneratedSoundBanksChanged(const TArray<FFileChangeData>& ChangedFiles);
  43. void TimerTick(float DeltaSeconds);
  44. void EndParseTimer();
  45. void OnSoundBankGenerationDone() const;
  46. void NotifyFilesChanged();
  47. void HideNotification();
  48. void UpdateNotificationOnGenerationComplete() const;
  49. void UpdateNotification() const;
  50. FDelegateHandle GeneratedSoundBanksHandle;
  51. FDelegateHandle CacheChangedHandle;
  52. FDelegateHandle PostEditorTickHandle;
  53. FDelegateHandle ProjectParsedHandle;
  54. FDelegateHandle SettingsChangedHandle;
  55. FDelegateHandle UserSettingsChangedHandle;
  56. bool bParseTimerRunning = false;
  57. float ParseTimer= 0;
  58. const float ParseDelaySeconds = 10.0f;
  59. TSharedPtr<SNotificationItem> NotificationItem;
  60. bool bCacheFolderExists = false;
  61. bool bGeneratedSoundBanksFolderExists = false;
  62. };