48 lines
1.8 KiB
C++
48 lines
1.8 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "LyraSettingAction_SafeZoneEditor.h"
|
|
|
|
#include "DataSource/GameSettingDataSourceDynamic.h"
|
|
#include "HAL/Platform.h"
|
|
#include "Internationalization/Internationalization.h"
|
|
#include "Internationalization/Text.h"
|
|
#include "Misc/Optional.h"
|
|
#include "Player/LyraLocalPlayer.h"
|
|
#include "Settings/LyraGameSettingRegistry.h"
|
|
#include "Widgets/Layout/SSafeZone.h"
|
|
|
|
class UGameSetting;
|
|
|
|
#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 |