2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "DetailCustomizationsPrivatePCH.h"
|
|
|
|
|
#include "NavLinkStructCustomization.h"
|
2014-11-12 04:58:53 -05:00
|
|
|
#include "AI/Navigation/NavLinkDefinition.h"
|
|
|
|
|
#include "AI/Navigation/NavigationSystem.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "FNavLinkStructCustomization"
|
|
|
|
|
|
2014-06-04 10:16:14 -04:00
|
|
|
TSharedRef<IPropertyTypeCustomization> FNavLinkStructCustomization::MakeInstance( )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
return MakeShareable(new FNavLinkStructCustomization);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 11:16:24 -04:00
|
|
|
void FNavLinkStructCustomization::CustomizeHeader( TSharedRef<IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
TSharedPtr<IPropertyHandle> CommentHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FNavigationLinkBase,Description));
|
|
|
|
|
FString Desc;
|
|
|
|
|
|
|
|
|
|
if (CommentHandle.IsValid())
|
|
|
|
|
{
|
|
|
|
|
CommentHandle->GetValue(Desc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HeaderRow.NameContent()
|
|
|
|
|
[
|
|
|
|
|
StructPropertyHandle->CreatePropertyNameWidget()
|
|
|
|
|
]
|
|
|
|
|
.ValueContent()
|
|
|
|
|
.MaxDesiredWidth(400.0f)
|
|
|
|
|
[
|
|
|
|
|
SNew(STextBlock)
|
2015-01-07 09:52:40 -05:00
|
|
|
.Text(FText::FromString(Desc))
|
2014-03-14 14:13:41 -04:00
|
|
|
.Font(StructCustomizationUtils.GetRegularFont())
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 11:16:24 -04:00
|
|
|
void FNavLinkStructCustomization::CustomizeChildren( TSharedRef<class IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
uint32 NumChildren = 0;
|
|
|
|
|
StructPropertyHandle->GetNumChildren(NumChildren);
|
|
|
|
|
|
|
|
|
|
FString AgentPrefix("bSupportsAgent");
|
|
|
|
|
const UNavigationSystem* DefNavSys = (UNavigationSystem*)(UNavigationSystem::StaticClass()->GetDefaultObject());
|
2015-01-28 06:26:29 -05:00
|
|
|
const int32 NumAgents = FMath::Min(DefNavSys->GetSupportedAgents().Num(), 16);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
for (uint32 i = 0; i < NumChildren; i++)
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<IPropertyHandle> PropHandle = StructPropertyHandle->GetChildHandle(i);
|
|
|
|
|
if (PropHandle->GetProperty() && PropHandle->GetProperty()->GetName().StartsWith(AgentPrefix))
|
|
|
|
|
{
|
|
|
|
|
int32 AgentIdx = -1;
|
|
|
|
|
TTypeFromString<int32>::FromString(AgentIdx, *(PropHandle->GetProperty()->GetName().Mid(AgentPrefix.Len()) ));
|
|
|
|
|
|
|
|
|
|
if (AgentIdx >= 0 && AgentIdx < NumAgents)
|
|
|
|
|
{
|
2015-01-28 06:26:29 -05:00
|
|
|
FText PropName = FText::Format(LOCTEXT("SupportedAgentFmt", "Supports Agent: {0}"), FText::FromName(DefNavSys->GetSupportedAgents()[AgentIdx].Name));
|
2014-12-01 11:19:41 -05:00
|
|
|
StructBuilder.AddChildContent(PropName)
|
2014-03-14 14:13:41 -04:00
|
|
|
.NameContent()
|
|
|
|
|
[
|
|
|
|
|
SNew(STextBlock)
|
|
|
|
|
.Text(PropName)
|
|
|
|
|
.Font(StructCustomizationUtils.GetRegularFont())
|
|
|
|
|
]
|
|
|
|
|
.ValueContent()
|
|
|
|
|
[
|
|
|
|
|
PropHandle->CreatePropertyValueWidget()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StructBuilder.AddChildProperty(PropHandle.ToSharedRef());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|