You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Moved SmartObjects out of restricted folder Moved StateTree out of restricted folder Moved ZoneGraph out of restricted folder Moved ZoneGraphAnnotations out of restricted folder #jira UE-115297 #ROBOMERGE-OWNER: mieszko.zielinski #ROBOMERGE-AUTHOR: mieszko.zielinski #ROBOMERGE-SOURCE: CL 17648223 via CL 17648246 via CL 17648261 via CL 17648385 via CL 17648390 via CL 17648742 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Test -> Main) (v875-17642767) [CL 17648750 by mieszko zielinski in ue5-main branch]
91 lines
2.1 KiB
C++
91 lines
2.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
#include "ZoneGraphPropertyUtils.h"
|
|
#include "ZoneGraphTypes.h"
|
|
#include "ZoneGraphSettings.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "ZoneGraphEditor"
|
|
|
|
namespace UE::ZoneGraph::PropertyUtils
|
|
{
|
|
|
|
FLinearColor GetMaskColor(TSharedPtr<IPropertyHandle> MaskProperty)
|
|
{
|
|
if (!MaskProperty.IsValid())
|
|
{
|
|
return FLinearColor::Transparent;
|
|
}
|
|
|
|
const UZoneGraphSettings* ZoneGraphSettings = GetDefault<UZoneGraphSettings>();
|
|
check(ZoneGraphSettings);
|
|
TConstArrayView<FZoneGraphTagInfo> TagInfos = ZoneGraphSettings->GetTagInfos();
|
|
|
|
TOptional<FZoneGraphTagMask> TagsOpt = UE::ZoneGraph::PropertyUtils::GetValue<FZoneGraphTagMask>(MaskProperty);
|
|
if (TagsOpt.IsSet())
|
|
{
|
|
FZoneGraphTagMask Tags = TagsOpt.GetValue();
|
|
// Pick the first color
|
|
FLinearColor Color = FLinearColor::Black;
|
|
for (const FZoneGraphTagInfo& Info : TagInfos)
|
|
{
|
|
if (Tags.Contains(Info.Tag))
|
|
{
|
|
if (Info.IsValid())
|
|
{
|
|
Color = FLinearColor(Info.Color);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return Color;
|
|
}
|
|
return FLinearColor::Transparent;
|
|
}
|
|
|
|
FText GetMaskDescription(TSharedPtr<IPropertyHandle> MaskProperty)
|
|
{
|
|
if (!MaskProperty.IsValid())
|
|
{
|
|
return FText::GetEmpty();
|
|
}
|
|
|
|
const UZoneGraphSettings* ZoneGraphSettings = GetDefault<UZoneGraphSettings>();
|
|
check(ZoneGraphSettings);
|
|
TConstArrayView<FZoneGraphTagInfo> TagInfos = ZoneGraphSettings->GetTagInfos();
|
|
|
|
TOptional<FZoneGraphTagMask> TagsOpt = UE::ZoneGraph::PropertyUtils::GetValue<FZoneGraphTagMask>(MaskProperty);
|
|
if (TagsOpt.IsSet())
|
|
{
|
|
FZoneGraphTagMask Tags = TagsOpt.GetValue();
|
|
|
|
TArray<FText> Names;
|
|
for (const FZoneGraphTagInfo& Info : TagInfos)
|
|
{
|
|
if (Tags.Contains(Info.Tag))
|
|
{
|
|
if (Info.IsValid())
|
|
{
|
|
Names.Add(FText::FromName(Info.Name));
|
|
}
|
|
}
|
|
}
|
|
if (Names.Num() == 0)
|
|
{
|
|
return LOCTEXT("EmptyMask", "(Empty)");
|
|
}
|
|
else
|
|
{
|
|
if (Names.Num() > 2)
|
|
{
|
|
Names.SetNum(2);
|
|
Names.Add(FText::FromString(TEXT("...")));
|
|
}
|
|
}
|
|
return FText::Join(FText::FromString(TEXT(", ")), Names);
|
|
}
|
|
|
|
return LOCTEXT("MultipleSelected", "(Multiple Selected)");
|
|
}
|
|
|
|
} // UE::ZoneGraph::PropertyUtils
|
|
|
|
#undef LOCTEXT_NAMESPACE |