GraphNode_Rename is good
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include "WingFetcher.h"
|
||||
#include "WingUtils.h"
|
||||
#include "EdGraph/EdGraphNode.h"
|
||||
#include "Kismet2/Kismet2NameValidators.h"
|
||||
#include "GraphNode_Rename.generated.h"
|
||||
|
||||
|
||||
@@ -38,22 +37,7 @@ public:
|
||||
UEdGraphNode* FoundNode = F.Walk(Node).Cast<UEdGraphNode>();
|
||||
if (!FoundNode) return;
|
||||
|
||||
if (!FoundNode->bCanRenameNode)
|
||||
{
|
||||
UWingServer::Printf(TEXT("ERROR: Node %s does not support renaming.\n"), *WingUtils::FormatName(FoundNode));
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate the proposed name
|
||||
TSharedPtr<INameValidatorInterface> Validator = FNameValidatorFactory::MakeValidator(FoundNode);
|
||||
EValidatorResult Result = Validator->IsValid(Name, false);
|
||||
if (Result != EValidatorResult::Ok && Result != EValidatorResult::ExistingName)
|
||||
{
|
||||
UWingServer::Printf(TEXT("ERROR: %s\n"), *INameValidatorInterface::GetErrorString(Name, Result));
|
||||
return;
|
||||
}
|
||||
|
||||
FoundNode->Modify();
|
||||
if (!WingUtils::CheckCanRename(FoundNode, Name)) return;
|
||||
FoundNode->OnRenameNode(Name);
|
||||
|
||||
UWingServer::Printf(TEXT("Renamed node to %s\n"), *Name);
|
||||
|
||||
@@ -20,6 +20,9 @@ public:
|
||||
UPROPERTY(meta=(Description="Args e.g. 'int x,float y'"))
|
||||
FString Args;
|
||||
|
||||
UPROPERTY(meta=(Optional, Description="Also rename the node (e.g. custom event name)"))
|
||||
FString Rename;
|
||||
|
||||
virtual FString GetDescription() const override
|
||||
{
|
||||
return TEXT("Set the user-defined pins (arguments or return values) on a function entry, result, custom event, or tunnel node.");
|
||||
@@ -37,6 +40,12 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Rename.IsEmpty())
|
||||
{
|
||||
if (!WingUtils::CheckCanRename(NodeObj, Rename)) return;
|
||||
NodeObj->OnRenameNode(Rename);
|
||||
}
|
||||
|
||||
if (!WingFunctionArgs::SetArgs(NodeObj, Args)) return;
|
||||
|
||||
UWingServer::Printf(TEXT("Args set to: %s\n"), *WingFunctionArgs::GetArgs(NodeObj));
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "K2Node_EditablePinBase.h"
|
||||
#include "EdGraph/EdGraphSchema.h"
|
||||
#include "Kismet2/BlueprintEditorUtils.h"
|
||||
#include "Kismet2/Kismet2NameValidators.h"
|
||||
#include "Kismet2/KismetEditorUtilities.h"
|
||||
#include "UObject/UObjectIterator.h"
|
||||
#include "UObject/UnrealType.h"
|
||||
@@ -379,6 +380,23 @@ bool WingUtils::CheckExactlyNoneNamed(int Count, const TCHAR *Kind, const FStrin
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WingUtils::CheckCanRename(UEdGraphNode* Node, const FString &Name)
|
||||
{
|
||||
if (!Node->bCanRenameNode)
|
||||
{
|
||||
UWingServer::Printf(TEXT("ERROR: Node %s does not support renaming.\n"), *FormatName(Node));
|
||||
return false;
|
||||
}
|
||||
TSharedPtr<INameValidatorInterface> Validator = FNameValidatorFactory::MakeValidator(Node);
|
||||
EValidatorResult Result = Validator->IsValid(Name, false);
|
||||
if (Result != EValidatorResult::Ok && Result != EValidatorResult::ExistingName)
|
||||
{
|
||||
UWingServer::Printf(TEXT("ERROR: %s\n"), *INameValidatorInterface::GetErrorString(Name, Result));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Blueprint helpers
|
||||
// ============================================================
|
||||
|
||||
@@ -258,6 +258,7 @@ public:
|
||||
// ----- Common Error Reporting -----
|
||||
static bool CheckExactlyOneNamed(int Count, const TCHAR *Kind, const FString &Name);
|
||||
static bool CheckExactlyNoneNamed(int Count, const TCHAR *Kind, const FString &Name);
|
||||
static bool CheckCanRename(UEdGraphNode* Node, const FString &Name);
|
||||
|
||||
private:
|
||||
static FString UnsanitizeName(const FString &Input);
|
||||
|
||||
Reference in New Issue
Block a user