FBlueprintNodeSignature UK2Node_MacroInstance::GetSignature() const { FBlueprintNodeSignature NodeSignature = Super::GetSignature(); NodeSignature.AddSubObject(GetMacroGraph()); return NodeSignature; }
FText UK2Node_MacroInstance::GetKeywords() const { FText Keywords = GetAssociatedGraphMetadata(GetMacroGraph())->Keywords; // If the Macro has Compact Node Title data, append the compact node title as a Keyword so it can be searched. if (ShouldDrawCompact()) { Keywords = FText::Format(FText::FromString(TEXT("{0} {1}")), Keywords, GetCompactNodeTitle()); } return Keywords; }
void UK2Node_MacroInstance::GetNodeAttributes( TArray<TKeyValuePair<FString, FString>>& OutNodeAttributes ) const { FString MacroName( TEXT( "InvalidMacro" )); if( UEdGraph* MacroGraph = GetMacroGraph() ) { MacroName = MacroGraph->GetName(); } OutNodeAttributes.Add( TKeyValuePair<FString, FString>( TEXT( "Type" ), TEXT( "Macro" ) )); OutNodeAttributes.Add( TKeyValuePair<FString, FString>( TEXT( "Class" ), GetClass()->GetName() )); OutNodeAttributes.Add( TKeyValuePair<FString, FString>( TEXT( "Name" ), MacroName )); }
FText UK2Node_MacroInstance::GetMenuCategory() const { FText MenuCategory = FEditorCategoryUtils::GetCommonCategory(FCommonEditorCategory::Utilities); if (UEdGraph* MacroGraph = GetMacroGraph()) { FKismetUserDeclaredFunctionMetadata* MacroGraphMetadata = UK2Node_MacroInstance::GetAssociatedGraphMetadata(MacroGraph); if ((MacroGraphMetadata != nullptr) && !MacroGraphMetadata->Category.IsEmpty()) { MenuCategory = FText::FromString(MacroGraphMetadata->Category); } } return MenuCategory; }
bool UK2Node_MacroInstance::CanPasteHere(const UEdGraph* TargetGraph) const { bool bCanPaste = false; UBlueprint* MacroBlueprint = GetSourceBlueprint(); UBlueprint* TargetBlueprint = FBlueprintEditorUtils::FindBlueprintForGraph(TargetGraph); if ((MacroBlueprint != nullptr) && (TargetBlueprint != nullptr)) { // Only allow "local" macro instances or instances from a macro library blueprint with the same parent class check(MacroBlueprint->ParentClass != nullptr && TargetBlueprint->ParentClass != nullptr); bCanPaste = (MacroBlueprint == TargetBlueprint) || (MacroBlueprint->BlueprintType == BPTYPE_MacroLibrary && TargetBlueprint->ParentClass->IsChildOf(MacroBlueprint->ParentClass)); } // Macro Instances are not allowed in it's own graph UEdGraph* MacroGraph = GetMacroGraph(); bCanPaste &= (MacroGraph != TargetGraph); // nor in Function graphs if the macro has latent functions in it bool const bIsTargetFuncGraph = (TargetGraph->GetSchema()->GetGraphType(TargetGraph) == GT_Function); bCanPaste &= (!bIsTargetFuncGraph || !FBlueprintEditorUtils::CheckIfGraphHasLatentFunctions(MacroGraph)); return bCanPaste && Super::CanPasteHere(TargetGraph); }
FText UK2Node_MacroInstance::GetCompactNodeTitle() const { FText ResultText; if (FKismetUserDeclaredFunctionMetadata* MacroGraphMetadata = GetAssociatedGraphMetadata(GetMacroGraph())) { ResultText = MacroGraphMetadata->CompactNodeTitle; } return ResultText; }