AkItemProperties.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 "Components/Widget.h"
  17. #include "SAkItemProperties.h"
  18. #include "Kismet/BlueprintFunctionLibrary.h"
  19. #include "Widgets/Text/STextBlock.h"
  20. #include "AkItemProperties.generated.h"
  21. class IMenu;
  22. class SButton;
  23. /** A delegate type invoked when a selection changes somewhere. */
  24. DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnItemPropertySelectionChanged, FString, PropertySelected);
  25. /** A delegate type invoked when a property is being dragged. */
  26. DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnItemPropertyDragDetected, FString, PropertyDragged);
  27. /*------------------------------------------------------------------------------------
  28. FAkPropertyToControl
  29. ------------------------------------------------------------------------------------*/
  30. /**
  31. * Structure for property to be controlled by the UI.
  32. */
  33. USTRUCT(BlueprintType)
  34. struct AKAUDIO_API FAkPropertyToControl
  35. {
  36. GENERATED_BODY()
  37. /**
  38. * The name of the item to control
  39. */
  40. UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = ItemProperty, meta = (DisplayName = "Property"))
  41. FString ItemProperty;
  42. };
  43. /*------------------------------------------------------------------------------------
  44. UAkItemPropertiesConv
  45. ------------------------------------------------------------------------------------*/
  46. UCLASS()
  47. class AKAUDIO_API UAkItemPropertiesConv : public UBlueprintFunctionLibrary
  48. {
  49. GENERATED_BODY()
  50. public:
  51. UAkItemPropertiesConv(const class FObjectInitializer& ObjectInitializer);
  52. /** Converts an AkPropertyToControl value to a string */
  53. UFUNCTION(BlueprintPure, meta = (DisplayName = "ToString (FAkPropertyToControl)", CompactNodeTitle = "->", BlueprintAutocast), Category = "Utilities|String")
  54. static FString Conv_FAkPropertyToControlToString(const FAkPropertyToControl& INAkPropertyToControl);
  55. /** Converts an AkPropertyToControl value to a localizable text */
  56. UFUNCTION(BlueprintPure, meta = (DisplayName = "ToText (FAkPropertyToControl)", CompactNodeTitle = "->", BlueprintAutocast), Category = "Utilities|Text")
  57. static FText Conv_FAkPropertyToControlToText(const FAkPropertyToControl& INAkPropertyToControl);
  58. };
  59. /*------------------------------------------------------------------------------------
  60. UAkItemProperties
  61. ------------------------------------------------------------------------------------*/
  62. /**
  63. * A widget that shows the Wwise properties list.
  64. */
  65. UCLASS(config = Editor, defaultconfig)
  66. class AKAUDIO_API UAkItemProperties : public UWidget
  67. {
  68. GENERATED_BODY()
  69. public:
  70. UAkItemProperties(const FObjectInitializer& ObjectInitializer);
  71. typedef TSlateDelegates< TSharedPtr< FString > >::FOnSelectionChanged FOnSelectionChanged;
  72. /** Called when the property selection changes. */
  73. UPROPERTY(BlueprintAssignable, Category = "Widget Event")
  74. FOnItemPropertySelectionChanged OnSelectionChanged;
  75. /** Called when a property is dragged from the property list. */
  76. UPROPERTY(BlueprintAssignable, Category = "Widget Event")
  77. FOnItemPropertyDragDetected OnPropertyDragged;
  78. /** Returns all properties currently selected in the Wwise properties list */
  79. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic")
  80. FString GetSelectedProperty() const;
  81. /** returns the current text of the searchBox */
  82. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic")
  83. FString GetSearchText() const;
  84. /** sets the current text of the searchBox */
  85. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic")
  86. void SetSearchText(const FString& newText);
  87. // UVisual interface
  88. virtual void ReleaseSlateResources(bool bReleaseChildren) override;
  89. // End of UVisual interface
  90. #if WITH_EDITOR
  91. virtual const FText GetPaletteCategory() override;
  92. #endif
  93. protected:
  94. // UWidget interface
  95. virtual TSharedRef<SWidget> RebuildWidget() override;
  96. // End of UWidget interface
  97. private:
  98. /** Delegate used to handle the value of the property to be controlled */
  99. void PropertySelectionChanged(TSharedPtr< FString > PropertySelected, ESelectInfo::Type SelectInfo);
  100. /** Delegate used to handle the drag detected action on the items properties. */
  101. FReply HandleOnDragDetected(const FGeometry& Geometry, const FPointerEvent& MouseEvent);
  102. private:
  103. /** The widget to display the property name */
  104. TSharedPtr<STextBlock> PropertyTextBlock;
  105. /** The Wwise list used to pick an item property */
  106. TSharedPtr<SAkItemProperties> WwiseProperties;
  107. };