WwiseUmgDragDropOp.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 "CoreMinimal.h"
  17. #include "Input/DragAndDrop.h"
  18. #include "Widgets/DeclarativeSyntaxSupport.h"
  19. #include "Widgets/SBoxPanel.h"
  20. #include "Widgets/Layout/SBorder.h"
  21. #include "Widgets/Images/SImage.h"
  22. #include "Widgets/Text/STextBlock.h"
  23. #include "WaapiPicker/WwiseTreeItem.h"
  24. #include "AkAudioStyle.h"
  25. class AKAUDIO_API FWwiseUmgDragDropOp : public FDragDropOperation
  26. {
  27. public:
  28. DRAG_DROP_OPERATOR_TYPE(FWwiseUmgDragDropOp, FDragDropOperation)
  29. static TSharedRef<FWwiseUmgDragDropOp> New(const TArray<TSharedPtr<FWwiseTreeItem>>& in_WwiseAssets)
  30. {
  31. TSharedRef<FWwiseUmgDragDropOp> Operation = MakeShareable(new FWwiseUmgDragDropOp);
  32. Operation->MouseCursor = EMouseCursor::GrabHandClosed;
  33. if (in_WwiseAssets.Num() && in_WwiseAssets[0].IsValid())
  34. {
  35. Operation->WwiseAssets = in_WwiseAssets;
  36. Operation->Icon = FAkAudioStyle::GetBrush(in_WwiseAssets[0]->ItemType);
  37. }
  38. Operation->Construct();
  39. return Operation;
  40. }
  41. const TArray< TSharedPtr<FWwiseTreeItem> >& GetWiseItems() const
  42. {
  43. return WwiseAssets;
  44. }
  45. public:
  46. FText GetDecoratorText() const
  47. {
  48. FString Text = ((WwiseAssets.Num() == 1) && WwiseAssets[0].IsValid()) ? WwiseAssets[0]->DisplayName : TEXT("");
  49. if (WwiseAssets.Num() > 1 )
  50. {
  51. Text = FString::Printf(TEXT("Can't handle more than one item"));
  52. }
  53. return FText::FromString(Text);
  54. }
  55. const FSlateBrush* GetIcon() const
  56. {
  57. return Icon;
  58. }
  59. virtual TSharedPtr<SWidget> GetDefaultDecorator() const override
  60. {
  61. return
  62. SNew(SBorder)
  63. .BorderImage(FAkAudioStyle::GetBrush("AudiokineticTools.AssetDragDropTooltipBackground"))
  64. .Content()
  65. [
  66. SNew(SHorizontalBox)
  67. // Left slot is wwise item icon.
  68. + SHorizontalBox::Slot()
  69. .AutoWidth()
  70. .VAlign(VAlign_Center)
  71. [
  72. SNew(SImage)
  73. .Image(this, &FWwiseUmgDragDropOp::GetIcon)
  74. ]
  75. // Right slot for the item name.
  76. + SHorizontalBox::Slot()
  77. .AutoWidth()
  78. .VAlign(VAlign_Center)
  79. [
  80. SNew(SHorizontalBox)
  81. +SHorizontalBox::Slot()
  82. .AutoWidth()
  83. .Padding(3,0,3,0)
  84. .VAlign(VAlign_Center)
  85. [
  86. SNew(STextBlock)
  87. .Text(this, &FWwiseUmgDragDropOp::GetDecoratorText)
  88. ]
  89. ]
  90. ];
  91. }
  92. private:
  93. /** Data for the asset this item represents */
  94. TArray<TSharedPtr<FWwiseTreeItem>> WwiseAssets;
  95. const FSlateBrush* Icon;
  96. };