Files
UnrealEngineUWP/Engine/Source/Editor/BlueprintGraph/Classes/K2Node_MathExpression.h
Mike Beach 1dfbb2d829 Optimizing BP node titles (caching any that use FText::Format(), which is slow).
[CL 2282225 by Mike Beach in Main branch]
2014-09-02 19:08:09 -04:00

71 lines
2.4 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "K2Node_Composite.h"
#include "EdGraph/EdGraphNodeUtils.h" // for FNodeTextCache
#include "K2Node_MathExpression.generated.h"
/**
* This node type acts like a collapsed node, a single node that represents
* a larger sub-network of nodes (contained within a sub-graph). This node will
* take the math expression it was named with, and attempt to convert it into a
* series of math nodes. If it is unsuccessful, then it generates a series of
* actionable errors.
*/
UCLASS()
class BLUEPRINTGRAPH_API UK2Node_MathExpression : public UK2Node_Composite
{
GENERATED_UCLASS_BODY()
public:
// The math expression to evaluate
UPROPERTY(EditAnywhere, Category = Expression)
FString Expression;
public:
// UObject interface
virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
// End of UObject interface
// UEdGraphNode interface
virtual TSharedPtr<class INameValidatorInterface> MakeNameValidator() const override;
virtual void OnRenameNode(const FString& NewName) override;
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
virtual void PostPlacedNewNode() override;
virtual void ReconstructNode() override;
// End of UEdGraphNode interface
// UK2Node interface
virtual void GetMenuEntries(FGraphContextMenuBuilder& ContextMenuBuilder) const override;
virtual void ValidateNodeDuringCompilation(class FCompilerResultsLog& MessageLog) const override;
virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override;
// End of UK2Node interface
private:
/**
* Clears this node's sub-graph, and then takes the supplied string and
* parses, and converts it into a series of new graph nodes.
*
* @param NewExpression The new string we wish to replace the current "Expression".
*/
void RebuildExpression(FString NewExpression);
/**
* Clears the cached expression string, deletes all generated node, clears
* input pins, and resets the parser and graph generator (priming this node
* for a new expression).
*/
void ClearExpression();
private:
/** Cached so we don't have to regenerate it when the graph is recompiled */
TSharedPtr<class FCompilerResultsLog> CachedMessageLog;
/** Constructing FText strings can be costly, so we cache the node's title */
FNodeTextCache CachedNodeTitle;
};