1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #include "ReloadPopup.h"
- #include "AkAudioStyle.h"
- #include "AkAudioModule.h"
- #include "Async/Async.h"
- #include "Framework/Notifications/NotificationManager.h"
- #include "Widgets/Notifications/SNotificationList.h"
- #define LOCTEXT_NAMESPACE "AkAudio"
- TSharedPtr<SNotificationItem> FReloadPopup::RefreshNotificationItem;
- FReloadPopup::FReloadPopup()
- {
-
- }
- void FReloadPopup::NotifyProjectRefresh()
- {
- if (!FApp::CanEverRender())
- {
- return;
- }
- AsyncTask(ENamedThreads::Type::GameThread, [this]
- {
- FText InfoString = LOCTEXT("ReloadPopupRefreshData", "Wwise project database was updated.\nReload Wwise Asset Data?");
- FSimpleDelegate RefreshDelegate = FSimpleDelegate();
- RefreshDelegate.BindRaw(this, &FReloadPopup::Reload);
- FSimpleDelegate HideDelegate = FSimpleDelegate();
- HideDelegate.BindRaw(this, &FReloadPopup::HideRefreshNotification);
- FNotificationButtonInfo RefreshButton = FNotificationButtonInfo(LOCTEXT("WwiseDataRefresh", "Refresh"), FText(), RefreshDelegate);
- FNotificationButtonInfo HideButton = FNotificationButtonInfo(LOCTEXT("WwiseDataNotNow", "Not Now"), FText(), HideDelegate);
- FNotificationInfo Info(InfoString);
- Info.ButtonDetails.Add(RefreshButton);
- Info.ButtonDetails.Add(HideButton);
- Info.Image = FAkAudioStyle::GetBrush(TEXT("AudiokineticTools.AkBrowserTabIcon"));
- Info.bUseSuccessFailIcons = false;
- Info.FadeOutDuration = 0.5f;
- Info.ExpireDuration = 10.0f;
- RefreshNotificationItem = FSlateNotificationManager::Get().AddNotification(Info);
- if (RefreshNotificationItem.IsValid())
- {
- RefreshNotificationItem->SetCompletionState(SNotificationItem::CS_Pending);
- }
- });
- }
- void FReloadPopup::Reload()
- {
- if (!FApp::CanEverRender())
- {
- return;
- }
- AsyncTask(ENamedThreads::Type::GameThread, [this]
- {
- FAkAudioModule::AkAudioModuleInstance->ReloadWwiseAssetData();
- if (RefreshNotificationItem)
- {
- RefreshNotificationItem->Fadeout();
- }
- });
- }
- void FReloadPopup::HideRefreshNotification()
- {
- if (!FApp::CanEverRender())
- {
- return;
- }
- AsyncTask(ENamedThreads::Type::GameThread, [this]
- {
- if (RefreshNotificationItem)
- {
- RefreshNotificationItem->Fadeout();
- }
- });
- }
- #undef LOCTEXT_NAMESPACE
|