Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeModule/Private/Tasks/StateTreeDebugTextTask.cpp
mikko mononen ef148ecd80 StateTree: StateTree UI spring clean.
- Added icons and icon colors for ST nodes
- Implemented icons for some common ST nodes
- Small update to ST logic icons
- Added icons to the task list in State treeview row, adjusted task list BG color to make icons visible
- Fixed ST editor tabs icons and names (e.g. there were two tabs that had the same label)
- Moved ST node picker to separate class
- Moved category array customization to common helper function
- Added node icons to the ST node picker
- Add node button is not node selector too (simila to Niagara)
- Consolidated the add button style across all lists
- Cleaned up the node customization
  - Moved type selector, debug, and property controls into one menu at right
  - The combined menu can be also summoned using right click
  - Renaming now has to be triggered via the menu
  - Replacing node happens via menu
  - Most of the row was left "clickable" to later use it for selection
  - Improved the visualization and controls for the expression indentation
- Cleaned up state customization
  - Moved parameters to own category (similar to the tree params)
  - Moved event to the enter conditions category
- Cleaned up transition customization
  - Improved the transition display
  - Consolidated add button styles

#jira UE-180608
#rb Juan.Portillo, Mieszko.Zielinski

[CL 33030431 by mikko mononen in ue5-main branch]
2024-04-17 03:01:36 -04:00

77 lines
2.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "StateTreeDebugTextTask.h"
#include "StateTreeExecutionContext.h"
#include "GameFramework/Actor.h"
#include "DrawDebugHelpers.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(StateTreeDebugTextTask)
#define LOCTEXT_NAMESPACE "StateTree"
EStateTreeRunStatus FStateTreeDebugTextTask::EnterState(FStateTreeExecutionContext& Context, const FStateTreeTransitionResult& Transition) const
{
if (!bEnabled)
{
return EStateTreeRunStatus::Succeeded;
}
const FInstanceDataType& InstanceData = Context.GetInstanceData(*this);
const UWorld* World = Context.GetWorld();
if (World == nullptr && InstanceData.ReferenceActor != nullptr)
{
World = InstanceData.ReferenceActor->GetWorld();
}
// Reference actor is not required (offset will be used as a global world location)
// but a valid world is required.
if (World == nullptr)
{
return EStateTreeRunStatus::Failed;
}
DrawDebugString(World, Offset, Text, InstanceData.ReferenceActor, TextColor, /*Duration*/-1, /*DrawShadows*/true, FontScale);
return EStateTreeRunStatus::Running;
}
void FStateTreeDebugTextTask::ExitState(FStateTreeExecutionContext& Context, const FStateTreeTransitionResult& Transition) const
{
if (!bEnabled)
{
return;
}
const FInstanceDataType& InstanceData = Context.GetInstanceData(*this);
const UWorld* World = Context.GetWorld();
if (World == nullptr && InstanceData.ReferenceActor != nullptr)
{
World = InstanceData.ReferenceActor->GetWorld();
}
// Reference actor is not required (offset was used as a global world location)
// but a valid world is required.
if (World == nullptr)
{
return;
}
// Drawing an empty text will remove the HUD DebugText entries associated to the target actor
DrawDebugString(World, Offset, "", InstanceData.ReferenceActor);
}
#if WITH_EDITOR
FText FStateTreeDebugTextTask::GetDescription(const FGuid& ID, FStateTreeDataView InstanceDataView, const IStateTreeBindingLookup& BindingLookup, EStateTreeNodeFormatting Formatting) const
{
const FText Format = (Formatting == EStateTreeNodeFormatting::RichText)
? LOCTEXT("DebugTextRich", "<b>Debug Text</> \"{Text}\"")
: LOCTEXT("DebugText", "Debug Text \"{Text}\"");
return FText::FormatNamed(Format,
TEXT("Text"), FText::FromString(Text));
}
#endif
#undef LOCTEXT_NAMESPACE