Files
UnrealEngineUWP/Engine/Source/Editor/BlueprintGraph/Classes/K2Node_StructOperation.h
Phillip Kavan f64e3e18d7 Some minor refactoring to assist with auto-importing external type object dependency namespaces into the Blueprint editor context in response to user actions.
Change summary:
- Moved base definition of UK2Node::HasExternalDependencies() up one level to UEdGraphNode (to avoid blind casts in a context where we may not necessarily have a UK2Node subtype).
- Updated subtype headers that override HasExternalDependencies() to relocate the declaration into the class declaration's 'UEdGraphNode overrides' section (for clarity).
- Reverted previous UBlueprintNodeSpawner::ImportTarget solution in favor of using node dependencies; this allows auto-import actions to scale more easily to all existing node subtypes and avoids data duplication.
- Modified SBlueprintActionMenu::OnActionSelected() to utilize the new method for determining which namespace(s) to auto-import after executing a node spawner action in response to a context menu item selection (UE-146803).
- Reverted FBlueprintNamespaceUtilities::GetPropertyValueNamespaces() back to its original 5.0 signature so that it uses a TSet<FString> for the output rather than a TArray<FString>; this fits in better with input to other APIs.
- Renamed FBlueprintEditor::FImportNamespaceParameters to FImportNamespaceExParameters (for clarity).
- Changed the 'FBlueprintEditor::FImportNamespaceParameters::AdditionalNamespaces' member to a TSet<FString> containing *all* namespaces to import rather than limiting to only additional ones.
- Reverted FBlueprintEditor::ImportNamespace() back to its original 5.0 signature and added/implemented FBlueprintEditor::ImportNamespaceEx() as the "extended" version that allows for batched imports and future customizations.
- Revised existing FBlueprintEditor::ImportNamespace() call sites to utilize and/or conform to the extended ImportNamespaceEx() API where appropriate.

#jira UE-146803
#rb Benjamin.Fox
#preflight 623cf3a433709ff50128e8d4

[CL 19505118 by Phillip Kavan in ue5-main branch]
2022-03-24 19:50:46 -04:00

67 lines
2.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "K2Node.h"
#include "K2Node_Variable.h"
#include "K2Node_StructOperation.generated.h"
UCLASS(MinimalAPI, abstract)
class UK2Node_StructOperation : public UK2Node_Variable
{
GENERATED_UCLASS_BODY()
/** Class that this variable is defined in. */
UPROPERTY()
TObjectPtr<UScriptStruct> StructType;
//~ Begin UEdGraphNode Interface
virtual FString GetPinMetaData(FName InPinName, FName InKey) override;
virtual bool HasExternalDependencies(TArray<class UStruct*>* OptionalOutput = nullptr) const override;
//~ End UEdGraphNode Interface
//~ Begin UK2Node Interface
//virtual bool DrawNodeAsVariable() const override { return true; }
virtual bool ShouldShowNodeProperties() const override { return true; }
virtual void ValidateNodeDuringCompilation(class FCompilerResultsLog& MessageLog) const override;
virtual FString GetFindReferenceSearchString() const override;
virtual bool IsActionFilteredOut(class FBlueprintActionFilter const& Filter) override;
//~ End UK2Node Interface
protected:
// Updater for subclasses that allow hiding pins
struct FStructOperationOptionalPinManager : public FOptionalPinManager
{
//~ Begin FOptionalPinsUpdater Interface
virtual void GetRecordDefaults(FProperty* TestProperty, FOptionalPinFromProperty& Record) const override
{
Record.bCanToggleVisibility = true;
Record.bShowPin = true;
if (TestProperty)
{
Record.bShowPin = !TestProperty->HasMetaData(TEXT("PinHiddenByDefault"));
if (Record.bShowPin)
{
if (UStruct* OwnerStruct = TestProperty->GetOwnerStruct())
{
Record.bShowPin = !OwnerStruct->HasMetaData(TEXT("HiddenByDefault"));
}
}
}
}
virtual void CustomizePinData(UEdGraphPin* Pin, FName SourcePropertyName, int32 ArrayIndex, FProperty* Property) const override;
// End of FOptionalPinsUpdater interfac
};
bool DoRenamedPinsMatch(const UEdGraphPin* NewPin, const UEdGraphPin* OldPin, bool bStructInVariablesOut) const;
/** Utility function to set up menu actions to set the struct type and promote category */
DECLARE_DELEGATE_RetVal_TwoParams(bool, FMakeStructSpawnerAllowedDelegate, const UScriptStruct*, bool);
void SetupMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar, const FMakeStructSpawnerAllowedDelegate& AllowedDelegate, EEdGraphPinDirection PinDirectionToPromote) const;
};