WwiseReconcile.h 3.2 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 "Wwise/WwiseProjectDatabaseImpl.h"
  17. #include "WaapiPicker/WwiseTreeItem.h"
  18. #include "Wwise/Ref/WwiseAnyRef.h"
  19. struct FScopedSlowTask;
  20. enum class EWwiseReconcileOperationFlags
  21. {
  22. None = 0,
  23. Create = 1 << 0,
  24. UpdateExisting = 1 << 1,
  25. RenameExisting = 1 << 2,
  26. Delete = 1 << 3,
  27. All = Create | UpdateExisting | Delete | RenameExisting
  28. };
  29. ENUM_CLASS_FLAGS(EWwiseReconcileOperationFlags)
  30. struct FWwiseNewAsset
  31. {
  32. const FWwiseAnyRef* WwiseAnyRef = nullptr;
  33. bool bAssetExists = false;
  34. };
  35. struct FWwiseReconcileItem
  36. {
  37. EWwiseReconcileOperationFlags OperationRequired = EWwiseReconcileOperationFlags::None;
  38. FAssetData Asset;
  39. FWwiseNewAsset WwiseAnyRef;
  40. FGuid ItemId;
  41. bool operator==(const FWwiseReconcileItem& Other) const
  42. {
  43. if(ItemId.IsValid())
  44. {
  45. return ItemId == Other.ItemId;
  46. }
  47. else
  48. {
  49. return Asset.AssetName == Other.Asset.AssetName;
  50. }
  51. }
  52. };
  53. class WWISERECONCILE_API FWwiseReconcile
  54. {
  55. TMap<FGuid, FWwiseNewAsset> GuidToWwiseRef;
  56. TArray<FAssetData> AssetsToUpdate;
  57. TArray<FAssetData> AssetsToRename;
  58. TArray<FAssetData> AssetsToDelete;
  59. TArray<FWwiseNewAsset> AssetsToCreate;
  60. static FWwiseReconcile* Instance;
  61. FWwiseReconcile() {};
  62. bool IsAssetOutOfDate(const FAssetData& AssetData, const FWwiseAnyRef& WwiseRef);
  63. void GetAllWwiseRefs();
  64. friend class FWwiseReconcileModule;
  65. static void Init();
  66. static void Terminate();
  67. public:
  68. static FWwiseReconcile* Get();
  69. void GetAllAssets(TArray<FWwiseReconcileItem>& ReconcileItems);
  70. TArray<FAssetData> CreateAssets(FScopedSlowTask& SlowTask);
  71. TArray<FAssetData> UpdateExistingAssets(FScopedSlowTask& SlowTask);
  72. void ConvertWwiseItemTypeToReconcileItem(const TArray<TSharedPtr<FWwiseTreeItem>>& InWwiseItems, TArray<FWwiseReconcileItem>& OutReconcileItems, EWwiseReconcileOperationFlags OperationFlags = EWwiseReconcileOperationFlags::All, bool bFirstLevel = true);
  73. bool RenameExistingAssets(FScopedSlowTask& SlowTask);
  74. int GetNumberOfAssets();
  75. int32 DeleteAssets(FScopedSlowTask& SlowTask);
  76. UClass* GetUClassFromWwiseRefType(EWwiseRefType RefType);
  77. void GetAssetChanges(TArray<FWwiseReconcileItem>& ReconcileItems, EWwiseReconcileOperationFlags OperationFlags = EWwiseReconcileOperationFlags::All);
  78. bool ReconcileAssets(EWwiseReconcileOperationFlags OperationFlags = EWwiseReconcileOperationFlags::All);
  79. };