RealtimeStyleTransferRuntime/Source/LyraGame/UI/Subsystem/LyraUIMessaging.cpp

43 lines
1.6 KiB
C++
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#include "LyraUIMessaging.h"
#include "NativeGameplayTags.h"
#include "Player/LyraLocalPlayer.h"
#include "PrimaryGameLayout.h"
#include "Messaging/CommonGameDialog.h"
UE_DEFINE_GAMEPLAY_TAG_STATIC(TAG_UI_LAYER_MODAL, "UI.Layer.Modal");
void ULyraUIMessaging::Initialize(FSubsystemCollectionBase& Collection)
{
Super::Initialize(Collection);
ConfirmationDialogClassPtr = ConfirmationDialogClass.LoadSynchronous();
ErrorDialogClassPtr = ErrorDialogClass.LoadSynchronous();
}
void ULyraUIMessaging::ShowConfirmation(UCommonGameDialogDescriptor* DialogDescriptor, FCommonMessagingResultDelegate ResultCallback)
{
if (ULyraLocalPlayer* LocalPlayer = GetLocalPlayer<ULyraLocalPlayer>())
{
if (UPrimaryGameLayout* RootLayout = LocalPlayer->GetRootUILayout())
{
RootLayout->PushWidgetToLayerStack<UCommonGameDialog>(TAG_UI_LAYER_MODAL, ConfirmationDialogClassPtr, [DialogDescriptor, ResultCallback](UCommonGameDialog& Dialog) {
Dialog.SetupDialog(DialogDescriptor, ResultCallback);
});
}
}
}
void ULyraUIMessaging::ShowError(UCommonGameDialogDescriptor* DialogDescriptor, FCommonMessagingResultDelegate ResultCallback)
{
if (ULyraLocalPlayer* LocalPlayer = GetLocalPlayer<ULyraLocalPlayer>())
{
if (UPrimaryGameLayout* RootLayout = LocalPlayer->GetRootUILayout())
{
RootLayout->PushWidgetToLayerStack<UCommonGameDialog>(TAG_UI_LAYER_MODAL, ErrorDialogClassPtr, [DialogDescriptor, ResultCallback](UCommonGameDialog& Dialog) {
Dialog.SetupDialog(DialogDescriptor, ResultCallback);
});
}
}
}