You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
StateTree: Added support for description and icon for BP nodes.
#rb Thomas.Sarkanen, Yoan.StAmant [CL 33098383 by mikko mononen in ue5-main branch]
This commit is contained in:
@@ -47,10 +47,33 @@ bool FStateTreeBlueprintConditionWrapper::TestCondition(FStateTreeExecutionConte
|
||||
#if WITH_EDITOR
|
||||
FText FStateTreeBlueprintConditionWrapper::GetDescription(const FGuid& ID, FStateTreeDataView InstanceDataView, const IStateTreeBindingLookup& BindingLookup, EStateTreeNodeFormatting Formatting) const
|
||||
{
|
||||
if (ConditionClass)
|
||||
FText Description;
|
||||
if (const UStateTreeConditionBlueprintBase* Instance = InstanceDataView.GetPtr<UStateTreeConditionBlueprintBase>())
|
||||
{
|
||||
return ConditionClass->GetDisplayNameText();
|
||||
Description = Instance->GetDescription(ID, InstanceDataView, BindingLookup, Formatting);
|
||||
}
|
||||
return FText::GetEmpty();
|
||||
if (Description.IsEmpty() && ConditionClass)
|
||||
{
|
||||
Description = ConditionClass->GetDisplayNameText();
|
||||
}
|
||||
return Description;
|
||||
}
|
||||
|
||||
FName FStateTreeBlueprintConditionWrapper::GetIconName() const
|
||||
{
|
||||
if (const UStateTreeNodeBlueprintBase* NodeCDO = GetDefault<const UStateTreeNodeBlueprintBase>(ConditionClass))
|
||||
{
|
||||
return NodeCDO->GetIconName();
|
||||
}
|
||||
return FStateTreeConditionBase::GetIconName();
|
||||
}
|
||||
|
||||
FColor FStateTreeBlueprintConditionWrapper::GetIconColor() const
|
||||
{
|
||||
if (const UStateTreeNodeBlueprintBase* NodeCDO = GetDefault<const UStateTreeNodeBlueprintBase>(ConditionClass))
|
||||
{
|
||||
return NodeCDO->GetIconColor();
|
||||
}
|
||||
return FStateTreeConditionBase::GetIconColor();
|
||||
}
|
||||
#endif
|
||||
@@ -77,10 +77,33 @@ void FStateTreeBlueprintEvaluatorWrapper::Tick(FStateTreeExecutionContext& Conte
|
||||
#if WITH_EDITOR
|
||||
FText FStateTreeBlueprintEvaluatorWrapper::GetDescription(const FGuid& ID, FStateTreeDataView InstanceDataView, const IStateTreeBindingLookup& BindingLookup, EStateTreeNodeFormatting Formatting) const
|
||||
{
|
||||
if (EvaluatorClass)
|
||||
FText Description;
|
||||
if (const UStateTreeEvaluatorBlueprintBase* Instance = InstanceDataView.GetPtr<UStateTreeEvaluatorBlueprintBase>())
|
||||
{
|
||||
return EvaluatorClass->GetDisplayNameText();
|
||||
Description = Instance->GetDescription(ID, InstanceDataView, BindingLookup, Formatting);
|
||||
}
|
||||
return FText::GetEmpty();
|
||||
if (Description.IsEmpty() && EvaluatorClass)
|
||||
{
|
||||
Description = EvaluatorClass->GetDisplayNameText();
|
||||
}
|
||||
return Description;
|
||||
}
|
||||
|
||||
FName FStateTreeBlueprintEvaluatorWrapper::GetIconName() const
|
||||
{
|
||||
if (const UStateTreeNodeBlueprintBase* NodeCDO = GetDefault<const UStateTreeNodeBlueprintBase>(EvaluatorClass))
|
||||
{
|
||||
return NodeCDO->GetIconName();
|
||||
}
|
||||
return FStateTreeEvaluatorBase::GetIconName();
|
||||
}
|
||||
|
||||
FColor FStateTreeBlueprintEvaluatorWrapper::GetIconColor() const
|
||||
{
|
||||
if (const UStateTreeNodeBlueprintBase* NodeCDO = GetDefault<const UStateTreeNodeBlueprintBase>(EvaluatorClass))
|
||||
{
|
||||
return NodeCDO->GetIconColor();
|
||||
}
|
||||
return FStateTreeEvaluatorBase::GetIconColor();
|
||||
}
|
||||
#endif
|
||||
@@ -9,6 +9,13 @@
|
||||
|
||||
#include UE_INLINE_GENERATED_CPP_BY_NAME(StateTreeNodeBlueprintBase)
|
||||
|
||||
#define LOCTEXT_NAMESPACE "StateTree"
|
||||
|
||||
#if WITH_EDITOR
|
||||
FGuid UStateTreeNodeBlueprintBase::CachedNodeID;
|
||||
const IStateTreeBindingLookup* UStateTreeNodeBlueprintBase::CachedBindingLookup = nullptr;
|
||||
#endif
|
||||
|
||||
UWorld* UStateTreeNodeBlueprintBase::GetWorld() const
|
||||
{
|
||||
// The items are duplicated as the State Tree execution context as outer, so this should be essentially the same as GetWorld() on StateTree context.
|
||||
@@ -149,3 +156,58 @@ DEFINE_FUNCTION(UStateTreeNodeBlueprintBase::execGetPropertyReference)
|
||||
Stack.MostRecentProperty = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
FText UStateTreeNodeBlueprintBase::GetDescription(const FGuid& ID, FStateTreeDataView InstanceDataView, const IStateTreeBindingLookup& BindingLookup, EStateTreeNodeFormatting Formatting) const
|
||||
{
|
||||
FText Result;
|
||||
|
||||
const FGuid OldCachedNodeID = CachedNodeID;
|
||||
const IStateTreeBindingLookup* OldCachedBindingLookup = CachedBindingLookup;
|
||||
|
||||
CachedNodeID = ID;
|
||||
CachedBindingLookup = &BindingLookup;
|
||||
|
||||
Result = Description;
|
||||
if (Result.IsEmpty())
|
||||
{
|
||||
Result = ReceiveGetDescription(Formatting);
|
||||
}
|
||||
if (Result.IsEmpty())
|
||||
{
|
||||
Result = GetClass()->GetDisplayNameText();
|
||||
}
|
||||
|
||||
CachedNodeID = OldCachedNodeID;
|
||||
CachedBindingLookup = OldCachedBindingLookup;
|
||||
|
||||
return Result;
|
||||
}
|
||||
#endif
|
||||
|
||||
FText UStateTreeNodeBlueprintBase::GetPropertyDescriptionByPropertyName(FName PropertyName) const
|
||||
{
|
||||
FText Result;
|
||||
#if WITH_EDITOR
|
||||
// Try property binding first
|
||||
if (CachedBindingLookup)
|
||||
{
|
||||
const FStateTreePropertyPath Path(CachedNodeID, PropertyName);
|
||||
Result = CachedBindingLookup->GetBindingSourceDisplayName(Path);
|
||||
}
|
||||
|
||||
// No binding, get the value.
|
||||
if (Result.IsEmpty())
|
||||
{
|
||||
if (const FProperty* Property = GetClass()->FindPropertyByName(PropertyName))
|
||||
{
|
||||
FString Value;
|
||||
Property->ExportText_InContainer(0, Value, this, this, nullptr, PPF_PropertyWindow | PPF_BlueprintDebugView);
|
||||
Result = FText::FromString(Value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Result;
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
@@ -149,10 +149,33 @@ EStateTreeRunStatus FStateTreeBlueprintTaskWrapper::Tick(FStateTreeExecutionCont
|
||||
#if WITH_EDITOR
|
||||
FText FStateTreeBlueprintTaskWrapper::GetDescription(const FGuid& ID, FStateTreeDataView InstanceDataView, const IStateTreeBindingLookup& BindingLookup, EStateTreeNodeFormatting Formatting) const
|
||||
{
|
||||
if (TaskClass)
|
||||
FText Description;
|
||||
if (const UStateTreeTaskBlueprintBase* Instance = InstanceDataView.GetPtr<UStateTreeTaskBlueprintBase>())
|
||||
{
|
||||
return TaskClass->GetDisplayNameText();
|
||||
Description = Instance->GetDescription(ID, InstanceDataView, BindingLookup, Formatting);
|
||||
}
|
||||
return FText::GetEmpty();
|
||||
if (Description.IsEmpty() && TaskClass)
|
||||
{
|
||||
Description = TaskClass->GetDisplayNameText();
|
||||
}
|
||||
return Description;
|
||||
}
|
||||
|
||||
FName FStateTreeBlueprintTaskWrapper::GetIconName() const
|
||||
{
|
||||
if (const UStateTreeNodeBlueprintBase* NodeCDO = GetDefault<const UStateTreeNodeBlueprintBase>(TaskClass))
|
||||
{
|
||||
return NodeCDO->GetIconName();
|
||||
}
|
||||
return FStateTreeTaskBase::GetIconName();
|
||||
}
|
||||
|
||||
FColor FStateTreeBlueprintTaskWrapper::GetIconColor() const
|
||||
{
|
||||
if (const UStateTreeNodeBlueprintBase* NodeCDO = GetDefault<const UStateTreeNodeBlueprintBase>(TaskClass))
|
||||
{
|
||||
return NodeCDO->GetIconColor();
|
||||
}
|
||||
return FStateTreeTaskBase::GetIconColor();
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user