Files
UnrealEngineUWP/Engine/Source/Editor/BlueprintGraph/Classes/K2Node_DynamicCast.h
Phillip Kavan 8e3e596f9b Exclude node spawner actions for non-imported component types from the Blueprint graph context menu when Blueprint namespace editor features are enabled.
Change summary:
- Extended FBlueprintActionContext to include a weak ptr to the current IBlueprintEditor context.
- Added ENUM_CLASS_FLAGS() for the FBlueprintActionFilter::EFlags enumeration (for use as bitflags).
- Deprecated the current FBlueprintActionFilter constructor, replaced with a more explicitly-typed EFlags param.
- FBlueprintActionFilter now internally stores its filter flags. Also added FBlueprintActionFilter::HasAnyFlags/HasAllFlags().
- Minor refactor to a few action filter delegates to query the filter flags locally rather than add bool flags to delegate payloads.
- The FBlueprintActionFilter constructor now unsets the non-imported filter flag if Blueprint namespace editor settings are disabled.
- BlueprintActionFilterImpl::IsNonImportedObject() now utilizes the filter context rather than iterate the Blueprints array to find open asset editors.
- Added an override for UBlueprintComponentNodeSpawner::IsTemplateNodeFilteredOut(). This is now used to filter out any loaded or unloaded BP component types from the context menu.
- Cleaned up display inconsistencies in the menu UI spec between loaded vs. unloaded "Add Component" node spawner actions in the context menu.
- Added an FSoftObjectPath variant of IBlueprintEditor::IsNonImportedObject() (to support unloaded non-native component type entries which store the class object path). Implemented as FBlueprintEditor::IsNonImportedObject(FSoftObjectPath).
- Added an override for UK2Node_DynamicCast::IsActionFilteredOut() to exclude cast operator actions for non-native component types if they are not imported into the current editor context.
- Modified SBlueprintActionMenu, SBlueprintFavoritesPalette and SBlueprintLibraryPalette to include the current editor context in applicable action filter context(s).

#jira UE-149760
#rb Ben.Hoffman
#preflight 62753dd9e31cfc52d5bd0539

[CL 20077282 by Phillip Kavan in ue5-main branch]
2022-05-06 11:49:20 -04:00

87 lines
3.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "Templates/SubclassOf.h"
#include "BlueprintNodeSignature.h"
#include "K2Node.h"
#include "Textures/SlateIcon.h"
#include "EdGraph/EdGraphNodeUtils.h"
#include "K2Node_DynamicCast.generated.h"
UCLASS(MinimalAPI)
class UK2Node_DynamicCast : public UK2Node
{
GENERATED_UCLASS_BODY()
/** The type that the input should try to be cast to */
UPROPERTY()
TSubclassOf<class UObject> TargetType;
//~ Begin UEdGraphNode Interface
virtual void AllocateDefaultPins() override;
virtual FLinearColor GetNodeTitleColor() const override;
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
virtual FText GetTooltipText() const override;
virtual FSlateIcon GetIconAndTint(FLinearColor& OutColor) const override;
virtual void GetNodeContextMenuActions(class UToolMenu* Menu, class UGraphNodeContextMenuContext* Context) const override;
virtual bool IncludeParentNodeContextMenu() const override { return true; }
virtual void PostReconstructNode() override;
virtual void PostPlacedNewNode() override;
virtual bool HasExternalDependencies(TArray<class UStruct*>* OptionalOutput) const override;
//~ End UEdGraphNode Interface
//~ Begin UK2Node Interface
virtual ERedirectType DoPinsMatchForReconstruction(const UEdGraphPin* NewPin, int32 NewPinIndex, const UEdGraphPin* OldPin, int32 OldPinIndex) const override;
virtual class FNodeHandlingFunctor* CreateNodeHandler(class FKismetCompilerContext& CompilerContext) const override;
virtual FText GetMenuCategory() const override;
virtual FBlueprintNodeSignature GetSignature() const override;
virtual bool IsNodePure() const override { return bIsPureCast; }
virtual bool IsConnectionDisallowed(const UEdGraphPin* MyPin, const UEdGraphPin* OtherPin, FString& OutReason) const override;
virtual void NotifyPinConnectionListChanged(UEdGraphPin* Pin) override;
virtual void ReallocatePinsDuringReconstruction(TArray<UEdGraphPin*>& OldPins) override;
virtual void ValidateNodeDuringCompilation(class FCompilerResultsLog& MessageLog) const override;
virtual bool IsActionFilteredOut(const class FBlueprintActionFilter& Filter) override;
//~ End UK2Node Interface
/** Get the 'valid cast' exec pin */
BLUEPRINTGRAPH_API UEdGraphPin* GetValidCastPin() const;
/** Get the 'invalid cast' exec pin */
BLUEPRINTGRAPH_API UEdGraphPin* GetInvalidCastPin() const;
/** Get the cast result pin */
BLUEPRINTGRAPH_API UEdGraphPin* GetCastResultPin() const;
/** Get the input object to be casted pin */
BLUEPRINTGRAPH_API virtual UEdGraphPin* GetCastSourcePin() const;
/** Get the boolean output pin that signifies a successful/failed cast. */
BLUEPRINTGRAPH_API virtual UEdGraphPin* GetBoolSuccessPin() const;
/**
* Will change the node's purity, and reallocate pins accordingly (adding/
* removing exec pins).
*
* @param bNewPurity The new value for bIsPureCast.
*/
BLUEPRINTGRAPH_API void SetPurity(bool bNewPurity);
protected:
/** Flips the node's purity (adding/removing exec pins as needed). */
void TogglePurity();
/** Update exec pins when converting from impure to pure. */
bool ReconnectPureExecPins(TArray<UEdGraphPin*>& OldPins);
/** Constructing FText strings can be costly, so we cache the node's title */
FNodeTextCache CachedNodeTitle;
UPROPERTY()
bool bIsPureCast;
};