48 lines
2.0 KiB
C++
48 lines
2.0 KiB
C++
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||
|
|
|
||
|
|
#include "NpcScheduleAssetCustomization.h"
|
||
|
|
|
||
|
|
#include "DetailCategoryBuilder.h"
|
||
|
|
#include "DetailLayoutBuilder.h"
|
||
|
|
#include "DetailWidgetRow.h"
|
||
|
|
|
||
|
|
#include "NpcScheduleTimeline.h"
|
||
|
|
#include "ProjectEleri/Ai/NpcScheduleAsset.h"
|
||
|
|
|
||
|
|
#define LOCTEXT_NAMESPACE "NpcScheduleAssetCustomization"
|
||
|
|
|
||
|
|
TSharedRef<IDetailCustomization> FNpcScheduleAssetCustomization::MakeInstance() {
|
||
|
|
return MakeShareable(new FNpcScheduleAssetCustomization());
|
||
|
|
}
|
||
|
|
|
||
|
|
void FNpcScheduleAssetCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) {
|
||
|
|
// The asset being customized. The weak pointers the panel hands over are the whole reason the strip
|
||
|
|
// holds one of its own rather than a raw pointer: an asset can be deleted while a tab showing it is
|
||
|
|
// still open, and the strip has to draw an empty day rather than a dangling one.
|
||
|
|
TArray<TWeakObjectPtr<UObject>> Objects;
|
||
|
|
DetailBuilder.GetObjectsBeingCustomized(Objects);
|
||
|
|
|
||
|
|
UNpcScheduleAsset* Schedule = Objects.Num() > 0 ? Cast<UNpcScheduleAsset>(Objects[0].Get()) : nullptr;
|
||
|
|
|
||
|
|
// A category of this module's own, sorted after the one an asset's properties land in, so that the
|
||
|
|
// strip is drawn under every row the asset already had rather than beside them. It is created even
|
||
|
|
// when nothing is being customized, so that a panel left open on a deleted asset still has a strip
|
||
|
|
// in it saying so.
|
||
|
|
IDetailCategoryBuilder& TimelineCategory = DetailBuilder.EditCategory(
|
||
|
|
TEXT("ScheduleTimeline"),
|
||
|
|
LOCTEXT("TimelineCategoryLabel", "Day Timeline"),
|
||
|
|
ECategoryPriority::Uncommon);
|
||
|
|
|
||
|
|
// The whole row, name column and value column both, because the strip is a picture of the day and
|
||
|
|
// not the value of anything: it is laid out against the width of the panel it is handed, and this
|
||
|
|
// is the slot that hands it all of it.
|
||
|
|
TimelineCategory.AddCustomRow(LOCTEXT("TimelineRowLabel", "Day Timeline"))
|
||
|
|
.WholeRowContent()
|
||
|
|
[
|
||
|
|
SNew(SNpcScheduleTimeline)
|
||
|
|
.Schedule(Schedule)
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
#undef LOCTEXT_NAMESPACE
|