Files
UnrealEngineUWP/Engine/Plugins/Experimental/CommonConversation/Source/CommonConversationGraph/Private/ConversationGraphNode_Knot.cpp
Marc Audy 8f73cd7fa9 Merge UE5/Release-Engine-Staging @ 15630841 to UE5/Main
This represents UE4/Main @ 15601601

[CL 15631170 by Marc Audy in ue5-main branch]
2021-03-05 19:27:14 -04:00

99 lines
2.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "ConversationGraphNode_Knot.h"
#include "Kismet2/Kismet2NameValidators.h"
#include "EdGraph/EdGraphPin.h"
#include "SGraphNodeKnot.h"
#define LOCTEXT_NAMESPACE "ConversationGraph"
static const char* PC_Wildcard = "wildcard";
/////////////////////////////////////////////////////
// UConversationGraphNode_Knot
UConversationGraphNode_Knot::UConversationGraphNode_Knot(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
bCanRenameNode = true;
}
void UConversationGraphNode_Knot::AllocateDefaultPins()
{
const FName InputPinName(TEXT("InputPin"));
const FName OutputPinName(TEXT("OutputPin"));
UEdGraphPin* MyInputPin = CreatePin(EGPD_Input, PC_Wildcard, InputPinName);
MyInputPin->bDefaultValueIsIgnored = true;
UEdGraphPin* MyOutputPin = CreatePin(EGPD_Output, PC_Wildcard, OutputPinName);
}
FText UConversationGraphNode_Knot::GetTooltipText() const
{
//@TODO: Should pull the tooltip from the source pin
return LOCTEXT("KnotTooltip", "Reroute Node (reroutes wires)");
}
FText UConversationGraphNode_Knot::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
if (TitleType == ENodeTitleType::EditableTitle)
{
return FText::FromString(NodeComment);
}
else if (TitleType == ENodeTitleType::MenuTitle)
{
return LOCTEXT("KnotListTitle", "Add Reroute Node...");
}
else
{
return LOCTEXT("KnotTitle", "Reroute Node");
}
}
bool UConversationGraphNode_Knot::ShouldOverridePinNames() const
{
return true;
}
FText UConversationGraphNode_Knot::GetPinNameOverride(const UEdGraphPin& Pin) const
{
// Keep the pin size tiny
return FText::GetEmpty();
}
void UConversationGraphNode_Knot::OnRenameNode(const FString& NewName)
{
NodeComment = NewName;
}
bool UConversationGraphNode_Knot::CanSplitPin(const UEdGraphPin* Pin) const
{
return false;
}
TSharedPtr<class INameValidatorInterface> UConversationGraphNode_Knot::MakeNameValidator() const
{
// Comments can be duplicated, etc...
return MakeShareable(new FDummyNameValidator(EValidatorResult::Ok));
}
UEdGraphPin* UConversationGraphNode_Knot::GetPassThroughPin(const UEdGraphPin* FromPin) const
{
if(FromPin && Pins.Contains(FromPin))
{
return FromPin == Pins[0] ? Pins[1] : Pins[0];
}
return nullptr;
}
TSharedPtr<SGraphNode> UConversationGraphNode_Knot::CreateVisualWidget()
{
return SNew(SGraphNodeKnot, this);
}
/////////////////////////////////////////////////////
#undef LOCTEXT_NAMESPACE