AkSettingsDetailsCustomization.cpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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 "AkSettingsDetailsCustomization.h"
  16. #include "AkSettings.h"
  17. #include "WwiseUEFeatures.h"
  18. #include "DetailCategoryBuilder.h"
  19. #include "DetailLayoutBuilder.h"
  20. #include "DetailWidgetRow.h"
  21. #include "IStructureDetailsView.h"
  22. #include "Widgets/Input/SNumericEntryBox.h"
  23. #include "Widgets/Input/SButton.h"
  24. #include "Editor.h"
  25. #define LOCTEXT_NAMESPACE "AudiokineticTools"
  26. /** Dialog widget used to display function properties */
  27. class SDecayKeyEntryDialog : public SCompoundWidget
  28. {
  29. SLATE_BEGIN_ARGS(SDecayKeyEntryDialog) {}
  30. SLATE_END_ARGS()
  31. // We call this from a delegate that is called when the window has correctly been added to the slate application.
  32. // See FAkSettingsDetailsCustomization::InsertKeyModal.
  33. void FocusNumericEntryBox()
  34. {
  35. if (numberBox != nullptr)
  36. {
  37. FSlateApplication::Get().ClearAllUserFocus();
  38. FSlateApplication::Get().SetAllUserFocus(numberBox);
  39. FSlateApplication::Get().ClearKeyboardFocus();
  40. FSlateApplication::Get().SetKeyboardFocus(numberBox);
  41. }
  42. }
  43. void Construct(const FArguments& InArgs, TWeakPtr<SWindow> InParentWindow, float& decay)
  44. {
  45. bCommitted = false;
  46. ChildSlot
  47. [
  48. SNew(SVerticalBox)
  49. + SVerticalBox::Slot()
  50. .AutoHeight()
  51. [
  52. SNew(SBorder)
  53. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  54. .VAlign(VAlign_Center)
  55. .HAlign(HAlign_Center)
  56. [
  57. SNew(SVerticalBox)
  58. + SVerticalBox::Slot()
  59. .Padding(2.0f)
  60. .AutoHeight()
  61. [
  62. SAssignNew(numberBox, SNumericEntryBox<float>)
  63. .MinValue(0.0f)
  64. .MaxValue(100.0f)
  65. .Value_Lambda([&decay]() {return decay;})
  66. .OnValueCommitted_Lambda([this, InParentWindow, &decay](const float& value, ETextCommit::Type commitType)
  67. {
  68. if (commitType == ETextCommit::Type::OnCleared)
  69. decay = 0.0f;
  70. else
  71. decay = value;
  72. if (commitType == ETextCommit::OnEnter)
  73. {
  74. bCommitted = true;
  75. if (InParentWindow.IsValid())
  76. {
  77. InParentWindow.Pin()->RequestDestroyWindow();
  78. }
  79. }
  80. })
  81. .OnValueChanged_Lambda([&decay](const float& value)
  82. {
  83. decay = value;
  84. })
  85. ]
  86. + SVerticalBox::Slot()
  87. .Padding(2.0f)
  88. .AutoHeight()
  89. [
  90. SNew(SButton)
  91. .ForegroundColor(FLinearColor::White)
  92. .OnClicked_Lambda([this, InParentWindow, InArgs]()
  93. {
  94. if (InParentWindow.IsValid())
  95. {
  96. InParentWindow.Pin()->RequestDestroyWindow();
  97. }
  98. bCommitted = true;
  99. return FReply::Handled();
  100. })
  101. .ToolTipText(FText::FromString("Insert given key value"))
  102. [
  103. SNew(STextBlock)
  104. .TextStyle(FAkAppStyle::Get(), "FlatButton.DefaultTextStyle")
  105. .Text(FText::FromString("Insert"))
  106. ]
  107. ]
  108. ]
  109. ]
  110. ];
  111. }
  112. bool bCommitted = false;
  113. TSharedPtr<SNumericEntryBox<float>> numberBox = nullptr;
  114. };
  115. /** Dialog widget used to display function properties */
  116. class SClearWarningDialog : public SCompoundWidget
  117. {
  118. SLATE_BEGIN_ARGS(SClearWarningDialog) {}
  119. SLATE_END_ARGS()
  120. void Construct(const FArguments& InArgs, TWeakPtr<SWindow> InParentWindow)
  121. {
  122. bOKPressed = false;
  123. ChildSlot
  124. [
  125. SNew(SVerticalBox)
  126. + SVerticalBox::Slot()
  127. .AutoHeight()
  128. [
  129. SNew(SBorder)
  130. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  131. .VAlign(VAlign_Center)
  132. .HAlign(HAlign_Center)
  133. [
  134. SNew(SVerticalBox)
  135. + SVerticalBox::Slot()
  136. .Padding(2.0f)
  137. .AutoHeight()
  138. [
  139. SNew(STextBlock)
  140. .Text(FText::FromString("Warning: This will remove all aux bus values in the map. Do you want to continue?"))
  141. ]
  142. ]
  143. ]
  144. + SVerticalBox::Slot()
  145. .AutoHeight()
  146. [
  147. SNew(SBorder)
  148. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  149. .VAlign(VAlign_Center)
  150. .HAlign(HAlign_Center)
  151. [
  152. SNew(SHorizontalBox)
  153. + SHorizontalBox::Slot()
  154. .Padding(2.0f)
  155. .AutoWidth()
  156. [
  157. SNew(SButton)
  158. .ButtonStyle(FAkAppStyle::Get(), "FlatButton.Success")
  159. .ForegroundColor(FLinearColor::White)
  160. .OnClicked_Lambda([this, InParentWindow, InArgs]()
  161. {
  162. if (InParentWindow.IsValid())
  163. {
  164. InParentWindow.Pin()->RequestDestroyWindow();
  165. }
  166. bOKPressed = true;
  167. return FReply::Handled();
  168. })
  169. .ToolTipText(FText::FromString("Clear aux bus assignment map"))
  170. [
  171. SNew(STextBlock)
  172. .TextStyle(FAkAppStyle::Get(), "FlatButton.DefaultTextStyle")
  173. .Text(FText::FromString("Clear"))
  174. ]
  175. ]
  176. + SHorizontalBox::Slot()
  177. .Padding(2.0f)
  178. .AutoWidth()
  179. [
  180. SNew(SButton)
  181. .ButtonStyle(FAkAppStyle::Get(), "FlatButton.Default")
  182. .ForegroundColor(FLinearColor::White)
  183. .OnClicked_Lambda([this, InParentWindow, InArgs]()
  184. {
  185. if (InParentWindow.IsValid())
  186. {
  187. InParentWindow.Pin()->RequestDestroyWindow();
  188. }
  189. return FReply::Handled();
  190. })
  191. .ToolTipText(FText::FromString("Cancel"))
  192. [
  193. SNew(STextBlock)
  194. .TextStyle(FAkAppStyle::Get(), "FlatButton.DefaultTextStyle")
  195. .Text(FText::FromString("Cancel"))
  196. ]
  197. ]
  198. ]
  199. ]
  200. ];
  201. }
  202. bool bOKPressed;
  203. };
  204. TSharedRef<IDetailCustomization> FAkSettingsDetailsCustomization::MakeInstance()
  205. {
  206. return MakeShareable(new FAkSettingsDetailsCustomization);
  207. }
  208. void FAkSettingsDetailsCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailLayout)
  209. {
  210. IDetailCategoryBuilder& GeometryCategoryBuilder = DetailLayout.EditCategory("Geometry Surface Properties", FText::GetEmpty(), ECategoryPriority::Uncommon);
  211. GeometryCategoryBuilder.AddCustomRow(FText::FromString("Update Geometry Map")).WholeRowContent()
  212. [
  213. SNew(SVerticalBox)
  214. + SVerticalBox::Slot().AutoHeight().Padding(2)
  215. [
  216. SNew(SHorizontalBox)
  217. + SHorizontalBox::Slot().AutoWidth()
  218. [
  219. SNew(SButton)
  220. .Text(FText::FromString("Verify and Update"))
  221. .ToolTipText(FText::FromString("Verify each row of the Geometry Surface Properties Table below and remove rows with an invalid Physical Material."))
  222. .OnClicked_Raw(this, &FAkSettingsDetailsCustomization::VerifyAndUpdateGeometrySurfacePropertiesTable)
  223. ]
  224. + SHorizontalBox::Slot().FillWidth(8)
  225. ]
  226. ];
  227. }
  228. FReply FAkSettingsDetailsCustomization::VerifyAndUpdateGeometrySurfacePropertiesTable()
  229. {
  230. UAkSettings* AkSettings = GetMutableDefault<UAkSettings>();
  231. if (AkSettings != nullptr)
  232. AkSettings->VerifyAndUpdateGeometrySurfacePropertiesTable();
  233. return FReply::Handled();
  234. }
  235. #undef LOCTEXT_NAMESPACE