RealtimeStyleTransferRuntime/Source/LyraGame/Settings/CustomSettings/LyraSettingAction_SafeZoneE...

41 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 "LyraSettingAction_SafeZoneEditor.h"
#include "Settings/LyraGameSettingRegistry.h"
#include "Settings/LyraSettingsLocal.h"
#include "Player/LyraLocalPlayer.h"
#include "Widgets/Layout/SSafeZone.h"
#define LOCTEXT_NAMESPACE "LyraSettings"
ULyraSettingAction_SafeZoneEditor::ULyraSettingAction_SafeZoneEditor()
{
SafeZoneValueSetting = NewObject<ULyraSettingValueScalarDynamic_SafeZoneValue>();
SafeZoneValueSetting->SetDevName(TEXT("SafeZoneValue"));
SafeZoneValueSetting->SetDisplayName(LOCTEXT("SafeZoneValue_Name", "Safe Zone Value"));
SafeZoneValueSetting->SetDescriptionRichText(LOCTEXT("SafeZoneValue_Description", "The safezone area percentage."));
SafeZoneValueSetting->SetDefaultValue(0.0f);
SafeZoneValueSetting->SetDynamicGetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(GetSafeZone));
SafeZoneValueSetting->SetDynamicSetter(GET_LOCAL_SETTINGS_FUNCTION_PATH(SetSafeZone));
SafeZoneValueSetting->SetDisplayFormat([](double SourceValue, double NormalizedValue){ return FText::AsNumber(SourceValue); });
SafeZoneValueSetting->SetSettingParent(this);
}
TArray<UGameSetting*> ULyraSettingAction_SafeZoneEditor::GetChildSettings()
{
return { SafeZoneValueSetting };
}
void ULyraSettingValueScalarDynamic_SafeZoneValue::ResetToDefault()
{
Super::ResetToDefault();
SSafeZone::SetGlobalSafeZoneScale(TOptional<float>(DefaultValue.Get(0.0f)));
}
void ULyraSettingValueScalarDynamic_SafeZoneValue::RestoreToInitial()
{
Super::RestoreToInitial();
SSafeZone::SetGlobalSafeZoneScale(TOptional<float>(InitialValue));
}
#undef LOCTEXT_NAMESPACE