// Copyright Epic Games, Inc. All Rights Reserved. #include "LyraSettingScreen.h" #include "Containers/Array.h" #include "Delegates/Delegate.h" #include "Input/CommonUIInputTypes.h" #include "Player/LyraLocalPlayer.h" #include "Settings/LyraGameSettingRegistry.h" #include "Templates/Casts.h" class UGameSettingRegistry; void ULyraSettingScreen::NativeOnInitialized() { Super::NativeOnInitialized(); BackHandle = RegisterUIActionBinding(FBindUIActionArgs(BackInputActionData, true, FSimpleDelegate::CreateUObject(this, &ThisClass::HandleBackAction))); ApplyHandle = RegisterUIActionBinding(FBindUIActionArgs(ApplyInputActionData, true, FSimpleDelegate::CreateUObject(this, &ThisClass::HandleApplyAction))); CancelChangesHandle = RegisterUIActionBinding(FBindUIActionArgs(CancelChangesInputActionData, true, FSimpleDelegate::CreateUObject(this, &ThisClass::HandleCancelChangesAction))); } UGameSettingRegistry* ULyraSettingScreen::CreateRegistry() { ULyraGameSettingRegistry* NewRegistry = NewObject(); if (ULyraLocalPlayer* LocalPlayer = CastChecked(GetOwningLocalPlayer())) { NewRegistry->Initialize(LocalPlayer); } return NewRegistry; } void ULyraSettingScreen::HandleBackAction() { if (AttemptToPopNavigation()) { return; } ApplyChanges(); DeactivateWidget(); } void ULyraSettingScreen::HandleApplyAction() { ApplyChanges(); } void ULyraSettingScreen::HandleCancelChangesAction() { CancelChanges(); } void ULyraSettingScreen::OnSettingsDirtyStateChanged_Implementation(bool bSettingsDirty) { if (bSettingsDirty) { if (!GetActionBindings().Contains(ApplyHandle)) { AddActionBinding(ApplyHandle); } if (!GetActionBindings().Contains(CancelChangesHandle)) { AddActionBinding(CancelChangesHandle); } } else { RemoveActionBinding(ApplyHandle); RemoveActionBinding(CancelChangesHandle); } }