// Copyright Epic Games, Inc. All Rights Reserved. #include "LyraGameSettingRegistry.h" #include "Engine/LocalPlayer.h" #include "GameSettingCollection.h" #include "HAL/Platform.h" #include "LyraSettingsLocal.h" #include "LyraSettingsShared.h" #include "Player/LyraLocalPlayer.h" #include "Templates/Casts.h" DEFINE_LOG_CATEGORY(LogLyraGameSettingRegistry); #define LOCTEXT_NAMESPACE "Lyra" //-------------------------------------- // ULyraGameSettingRegistry //-------------------------------------- ULyraGameSettingRegistry::ULyraGameSettingRegistry() { } ULyraGameSettingRegistry* ULyraGameSettingRegistry::Get(ULyraLocalPlayer* InLocalPlayer) { ULyraGameSettingRegistry* Registry = FindObject(InLocalPlayer, TEXT("LyraGameSettingRegistry"), true); if (Registry == nullptr) { Registry = NewObject(InLocalPlayer, TEXT("LyraGameSettingRegistry")); Registry->Initialize(InLocalPlayer); } return Registry; } bool ULyraGameSettingRegistry::IsFinishedInitializing() const { if (Super::IsFinishedInitializing()) { if (ULyraLocalPlayer* LocalPlayer = Cast(OwningLocalPlayer)) { if (LocalPlayer->GetSharedSettings() == nullptr) { return false; } } return true; } return false; } void ULyraGameSettingRegistry::OnInitialize(ULocalPlayer* InLocalPlayer) { ULyraLocalPlayer* LyraLocalPlayer = Cast(InLocalPlayer); VideoSettings = InitializeVideoSettings(LyraLocalPlayer); InitializeVideoSettings_FrameRates(VideoSettings, LyraLocalPlayer); RegisterSetting(VideoSettings); AudioSettings = InitializeAudioSettings(LyraLocalPlayer); RegisterSetting(AudioSettings); GameplaySettings = InitializeGameplaySettings(LyraLocalPlayer); RegisterSetting(GameplaySettings); MouseAndKeyboardSettings = InitializeMouseAndKeyboardSettings(LyraLocalPlayer); RegisterSetting(MouseAndKeyboardSettings); GamepadSettings = InitializeGamepadSettings(LyraLocalPlayer); RegisterSetting(GamepadSettings); } void ULyraGameSettingRegistry::SaveChanges() { Super::SaveChanges(); if (ULyraLocalPlayer* LocalPlayer = Cast(OwningLocalPlayer)) { // Game user settings need to be applied to handle things like resolution, this saves indirectly LocalPlayer->GetLocalSettings()->ApplySettings(false); LocalPlayer->GetSharedSettings()->ApplySettings(); LocalPlayer->GetSharedSettings()->SaveSettings(); } } #undef LOCTEXT_NAMESPACE