Refactor Format Message, step 1
This commit is contained in:
@@ -43,20 +43,6 @@
|
|||||||
|
|
||||||
// All argument pins will have Names that start with "A:"
|
// All argument pins will have Names that start with "A:"
|
||||||
|
|
||||||
static bool IsArgumentPin(const UEdGraphPin *Pin) {
|
|
||||||
TCHAR pname[FName::StringBufferSize];
|
|
||||||
Pin->PinName.ToString(pname);
|
|
||||||
return pname[0] == 'A' && pname[1] == ':';
|
|
||||||
}
|
|
||||||
|
|
||||||
static FName ArgumentNameAddPrefix(const FString &name) {
|
|
||||||
FString Prefixed = FString("A:") + name;
|
|
||||||
return FName(*Prefixed);
|
|
||||||
}
|
|
||||||
|
|
||||||
static FString ArgumentNameRemovePrefix(const FName &name) {
|
|
||||||
return name.ToString().Mid(2, FName::StringBufferSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const FName VerbosityPinName(TEXT("Verbosity"));
|
static const FName VerbosityPinName(TEXT("Verbosity"));
|
||||||
static bool IsVerbosityPin(const UEdGraphPin *Pin) {
|
static bool IsVerbosityPin(const UEdGraphPin *Pin) {
|
||||||
@@ -121,9 +107,9 @@ void UK2Node_FormatMessage::CreateCorrectPins()
|
|||||||
for (auto It = Pins.CreateIterator(); It; ++It)
|
for (auto It = Pins.CreateIterator(); It; ++It)
|
||||||
{
|
{
|
||||||
UEdGraphPin* CheckPin = *It;
|
UEdGraphPin* CheckPin = *It;
|
||||||
if (IsArgumentPin(CheckPin))
|
if (HasPrefix(CheckPin->PinName, 'A'))
|
||||||
{
|
{
|
||||||
OldPins.Add(ArgumentNameRemovePrefix(CheckPin->PinName), CheckPin);
|
OldPins.Add(RemovePrefix(CheckPin->PinName).ToString(), CheckPin);
|
||||||
It.RemoveCurrent();
|
It.RemoveCurrent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,7 +123,7 @@ void UK2Node_FormatMessage::CreateCorrectPins()
|
|||||||
Pins.Emplace(*OldPin);
|
Pins.Emplace(*OldPin);
|
||||||
OldPins.Remove(Name);
|
OldPins.Remove(Name);
|
||||||
} else {
|
} else {
|
||||||
FName PrefixedName = ArgumentNameAddPrefix(Name);
|
FName PrefixedName = AddPrefix(Name, 'A');
|
||||||
CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Wildcard, PrefixedName);
|
CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Wildcard, PrefixedName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +141,7 @@ void UK2Node_FormatMessage::CreateCorrectPins()
|
|||||||
|
|
||||||
void UK2Node_FormatMessage::SynchronizeArgumentPinType(UEdGraphPin* Pin)
|
void UK2Node_FormatMessage::SynchronizeArgumentPinType(UEdGraphPin* Pin)
|
||||||
{
|
{
|
||||||
if (IsArgumentPin(Pin))
|
if (HasPrefix(Pin->PinName, 'A'))
|
||||||
{
|
{
|
||||||
const UEdGraphSchema_K2* K2Schema = Cast<const UEdGraphSchema_K2>(GetSchema());
|
const UEdGraphSchema_K2* K2Schema = Cast<const UEdGraphSchema_K2>(GetSchema());
|
||||||
|
|
||||||
@@ -227,8 +213,8 @@ FText UK2Node_FormatMessage::GetPinDisplayName(const UEdGraphPin* Pin) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For argument pins, we must strip off the Argument Pin Prefix.
|
// For argument pins, we must strip off the Argument Pin Prefix.
|
||||||
if (IsArgumentPin(Pin)) {
|
if (HasPrefix(Pin->PinName, 'A')) {
|
||||||
return FText::FromString(ArgumentNameRemovePrefix(Pin->PinName));
|
return FText::FromName(RemovePrefix(Pin->PinName));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, just return the Pin Name the normal way.
|
// Otherwise, just return the Pin Name the normal way.
|
||||||
@@ -385,7 +371,7 @@ void UK2Node_FormatMessage::ExpandNode(class FKismetCompilerContext& CompilerCon
|
|||||||
for(int32 ArgIdx = 0; ArgIdx < PinNames.Num(); ++ArgIdx)
|
for(int32 ArgIdx = 0; ArgIdx < PinNames.Num(); ++ArgIdx)
|
||||||
{
|
{
|
||||||
FString OriginalName = PinNames[ArgIdx];
|
FString OriginalName = PinNames[ArgIdx];
|
||||||
UEdGraphPin* ArgumentPin = FindPin(ArgumentNameAddPrefix(OriginalName), EGPD_Input);
|
UEdGraphPin* ArgumentPin = FindPin(AddPrefix(OriginalName, 'A'), EGPD_Input);
|
||||||
|
|
||||||
|
|
||||||
// Find a function that can convert the input into an FFormatArgumentData.
|
// Find a function that can convert the input into an FFormatArgumentData.
|
||||||
@@ -508,7 +494,7 @@ bool UK2Node_FormatMessage::IsConnectionDisallowed(const UEdGraphPin* MyPin, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Argument input pins may only be connected to Byte, Integer, Float, Text, and ETextGender pins...
|
// Argument input pins may only be connected to Byte, Integer, Float, Text, and ETextGender pins...
|
||||||
if (IsArgumentPin(MyPin))
|
if (HasPrefix(MyPin->PinName, 'A'))
|
||||||
{
|
{
|
||||||
const UEdGraphSchema_K2* K2Schema = Cast<const UEdGraphSchema_K2>(GetSchema());
|
const UEdGraphSchema_K2* K2Schema = Cast<const UEdGraphSchema_K2>(GetSchema());
|
||||||
const FName& OtherPinCategory = OtherPin->PinType.PinCategory;
|
const FName& OtherPinCategory = OtherPin->PinType.PinCategory;
|
||||||
|
|||||||
@@ -15,16 +15,7 @@
|
|||||||
|
|
||||||
#include "BreakToDebugger.h"
|
#include "BreakToDebugger.h"
|
||||||
#include "FormatDataLibrary.h"
|
#include "FormatDataLibrary.h"
|
||||||
#include "Containers/Array.h"
|
#include "LuprexK2Node.h"
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "EdGraph/EdGraphNode.h"
|
|
||||||
#include "EdGraph/EdGraphPin.h"
|
|
||||||
#include "HAL/Platform.h"
|
|
||||||
#include "Internationalization/Text.h"
|
|
||||||
#include "K2Node.h"
|
|
||||||
#include "UObject/NameTypes.h"
|
|
||||||
#include "UObject/ObjectMacros.h"
|
|
||||||
#include "UObject/UObjectGlobals.h"
|
|
||||||
|
|
||||||
#include "FormatMessage.generated.h"
|
#include "FormatMessage.generated.h"
|
||||||
|
|
||||||
@@ -86,7 +77,7 @@ class UObject;
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
UCLASS(MinimalAPI)
|
UCLASS(MinimalAPI)
|
||||||
class UK2Node_FormatMessage : public UK2Node
|
class UK2Node_FormatMessage : public UlxK2Node
|
||||||
{
|
{
|
||||||
GENERATED_UCLASS_BODY()
|
GENERATED_UCLASS_BODY()
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ FName UlxK2Node::AddPrefix(const FString &Name, char Prefix)
|
|||||||
return FName(*Prefixed);
|
return FName(*Prefixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UlxK2Node::HasPrefix(FName Name, char Prefix)
|
||||||
|
{
|
||||||
|
TCHAR pname[FName::StringBufferSize];
|
||||||
|
Name.ToString(pname);
|
||||||
|
return (pname[0] == Prefix) && (pname[1] == ':');
|
||||||
|
}
|
||||||
|
|
||||||
FName UlxK2Node::RemovePrefix(FName Name)
|
FName UlxK2Node::RemovePrefix(FName Name)
|
||||||
{
|
{
|
||||||
TCHAR pname[FName::StringBufferSize];
|
TCHAR pname[FName::StringBufferSize];
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ protected:
|
|||||||
/** Add a single-char prefix to a pin name, e.g. AddPrefix("foo", 'A') -> "A:foo" */
|
/** Add a single-char prefix to a pin name, e.g. AddPrefix("foo", 'A') -> "A:foo" */
|
||||||
static FName AddPrefix(const FString &Name, char Prefix);
|
static FName AddPrefix(const FString &Name, char Prefix);
|
||||||
|
|
||||||
|
/** Check if a pin name has a given single-char prefix. */
|
||||||
|
static bool HasPrefix(FName Name, char Prefix);
|
||||||
|
|
||||||
/** Strip a single-char prefix from a pin name, returning the original name if no prefix is found. */
|
/** Strip a single-char prefix from a pin name, returning the original name if no prefix is found. */
|
||||||
static FName RemovePrefix(FName Name);
|
static FName RemovePrefix(FName Name);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user