GraphNode_Rename is good
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
#include "WingFetcher.h"
|
#include "WingFetcher.h"
|
||||||
#include "WingUtils.h"
|
#include "WingUtils.h"
|
||||||
#include "EdGraph/EdGraphNode.h"
|
#include "EdGraph/EdGraphNode.h"
|
||||||
#include "Kismet2/Kismet2NameValidators.h"
|
|
||||||
#include "GraphNode_Rename.generated.h"
|
#include "GraphNode_Rename.generated.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -38,22 +37,7 @@ public:
|
|||||||
UEdGraphNode* FoundNode = F.Walk(Node).Cast<UEdGraphNode>();
|
UEdGraphNode* FoundNode = F.Walk(Node).Cast<UEdGraphNode>();
|
||||||
if (!FoundNode) return;
|
if (!FoundNode) return;
|
||||||
|
|
||||||
if (!FoundNode->bCanRenameNode)
|
if (!WingUtils::CheckCanRename(FoundNode, Name)) return;
|
||||||
{
|
|
||||||
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();
|
|
||||||
FoundNode->OnRenameNode(Name);
|
FoundNode->OnRenameNode(Name);
|
||||||
|
|
||||||
UWingServer::Printf(TEXT("Renamed node to %s\n"), *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'"))
|
UPROPERTY(meta=(Description="Args e.g. 'int x,float y'"))
|
||||||
FString Args;
|
FString Args;
|
||||||
|
|
||||||
|
UPROPERTY(meta=(Optional, Description="Also rename the node (e.g. custom event name)"))
|
||||||
|
FString Rename;
|
||||||
|
|
||||||
virtual FString GetDescription() const override
|
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.");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Rename.IsEmpty())
|
||||||
|
{
|
||||||
|
if (!WingUtils::CheckCanRename(NodeObj, Rename)) return;
|
||||||
|
NodeObj->OnRenameNode(Rename);
|
||||||
|
}
|
||||||
|
|
||||||
if (!WingFunctionArgs::SetArgs(NodeObj, Args)) return;
|
if (!WingFunctionArgs::SetArgs(NodeObj, Args)) return;
|
||||||
|
|
||||||
UWingServer::Printf(TEXT("Args set to: %s\n"), *WingFunctionArgs::GetArgs(NodeObj));
|
UWingServer::Printf(TEXT("Args set to: %s\n"), *WingFunctionArgs::GetArgs(NodeObj));
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "K2Node_EditablePinBase.h"
|
#include "K2Node_EditablePinBase.h"
|
||||||
#include "EdGraph/EdGraphSchema.h"
|
#include "EdGraph/EdGraphSchema.h"
|
||||||
#include "Kismet2/BlueprintEditorUtils.h"
|
#include "Kismet2/BlueprintEditorUtils.h"
|
||||||
|
#include "Kismet2/Kismet2NameValidators.h"
|
||||||
#include "Kismet2/KismetEditorUtilities.h"
|
#include "Kismet2/KismetEditorUtilities.h"
|
||||||
#include "UObject/UObjectIterator.h"
|
#include "UObject/UObjectIterator.h"
|
||||||
#include "UObject/UnrealType.h"
|
#include "UObject/UnrealType.h"
|
||||||
@@ -379,6 +380,23 @@ bool WingUtils::CheckExactlyNoneNamed(int Count, const TCHAR *Kind, const FStrin
|
|||||||
return true;
|
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
|
// Blueprint helpers
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|||||||
@@ -258,6 +258,7 @@ public:
|
|||||||
// ----- Common Error Reporting -----
|
// ----- Common Error Reporting -----
|
||||||
static bool CheckExactlyOneNamed(int Count, const TCHAR *Kind, const FString &Name);
|
static bool CheckExactlyOneNamed(int Count, const TCHAR *Kind, const FString &Name);
|
||||||
static bool CheckExactlyNoneNamed(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:
|
private:
|
||||||
static FString UnsanitizeName(const FString &Input);
|
static FString UnsanitizeName(const FString &Input);
|
||||||
|
|||||||
Reference in New Issue
Block a user