ProjectedResultColumn.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 "ProjectedResultColumn.h"
  16. #include "AkAudioStyle.h"
  17. #include "WaapiPicker/WwiseTreeItem.h"
  18. #include "Widgets/SWidget.h"
  19. #include "AkUnrealAssetDataHelper.h"
  20. #include "WwiseUnrealHelper.h"
  21. #include "ObjectTools.h"
  22. #include "AssetRegistry/AssetRegistryModule.h"
  23. #include "Widgets/Images/SImage.h"
  24. #include "Widgets/Text/STextBlock.h"
  25. #include "AssetViewUtils.h"
  26. #include "Misc/EngineBuildSettings.h"
  27. #define LOCTEXT_NAMESPACE "AkAudio"
  28. const FLinearColor WarningColor = FLinearColor(1.f, 0.33f, 0);
  29. FName FProjectedResultColumn::GetColumnId()
  30. {
  31. return FName("ReconcileProjectedResults");
  32. }
  33. const TSharedRef<SWidget> FProjectedResultColumn::ConstructRowWidget(FWwiseReconcileItem TreeItem,
  34. const STableRow<TSharedPtr<FWwiseReconcileItem>>& Row)
  35. {
  36. if (EnumHasAllFlags(TreeItem.OperationRequired, EWwiseReconcileOperationFlags::Delete))
  37. {
  38. bool bReferenced = false;
  39. bool bReferencedByUndo = false;
  40. ObjectTools::GatherObjectReferencersForDeletion(TreeItem.Asset.GetAsset(), bReferenced, bReferencedByUndo);
  41. if(bReferenced || bReferencedByUndo)
  42. {
  43. return SNew(SHorizontalBox)
  44. + SHorizontalBox::Slot()
  45. .AutoWidth()
  46. .VAlign(VAlign_Center)
  47. [
  48. SNew(STextBlock)
  49. .Text(FText::Format(LOCTEXT("ReconcileReferenced", "Asset {0} is referenced somewhere. Please delete this asset manually."), FText::FromString(TreeItem.Asset.AssetName.ToString())))
  50. .ColorAndOpacity(WarningColor)
  51. ];
  52. }
  53. return SNew(SHorizontalBox)
  54. + SHorizontalBox::Slot()
  55. .AutoWidth()
  56. .VAlign(VAlign_Center)
  57. [
  58. SNew(STextBlock)
  59. .Text(LOCTEXT("ReconcileDelete", "This Asset will be Deleted"))
  60. ];
  61. }
  62. auto WwiseRef = TreeItem.WwiseAnyRef.WwiseAnyRef;
  63. FName AssetName = AkUnrealAssetDataHelper::GetAssetDefaultName(WwiseRef);
  64. FString AssetPackagePath = AkUnrealAssetDataHelper::GetAssetDefaultPackagePath(WwiseRef);
  65. int PackageLength = AssetViewUtils::GetPackageLengthForCooking(AssetPackagePath / AssetName.ToString(), FEngineBuildSettings::IsInternalBuild());
  66. int MaxPath = AssetViewUtils::GetMaxCookPathLen();
  67. if (PackageLength > MaxPath || PackageLength >= NAME_SIZE)
  68. {
  69. return SNew(SHorizontalBox)
  70. + SHorizontalBox::Slot()
  71. .AutoWidth().
  72. VAlign(VAlign_Center)
  73. [
  74. SNew(STextBlock)
  75. .Text(LOCTEXT("ReconcileTooLong", "Asset path exceeds platform limit"))
  76. .ColorAndOpacity(WarningColor)
  77. ];
  78. }
  79. if(EnumHasAnyFlags(TreeItem.OperationRequired, EWwiseReconcileOperationFlags::Create | EWwiseReconcileOperationFlags::RenameExisting))
  80. {
  81. FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
  82. #if UE_5_1_OR_LATER
  83. FAssetData Asset = AssetRegistryModule.GetRegistry().GetAssetByObjectPath(AssetPackagePath / AkUnrealAssetDataHelper::GetAssetDefaultName(WwiseRef).ToString() + "." + AkUnrealAssetDataHelper::GetAssetDefaultName(WwiseRef).ToString());
  84. #else
  85. FName AssetPath = FName(AssetPackagePath / AkUnrealAssetDataHelper::GetAssetDefaultName(WwiseRef).ToString() + "." + AkUnrealAssetDataHelper::GetAssetDefaultName(WwiseRef).ToString());
  86. FAssetData Asset = AssetRegistryModule.GetRegistry().GetAssetByObjectPath(AssetPath);
  87. #endif
  88. if(Asset.IsValid())
  89. {
  90. FString DisplayedAssetPath = AssetPackagePath / AkUnrealAssetDataHelper::GetAssetDefaultName(WwiseRef).ToString();
  91. return SNew(SHorizontalBox)
  92. + SHorizontalBox::Slot()
  93. .AutoWidth().
  94. VAlign(VAlign_Center)
  95. [
  96. SNew(STextBlock)
  97. .Text(FText::Format(LOCTEXT("ReconcileExist", "Asset already exists at path {0}"), FText::FromString(DisplayedAssetPath)))
  98. .ColorAndOpacity(FLinearColor(WarningColor))
  99. ];
  100. }
  101. }
  102. return SNew(SHorizontalBox)
  103. + SHorizontalBox::Slot()
  104. .AutoWidth()
  105. .Padding(0, 1, 2, 1)
  106. .VAlign(VAlign_Center)
  107. [
  108. SNew(SImage)
  109. .Image(FAkAudioStyle::GetBrush(TreeItem.WwiseAnyRef.WwiseAnyRef->GetType()))
  110. ]
  111. + SHorizontalBox::Slot()
  112. .AutoWidth().
  113. VAlign(VAlign_Center)
  114. [
  115. SNew(STextBlock)
  116. .Text(FText::FromString(AssetPackagePath / AssetName.ToString()))
  117. ];
  118. }
  119. SHeaderRow::FColumn::FArguments FProjectedResultColumn::ConstructHeaderRowColumn()
  120. {
  121. SHeaderRow::FColumn::FArguments ProjectedResultColumnHeader = SHeaderRow::Column(GetColumnId());
  122. TAttribute<FText> StatusLabel;
  123. StatusLabel.Set(FText::FromString("Projected Result"));
  124. ProjectedResultColumnHeader.DefaultLabel(StatusLabel);
  125. ProjectedResultColumnHeader.DefaultTooltip(LOCTEXT("ProjectedResult_Tooltip", "The expected result of Reconciling an asset."));
  126. #if UE_5_0_OR_LATER
  127. ProjectedResultColumnHeader.FillSized(600.f);
  128. #else
  129. ProjectedResultColumnHeader.ManualWidth(600.f);
  130. #endif
  131. return ProjectedResultColumnHeader;
  132. }
  133. #undef LOCTEXT_NAMESPACE