SWaapiPickerRow.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. /*------------------------------------------------------------------------------------
  16. SWaapiPickerRow.h
  17. ------------------------------------------------------------------------------------*/
  18. #pragma once
  19. /*------------------------------------------------------------------------------------
  20. SWaapiPickerRow
  21. ------------------------------------------------------------------------------------*/
  22. #include "WwiseTreeItem.h"
  23. #include "AkWaapiClient.h"
  24. #include "Dom/JsonObject.h"
  25. #include "Widgets/Text/SInlineEditableTextBlock.h"
  26. #include "Widgets/SCompoundWidget.h"
  27. /** A single item in the Wwise tree. */
  28. class AKAUDIO_API SWaapiPickerRow : public SCompoundWidget
  29. {
  30. public:
  31. SLATE_BEGIN_ARGS(SWaapiPickerRow)
  32. : _WaapiPickerItem(TSharedPtr<FWwiseTreeItem>())
  33. , _ParentWidget()
  34. {}
  35. /** Data that represents the WwiseItem */
  36. SLATE_ARGUMENT(TSharedPtr<FWwiseTreeItem>, WaapiPickerItem)
  37. /** The parent widget */
  38. SLATE_ARGUMENT(TSharedPtr<SWidget>, ParentWidget)
  39. /** Callback to check if the widget is selected, should only be hooked up if parent widget is handling selection or focus. */
  40. SLATE_EVENT(FIsSelected, IsSelected)
  41. /** Text to highlight for this WwiseItem */
  42. SLATE_ATTRIBUTE(FText, HighlightText)
  43. SLATE_END_ARGS()
  44. /** Constructs this widget with InArgs */
  45. void Construct(const FArguments& InArgs);
  46. /** Trigger entry into edit mode */
  47. void EnterEditingMode();
  48. ~SWaapiPickerRow();
  49. private:
  50. /** Handles committing a name change */
  51. void HandleNameCommitted(const FText& NewText, ETextCommit::Type CommitInfo);
  52. /** Handles verifying a name change */
  53. bool HandleVerifyNameChanged(const FText& NewText, FText& OutErrorMessage);
  54. /** Checks whether the selected collection is not allowed to be renamed */
  55. bool IsWiseItemNameReadOnly() const;
  56. /** Returns the text of the WwiseItem name */
  57. FText GetNameText() const;
  58. /** Returns the text to use for the Wwise item tooltip */
  59. FText GetToolTipText() const;
  60. private:
  61. /** Handler for when a name was given to a new item */
  62. bool OnVerifyItemNameChanged(const TSharedPtr< FWwiseTreeItem >& WwiseItem, const FString& InNewItemName, FText& OutErrorMessage);
  63. /** Handler for when a name was given to an item */
  64. bool OnItemRenameCommitted(const TSharedPtr< FWwiseTreeItem >& WwiseItem, const FString& InNewItemName, FText& OutWarningMessage);
  65. public:
  66. struct KeyValueArgs
  67. {
  68. const FString keyArg;
  69. const FString valueArg;
  70. };
  71. /**
  72. * Call WAAPI to change the object name form the path or the id of the object (inFromIdOrPath).
  73. *
  74. * @param inUri The Unique Resource Identifier used to indicate a specific action to WAAPI; i.e. ak::wwise::core::object::setName
  75. * @param values An array that contains the pair of field and field value; e.i. when asking WAAPI to rename an item, the arguments are like this : {{object,id},{value,newname}}
  76. * @return A boolean to ensure that the call was successfully done.
  77. */
  78. static bool CallWaapiExecuteUri(const char* inUri, const TArray<KeyValueArgs>& values, TSharedPtr<FJsonObject>& outJsonResult);
  79. private:
  80. /** A shared pointer to the parent widget. */
  81. TSharedPtr<SWidget> ParentWidget;
  82. /** The data for this item */
  83. TWeakPtr<FWwiseTreeItem> WaapiPickerItem;
  84. /** Widget to display the name of the item and allows for renaming */
  85. TSharedPtr< SInlineEditableTextBlock > InlineRenameWidget;
  86. /** Handle to the registered EnterEditingMode delegate. */
  87. FDelegateHandle EnterEditingModeDelegateHandle;
  88. /** Broadcasts whenever renaming a tree item is requested */
  89. DECLARE_MULTICAST_DELEGATE(FRenamedRequestEvent)
  90. /** Broadcasts whenever a rename is requested */
  91. FRenamedRequestEvent OnRenamedRequestEvent;
  92. };