Files
UnrealEngineUWP/Engine/Source/Editor/GraphEditor/Private/MaterialNodes/SGraphNodeMaterialResult.cpp
Ben Marsh 149375b14b Update copyright notices to 2015.
[CL 2379638 by Ben Marsh in Main branch]
2014-12-07 19:09:38 -05:00

81 lines
2.5 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "GraphEditorCommon.h"
#include "SGraphNodeMaterialResult.h"
#include "TutorialMetaData.h"
/////////////////////////////////////////////////////
// SGraphNodeMaterialResult
void SGraphNodeMaterialResult::Construct(const FArguments& InArgs, UMaterialGraphNode_Root* InNode)
{
this->GraphNode = InNode;
this->RootNode = InNode;
this->SetCursor(EMouseCursor::CardinalCross);
this->UpdateGraphNode();
}
void SGraphNodeMaterialResult::CreatePinWidgets()
{
// Create Pin widgets for each of the pins.
for( int32 PinIndex=0; PinIndex < GraphNode->Pins.Num(); ++PinIndex )
{
UEdGraphPin* CurPin = GraphNode->Pins[PinIndex];
bool bHideNoConnectionPins = false;
if (OwnerGraphPanelPtr.IsValid())
{
bHideNoConnectionPins = OwnerGraphPanelPtr.Pin()->GetPinVisibility() == SGraphEditor::Pin_HideNoConnection;
}
const bool bPinHasConections = CurPin->LinkedTo.Num() > 0;
//const bool bPinDesiresToBeHidden = CurPin->bHidden || (bHideNoConnectionPins && !bPinHasConections);
UMaterialGraph* MaterialGraph = CastChecked<UMaterialGraph>(GraphNode->GetGraph());
check(PinIndex < MaterialGraph->MaterialInputs.Num());
const bool bPinDesiresToBeHidden = !MaterialGraph->MaterialInputs[PinIndex].IsVisiblePin(MaterialGraph->Material) || (bHideNoConnectionPins && !bPinHasConections);
if (!bPinDesiresToBeHidden)
{
TSharedPtr<SGraphPin> NewPin = CreatePinWidget(CurPin);
check(NewPin.IsValid());
NewPin->SetIsEditable(IsEditable);
this->AddPin(NewPin.ToSharedRef());
}
}
}
void SGraphNodeMaterialResult::MoveTo(const FVector2D& NewPosition, FNodeSet& NodeFilter)
{
SGraphNode::MoveTo(NewPosition, NodeFilter);
RootNode->Material->EditorX = RootNode->NodePosX;
RootNode->Material->EditorY = RootNode->NodePosY;
RootNode->Material->MarkPackageDirty();
RootNode->Material->MaterialGraph->MaterialDirtyDelegate.ExecuteIfBound();
}
void SGraphNodeMaterialResult::PopulateMetaTag(FGraphNodeMetaData* TagMeta) const
{
if( (GraphNode != nullptr) && (RootNode != nullptr) )
{
UMaterialGraph* OuterGraph = RootNode->GetTypedOuter<UMaterialGraph>();
if (OuterGraph != nullptr)
{
TagMeta->OuterName = OuterGraph->OriginalMaterialFullName;
// There is only one root node - so we dont need a guid.
TagMeta->Tag = FName(*FString::Printf(TEXT("MaterialResNode_%s"), *TagMeta->OuterName));
TagMeta->GUID.Invalidate();
TagMeta->FriendlyName = FString::Printf(TEXT("Material Result node in %s"), *TagMeta->OuterName);
}
}
}