// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "EdGraph/EdGraphNode.h" #include "NiagaraTypes.h" class UNiagaraNodeConvert; class FNiagaraConvertPinViewModel; class FNiagaraConvertPinSocketViewModel; /** A view model for an inner connection in a Niagara convert node. */ class FNiagaraConvertConnectionViewModel { public: const TSharedRef SourceSocket; const TSharedRef DestinationSocket; /** Creates a connection view model with a source and destination socket. */ FNiagaraConvertConnectionViewModel(TSharedRef InSourceSocket, TSharedRef InDestinationSocket) : SourceSocket(InSourceSocket) , DestinationSocket(InDestinationSocket) { } }; /** A view model for connection UI of the Niagara convert node. */ class FNiagaraConvertNodeViewModel : public TSharedFromThis { public: FNiagaraConvertNodeViewModel(UNiagaraNodeConvert& InConvertNode); /** Gets the view models for the input pins. */ const TArray>& GetInputPinViewModels(); /** Gets the view models for the output pins. */ const TArray>& GetOutputPinViewModels(); /** Gets the view models for the connections. */ const TArray> GetConnectionViewModels(); /** Gets the view model for the currently dragged socket, if there is one. */ TSharedPtr GetDraggedSocketViewModel() const; /** Sets the view model for the currently dragged socket. */ void SetDraggedSocketViewModel(TSharedPtr DraggedSocket); /** Determines whether two sockets can be connected giving a message about the connection. */ bool CanConnectSockets(TSharedRef SocketA, TSharedRef SocketB, FText& ConnectionMessage, bool& bIsWarningMessage); /** Connects two socket view models. */ void ConnectSockets(TSharedRef SocketA, TSharedRef SocketB); /** Disconnects a socket from all other connected sockets. */ void DisconnectSocket(TSharedRef Socket); /** Disconnects a socket from a specific socket. */ void DisconnectSockets(TSharedRef SocketA, TSharedRef SocketB); /** Returns whether or not a socket is connected. */ bool IsSocketConnected(TSharedRef Socket) const; /** Gets an array of sockets connected to a specific socket. */ void GetConnectedSockets(TSharedRef Socket, TArray>& ConnectedSockets); /** Do we show any of the switchboard UI?*/ bool IsWiringShown() const; /** Store off whether or not this socket is expanded.*/ void RecordChildrenShowing(bool bIsShowingChildren, FGuid PinId, const TArray& Path); /** Query whether or not htis socket is expanded.*/ bool AreChildrenShowing(FGuid PinId, const TArray& Path); private: /** Rebuilds the pin view models. */ void RefreshPinViewModels(); /** Marks the connection view models for rebuilding. */ void InvalidateConnectionViewModels(); /** Rebuilds the connection view models. */ void RefreshConnectionViewModels(); /** Gets a socket by it's pin id, path, and direction. */ TSharedPtr GetSocket(FGuid PinId, const TArray Path, EEdGraphPinDirection Direction); private: /** The convert node that this view model represents. */ UNiagaraNodeConvert& ConvertNode; /** Whether or not the pin view models need to be rebuilt before use. */ bool bPinViewModelsNeedRefresh; /** Whether or not the connection view models need to be rebuilt before use. */ bool bConnectionViewModelsNewRefresh; /** The input pin view models. */ TArray> InputPinViewModels; /** The output pin view models. */ TArray> OutputPinViewModels; /** The connection view models. */ TArray> ConnectionViewModels; /** The view model for the currently dragged socket if there is one. */ TSharedPtr DraggedSocketViewModel; };