WwiseBrowserHelpers.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 "WwiseBrowserForwards.h"
  17. #include "Templates/SharedPointer.h"
  18. #include "AssetRegistry/AssetData.h"
  19. #include "WaapiPicker/WwiseTreeItem.h"
  20. #include "WwiseBrowserHelpers.generated.h"
  21. class UAkAssetFactory;
  22. class UObject;
  23. class FString;
  24. UCLASS()
  25. class UAkDragDropBlocker : public UObject
  26. {
  27. GENERATED_BODY()
  28. };
  29. namespace WwiseBrowserHelpers
  30. {
  31. struct WwiseBrowserAssetPayload
  32. {
  33. FAssetData CreatedAsset;
  34. TArray<FAssetData> ExistingAssets;
  35. FString RelativePackagePath;
  36. FString Name;
  37. FGuid WwiseObjectGuid;
  38. };
  39. enum EAssetCreationMode
  40. {
  41. Transient,
  42. InPackage
  43. };
  44. enum EAssetDuplicationMode
  45. {
  46. DoDuplication,
  47. NoDuplication
  48. };
  49. /**
  50. * Recursively iterates over a WwiseTreeItem and its children
  51. * Found assets are added to the ExistingAssets array in the payload
  52. * If no assets are found, a new asset is created and the payload's CreatedAsset field is set
  53. *
  54. * @param WwiseTreeItem Current WwiseTreeItem we want to create assets from
  55. * @param InOutBrowserAssetPayloads The recursively filled array of WwiseBrowserAssetPayloads
  56. * @param InOutKnownGuids List of encountered Guids so the same asset payload is not created twice
  57. * This can happen when both an asset and its parent are selected in the browser
  58. * @param AssetCreationMode Create assets in the transient package or directly in the content directory
  59. * @param PackagePath Root path where the assets should be saved when AssetCreationMode is 'InPackage'
  60. * @param CurrentRelativePath Recursively built path of the assets relative to the root tree item
  61. */
  62. void FindOrCreateAssetsRecursive(
  63. const FWwiseTreeItemPtr& WwiseTreeItem,
  64. TArray<WwiseBrowserAssetPayload>& InOutBrowserAssetPayloads,
  65. TSet<FGuid>& InOutKnownGuids,
  66. const EAssetCreationMode AssetCreationMode,
  67. const FString& PackagePath = "",
  68. const FString& CurrentRelativePath = ""
  69. );
  70. FAssetData CreateBrowserAsset(const FString& AssetName, const FWwiseTreeItemPtr& WwiseTreeItem, UClass* AssetClass, const EAssetCreationMode AssetCreationMode, const FString& PackagePath);
  71. FAssetData CreateBrowserAssetTask(const FString& AssetName, const FWwiseTreeItemPtr& WwiseTreeItem, UClass* AssetClass, const EAssetCreationMode AssetCreationMode, const FString& PackagePath);
  72. FAssetData CreateTransientAsset(const ::FString& AssetName, const FWwiseTreeItemPtr& WwiseTreeItem, UClass* AssetClass);
  73. FAssetData CreateAssetInPackage(const ::FString& AssetName, const FWwiseTreeItemPtr& WwiseTreeItem, const FString& PackagePath, UClass* AssetClass);
  74. FAssetData CreateAsset(const ::FString& AssetName, const FWwiseTreeItemPtr& WwiseTreeItem, UClass* AssetClass, UPackage* Pkg);
  75. /**
  76. * Save, rename, duplicate assets produced by FindOrCreateAssetsRecursive
  77. *
  78. * @param Assets Array of WwiseBrowserAssetPayloads created to handle
  79. * @param RootPackagePath Root path where renamed and duplicated assets will be copied to
  80. * @param AssetCreationMode Must match the AssetCreationMode passed to FindOrCreateAssetsRecursive
  81. * @param AssetDuplicationMode Whether existing assets should be duplicated into a new asset placed relative to RootPackagePath
  82. */
  83. void SaveSelectedAssets(const TArray<WwiseBrowserAssetPayload> Assets, const FString& RootPackagePath, const EAssetCreationMode AssetCreationMode, const EAssetDuplicationMode AssetDuplicationMode);
  84. void SaveSelectedAssetsTask(const TArray<WwiseBrowserAssetPayload> Assets, const FString& RootPackagePath, const EAssetCreationMode AssetCreationMode, const EAssetDuplicationMode AssetDuplicationMode);
  85. UAkAssetFactory* GetAssetFactory(const FWwiseTreeItemPtr& WwiseTreeItem);
  86. EWwiseItemType::Type GetTypeFromClass(UClass* Class);
  87. bool CanCreateAsset(const FWwiseTreeItemPtr& Item);
  88. FLinearColor GetTextColor(bool UpToDate);
  89. const FName WwiseBrowserColumnId = TEXT("WwiseItem");
  90. }