Avoid Niagara graph nodes being gathered for game localization

#rb Shaun.Kime

[CL 9057370 by Jamie Dale in Dev-Editor branch]
This commit is contained in:
Jamie Dale
2019-09-24 17:33:34 -04:00
parent e5fb220915
commit ced417c5a9
5 changed files with 43 additions and 21 deletions

View File

@@ -7,6 +7,7 @@
#include "GraphEditAction.h"
#include "SNiagaraGraphNode.h"
#include "Misc/SecureHash.h"
#include "Serialization/PropertyLocalizationDataGathering.h"
#define LOCTEXT_NAMESPACE "NiagaraNode"
@@ -611,5 +612,12 @@ void UNiagaraNode::UpdateCompileHashForNode(FSHA1& HashState) const
HashState.Update((const uint8*)&ChangeId, sizeof(FGuid));
}
#if WITH_EDITORONLY_DATA
void UNiagaraNode::GatherForLocalization(FPropertyLocalizationDataGatherer& PropertyLocalizationDataGatherer, const EPropertyLocalizationGathererTextFlags GatherTextFlags) const
{
// Niagara nodes only contain editor-only text data
Super::GatherForLocalization(PropertyLocalizationDataGatherer, GatherTextFlags | EPropertyLocalizationGathererTextFlags::ForceEditorOnly);
}
#endif
#undef LOCTEXT_NAMESPACE

View File

@@ -267,13 +267,13 @@ FText UNiagaraNodeEmitter::GetNameFromEmitter()
{
if (EmitterHandle.GetId() == EmitterHandleId)
{
return FText::FromName(EmitterHandle.GetName());
return FText::AsCultureInvariant(EmitterHandle.GetName().ToString());
}
}
}
else if (CachedUniqueName.IsValid())
{
return FText::FromName(CachedUniqueName);
return FText::AsCultureInvariant(CachedUniqueName.ToString());
}
return FText();
}

View File

@@ -138,6 +138,10 @@ protected:
the input pins should have been visited already.*/
virtual void RouteParameterMapAroundMe(FNiagaraParameterMapHistoryBuilder& OutHistory, bool bRecursive) const;
#if WITH_EDITORONLY_DATA
virtual void GatherForLocalization(FPropertyLocalizationDataGatherer& PropertyLocalizationDataGatherer, const EPropertyLocalizationGathererTextFlags GatherTextFlags) const override;
#endif
/** The current change identifier for this node. Used to sync status with UNiagaraScripts.*/
UPROPERTY()
FGuid ChangeId;

View File

@@ -23,6 +23,9 @@ struct FSlateIcon;
struct FDiffResults;
struct FDiffSingleResult;
class FPropertyLocalizationDataGatherer;
enum class EPropertyLocalizationGathererTextFlags : uint8;
/**
* Struct used to define information for terminal types, e.g. types that can be contained
* by a container. Currently can represent strong/weak references to a type (only UObjects),
@@ -922,6 +925,12 @@ public:
void ForEachNodeDirectlyConnectedToOutputs(TFunctionRef<void(UEdGraphNode*)> Func);
protected:
#if WITH_EDITORONLY_DATA
/** Internal function used to gather pins from a graph node for localization */
friend void GatherGraphNodeForLocalization(const UObject* const Object, FPropertyLocalizationDataGatherer& PropertyLocalizationDataGatherer, const EPropertyLocalizationGathererTextFlags GatherTextFlags);
virtual void GatherForLocalization(FPropertyLocalizationDataGatherer& PropertyLocalizationDataGatherer, const EPropertyLocalizationGathererTextFlags GatherTextFlags) const;
#endif
/**
* Finds the difference in properties of node instance, for subobjects
*

View File

@@ -124,32 +124,33 @@ void UGraphNodeContextMenuContext::Init(const UEdGraph* InGraph, const UEdGraphN
// UEdGraphNode
#if WITH_EDITORONLY_DATA
namespace
void GatherGraphNodeForLocalization(const UObject* const Object, FPropertyLocalizationDataGatherer& PropertyLocalizationDataGatherer, const EPropertyLocalizationGathererTextFlags GatherTextFlags)
{
void GatherGraphNodeForLocalization(const UObject* const Object, FPropertyLocalizationDataGatherer& PropertyLocalizationDataGatherer, const EPropertyLocalizationGathererTextFlags GatherTextFlags)
{
const UEdGraphNode* const GraphNode = CastChecked<UEdGraphNode>(Object);
const UEdGraphNode* const GraphNode = CastChecked<UEdGraphNode>(Object);
GraphNode->GatherForLocalization(PropertyLocalizationDataGatherer, GatherTextFlags);
}
// We need to gather graph pins separately as they're no longer UObjects or UProperties
// plus they have custom logic for working out whether they're the default value
const FString PathToObject = GraphNode->GetPathName();
for (const UEdGraphPin* Pin : GraphNode->Pins)
void UEdGraphNode::GatherForLocalization(FPropertyLocalizationDataGatherer& PropertyLocalizationDataGatherer, const EPropertyLocalizationGathererTextFlags GatherTextFlags) const
{
// We need to gather graph pins separately as they're no longer UObjects or UProperties
// plus they have custom logic for working out whether they're the default value
const FString PathToObject = GetPathName();
for (const UEdGraphPin* Pin : Pins)
{
if (!Pin->DefaultTextValue.IsEmpty())
{
if (!Pin->DefaultTextValue.IsEmpty())
if (Pin->DoesDefaultValueMatchAutogenerated())
{
if (Pin->DoesDefaultValueMatchAutogenerated())
{
PropertyLocalizationDataGatherer.MarkDefaultTextInstance(Pin->DefaultTextValue);
}
else
{
PropertyLocalizationDataGatherer.GatherTextInstance(Pin->DefaultTextValue, FString::Printf(TEXT("%s.%s"), *PathToObject, *Pin->GetName()), /*bIsEditorOnly*/true);
}
PropertyLocalizationDataGatherer.MarkDefaultTextInstance(Pin->DefaultTextValue);
}
else
{
PropertyLocalizationDataGatherer.GatherTextInstance(Pin->DefaultTextValue, FString::Printf(TEXT("%s.%s"), *PathToObject, *Pin->GetName()), /*bIsEditorOnly*/true);
}
}
PropertyLocalizationDataGatherer.GatherLocalizationDataFromObject(GraphNode, GatherTextFlags);
}
PropertyLocalizationDataGatherer.GatherLocalizationDataFromObject(this, GatherTextFlags);
}
#endif