2023-10-28 02:46:42 +02:00
|
|
|
// Copyright 2023 MrRobin. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "DetailCustomizations/MyDateTimeDetailCustomization.h"
|
|
|
|
|
|
|
|
|
|
#include "Containers/Array.h"
|
|
|
|
|
#include "Containers/UnrealString.h"
|
|
|
|
|
#include "DetailWidgetRow.h"
|
|
|
|
|
#include "Fonts/SlateFontInfo.h"
|
|
|
|
|
#include "HAL/PlatformCrt.h"
|
|
|
|
|
#include "Internationalization/Internationalization.h"
|
|
|
|
|
#include "Misc/Attribute.h"
|
|
|
|
|
#include "Misc/DateTime.h"
|
|
|
|
|
#include "PropertyHandle.h"
|
|
|
|
|
#include "Styling/AppStyle.h"
|
|
|
|
|
#include "Styling/ISlateStyle.h"
|
|
|
|
|
#include "UObject/NameTypes.h"
|
|
|
|
|
#include "UObject/UnrealType.h"
|
|
|
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
|
|
|
|
|
|
|
|
#include "DetailLayoutBuilder.h"
|
|
|
|
|
#include "Widgets/Input/SNumericEntryBox.h"
|
|
|
|
|
#include "Widgets/Input/SVectorInputBox.h"
|
2023-10-28 20:43:30 +02:00
|
|
|
#include "Widgets/Input/NumericTypeInterface.h"
|
|
|
|
|
#include "Widgets/Input/NumericUnitTypeInterface.inl"
|
|
|
|
|
#include "Math/UnitConversion.h"
|
|
|
|
|
|
|
|
|
|
// SExpanderArrow
|
2023-10-28 02:46:42 +02:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "MyDateTimeDetailCustomization"
|
|
|
|
|
|
|
|
|
|
/* IDetailCustomization interface
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void FMyDateTimeDetailCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
|
|
|
|
|
{
|
|
|
|
|
/* do nothing */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FMyDateTimeDetailCustomization::CustomizeHeader(TSharedRef<IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
|
|
|
|
|
{
|
|
|
|
|
PropertyHandle = StructPropertyHandle;
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
SAssignNew(YearEntryBox, SNumericEntryBox<double>)
|
2023-10-28 20:43:30 +02:00
|
|
|
.AllowSpin(true)
|
|
|
|
|
.MinValue(1)
|
|
|
|
|
.MaxValue(9999)
|
|
|
|
|
.MinSliderValue(1)
|
|
|
|
|
.MaxSliderValue(9999)
|
2023-10-28 23:18:17 +02:00
|
|
|
.MinFractionalDigits(0)
|
|
|
|
|
.MaxFractionalDigits(0)
|
2023-10-28 20:43:30 +02:00
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 3)
|
|
|
|
|
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 3)
|
|
|
|
|
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 3)
|
|
|
|
|
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
|
|
|
|
|
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
|
2023-10-28 23:18:17 +02:00
|
|
|
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Years)))
|
2023-10-28 20:43:30 +02:00
|
|
|
.LinearDeltaSensitivity(1);
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
SAssignNew(MonthEntryBox, SNumericEntryBox<double>)
|
2023-10-28 20:43:30 +02:00
|
|
|
.AllowSpin(true)
|
|
|
|
|
.MinValue(1)
|
|
|
|
|
.MaxValue(12)
|
|
|
|
|
.MinSliderValue(1)
|
|
|
|
|
.MaxSliderValue(12)
|
2023-10-28 23:18:17 +02:00
|
|
|
.MinFractionalDigits(0)
|
|
|
|
|
.MaxFractionalDigits(0)
|
2023-10-28 20:43:30 +02:00
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 4)
|
|
|
|
|
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 4)
|
|
|
|
|
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 4)
|
|
|
|
|
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
|
|
|
|
|
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
|
2023-10-28 23:18:17 +02:00
|
|
|
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Months)))
|
2023-10-28 20:43:30 +02:00
|
|
|
.LinearDeltaSensitivity(1);
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
SAssignNew(DayEntryBox, SNumericEntryBox<double>)
|
2023-10-28 20:43:30 +02:00
|
|
|
.AllowSpin(true)
|
|
|
|
|
.MinValue(1)
|
|
|
|
|
.MaxValue(31)
|
|
|
|
|
.MinSliderValue(1)
|
|
|
|
|
.MaxSliderValue(31)
|
2023-10-28 23:18:17 +02:00
|
|
|
.MinFractionalDigits(0)
|
|
|
|
|
.MaxFractionalDigits(0)
|
2023-10-28 20:43:30 +02:00
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 5)
|
|
|
|
|
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 5)
|
|
|
|
|
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 5)
|
|
|
|
|
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
|
|
|
|
|
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
|
2023-10-28 23:18:17 +02:00
|
|
|
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Days)))
|
2023-10-28 20:43:30 +02:00
|
|
|
.LinearDeltaSensitivity(1);
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
SAssignNew(HourEntryBox, SNumericEntryBox<double>)
|
2023-10-28 20:43:30 +02:00
|
|
|
.AllowSpin(true)
|
|
|
|
|
.MinValue(0)
|
|
|
|
|
.MaxValue(23)
|
|
|
|
|
.MinSliderValue(0)
|
|
|
|
|
.MaxSliderValue(23)
|
2023-10-28 23:18:17 +02:00
|
|
|
.MinFractionalDigits(0)
|
|
|
|
|
.MaxFractionalDigits(0)
|
2023-10-28 20:43:30 +02:00
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 0)
|
|
|
|
|
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 0)
|
|
|
|
|
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 0)
|
|
|
|
|
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
|
|
|
|
|
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
|
2023-10-28 23:18:17 +02:00
|
|
|
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Hours)))
|
2023-10-28 20:43:30 +02:00
|
|
|
.LinearDeltaSensitivity(1);
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
SAssignNew(MinuteEntryBox, SNumericEntryBox<double>)
|
2023-10-28 20:43:30 +02:00
|
|
|
.AllowSpin(true)
|
|
|
|
|
.MinValue(0)
|
|
|
|
|
.MaxValue(59)
|
|
|
|
|
.MinSliderValue(0)
|
|
|
|
|
.MaxSliderValue(59)
|
2023-10-28 23:18:17 +02:00
|
|
|
.MinFractionalDigits(0)
|
|
|
|
|
.MaxFractionalDigits(0)
|
2023-10-28 20:43:30 +02:00
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 1)
|
|
|
|
|
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 1)
|
|
|
|
|
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 1)
|
|
|
|
|
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
|
|
|
|
|
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
|
2023-10-28 23:18:17 +02:00
|
|
|
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Minutes)))
|
2023-10-28 20:43:30 +02:00
|
|
|
.LinearDeltaSensitivity(1);
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
SAssignNew(SecondEntryBox, SNumericEntryBox<double>)
|
2023-10-28 20:43:30 +02:00
|
|
|
.AllowSpin(true)
|
|
|
|
|
.MinValue(0)
|
|
|
|
|
.MaxValue(59)
|
|
|
|
|
.MinSliderValue(0)
|
|
|
|
|
.MaxSliderValue(59)
|
2023-10-28 23:18:17 +02:00
|
|
|
.MinFractionalDigits(0)
|
|
|
|
|
.MaxFractionalDigits(0)
|
2023-10-28 20:43:30 +02:00
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 2)
|
|
|
|
|
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 2)
|
|
|
|
|
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 2)
|
|
|
|
|
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
|
|
|
|
|
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
|
2023-10-28 23:18:17 +02:00
|
|
|
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Seconds)))
|
2023-10-28 20:43:30 +02:00
|
|
|
.LinearDeltaSensitivity(1);
|
2023-10-28 02:46:42 +02:00
|
|
|
|
|
|
|
|
HeaderRow
|
|
|
|
|
.NameContent()
|
|
|
|
|
[
|
|
|
|
|
StructPropertyHandle->CreatePropertyNameWidget()
|
|
|
|
|
]
|
|
|
|
|
.ValueContent()
|
|
|
|
|
.MinDesiredWidth(125.0f * 3.0f)
|
2023-10-28 20:43:30 +02:00
|
|
|
.MaxDesiredWidth(125.0f * 3.0f)
|
2023-10-28 02:46:42 +02:00
|
|
|
[
|
|
|
|
|
SNew(SVerticalBox)
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
2023-10-28 20:43:30 +02:00
|
|
|
.Padding(0.0f, 0.0f, 2.0f, 0.0f)
|
2023-10-28 02:46:42 +02:00
|
|
|
[
|
2023-10-28 20:43:30 +02:00
|
|
|
YearEntryBox.ToSharedRef()
|
2023-10-28 02:46:42 +02:00
|
|
|
]
|
|
|
|
|
+ SHorizontalBox::Slot()
|
2023-10-28 20:43:30 +02:00
|
|
|
.Padding(2.0f, 0.0f)
|
2023-10-28 02:46:42 +02:00
|
|
|
[
|
2023-10-28 20:43:30 +02:00
|
|
|
MonthEntryBox.ToSharedRef()
|
2023-10-28 02:46:42 +02:00
|
|
|
]
|
|
|
|
|
+ SHorizontalBox::Slot()
|
2023-10-28 20:43:30 +02:00
|
|
|
.Padding(2.0f, 0.0f, 0.0f, 0.0f)
|
2023-10-28 02:46:42 +02:00
|
|
|
[
|
2023-10-28 20:43:30 +02:00
|
|
|
DayEntryBox.ToSharedRef()
|
2023-10-28 02:46:42 +02:00
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.AutoHeight()
|
2023-10-28 20:43:30 +02:00
|
|
|
[
|
|
|
|
|
SNew(SSpacer)
|
|
|
|
|
.Size(FVector2D(8.0f))
|
|
|
|
|
]
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.AutoHeight()
|
2023-10-28 02:46:42 +02:00
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
2023-10-28 20:43:30 +02:00
|
|
|
.Padding(0.0f, 0.0f, 2.0f, 0.0f)
|
2023-10-28 02:46:42 +02:00
|
|
|
[
|
2023-10-28 20:43:30 +02:00
|
|
|
HourEntryBox.ToSharedRef()
|
2023-10-28 02:46:42 +02:00
|
|
|
]
|
|
|
|
|
+ SHorizontalBox::Slot()
|
2023-10-28 20:43:30 +02:00
|
|
|
.Padding(2.0f, 0.0f)
|
2023-10-28 02:46:42 +02:00
|
|
|
[
|
2023-10-28 20:43:30 +02:00
|
|
|
MinuteEntryBox.ToSharedRef()
|
2023-10-28 02:46:42 +02:00
|
|
|
]
|
|
|
|
|
+ SHorizontalBox::Slot()
|
2023-10-28 20:43:30 +02:00
|
|
|
.Padding(2.0f, 0.0f, 0.0f, 0.0f)
|
2023-10-28 02:46:42 +02:00
|
|
|
[
|
2023-10-28 20:43:30 +02:00
|
|
|
SecondEntryBox.ToSharedRef()
|
2023-10-28 02:46:42 +02:00
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* FMyDateTimeDetailCustomization callbacks
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
TOptional<double> FMyDateTimeDetailCustomization::OnGetValue(int32 Index) const
|
2023-10-28 02:46:42 +02:00
|
|
|
{
|
|
|
|
|
TArray<void*> RawData;
|
|
|
|
|
PropertyHandle->AccessRawData(RawData);
|
|
|
|
|
|
|
|
|
|
if (RawData.Num() != 1)
|
2023-10-28 23:18:17 +02:00
|
|
|
return TOptional<double>();
|
2023-10-28 02:46:42 +02:00
|
|
|
|
|
|
|
|
if (RawData[0] == nullptr)
|
2023-10-28 23:18:17 +02:00
|
|
|
return TOptional<double>();
|
2023-10-28 02:46:42 +02:00
|
|
|
|
|
|
|
|
auto* DateTime = ((FDateTime*)RawData[0]);
|
|
|
|
|
|
|
|
|
|
switch (Index)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
2023-10-28 23:18:17 +02:00
|
|
|
return TOptional<double>(DateTime->GetHour());
|
2023-10-28 02:46:42 +02:00
|
|
|
|
|
|
|
|
case 1:
|
2023-10-28 23:18:17 +02:00
|
|
|
return TOptional<double>(DateTime->GetMinute());
|
2023-10-28 02:46:42 +02:00
|
|
|
|
|
|
|
|
case 2:
|
2023-10-28 23:18:17 +02:00
|
|
|
return TOptional<double>(DateTime->GetSecond());
|
2023-10-28 02:46:42 +02:00
|
|
|
|
|
|
|
|
case 3:
|
2023-10-28 23:18:17 +02:00
|
|
|
return TOptional<double>(DateTime->GetYear());
|
2023-10-28 02:46:42 +02:00
|
|
|
|
|
|
|
|
case 4:
|
2023-10-28 23:18:17 +02:00
|
|
|
return TOptional<double>(DateTime->GetMonth());
|
2023-10-28 02:46:42 +02:00
|
|
|
|
|
|
|
|
case 5:
|
2023-10-28 23:18:17 +02:00
|
|
|
return TOptional<double>(DateTime->GetDay());
|
2023-10-28 02:46:42 +02:00
|
|
|
|
|
|
|
|
default:
|
2023-10-28 23:18:17 +02:00
|
|
|
return TOptional<double>();
|
2023-10-28 02:46:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FMyDateTimeDetailCustomization::OnBeginSliderMovement()
|
|
|
|
|
{
|
|
|
|
|
bIsUsingSlider = true;
|
|
|
|
|
|
|
|
|
|
GEditor->BeginTransaction(
|
|
|
|
|
FText::Format(
|
|
|
|
|
NSLOCTEXT("MyDateTimeDetailCustomization", "SetDateTimeProperty", "Edit {0}"),
|
|
|
|
|
PropertyHandle->GetPropertyDisplayName())
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
void FMyDateTimeDetailCustomization::OnEndSliderMovement(double NewValue)
|
2023-10-28 02:46:42 +02:00
|
|
|
{
|
|
|
|
|
bIsUsingSlider = false;
|
|
|
|
|
|
|
|
|
|
GEditor->EndTransaction();
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
void FMyDateTimeDetailCustomization::OnValueCommitted(double NewValue, ETextCommit::Type CommitType, int32 Index)
|
2023-10-28 02:46:42 +02:00
|
|
|
{
|
2023-10-28 23:18:17 +02:00
|
|
|
NewValue = FMath::CeilToDouble(NewValue);
|
|
|
|
|
|
2023-10-28 02:46:42 +02:00
|
|
|
TArray<void*> RawData;
|
|
|
|
|
|
|
|
|
|
PropertyHandle->AccessRawData(RawData);
|
|
|
|
|
PropertyHandle->NotifyPreChange();
|
|
|
|
|
|
|
|
|
|
for (auto RawDataInstance : RawData)
|
|
|
|
|
{
|
|
|
|
|
auto* DateTime = (FDateTime*)RawDataInstance;
|
|
|
|
|
|
|
|
|
|
int32 Year = DateTime->GetYear();
|
|
|
|
|
int32 Month = DateTime->GetMonth();
|
|
|
|
|
int32 Day = DateTime->GetDay();
|
|
|
|
|
|
|
|
|
|
int32 Hour = DateTime->GetHour();
|
|
|
|
|
int32 Minute = DateTime->GetMinute();
|
|
|
|
|
int32 Second = DateTime->GetSecond();
|
|
|
|
|
|
|
|
|
|
int32 MaxDays = FDateTime::DaysInMonth(Year, Month);
|
|
|
|
|
|
|
|
|
|
switch (Index)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
*DateTime = FDateTime(Year, Month, Day > MaxDays ? MaxDays : Day, NewValue, Minute, Second);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
*DateTime = FDateTime(Year, Month, Day > MaxDays ? MaxDays : Day, Hour, NewValue, Second);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
*DateTime = FDateTime(Year, Month, Day > MaxDays ? MaxDays : Day, Hour, Minute, NewValue);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
{
|
|
|
|
|
MaxDays = FDateTime::DaysInMonth(NewValue, Month);
|
|
|
|
|
*DateTime = FDateTime(NewValue, Month, Day > MaxDays ? MaxDays : Day, Hour, Minute, Second);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
{
|
|
|
|
|
MaxDays = FDateTime::DaysInMonth(Year, NewValue);
|
|
|
|
|
*DateTime = FDateTime(Year, NewValue, Day > MaxDays ? MaxDays : Day, Hour, Minute, Second);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
*DateTime = FDateTime(Year, Month, NewValue > MaxDays ? MaxDays : NewValue, Hour, Minute, Second);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertyHandle->NotifyPostChange(EPropertyChangeType::ValueSet);
|
|
|
|
|
PropertyHandle->NotifyFinishedChangingProperties();
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
void FMyDateTimeDetailCustomization::OnValueChanged(double NewValue, int32 Index)
|
2023-10-28 02:46:42 +02:00
|
|
|
{
|
|
|
|
|
if (!bIsUsingSlider)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-10-28 23:18:17 +02:00
|
|
|
NewValue = FMath::CeilToDouble(NewValue);
|
|
|
|
|
|
2023-10-28 02:46:42 +02:00
|
|
|
TArray<void*> RawData;
|
|
|
|
|
|
|
|
|
|
PropertyHandle->AccessRawData(RawData);
|
|
|
|
|
PropertyHandle->NotifyPreChange();
|
|
|
|
|
|
|
|
|
|
for (auto RawDataInstance : RawData)
|
|
|
|
|
{
|
|
|
|
|
auto* DateTime = (FDateTime*)RawDataInstance;
|
|
|
|
|
|
|
|
|
|
int32 Year = DateTime->GetYear();
|
|
|
|
|
int32 Month = DateTime->GetMonth();
|
|
|
|
|
int32 Day = DateTime->GetDay();
|
|
|
|
|
|
|
|
|
|
int32 Hour = DateTime->GetHour();
|
|
|
|
|
int32 Minute = DateTime->GetMinute();
|
|
|
|
|
int32 Second = DateTime->GetSecond();
|
|
|
|
|
|
|
|
|
|
int32 MaxDays = FDateTime::DaysInMonth(Year, Month);
|
|
|
|
|
|
|
|
|
|
switch (Index)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
*DateTime = FDateTime(Year, Month, Day > MaxDays ? MaxDays : Day, NewValue, Minute, Second);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
*DateTime = FDateTime(Year, Month, Day > MaxDays ? MaxDays : Day, Hour, NewValue, Second);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
*DateTime = FDateTime(Year, Month, Day > MaxDays ? MaxDays : Day, Hour, Minute, NewValue);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
{
|
|
|
|
|
MaxDays = FDateTime::DaysInMonth(NewValue, Month);
|
|
|
|
|
*DateTime = FDateTime(NewValue, Month, Day > MaxDays ? MaxDays : Day, Hour, Minute, Second);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
{
|
|
|
|
|
MaxDays = FDateTime::DaysInMonth(Year, NewValue);
|
|
|
|
|
*DateTime = FDateTime(Year, NewValue, Day > MaxDays ? MaxDays : Day, Hour, Minute, Second);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
*DateTime = FDateTime(Year, Month, NewValue > MaxDays ? MaxDays : NewValue, Hour, Minute, Second);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertyHandle->NotifyPostChange(EPropertyChangeType::ValueSet);
|
|
|
|
|
PropertyHandle->NotifyFinishedChangingProperties();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|