AkAssetMigrationHelper.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 "Containers/Map.h"
  17. #include "Containers/Array.h"
  18. #include "Misc/Guid.h"
  19. #include "AssetRegistry/AssetData.h"
  20. struct PropertyToChange;
  21. namespace AkAssetMigration
  22. {
  23. enum EBankTransferMode
  24. {
  25. NoTransfer,
  26. WAAPI,
  27. DefinitionFile,
  28. };
  29. struct FMigrationOperations
  30. {
  31. bool bDoDeprecatedAssetCleanup = false;
  32. bool bDoAssetMigration= false;
  33. bool bDoBankCleanup= false;
  34. bool bTransferAutoload = false;
  35. bool bDoProjectUpdate= false;
  36. bool bCancelled = false;
  37. bool bIgnoreBankTransferErrors = false;
  38. FString GeneratedSoundBankDirectory = "";
  39. FString DefinitionFilePath = "";
  40. EBankTransferMode BankTransferMethod = EBankTransferMode::NoTransfer;
  41. };
  42. struct FMigrationContext
  43. {
  44. bool bBanksInProject = false;
  45. bool bDeprecatedAssetsInProject = false;
  46. bool bAssetsNeedMigration = false;
  47. bool bProjectSettingsNotUpToDate = false;
  48. int NumDeprecatedAssetsInProject = 0;
  49. };
  50. struct FLinkedAssetEntry
  51. {
  52. FString AssetName;
  53. FGuid WwiseGuid;
  54. FString AssetPath;
  55. UPackage* Package;
  56. };
  57. struct FBankEntry
  58. {
  59. FAssetData BankAssetData;
  60. TArray<FLinkedAssetEntry> LinkedEvents;
  61. TArray<FLinkedAssetEntry> LinkedAuxBusses;
  62. };
  63. struct FBankTransferError
  64. {
  65. FString ErrorMessage;
  66. bool bHasBankEntry;
  67. FBankEntry BankEntry;
  68. };
  69. enum EDefinitionFileCreationResult
  70. {
  71. Success,
  72. OpenFailure,
  73. WriteFailure
  74. };
  75. void PromptMigration(const FMigrationContext& MigrationOptions, FMigrationOperations& OutMigrationOperations);
  76. bool MigrateAudioBanks(const FMigrationOperations& TransferMode, const bool bCleanupAssets, const bool bWasUsingEBP, const bool bTransferAutoLoad, const FString DefinitionFilePath);
  77. bool MigrateWwiseAssets(const TArray<FAssetData> & WwiseAssets, bool bShouldSplitSwitchContainerMedia);
  78. void FindWwiseAssetsInProject(TArray<FAssetData>& OutFoundAssets);
  79. bool PromptFailedBankTransfer(const TArray<FBankTransferError>& ErrorMessages);
  80. FString FormatWaapiErrorMessage(const TArray<FBankTransferError>& ErrorMessages);
  81. void FindDeprecatedAssets(TArray<FAssetData>& OutDeprecatedAssets);
  82. bool DeleteDeprecatedAssets(const TArray<FAssetData>& InAssetsToDelete);
  83. void FillBanksToTransfer(TMap<FString, FBankEntry>& BanksToTransfer);
  84. TArray<FBankTransferError> TransferUserBanksWaapi(const TMap<FString, FBankEntry>& BanksToTransfer, TSet<FAssetData>& FailedBanks, const bool bIncludeMedia);
  85. bool CreateBankWaapi(const FString& BankName, const FBankEntry& BankEntry, FGuid& OutBankGuid, TArray<FBankTransferError>& ErrorMessages);
  86. bool SetBankIncludesWaapi(const FBankEntry& BankEntry, const FGuid& BankId, const bool bIncludeMedia, TArray<FBankTransferError>& ErrorMessages);
  87. bool SaveProjectWaapi(TArray<FBankTransferError>& ErrorMessages);
  88. EDefinitionFileCreationResult WriteBankDefinitionFile(const TMap<FString, FBankEntry>& InBanksToTransfer, const bool bIncludeMedia, const FString DefinitionFilePath);
  89. bool WriteBankDefinition(const FBankEntry& BankEntry, TUniquePtr<IFileHandle>& FileWriter, const bool bIncludeMedia);
  90. bool MigrateProjectSettings(FString& ProjectContent, const bool bWasUsingEBP, const bool bUseGeneratedSubFolders, const FString& GeneratedSoundBanksFolder);
  91. bool SetStandardSettings(FString& ProjectContent);
  92. struct PropertyToChange
  93. {
  94. FString Name;
  95. FString Value;
  96. FString Xml;
  97. PropertyToChange(FString n, FString v, FString x)
  98. : Name(n)
  99. , Value(v)
  100. , Xml(x)
  101. {}
  102. };
  103. bool InsertProperties(const TArray<PropertyToChange>& PropertiesToChange, FString& ProjectContent);
  104. };