AkMigrationWidgets.cpp 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  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 "AkMigrationWidgets.h"
  16. #include "AkSettingsPerUser.h"
  17. #include "WwiseUEFeatures.h"
  18. #include "AkUnrealEditorHelper.h"
  19. #include "WwiseUnrealHelper.h"
  20. #include "AkWaapiClient.h"
  21. #include "DesktopPlatformModule.h"
  22. #include "Framework/Application/SlateApplication.h"
  23. #include "Framework/Application/SlateApplication.h"
  24. #include "Framework/MultiBox/MultiBoxBuilder.h"
  25. #include "IDesktopPlatform.h"
  26. #include "Interfaces/IMainFrameModule.h"
  27. #include "Widgets/Layout/SHeader.h"
  28. #include "Widgets/Input/SButton.h"
  29. #include "Widgets/Input/SCheckBox.h"
  30. #include "Widgets/Input/SEditableTextBox.h"
  31. #include "Widgets/Input/SHyperlink.h"
  32. #include "Widgets/Input/SMultiLineEditableTextBox.h"
  33. #include "Widgets/Layout/SSpacer.h"
  34. #include "Widgets/Layout/SExpandableArea.h"
  35. #include "Widgets/Text/STextBlock.h"
  36. #define LOCTEXT_NAMESPACE "AkAudio"
  37. namespace MigrationDialogUtils
  38. {
  39. inline const FSlateBrush* GetExpandableAreaBorderImage(const SExpandableArea& Area)
  40. {
  41. if (Area.IsTitleHovered())
  42. {
  43. return Area.IsExpanded() ? FAkAppStyle::Get().GetBrush("DetailsView.CategoryTop_Hovered") : FAkAppStyle::Get().GetBrush("DetailsView.CollapsedCategory_Hovered");
  44. }
  45. return Area.IsExpanded() ? FAkAppStyle::Get().GetBrush("DetailsView.CategoryTop") : FAkAppStyle::Get().GetBrush("DetailsView.CollapsedCategory");
  46. }
  47. }
  48. void SMigrationWidget::Construct(const FArguments& InArgs)
  49. {
  50. bShowBankTransfer = InArgs._ShowBankTransfer;
  51. bShowMediaCleanup = InArgs._ShowDeprecatedAssetCleanup;
  52. bShowAssetMigration = InArgs._ShowAssetMigration;
  53. bShowProjectMigration = InArgs._ShowProjectMigration;
  54. Dialog = InArgs._Dialog;
  55. ChildSlot
  56. [
  57. SNew(SBox)
  58. .MaxDesiredWidth(800)
  59. [
  60. SNew(SVerticalBox)
  61. + SVerticalBox::Slot()
  62. [
  63. SNew(SBorder)
  64. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  65. .Padding(4.0f)
  66. [
  67. SNew(SVerticalBox)
  68. /// Intro title
  69. + SVerticalBox::Slot()
  70. .Padding(0, 5)
  71. .AutoHeight()
  72. .HAlign(EHorizontalAlignment::HAlign_Center)
  73. [
  74. SNew(STextBlock)
  75. .Text(LOCTEXT("MigrationWelcome",
  76. "Migrating to Single Source of Truth\n"
  77. ))
  78. .Font(FAkAppStyle::Get().GetFontStyle("StandardDialog.LargeFont"))
  79. ]
  80. /// Intro text
  81. + SVerticalBox::Slot()
  82. .Padding(0, 0)
  83. .AutoHeight()
  84. [
  85. SNew(STextBlock)
  86. .Text(LOCTEXT("MigrationIntroText",
  87. "We recommend performing all necessary migration steps as soon as possible, in a single operation. Since the migration operation has an impact on Unreal assets, ensure to checkout all Wwise-related assets from Source control. "
  88. "Migration will also potentially update settings in your Wwise project. It is important to first check-out, open, and migrate the Wwise Project in Wwise Authoring BEFORE pressing 'Continue'.\n"
  89. ))
  90. .AutoWrapText(true)
  91. ]
  92. /// More info hyperlink
  93. + SVerticalBox::Slot()
  94. .Padding(0, 0)
  95. .AutoHeight()
  96. [
  97. SNew(SHorizontalBox)
  98. + SHorizontalBox::Slot()
  99. .Padding(2.0f)
  100. .AutoWidth()
  101. [
  102. SNew(SHyperlink)
  103. .Text(LOCTEXT("MigrationNotesLink", "Please refer to Wwise 2022.1 migration notes for more information about the migration process."))
  104. .OnNavigate_Lambda([=]{ FPlatformProcess::LaunchURL(TEXT("https://www.audiokinetic.com/library/edge/?source=UE4&id=pg_important_migration_notes_2022_1_0.html"), nullptr, nullptr); })
  105. ]
  106. + SHorizontalBox::Slot()
  107. [
  108. SNew(SSpacer)
  109. ]
  110. ]
  111. /// Necessary steps text:
  112. + SVerticalBox::Slot()
  113. .Padding(0, 0)
  114. .AutoHeight()
  115. [
  116. SNew(STextBlock)
  117. .Text(LOCTEXT("MigrationIntroNecessarySteps",
  118. "\nBelow are the necessary migration steps for your project:\n"
  119. ))
  120. .AutoWrapText(true)
  121. ]
  122. /// Transfer SoundBanks option
  123. + SVerticalBox::Slot()
  124. .AutoHeight()
  125. [
  126. SAssignNew(BankTransferWidget, SBankTransferWidget)
  127. .Visibility(this, &SMigrationWidget::GetBankTransferWidgetVisibility)
  128. ]
  129. /// Deleting deprecated assets
  130. + SVerticalBox::Slot()
  131. .Padding(0, 5)
  132. .AutoHeight()
  133. [
  134. SAssignNew(DeprecatedAssetCleanupWidget, SDeprecatedAssetCleanupWidget)
  135. .Visibility(this, &SMigrationWidget::GetMediaCleanupWidgetVisibility)
  136. .NumDeprecatedAssets(InArgs._NumDeprecatedAssets)
  137. ]
  138. /// Migrating assets
  139. + SVerticalBox::Slot()
  140. .Padding(0, 5)
  141. .AutoHeight()
  142. [
  143. SAssignNew(AssetMigrationWidget, SAssetMigrationWidget)
  144. .Visibility(this, &SMigrationWidget::GetAssetMigrationWidgetVisibility)
  145. ]
  146. // Migrating Wwise Project options
  147. + SVerticalBox::Slot()
  148. .Padding(0, 5)
  149. .AutoHeight()
  150. [
  151. SAssignNew(ProjectMigrationWidget, SProjectMigrationWidget)
  152. .Visibility(this, &SMigrationWidget::GetProjectMigrationWidgetVisibility)
  153. ]
  154. + SVerticalBox::Slot()
  155. .Padding(0, 5)
  156. .AutoHeight()
  157. [
  158. SNew(STextBlock)
  159. .Text(LOCTEXT("GeneralInfo",
  160. "If you choose the cancel option or a subset of operations to perform, you can open this dialog at a later time from the Build Menu under Audiokinetic > Finish Project Migration.\n"
  161. ))
  162. .Font(FAkAppStyle::Get().GetFontStyle("StandardDialog.LargeFont"))
  163. .AutoWrapText(true)
  164. ]
  165. + SVerticalBox::Slot()
  166. .AutoHeight()
  167. [
  168. SNew(SBorder)
  169. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  170. .VAlign(VAlign_Center)
  171. .HAlign(HAlign_Center)
  172. [
  173. SNew(SHorizontalBox)
  174. + SHorizontalBox::Slot()
  175. .Padding(2.0f)
  176. .AutoWidth()
  177. [
  178. SNew(SButton)
  179. .ButtonStyle(FAkAppStyle::Get(), "FlatButton.Success")
  180. .ForegroundColor(FLinearColor::White)
  181. .OnClicked(this, &SMigrationWidget::OnContinueClicked)
  182. .IsEnabled(this, &SMigrationWidget::CanClickContinue)
  183. .ToolTipText(this, &SMigrationWidget::GetContinueToolTip)
  184. [
  185. SNew(STextBlock)
  186. .TextStyle(FAkAppStyle::Get(), "FlatButton.DefaultTextStyle")
  187. .Text(FText::FromString("Continue"))
  188. ]
  189. ]
  190. + SHorizontalBox::Slot()
  191. .Padding(2.0f)
  192. .AutoWidth()
  193. [
  194. SNew(SButton)
  195. .ButtonStyle(FAkAppStyle::Get(), "FlatButton.Default")
  196. .ForegroundColor(FLinearColor::White)
  197. .OnClicked(this, &SMigrationWidget::OnCancelClicked)
  198. .ToolTipText(FText::FromString("Cancel"))
  199. [
  200. SNew(STextBlock)
  201. .TextStyle(FAkAppStyle::Get(), "FlatButton.DefaultTextStyle")
  202. .Text(FText::FromString("Cancel"))
  203. ]
  204. ]
  205. ]
  206. ]
  207. ]
  208. ]
  209. ]
  210. ];
  211. }
  212. bool SMigrationWidget::CanClickContinue() const
  213. {
  214. if (bShowBankTransfer && BankTransferWidget->SoundBankTransferCheckBox->IsChecked())
  215. {
  216. if (BankTransferWidget->BankTransferMethod == AkAssetMigration::EBankTransferMode::NoTransfer)
  217. {
  218. return false;
  219. }
  220. if (BankTransferWidget->BankTransferMethod == AkAssetMigration::EBankTransferMode::DefinitionFile && BankTransferWidget->SoundBankDefinitionFilePath.IsEmpty())
  221. {
  222. return false;
  223. }
  224. }
  225. return true;
  226. }
  227. FText SMigrationWidget::GetContinueToolTip() const
  228. {
  229. if (bShowBankTransfer && BankTransferWidget->SoundBankTransferCheckBox->IsChecked())
  230. {
  231. if (BankTransferWidget->BankTransferMethod == AkAssetMigration::EBankTransferMode::NoTransfer)
  232. {
  233. return FText::FromString("Please choose a SoundBank transfer method first");
  234. }
  235. if (BankTransferWidget->BankTransferMethod == AkAssetMigration::EBankTransferMode::DefinitionFile && BankTransferWidget->SoundBankDefinitionFilePath.IsEmpty())
  236. {
  237. return FText::FromString("Please choose a SoundBank Definition file path first");
  238. }
  239. }
  240. return FText::FromString("Continue");
  241. }
  242. FReply SMigrationWidget::OnContinueClicked()
  243. {
  244. FSlateApplication::Get().RequestDestroyWindow(Dialog.ToSharedRef());
  245. return FReply::Handled();
  246. }
  247. FReply SMigrationWidget::OnCancelClicked()
  248. {
  249. BankTransferWidget->BankTransferMethod = AkAssetMigration::EBankTransferMode::NoTransfer;
  250. BankTransferWidget->DeleteSoundBanksCheckBox->SetIsChecked(false);
  251. BankTransferWidget->TransferAutoLoadCheckBox->SetIsChecked(false);
  252. DeprecatedAssetCleanupWidget->DeleteAssetsCheckBox->SetIsChecked(false);
  253. AssetMigrationWidget->MigrateAssetsCheckBox->SetIsChecked(false);
  254. bCancel = true;
  255. FSlateApplication::Get().RequestDestroyWindow(Dialog.ToSharedRef());
  256. return FReply::Handled();
  257. }
  258. EVisibility SMigrationWidget::GetBankTransferWidgetVisibility() const
  259. {
  260. return bShowBankTransfer ? EVisibility::Visible : EVisibility::Collapsed;
  261. }
  262. EVisibility SMigrationWidget::GetMediaCleanupWidgetVisibility() const
  263. {
  264. return bShowMediaCleanup ? EVisibility::Visible : EVisibility::Collapsed;
  265. }
  266. EVisibility SMigrationWidget::GetAssetMigrationWidgetVisibility() const
  267. {
  268. return bShowAssetMigration ? EVisibility::Visible : EVisibility::Collapsed;
  269. }
  270. EVisibility SMigrationWidget::GetProjectMigrationWidgetVisibility() const
  271. {
  272. return bShowProjectMigration ? EVisibility::Visible : EVisibility::Collapsed;
  273. }
  274. void SBankTransferWidget::Construct(const FArguments& InArgs)
  275. {
  276. SoundBankDefinitionFilePath = WwiseUnrealHelper::GetProjectDirectory() + "SoundBankDefinition.tsv";
  277. ChildSlot
  278. [
  279. SNew(SVerticalBox)
  280. + SVerticalBox::Slot()
  281. [
  282. SAssignNew(ExpandableSection, SExpandableArea)
  283. .InitiallyCollapsed(false)
  284. .BorderBackgroundColor(FLinearColor(0.6f, 0.6f, 0.6f, 1.0f))
  285. .BorderImage_Lambda([this]() { return MigrationDialogUtils::GetExpandableAreaBorderImage(*ExpandableSection); })
  286. .HeaderContent()
  287. [
  288. SNew(STextBlock)
  289. .Text(LOCTEXT("SounbankMigrationHeader", "Soundbank Migration"))
  290. .Font(FAkAppStyle::Get().GetFontStyle("DetailsView.CategoryFontStyle"))
  291. .ShadowOffset(FVector2D(1.0f, 1.0f))
  292. ]
  293. .BodyContent()
  294. [
  295. SNew(SVerticalBox)
  296. + SVerticalBox::Slot()
  297. [
  298. SNew(SBorder)
  299. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  300. .Padding(4.0f)
  301. [
  302. SNew(SVerticalBox)
  303. + SVerticalBox::Slot()
  304. .FillHeight(0.05f)
  305. [
  306. SNew(SSpacer)
  307. ]
  308. + SVerticalBox::Slot()
  309. .AutoHeight()
  310. .HAlign(EHorizontalAlignment::HAlign_Left)
  311. [
  312. SNew(STextBlock)
  313. .Text(LOCTEXT("BankMigrationMessageBegin",
  314. "AkAudioBanks assets are no longer used in the integration and must be deleted.\n"
  315. "You can optionally transfer your SoundBank structures defined in Unreal back to Wwise Authoring (before deleting them).\n"
  316. "The 'Auto Load' property on AkAudioBank assets can also optionally be transferred to the assets that were grouped in them.\n"
  317. ))
  318. .AutoWrapText(true)
  319. ]
  320. + SVerticalBox::Slot()
  321. .FillHeight(0.10f)
  322. [
  323. SNew(SSpacer)
  324. ]
  325. + SVerticalBox::Slot()
  326. .FillHeight(0.10f)
  327. [
  328. SNew(SSpacer)
  329. ]
  330. + SVerticalBox::Slot()
  331. .AutoHeight()
  332. .Padding(0.0f, 2.0f)
  333. .HAlign(EHorizontalAlignment::HAlign_Left)
  334. [
  335. SNew(SHorizontalBox)
  336. + SHorizontalBox::Slot()
  337. .AutoWidth()
  338. .Padding(0.0f, 2.0f)
  339. [
  340. SAssignNew(SoundBankTransferCheckBox, SCheckBox)
  341. .IsChecked(ECheckBoxState::Checked)
  342. .OnCheckStateChanged(this, &SBankTransferWidget::OnCheckedTransferBanks)
  343. .Content()
  344. [
  345. SNew(STextBlock)
  346. .Text(LOCTEXT("DoTransferMessage", "Transfer SoundBanks To Wwise"))
  347. .ToolTipText(LOCTEXT("TransferAkAudioBankToolTip", "Create SoundBanks in the Wwise project matching the AkAudioBank assets in Unreal.\nThey will contain the same Events and Aux Busses that were grouped into the Unreal assets."))
  348. .Font(FAkAppStyle::Get().GetFontStyle("StandardDialog.LargeFont"))
  349. ]
  350. ]
  351. + SHorizontalBox::Slot()
  352. .HAlign(EHorizontalAlignment::HAlign_Left)
  353. .AutoWidth()
  354. .Padding(8.0f, 2.0f)
  355. [
  356. SNew(SBorder)
  357. .BorderBackgroundColor(this, &SBankTransferWidget::GetDropDownBorderColour)
  358. .ColorAndOpacity(this, &SBankTransferWidget::GetDropDownColour)
  359. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  360. [
  361. SNew(SComboButton)
  362. .ToolTipText(LOCTEXT("ComboButtonTip", "Choose a transfer method from the drop-down menu."))
  363. .OnGetMenuContent(this, &SBankTransferWidget::OnGetTransferMethodMenu)
  364. .ContentPadding(FMargin(0))
  365. .Visibility(this, &SBankTransferWidget::GetTransferMethodVisibility)
  366. .ButtonContent()
  367. [
  368. SNew(STextBlock)
  369. .Text(this, &SBankTransferWidget::GetTransferMethodText)
  370. ]
  371. ]
  372. ]
  373. ]
  374. + SVerticalBox::Slot()
  375. .Padding(0, 5)
  376. .AutoHeight()
  377. [
  378. SAssignNew(SoundBankDefinitionFilePathPicker, SDefinitionFilePicker)
  379. .FilePath(SoundBankDefinitionFilePath)
  380. .OnFileChanged(this, &SBankTransferWidget::SetDefinitionFilePath)
  381. .Visibility(this, &SBankTransferWidget::GetDefinitionFilePathVisibility)
  382. ]
  383. +SVerticalBox::Slot()
  384. .AutoHeight()
  385. .Padding(0.0f, 2.0f)
  386. .HAlign(EHorizontalAlignment::HAlign_Left)
  387. [
  388. SAssignNew(TransferAutoLoadCheckBox, SCheckBox)
  389. .IsChecked(ECheckBoxState::Checked)
  390. .ToolTipText(LOCTEXT("TransferAutoloadTooltip", "Transfer SoundBank Auto Load property from deprecated AkAudioBank assets to the AkAudioType assets that were grouped in them."))
  391. .Content()
  392. [
  393. SNew(STextBlock)
  394. .Text(LOCTEXT("TransferAutoloadMessage", "Transfer Auto Load property from AkAudioBank assets to AkAudioType assets"))
  395. .Font(FAkAppStyle::Get().GetFontStyle("StandardDialog.LargeFont"))
  396. ]
  397. ]
  398. +SVerticalBox::Slot()
  399. .AutoHeight()
  400. .Padding(0.0f, 2.0f)
  401. .HAlign(EHorizontalAlignment::HAlign_Left)
  402. [
  403. SAssignNew(DeleteSoundBanksCheckBox, SCheckBox)
  404. .IsChecked(ECheckBoxState::Checked)
  405. .Content()
  406. [
  407. SNew(STextBlock)
  408. .Text(LOCTEXT("DeleteAkAudioBankMessage", " Delete AkAudioBank Assets"))
  409. .ToolTipText(LOCTEXT("DeleteAkAudioBankToolTip", "Delete all AkAudioBank assets in the unreal project."))
  410. .Font(FAkAppStyle::Get().GetFontStyle("StandardDialog.LargeFont"))
  411. ]
  412. ]
  413. ]
  414. ]
  415. ]
  416. ]
  417. ];
  418. }
  419. EVisibility SBankTransferWidget::GetDefinitionFilePathVisibility() const
  420. {
  421. return SoundBankTransferCheckBox->IsChecked() && BankTransferMethod == AkAssetMigration::EBankTransferMode::DefinitionFile ? EVisibility::Visible : EVisibility::Collapsed;
  422. }
  423. void SBankTransferWidget::SetDefinitionFilePath(const FString& PickedPath)
  424. {
  425. SoundBankDefinitionFilePath = PickedPath;
  426. }
  427. void SBankTransferWidget::SetTransferMethod(AkAssetMigration::EBankTransferMode TransferMethod)
  428. {
  429. BankTransferMethod = TransferMethod;
  430. }
  431. void SBankTransferWidget::OnCheckedTransferBanks(ECheckBoxState NewState)
  432. {
  433. if (NewState != ECheckBoxState::Checked)
  434. {
  435. BankTransferMethod = AkAssetMigration::EBankTransferMode::NoTransfer;
  436. }
  437. }
  438. EVisibility SBankTransferWidget::GetTransferMethodVisibility() const
  439. {
  440. return SoundBankTransferCheckBox->IsChecked() ? EVisibility::Visible : EVisibility::Collapsed;
  441. }
  442. FText SBankTransferWidget::GetTransferMethodText() const
  443. {
  444. if (BankTransferMethod == AkAssetMigration::EBankTransferMode::DefinitionFile)
  445. {
  446. return LOCTEXT("SoundBankDefinition", "Create SoundBank Definition File");
  447. }
  448. else if (BankTransferMethod == AkAssetMigration::EBankTransferMode::WAAPI)
  449. {
  450. return LOCTEXT("WaapiTransfer", "WAAPI");
  451. }
  452. return LOCTEXT("NoTransferMethodSet", "Choose a transfer method...");
  453. }
  454. FSlateColor SBankTransferWidget::GetDropDownBorderColour() const
  455. {
  456. if (BankTransferMethod == AkAssetMigration::EBankTransferMode::NoTransfer && SoundBankTransferCheckBox->IsChecked())
  457. {
  458. return FLinearColor::Red;
  459. }
  460. return FLinearColor::White;
  461. }
  462. FLinearColor SBankTransferWidget::GetDropDownColour() const
  463. {
  464. if (BankTransferMethod == AkAssetMigration::EBankTransferMode::NoTransfer && SoundBankTransferCheckBox->IsChecked())
  465. {
  466. return FLinearColor::Red;
  467. }
  468. return FLinearColor::White;
  469. }
  470. TSharedRef<SWidget> SBankTransferWidget::OnGetTransferMethodMenu()
  471. {
  472. FMenuBuilder MenuBuilder(true, nullptr);
  473. MenuBuilder.AddMenuEntry(
  474. LOCTEXT("SoundBankDefinition", "Create SoundBank Definition File"),
  475. FText(),
  476. FSlateIcon(),
  477. FUIAction(
  478. FExecuteAction::CreateSP(this, &SBankTransferWidget::SetTransferMethod, AkAssetMigration::EBankTransferMode::DefinitionFile)
  479. )
  480. );
  481. MenuBuilder.AddMenuEntry(
  482. LOCTEXT("WaapiTransferMenuItemText","WAAPI"),
  483. FText(),
  484. FSlateIcon(),
  485. FUIAction(
  486. FExecuteAction::CreateSP(this, &SBankTransferWidget::SetTransferMethod, AkAssetMigration::EBankTransferMode::WAAPI),
  487. FCanExecuteAction::CreateSP(this, &SBankTransferWidget::CheckWaapiConnection)
  488. )
  489. );
  490. MenuBuilder.EndSection();
  491. return MenuBuilder.MakeWidget();
  492. }
  493. bool SBankTransferWidget::CheckWaapiConnection() const
  494. {
  495. bool bWaapiConnected = false;
  496. if (auto UserSettings = GetDefault<UAkSettingsPerUser>())
  497. {
  498. if (!UserSettings->bAutoConnectToWAAPI)
  499. {
  500. LOCTEXT("WaapiTransferMenuItemText","WAAPI (Auto Connect to WAAPI disabled in user settings)");
  501. }
  502. else
  503. {
  504. FAkWaapiClient* WaapiClient = FAkWaapiClient::Get();
  505. bWaapiConnected = WaapiClient && WaapiClient->IsConnected();
  506. if (!bWaapiConnected)
  507. {
  508. LOCTEXT("WaapiTransferMenuItemText","WAAPI (WAAPI connection not established)");
  509. }
  510. }
  511. }
  512. if (bWaapiConnected)
  513. {
  514. LOCTEXT("WaapiTransferMenuItemText","WAAPI");
  515. }
  516. return bWaapiConnected;
  517. }
  518. void SDeprecatedAssetCleanupWidget::Construct(const FArguments& InArgs)
  519. {
  520. ChildSlot
  521. [
  522. SNew(SVerticalBox)
  523. + SVerticalBox::Slot()
  524. [
  525. SAssignNew(ExpandableSection, SExpandableArea)
  526. .InitiallyCollapsed(false)
  527. .BorderBackgroundColor(FLinearColor(0.6f, 0.6f, 0.6f, 1.0f))
  528. .BorderImage_Lambda([this]() { return MigrationDialogUtils::GetExpandableAreaBorderImage(*ExpandableSection); })
  529. .HeaderContent()
  530. [
  531. SNew(STextBlock)
  532. .Text(LOCTEXT("MediaCleanupHeader", "Delete deprecated assets"))
  533. .Font(FAkAppStyle::Get().GetFontStyle("DetailsView.CategoryFontStyle"))
  534. .ShadowOffset(FVector2D(1.0f, 1.0f))
  535. ]
  536. .BodyContent()
  537. [
  538. SNew(SVerticalBox)
  539. + SVerticalBox::Slot()
  540. [
  541. SNew(SBorder)
  542. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  543. .Padding(4.0f)
  544. [
  545. SNew(SVerticalBox)
  546. + SVerticalBox::Slot()
  547. .AutoHeight()
  548. .Padding(4.0f)
  549. .HAlign(EHorizontalAlignment::HAlign_Left)
  550. [
  551. SNew(STextBlock)
  552. .Text(FText::FormatOrdered(LOCTEXT("AssetCleanupMessageBegin",
  553. "AkMediaAsset, AkFolder and AkPlatformAssetData have been deprecated, all assets of this type will be deleted from the project. "
  554. "The project currently contains {0} such assets.\n"), FText::FromString(FString::FromInt(InArgs._NumDeprecatedAssets))
  555. ))
  556. .AutoWrapText(true)
  557. ]
  558. + SVerticalBox::Slot()
  559. .AutoHeight()
  560. .Padding(0.0f, 2.0f)
  561. .HAlign(EHorizontalAlignment::HAlign_Left)
  562. [
  563. SAssignNew(DeleteAssetsCheckBox, SCheckBox)
  564. .IsChecked(ECheckBoxState::Checked)
  565. .Content()
  566. [
  567. SNew(STextBlock)
  568. .Text(LOCTEXT("DeleteAssetMessage", " Delete deprecated assets"))
  569. .ToolTipText(LOCTEXT("DeleteMediaToolTip", "Delete all deprecated assets that are still in the project"))
  570. .Font(FAkAppStyle::Get().GetFontStyle("StandardDialog.LargeFont"))
  571. ]
  572. ]
  573. ]
  574. ]
  575. ]
  576. ]
  577. ];
  578. }
  579. void SAssetMigrationWidget::Construct(const FArguments& InArgs)
  580. {
  581. ChildSlot
  582. [
  583. SNew(SVerticalBox)
  584. + SVerticalBox::Slot()
  585. [
  586. SAssignNew(ExpandableSection, SExpandableArea)
  587. .InitiallyCollapsed(false)
  588. .BorderBackgroundColor(FLinearColor(0.6f, 0.6f, 0.6f, 1.0f))
  589. .BorderImage_Lambda([this]() { return MigrationDialogUtils::GetExpandableAreaBorderImage(*ExpandableSection); })
  590. .HeaderContent()
  591. [
  592. SNew(STextBlock)
  593. .Text(LOCTEXT("UpdateAssetsHeader", "Migrate Wwise Assets"))
  594. .Font(FAkAppStyle::Get().GetFontStyle("DetailsView.CategoryFontStyle"))
  595. .ShadowOffset(FVector2D(1.0f, 1.0f))
  596. ]
  597. .BodyContent()
  598. [
  599. SNew(SVerticalBox)
  600. + SVerticalBox::Slot()
  601. [
  602. SNew(SBorder)
  603. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  604. .Padding(4.0f)
  605. [
  606. SNew(SVerticalBox)
  607. + SVerticalBox::Slot()
  608. .FillHeight(0.05f)
  609. [
  610. SNew(SSpacer)
  611. ]
  612. + SVerticalBox::Slot()
  613. .AutoHeight()
  614. .HAlign(EHorizontalAlignment::HAlign_Left)
  615. [
  616. SNew(STextBlock)
  617. .Text(LOCTEXT("AssetMigrationMessageBegin",
  618. "Wwise asset properties have changed and they no longer serialize SoundBank or media binary data.\n"
  619. "Wwise asset properties will be updated and reserialized to the disk."
  620. ))
  621. .AutoWrapText(true)
  622. ]
  623. + SVerticalBox::Slot()
  624. .AutoHeight()
  625. .Padding(0.0f, 2.0f)
  626. .HAlign(EHorizontalAlignment::HAlign_Left)
  627. [
  628. SAssignNew(MigrateAssetsCheckBox, SCheckBox)
  629. .IsChecked(ECheckBoxState::Checked)
  630. .Content()
  631. [
  632. SNew(STextBlock)
  633. .Text(LOCTEXT("MigrateAssetsMessage", " Migrate Wwise assets"))
  634. .Font(FAkAppStyle::Get().GetFontStyle("StandardDialog.LargeFont"))
  635. .ToolTipText(LOCTEXT("MigrateAssetsTooltip", "Dirty and save all Wwise assets"))
  636. ]
  637. ]
  638. ]
  639. ]
  640. ]
  641. ]
  642. ];
  643. }
  644. void SProjectMigrationWidget::Construct(const FArguments& InArgs)
  645. {
  646. ChildSlot
  647. [
  648. SNew(SVerticalBox)
  649. + SVerticalBox::Slot()
  650. [
  651. SAssignNew(ExpandableSection, SExpandableArea)
  652. .InitiallyCollapsed(false)
  653. .BorderBackgroundColor(FLinearColor(0.6f, 0.6f, 0.6f, 1.0f))
  654. .BorderImage_Lambda([this]() { return MigrationDialogUtils::GetExpandableAreaBorderImage(*ExpandableSection); })
  655. .HeaderContent()
  656. [
  657. SNew(STextBlock)
  658. .Text(LOCTEXT("ProjectChangesHeader", "Update Wwise and Unreal project settings"))
  659. .Font(FAkAppStyle::Get().GetFontStyle("DetailsView.CategoryFontStyle"))
  660. .ShadowOffset(FVector2D(1.0f, 1.0f))
  661. ]
  662. .BodyContent()
  663. [
  664. SNew(SVerticalBox)
  665. + SVerticalBox::Slot()
  666. [
  667. SNew(SBorder)
  668. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  669. .Padding(4.0f)
  670. [
  671. SNew(SVerticalBox)
  672. + SVerticalBox::Slot()
  673. .FillHeight(0.05f)
  674. [
  675. SNew(SSpacer)
  676. ]
  677. + SVerticalBox::Slot()
  678. .AutoHeight()
  679. .HAlign(EHorizontalAlignment::HAlign_Left)
  680. [
  681. SNew(STextBlock)
  682. .Text(LOCTEXT("ProjectSettingsMigrationMessageBegin",
  683. "SoundBank generation settings in your Wwise project, and the Wwise Integration settings in your Unreal project, need to be updated.\n"
  684. ))
  685. .AutoWrapText(true)
  686. ]
  687. + SVerticalBox::Slot()
  688. .AutoHeight()
  689. .Padding(0.0f, 2.0f)
  690. .HAlign(EHorizontalAlignment::HAlign_Left)
  691. [
  692. SAssignNew(AutoMigrateCheckbox, SCheckBox)
  693. .IsChecked(ECheckBoxState::Checked)
  694. .Content()
  695. [
  696. SNew(STextBlock)
  697. .Text(LOCTEXT("UpdateProjectMessage", "Update project settings"))
  698. .Font(FAkAppStyle::Get().GetFontStyle("StandardDialog.LargeFont"))
  699. .ToolTipText(LOCTEXT("UpdateProjectTooltip", "Update Unreal project settings"))
  700. ]
  701. ]
  702. + SVerticalBox::Slot()
  703. .Padding(0, 5)
  704. .AutoHeight()
  705. [
  706. SNew(STextBlock)
  707. .Text(LOCTEXT("AkGeneratedSoundBanksFolderMigration",
  708. "\nGeneratedSoundBanks folder location:"
  709. ))
  710. .Visibility(this, &SProjectMigrationWidget::GetPathVisibility)
  711. ]
  712. + SVerticalBox::Slot()
  713. .Padding(0, 5)
  714. .AutoHeight()
  715. [
  716. SAssignNew(GeneratedSoundBanksFolderPickerWidget, SDirectoryPicker)
  717. .Directory(WwiseUnrealHelper::GetSoundBankDirectory())
  718. .Visibility(this, &SProjectMigrationWidget::GetPathVisibility)
  719. ]
  720. ]
  721. ]
  722. ]
  723. ]
  724. ];
  725. }
  726. EVisibility SProjectMigrationWidget::GetPathVisibility() const
  727. {
  728. return AutoMigrateCheckbox->IsChecked() ? EVisibility::Visible : EVisibility::Collapsed;
  729. }
  730. void SBankMigrationFailureWidget::Construct(const FArguments& InArgs)
  731. {
  732. Dialog = InArgs._Dialog;
  733. ChildSlot
  734. [
  735. SNew(SVerticalBox)
  736. + SVerticalBox::Slot()
  737. [
  738. SNew(SVerticalBox)
  739. + SVerticalBox::Slot()
  740. .Padding(4.0f)
  741. .AutoHeight()
  742. [
  743. SNew(STextBlock)
  744. .Text(LOCTEXT("BankMigrationFailureHeader", "Errors encountered while transfering banks"))
  745. .Font(FAkAppStyle::Get().GetFontStyle("DetailsView.CategoryFontStyle"))
  746. .ShadowOffset(FVector2D(1.0f, 1.0f))
  747. ]
  748. + SVerticalBox::Slot()
  749. .AutoHeight()
  750. .Padding(4.0f)
  751. [
  752. SNew(SBorder)
  753. .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
  754. [
  755. SNew(SVerticalBox)
  756. + SVerticalBox::Slot()
  757. .MaxHeight(600)
  758. .HAlign(EHorizontalAlignment::HAlign_Left)
  759. [
  760. SNew(SMultiLineEditableTextBox)
  761. .Text(InArgs._ErrorMessage)
  762. .AutoWrapText(true)
  763. .IsReadOnly(true)
  764. ]
  765. ]
  766. ]
  767. + SVerticalBox::Slot()
  768. .AutoHeight()
  769. .VAlign(VAlign_Center)
  770. .HAlign(HAlign_Center)
  771. .Padding(4.0f)
  772. [
  773. SNew(SHorizontalBox)
  774. + SHorizontalBox::Slot()
  775. .Padding(2.0f)
  776. .AutoWidth()
  777. [
  778. SNew(SButton)
  779. .ButtonStyle(FAkAppStyle::Get(), "FlatButton.Default")
  780. .ForegroundColor(FLinearColor::White)
  781. .OnClicked(this, &SBankMigrationFailureWidget::OnIgnoreClicked)
  782. .ToolTipText(FText::FromString("Ignore warnings and continue migration"))
  783. [
  784. SNew(STextBlock)
  785. .TextStyle(FAkAppStyle::Get(), "FlatButton.DefaultTextStyle")
  786. .Text(FText::FromString("Ignore Errors and Continue"))
  787. ]
  788. ]
  789. + SHorizontalBox::Slot()
  790. .Padding(2.0f)
  791. .AutoWidth()
  792. [
  793. SNew(SButton)
  794. .ButtonStyle(FAkAppStyle::Get(), "FlatButton.Default")
  795. .ForegroundColor(FLinearColor::White)
  796. .OnClicked(this, &SBankMigrationFailureWidget::OnCancelClicked)
  797. .ToolTipText(FText::FromString("Cancel the migration process to re-attempt at a later time"))
  798. [
  799. SNew(STextBlock)
  800. .TextStyle(FAkAppStyle::Get(), "FlatButton.DefaultTextStyle")
  801. .Text(FText::FromString("Cancel Migration"))
  802. ]
  803. ]
  804. ]
  805. ]
  806. ];
  807. }
  808. FReply SBankMigrationFailureWidget::OnCancelClicked()
  809. {
  810. bCancel = true;
  811. FSlateApplication::Get().RequestDestroyWindow(Dialog.ToSharedRef());
  812. return FReply::Handled();
  813. }
  814. FReply SBankMigrationFailureWidget::OnIgnoreClicked()
  815. {
  816. bCancel = false;
  817. FSlateApplication::Get().RequestDestroyWindow(Dialog.ToSharedRef());
  818. return FReply::Handled();
  819. }
  820. void SDefinitionFilePicker::Construct( const FArguments& InArgs )
  821. {
  822. OnFileChanged = InArgs._OnFileChanged;
  823. FilePath = InArgs._FilePath;
  824. Message = InArgs._Message;
  825. TSharedPtr<SButton> OpenButton;
  826. ChildSlot
  827. [
  828. SNew(SHorizontalBox)
  829. + SHorizontalBox::Slot()
  830. .FillWidth(1.0f)
  831. [
  832. SAssignNew(EditableTextBox, SEditableTextBox)
  833. .Text(this, &SDefinitionFilePicker::GetFilePathText)
  834. .OnTextChanged(this, &SDefinitionFilePicker::OnFileTextChanged)
  835. .OnTextCommitted(this, &SDefinitionFilePicker::OnFileTextCommitted)
  836. ]
  837. + SHorizontalBox::Slot()
  838. .AutoWidth()
  839. .Padding(4.0f, 0.0f, 0.0f, 0.0f)
  840. [
  841. SAssignNew(OpenButton, SButton)
  842. .ToolTipText(Message)
  843. .OnClicked(this, &SDefinitionFilePicker::BrowseForFile)
  844. [
  845. SNew(STextBlock)
  846. .Text(FText::FromString(TEXT("...")))
  847. ]
  848. ]
  849. ];
  850. OpenButton->SetEnabled(InArgs._IsEnabled);
  851. }
  852. void SDefinitionFilePicker::OnFileTextChanged(const FText& InFilePath)
  853. {
  854. FilePath = InFilePath.ToString();
  855. }
  856. void SDefinitionFilePicker::OnFileTextCommitted(const FText& InText, ETextCommit::Type InCommitType)
  857. {
  858. FilePath = InText.ToString();
  859. OnFileChanged.ExecuteIfBound(FilePath);
  860. }
  861. FString SDefinitionFilePicker::GetFilePath() const
  862. {
  863. return FilePath;
  864. }
  865. FText SDefinitionFilePicker::GetFilePathText() const
  866. {
  867. return FText::FromString(GetFilePath());
  868. }
  869. bool SDefinitionFilePicker::OpenDefinitionFilePicker(FString& OutFilePath, const FString& DefaultFilePath)
  870. {
  871. TArray<FString> OpenFileNames;
  872. bool bOpened = false;
  873. IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
  874. if (DesktopPlatform)
  875. {
  876. void* ParentWindowWindowHandle = NULL;
  877. IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame"));
  878. const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow();
  879. if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid())
  880. {
  881. ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle();
  882. }
  883. bool bAllowMultiSelect = false;
  884. FString FileTypes = TEXT("TSV Files (*.tsv)|*.tsv");
  885. FString DefaultFolder = FPaths::GetPath(DefaultFilePath);
  886. FString DefaultFile = FPaths::GetCleanFilename(DefaultFilePath);
  887. const FString Title = TEXT("Choose location for definition file");
  888. bOpened = DesktopPlatform->SaveFileDialog(
  889. ParentWindowWindowHandle,
  890. Title,
  891. *DefaultFolder,
  892. *DefaultFile,
  893. FileTypes,
  894. bAllowMultiSelect,
  895. OpenFileNames
  896. );
  897. }
  898. if (bOpened)
  899. {
  900. OutFilePath = FPaths::ConvertRelativePathToFull(OpenFileNames[0]);
  901. }
  902. return bOpened;
  903. }
  904. FReply SDefinitionFilePicker::BrowseForFile()
  905. {
  906. if ( OpenDefinitionFilePicker(FilePath, FilePath) )
  907. {
  908. OnFileChanged.ExecuteIfBound(FilePath);
  909. }
  910. return FReply::Handled();
  911. }
  912. #undef LOCTEXT_NAMESPACE