Files
UnrealEngineUWP/Engine/Source/Editor/BlueprintGraph/Private/K2Node_TemporaryVariable.cpp
Michael Schoell 0a41fb741e #summary Can search for nodes in the palette menu in Blueprints with both the native name and the localized name.
#add Added UEdGraphNode::GetNodeNativeTitle to return a native title for a node.
#add Added UEdGraphNode::GetNodeSearchTitle to return the native and localized title for a node, together, for searching.
#add Can hold "alt" over a node (in the graph panel, or the palette) to see the native name of the node.

#ttp 331252 - Blueprints: Editor: L10N: Blueprints need to consistently show localized node names and when searching need to search both the localized name and the native name

#codereview justin.sargent

[CL 2044506 by Michael Schoell in Main branch]
2014-04-23 18:30:37 -04:00

108 lines
3.2 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "BlueprintGraphPrivatePCH.h"
#include "KismetCompiler.h"
class FKCHandler_TemporaryVariable : public FNodeHandlingFunctor
{
public:
FKCHandler_TemporaryVariable(FKismetCompilerContext& InCompilerContext)
: FNodeHandlingFunctor(InCompilerContext)
{
}
virtual void RegisterNet(FKismetFunctionContext& Context, UEdGraphPin* Net) OVERRIDE
{
// This net is an anonymous temporary variable
FBPTerminal* Term = new (Context.IsEventGraph() ? Context.EventGraphLocals : Context.Locals) FBPTerminal();
FString NetName = Context.NetNameMap->MakeValidName(Net);
Term->CopyFromPin(Net, NetName);
UK2Node_TemporaryVariable* TempVarNode = CastChecked<UK2Node_TemporaryVariable>(Net->GetOwningNode());
Term->bIsSavePersistent = TempVarNode->bIsPersistent;
Context.NetMap.Add(Net, Term);
}
};
UK2Node_TemporaryVariable::UK2Node_TemporaryVariable(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
, bIsPersistent(false)
{
}
void UK2Node_TemporaryVariable::AllocateDefaultPins()
{
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
UEdGraphPin* VariablePin = CreatePin(EGPD_Output, TEXT(""), TEXT(""), NULL, false, false, TEXT("Variable"));
VariablePin->PinType = VariableType;
Super::AllocateDefaultPins();
}
FString UK2Node_TemporaryVariable::GetTooltip() const
{
FFormatNamedArguments Args;
Args.Add(TEXT("VariableType"), UEdGraphSchema_K2::TypeToText(VariableType));
return FText::Format(NSLOCTEXT("K2Node", "LocalTemporaryVariable", "Local temporary {VariableType} variable"), Args).ToString();
}
FText UK2Node_TemporaryVariable::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
FText Result = !bIsPersistent ? NSLOCTEXT("K2Node", "LocalVariable", "Local {VariableType}") : NSLOCTEXT("K2Node", "PersistentLocalVariable", "Persistent Local {VariableType}");
FFormatNamedArguments Args;
Args.Add(TEXT("VariableType"), UEdGraphSchema_K2::TypeToText(VariableType));
Result = FText::Format(Result, Args);
return Result;
}
FString UK2Node_TemporaryVariable::GetNodeNativeTitle(ENodeTitleType::Type TitleType) const
{
// Do not setup this function for localization, intentionally left unlocalized!
FString Result = !bIsPersistent ? TEXT("Local ") : TEXT("Persistent Local ");
Result += UEdGraphSchema_K2::TypeToString(VariableType);
return Result;
}
bool UK2Node_TemporaryVariable::IsNodePure() const
{
return true;
}
FString UK2Node_TemporaryVariable::GetDescriptiveCompiledName() const
{
FString Result = NSLOCTEXT("K2Node", "TempPinCategory", "Temp_").ToString() + VariableType.PinCategory;
if (!NodeComment.IsEmpty())
{
Result += TEXT("_");
Result += NodeComment;
}
// If this node is persistent, we need to add the NodeGuid, which should be propagated from the macro that created this, in order to ensure persistence
if (bIsPersistent)
{
Result += TEXT("_");
Result += NodeGuid.ToString();
}
return Result;
}
// get variable pin
UEdGraphPin* UK2Node_TemporaryVariable::GetVariablePin()
{
return FindPin(TEXT("Variable"));
}
FNodeHandlingFunctor* UK2Node_TemporaryVariable::CreateNodeHandler(FKismetCompilerContext& CompilerContext) const
{
return new FKCHandler_TemporaryVariable(CompilerContext);
}