Trying to add a combo graph editor.
This commit is contained in:
@@ -0,0 +1,209 @@
|
||||
// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
|
||||
|
||||
#include "Ed/EdComboActionGraph.h"
|
||||
|
||||
#include "Ed/EdComboActionGraphEdge.h"
|
||||
#include "Ed/EdComboActionGraphNode.h"
|
||||
#include "ComboActionGraph.h"
|
||||
#include "Nodes/ComboActionGraphNode.h"
|
||||
#include "Nodes/ComboActionGraphEdge.h"
|
||||
//#include "Helpers/MounteaDialogueGraphEditorHelpers.h"
|
||||
//#include "Helpers/MounteaDialogueGraphEditorUtilities.h"
|
||||
//#include "Helpers/MounteaDialogueSystemEditorBFC.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogEdComboActionGraph);
|
||||
|
||||
|
||||
void UEdComboActionGraph::RebuildComboActionGraph()
|
||||
{
|
||||
UE_LOG(LogEdComboActionGraph, Warning, TEXT("UEdComboActionGraph::RebuildComboActionGraph has been called"));
|
||||
|
||||
UComboActionGraph *Graph = GetComboActionGraph();
|
||||
|
||||
Clear();
|
||||
|
||||
for (int i = 0; i < Nodes.Num(); ++i)
|
||||
{
|
||||
if (UEdComboActionGraphNode *EdNode = Cast<UEdComboActionGraphNode>(Nodes[i]))
|
||||
{
|
||||
if (EdNode->ComboActionGraphNode == nullptr)
|
||||
continue;
|
||||
|
||||
UComboActionGraphNode *ComboActionGraphNode = EdNode->ComboActionGraphNode;
|
||||
|
||||
NodeMap.Add(ComboActionGraphNode, EdNode);
|
||||
|
||||
Graph->AllNodes.Add(ComboActionGraphNode);
|
||||
|
||||
//EdNode->SetDialogueNodeIndex( Graph->AllNodes.Find(EdNode->ComboActionGraphNode) );
|
||||
|
||||
for (int PinIdx = 0; PinIdx < EdNode->Pins.Num(); ++PinIdx)
|
||||
{
|
||||
UEdGraphPin* Pin = EdNode->Pins[PinIdx];
|
||||
|
||||
if (Pin->Direction != EEdGraphPinDirection::EGPD_Output)
|
||||
continue;
|
||||
|
||||
for (int LinkToIdx = 0; LinkToIdx < Pin->LinkedTo.Num(); ++LinkToIdx)
|
||||
{
|
||||
UComboActionGraphNode *ChildNode = nullptr;
|
||||
if (UEdComboActionGraphNode *EdNode_Child = Cast<UEdComboActionGraphNode>(Pin->LinkedTo[LinkToIdx]->GetOwningNode()))
|
||||
{
|
||||
ChildNode = EdNode_Child->ComboActionGraphNode;
|
||||
}
|
||||
else if (UEdComboActionGraphEdge *EdNode_Edge = Cast<UEdComboActionGraphEdge>(Pin->LinkedTo[LinkToIdx]->GetOwningNode()))
|
||||
{
|
||||
UEdComboActionGraphNode *Child = EdNode_Edge->GetEndNode();;
|
||||
if (Child != nullptr)
|
||||
{
|
||||
ChildNode = Child->ComboActionGraphNode;
|
||||
}
|
||||
}
|
||||
|
||||
if (ChildNode != nullptr)
|
||||
{
|
||||
ComboActionGraphNode->ChildrenNodes.Add(ChildNode);
|
||||
|
||||
ChildNode->ParentNodes.Add(ComboActionGraphNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogEdComboActionGraph, Error, TEXT("[RebuildComboActionGraph] Can't find child node"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (UEdComboActionGraphEdge *EdgeNode = Cast<UEdComboActionGraphEdge>(Nodes[i]))
|
||||
{
|
||||
UEdComboActionGraphNode *StartNode = EdgeNode->GetStartNode();
|
||||
UEdComboActionGraphNode *EndNode = EdgeNode->GetEndNode();
|
||||
UComboActionGraphEdge *Edge = EdgeNode->ComboActionGraphEdge;
|
||||
|
||||
if (StartNode == nullptr || EndNode == nullptr || Edge == nullptr)
|
||||
{
|
||||
UE_LOG(LogEdComboActionGraph, Error, TEXT("[RebuildMounteaDialogueGraph] Add edge failed."));
|
||||
continue;
|
||||
}
|
||||
|
||||
EdgeMap.Add(Edge, EdgeNode);
|
||||
|
||||
Edge->Graph = Graph;
|
||||
Edge->Rename(nullptr, Graph, REN_DontCreateRedirectors | REN_DoNotDirty);
|
||||
Edge->StartNode = StartNode->ComboActionGraphNode;
|
||||
Edge->EndNode = EndNode->ComboActionGraphNode;
|
||||
Edge->StartNode->Edges.Add(Edge->EndNode, Edge);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < Graph->AllNodes.Num(); ++i)
|
||||
{
|
||||
UComboActionGraphNode *Node = Graph->AllNodes[i];
|
||||
if (Node->ParentNodes.Num() == 0)
|
||||
{
|
||||
Graph->RootNodes.Add(Node);
|
||||
|
||||
SortNodes(Node);
|
||||
}
|
||||
|
||||
Node->Graph = Graph;
|
||||
Node->Rename(nullptr, Graph, REN_DontCreateRedirectors | REN_DoNotDirty);
|
||||
}
|
||||
|
||||
Graph->RootNodes.Sort([&](const UComboActionGraphNode &L, const UComboActionGraphNode &R)
|
||||
{
|
||||
UEdComboActionGraphNode* EdNode_LNode = NodeMap[&L];
|
||||
UEdComboActionGraphNode* EdNode_RNode = NodeMap[&R];
|
||||
return EdNode_LNode->NodePosX < EdNode_RNode->NodePosX;
|
||||
});
|
||||
}
|
||||
|
||||
UComboActionGraph *UEdComboActionGraph::GetComboActionGraph() const
|
||||
{
|
||||
return CastChecked<UComboActionGraph>(GetOuter());
|
||||
}
|
||||
|
||||
bool UEdComboActionGraph::Modify(bool bAlwaysMarkDirty)
|
||||
{
|
||||
bool Rtn = Super::Modify(bAlwaysMarkDirty);
|
||||
|
||||
this->GetComboActionGraph()->Modify();
|
||||
|
||||
for (int32 i = 0; i < Nodes.Num(); ++i)
|
||||
{
|
||||
Nodes[i]->Modify();
|
||||
}
|
||||
|
||||
return Rtn;
|
||||
}
|
||||
|
||||
void UEdComboActionGraph::PostEditUndo()
|
||||
{
|
||||
NotifyGraphChanged();
|
||||
|
||||
Super::PostEditUndo();
|
||||
}
|
||||
|
||||
//void UEdComboActionGraph::SetDialogueEditorPtr(TWeakPtr<FAssetEditor_MounteaDialogueGraph> NewPtr)
|
||||
//{
|
||||
// DialogueEditorPtr = NewPtr;
|
||||
//}
|
||||
|
||||
//bool UEdComboActionGraph::JumpToNode(const UMounteaDialogueGraphNode* Node)
|
||||
//{
|
||||
// return FComboActionGraphEditorUtilities::OpenEditorAndJumpToGraphNode(DialogueEditorPtr, *NodeMap.Find(Node));
|
||||
//}
|
||||
|
||||
void UEdComboActionGraph::Clear()
|
||||
{
|
||||
UComboActionGraph *Graph = this->GetComboActionGraph();
|
||||
|
||||
Graph->ClearGraph();
|
||||
this->NodeMap.Reset();
|
||||
this->EdgeMap.Reset();
|
||||
|
||||
for (int i = 0; i < this->Nodes.Num(); ++i)
|
||||
{
|
||||
if (UEdComboActionGraphNode *EdNode = Cast<UEdComboActionGraphNode>(Nodes[i]))
|
||||
{
|
||||
UComboActionGraphNode *MounteaDialogueGraphNode = EdNode->ComboActionGraphNode;
|
||||
MounteaDialogueGraphNode->ParentNodes.Reset();
|
||||
MounteaDialogueGraphNode->ChildrenNodes.Reset();
|
||||
MounteaDialogueGraphNode->Edges.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UEdComboActionGraph::SortNodes(UComboActionGraphNode *RootNode)
|
||||
{
|
||||
int Level = 0;
|
||||
TArray<UComboActionGraphNode*> CurrLevelNodes = { RootNode };
|
||||
TArray<UComboActionGraphNode*> NextLevelNodes;
|
||||
|
||||
while (CurrLevelNodes.Num() != 0)
|
||||
{
|
||||
int32 LevelWidth = 0;
|
||||
for (int i = 0; i < CurrLevelNodes.Num(); ++i)
|
||||
{
|
||||
UComboActionGraphNode *Node = CurrLevelNodes[i];
|
||||
|
||||
auto Comp = [&](const UComboActionGraphNode &L, const UComboActionGraphNode &R)
|
||||
{
|
||||
UEdComboActionGraphNode *EdNode_LNode = NodeMap[&L];
|
||||
UEdComboActionGraphNode *EdNode_RNode = NodeMap[&R];
|
||||
return EdNode_LNode->NodePosX < EdNode_RNode->NodePosX;
|
||||
};
|
||||
|
||||
Node->ChildrenNodes.Sort(Comp);
|
||||
Node->ParentNodes.Sort(Comp);
|
||||
|
||||
for (int j = 0; j < Node->ChildrenNodes.Num(); ++j)
|
||||
{
|
||||
NextLevelNodes.Add(Node->ChildrenNodes[j]);
|
||||
}
|
||||
}
|
||||
|
||||
CurrLevelNodes = NextLevelNodes;
|
||||
NextLevelNodes.Reset();
|
||||
++Level;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "EdGraph/EdGraph.h"
|
||||
|
||||
#include "EdComboActionGraph.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogEdComboActionGraph, Log, All);
|
||||
|
||||
|
||||
UCLASS()
|
||||
class COMBOINPUT_API UEdComboActionGraph : public UEdGraph
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual void RebuildComboActionGraph();
|
||||
|
||||
UComboActionGraph *GetComboActionGraph() const;
|
||||
|
||||
virtual bool Modify(bool bAlwaysMarkDirty) override;
|
||||
virtual void PostEditUndo() override;
|
||||
|
||||
//TWeakPtr<FAssetEditor_ComboActionGraph> GetDialogueEditorPtr() const { return DialogueEditorPtr; }
|
||||
//void SetDialogueEditorPtr(TWeakPtr<FAssetEditor_ComboActionGraph> NewPtr);
|
||||
//void ResetDialogueEditorPtr() { DialogueEditorPtr.Reset(); }
|
||||
|
||||
//bool JumpToNode(const class UComboActionGraphNode *Node);
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(Transient)
|
||||
TMap<class UComboActionGraphNode*, class UEdComboActionGraphNode*> NodeMap;
|
||||
|
||||
UPROPERTY(Transient)
|
||||
TMap<class UComboActionGraphEdge*, class UEdComboActionGraphEdge*> EdgeMap;
|
||||
|
||||
protected:
|
||||
|
||||
void Clear();
|
||||
void SortNodes(UComboActionGraphNode *RootNode);
|
||||
|
||||
private:
|
||||
|
||||
/** Pointer back to the Dialogue editor that owns us */
|
||||
//TWeakPtr<FAssetEditor_ComboActionGraph> DialogueEditorPtr;
|
||||
};
|
||||
@@ -0,0 +1,83 @@
|
||||
// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
|
||||
|
||||
#include "EdComboActionGraphEdge.h"
|
||||
|
||||
#include "EdComboActionGraphNode.h"
|
||||
#include "Nodes/ComboActionGraphEdge.h"
|
||||
|
||||
|
||||
void UEdComboActionGraphEdge::SetEdge(UComboActionGraphEdge *Edge)
|
||||
{
|
||||
this->ComboActionGraphEdge = Edge;
|
||||
}
|
||||
|
||||
void UEdComboActionGraphEdge::AllocateDefaultPins()
|
||||
{
|
||||
UEdGraphPin* Inputs = this->CreatePin(EGPD_Input, TEXT("Edge"), FName(), TEXT("In"));
|
||||
Inputs->bHidden = true;
|
||||
UEdGraphPin* Outputs = this->CreatePin(EGPD_Output, TEXT("Edge"), FName(), TEXT("Out"));
|
||||
Outputs->bHidden = true;
|
||||
}
|
||||
|
||||
FText UEdComboActionGraphEdge::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
||||
{
|
||||
return Super::GetNodeTitle(TitleType);
|
||||
}
|
||||
|
||||
void UEdComboActionGraphEdge::PinConnectionListChanged(UEdGraphPin *Pin)
|
||||
{
|
||||
if (Pin->LinkedTo.Num() == 0)
|
||||
{
|
||||
// Commit suicide; transitions must always have an input and output connection
|
||||
Modify();
|
||||
|
||||
// Our parent graph will have our graph in SubGraphs so needs to be modified to record that.
|
||||
if (UEdGraph *ParentGraph = GetGraph())
|
||||
{
|
||||
ParentGraph->Modify();
|
||||
}
|
||||
|
||||
DestroyNode();
|
||||
}
|
||||
}
|
||||
|
||||
void UEdComboActionGraphEdge::PrepareForCopying()
|
||||
{
|
||||
this->ComboActionGraphEdge->Rename(nullptr, this, REN_DontCreateRedirectors | REN_DoNotDirty);
|
||||
}
|
||||
|
||||
void UEdComboActionGraphEdge::CreateConnections(UEdComboActionGraphNode *Start, UEdComboActionGraphNode *End)
|
||||
{
|
||||
Pins[0]->Modify();
|
||||
Pins[0]->LinkedTo.Empty();
|
||||
|
||||
Start->GetOutputPin()->Modify();
|
||||
Pins[0]->MakeLinkTo(Start->GetOutputPin());
|
||||
|
||||
// This to next
|
||||
Pins[1]->Modify();
|
||||
Pins[1]->LinkedTo.Empty();
|
||||
|
||||
End->GetInputPin()->Modify();
|
||||
Pins[1]->MakeLinkTo(End->GetInputPin());
|
||||
}
|
||||
|
||||
UEdComboActionGraphNode *UEdComboActionGraphEdge::GetStartNode()
|
||||
{
|
||||
if (Pins[0]->LinkedTo.Num() > 0)
|
||||
{
|
||||
return Cast<UEdComboActionGraphNode>(Pins[0]->LinkedTo[0]->GetOwningNode());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UEdComboActionGraphNode *UEdComboActionGraphEdge::GetEndNode()
|
||||
{
|
||||
if (Pins[1]->LinkedTo.Num() > 0)
|
||||
{
|
||||
return Cast<UEdComboActionGraphNode>(Pins[1]->LinkedTo[0]->GetOwningNode());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "EdGraph/EdGraphNode.h"
|
||||
|
||||
#include "EdComboActionGraphEdge.generated.h"
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(MinimalAPI)
|
||||
class UEdComboActionGraphEdge : public UEdGraphNode
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY()
|
||||
class UEdGraph *Graph;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, Instanced, Category="Combo Action Graph")
|
||||
class UComboActionGraphEdge *ComboActionGraphEdge;
|
||||
|
||||
public:
|
||||
|
||||
void SetEdge(class UComboActionGraphEdge *Edge);
|
||||
|
||||
virtual void AllocateDefaultPins() override;
|
||||
|
||||
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
|
||||
|
||||
virtual void PinConnectionListChanged(UEdGraphPin *Pin) override;
|
||||
|
||||
virtual void PrepareForCopying() override;
|
||||
|
||||
virtual UEdGraphPin *GetInputPin() const { return Pins[0]; }
|
||||
virtual UEdGraphPin *GetOutputPin() const { return Pins[1]; }
|
||||
|
||||
void CreateConnections(class UEdComboActionGraphNode *Start, class UEdComboActionGraphNode* End);
|
||||
|
||||
class UEdComboActionGraphNode *GetStartNode();
|
||||
class UEdComboActionGraphNode *GetEndNode();
|
||||
};
|
||||
@@ -0,0 +1,169 @@
|
||||
// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
|
||||
|
||||
#include "EdComboActionGraphNode.h"
|
||||
|
||||
#include "Ed/EdComboActionGraph.h"
|
||||
#include "Helpers/ComboActionEditorBFC.h"
|
||||
#include "Nodes/ComboActionGraphNode.h"
|
||||
#include "Settings/ComboActionGraphEditorSettings.h"
|
||||
#include "Settings/FComboActionGraphEditorStyle.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "UEdComboActionGraphNode"
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogEdComboActionGraphNode);
|
||||
|
||||
|
||||
UEdComboActionGraphNode::UEdComboActionGraphNode()
|
||||
{
|
||||
bCanRenameNode = true;
|
||||
|
||||
bAllowCopy = true;
|
||||
bAllowDelete = true;
|
||||
bAllowDuplicate = true;
|
||||
bAllowPaste = true;
|
||||
}
|
||||
|
||||
UEdComboActionGraph *UEdComboActionGraphNode::GetEdComboActionGraph() const
|
||||
{
|
||||
return Cast<UEdComboActionGraph>(this->GetGraph());
|
||||
};
|
||||
|
||||
void UEdComboActionGraphNode::AllocateDefaultPins()
|
||||
{
|
||||
if (this->ComboActionGraphNode == nullptr)
|
||||
{
|
||||
UE_LOG(LogEdComboActionGraphNode, Error, TEXT("[AllocateDefaultPins] Cannot find Owning Graph Node!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->ComboActionGraphNode->bAllowInputNodes)
|
||||
{
|
||||
this->CreatePin(EGPD_Input, "MultipleNodes", FName(), TEXT("In"));
|
||||
}
|
||||
|
||||
if (this->ComboActionGraphNode->bAllowOutputNodes)
|
||||
{
|
||||
this->CreatePin(EGPD_Output, "MultipleNodes", FName(), TEXT("Out"));
|
||||
}
|
||||
}
|
||||
|
||||
FText UEdComboActionGraphNode::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
||||
{
|
||||
return UComboActionEditorBFC::GetNodeTitle(this->ComboActionGraphNode);
|
||||
}
|
||||
|
||||
void UEdComboActionGraphNode::PrepareForCopying()
|
||||
{
|
||||
this->ComboActionGraphNode->Rename(nullptr, this, REN_DontCreateRedirectors | REN_DoNotDirty);
|
||||
}
|
||||
|
||||
void UEdComboActionGraphNode::AutowireNewNode(UEdGraphPin* FromPin)
|
||||
{
|
||||
Super::AutowireNewNode(FromPin);
|
||||
|
||||
if (FromPin != nullptr)
|
||||
{
|
||||
if (GetSchema()->TryCreateConnection(FromPin, GetInputPin()))
|
||||
{
|
||||
FromPin->GetOwningNode()->NodeConnectionListChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FLinearColor UEdComboActionGraphNode::GetBackgroundColor() const
|
||||
{
|
||||
// Getting Node colour based on the Settings if any found, otherwise use this logic
|
||||
if (UComboActionGraphEditorSettings *GraphEditorSettings = GetMutableDefault<UComboActionGraphEditorSettings>())
|
||||
{
|
||||
FLinearColor ReturnColour;
|
||||
if (GraphEditorSettings->FindNodeBackgroundColourOverride(this->ComboActionGraphNode->GetClass(), ReturnColour))
|
||||
{
|
||||
return ReturnColour;
|
||||
}
|
||||
}
|
||||
|
||||
return this->ComboActionGraphNode ? this->ComboActionGraphNode->GetBackgroundColor() : FLinearColor::Black;
|
||||
}
|
||||
|
||||
UEdGraphPin* UEdComboActionGraphNode::GetInputPin() const
|
||||
{
|
||||
return Pins[0];
|
||||
}
|
||||
|
||||
UEdGraphPin* UEdComboActionGraphNode::GetOutputPin() const
|
||||
{
|
||||
if (Pins.IsValidIndex(1))
|
||||
{
|
||||
return Pins[1];
|
||||
}
|
||||
|
||||
return Pins[0];
|
||||
}
|
||||
|
||||
bool UEdComboActionGraphNode::CanUserDeleteNode() const
|
||||
{
|
||||
if(!Super::CanUserDeleteNode())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->ComboActionGraphNode)
|
||||
{
|
||||
return this->ComboActionGraphNode->bAllowDelete;
|
||||
}
|
||||
return bAllowDelete;
|
||||
}
|
||||
|
||||
bool UEdComboActionGraphNode::CanDuplicateNode() const
|
||||
{
|
||||
if(!Super::CanUserDeleteNode())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->ComboActionGraphNode)
|
||||
{
|
||||
return this->ComboActionGraphNode->bAllowCopy;
|
||||
}
|
||||
|
||||
return bAllowCopy;
|
||||
}
|
||||
|
||||
bool UEdComboActionGraphNode::CanUserPasteNodes() const
|
||||
{
|
||||
if (this->ComboActionGraphNode)
|
||||
{
|
||||
return this->ComboActionGraphNode->bAllowPaste;
|
||||
}
|
||||
|
||||
return bAllowPaste;
|
||||
}
|
||||
|
||||
FText UEdComboActionGraphNode::GetTooltipText() const
|
||||
{
|
||||
if (this->ComboActionGraphNode)
|
||||
{
|
||||
return this->ComboActionGraphNode->GetNodeTooltipText();
|
||||
}
|
||||
|
||||
return NSLOCTEXT("UEdComboActionGraphNode", "DefaultToolTip", "Mountea Dialogue Node");
|
||||
}
|
||||
|
||||
FSlateIcon UEdComboActionGraphNode::GetIconAndTint(FLinearColor& OutColor) const
|
||||
{
|
||||
static const FSlateIcon Icon = FSlateIcon(FComboActionGraphEditorStyle::GetAppStyleSetName(), "MDSStyleSet.Node.Icon.small");
|
||||
OutColor = this->ComboActionGraphNode->GetBackgroundColor();
|
||||
return Icon;
|
||||
}
|
||||
|
||||
void UEdComboActionGraphNode::PostEditUndo()
|
||||
{
|
||||
Super::PostEditUndo();
|
||||
}
|
||||
|
||||
void UEdComboActionGraphNode::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||
{
|
||||
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -0,0 +1,60 @@
|
||||
// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
#include "SEdComboActionGraphNode.h"
|
||||
#include "EdGraph/EdGraphNode.h"
|
||||
|
||||
#include "EdComboActionGraphNode.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogEdComboActionGraphNode, Log, All);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(MinimalAPI)
|
||||
class UEdComboActionGraphNode : public UEdGraphNode
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UEdComboActionGraphNode();
|
||||
|
||||
class UEdComboActionGraph *GetEdComboActionGraph() const;
|
||||
|
||||
virtual void AllocateDefaultPins() override;
|
||||
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
|
||||
virtual void PrepareForCopying() override;
|
||||
virtual void AutowireNewNode(UEdGraphPin *FromPin) override;
|
||||
|
||||
virtual FLinearColor GetBackgroundColor() const;
|
||||
virtual UEdGraphPin *GetInputPin() const;
|
||||
virtual UEdGraphPin *GetOutputPin() const;
|
||||
|
||||
virtual bool CanUserDeleteNode() const override;
|
||||
virtual bool CanDuplicateNode() const override;
|
||||
|
||||
virtual bool CanUserPasteNodes() const;
|
||||
|
||||
virtual FText GetTooltipText() const override;
|
||||
virtual FSlateIcon GetIconAndTint(FLinearColor &OutColor) const override;
|
||||
|
||||
#if WITH_EDITOR
|
||||
virtual void PostEditUndo() override;
|
||||
virtual void PostEditChangeProperty(FPropertyChangedEvent &PropertyChangedEvent) override;
|
||||
#endif
|
||||
|
||||
UPROPERTY(VisibleAnywhere, Instanced, Category="Combo Action Graph")
|
||||
class UComboActionGraphNode *ComboActionGraphNode;
|
||||
|
||||
SEdComboActionGraphNode *SEdNode;
|
||||
|
||||
private:
|
||||
bool bAllowCopy;
|
||||
bool bAllowDelete;
|
||||
bool bAllowDuplicate;
|
||||
bool bAllowPaste;
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,89 @@
|
||||
// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
#include "SGraphNode.h"
|
||||
#include "Settings\ComboActionGraphEditorSettings.h"
|
||||
|
||||
|
||||
class SEdComboActionGraphNode : public SGraphNode
|
||||
{
|
||||
public:
|
||||
SLATE_BEGIN_ARGS(SEdComboActionGraphNode) {}
|
||||
SLATE_END_ARGS()
|
||||
|
||||
void Construct(const FArguments &InArgs, class UEdComboActionGraphNode *InNode);
|
||||
|
||||
virtual void OnMouseEnter(const FGeometry &MyGeometry, const FPointerEvent &MouseEvent) override;
|
||||
virtual void OnMouseLeave(const FPointerEvent &MouseEvent) override;
|
||||
|
||||
const FSlateBrush *GetIndexBrush() const;
|
||||
|
||||
virtual void UpdateGraphNode() override;
|
||||
virtual void CreatePinWidgets() override;
|
||||
virtual void AddPin(const TSharedRef<SGraphPin> &PinToAdd) override;
|
||||
virtual bool IsNameReadOnly() const override;
|
||||
|
||||
void OnNameTextCommitted(const FText &InText, ETextCommit::Type CommitInfo);
|
||||
|
||||
virtual const FSlateBrush *GetNodeTypeBrush () const;
|
||||
virtual const FSlateBrush *GetTextNodeTypeBrush () const;
|
||||
virtual FSlateColor GetBorderBackgroundColor() const;
|
||||
virtual FSlateColor GetBorderFrontColor() const;
|
||||
virtual FSlateColor GetNodeTitleBackgroundColor() const;
|
||||
virtual FSlateColor GetDecoratorsBackgroundColor() const;
|
||||
|
||||
virtual FSlateColor GetPinsDockColor() const;
|
||||
|
||||
virtual EVisibility GetDragOverMarkerVisibility() const;
|
||||
|
||||
virtual const FSlateBrush *GetNameIcon() const;
|
||||
|
||||
virtual const FSlateBrush *GetInheritsImageBrush() const;
|
||||
virtual FSlateColor GetInheritsImageTint() const;
|
||||
|
||||
const FSlateBrush *GetBulletPointImageBrush() const;
|
||||
|
||||
virtual FText GetIndexOverlayTooltipText() const;
|
||||
virtual FText GetIndexText() const;
|
||||
EVisibility GetIndexSlotVisibility() const;
|
||||
FVector2D GetIndexSlotOffset() const;
|
||||
FVector2D GetIndexSlotSize() const;
|
||||
|
||||
virtual void OnIndexHoverStateChanged(bool bArg) const;
|
||||
virtual FSlateColor GetOverlayWidgetBackgroundColor(bool bArg) const;
|
||||
|
||||
bool HasGraphDecorators() const;
|
||||
bool HasNodeDecorators() const;
|
||||
|
||||
virtual FText GetDecoratorsText() const;
|
||||
virtual FText GetNumberOfDecorators() const;
|
||||
virtual FText GetDecoratorsInheritanceText() const;
|
||||
|
||||
EVisibility ShowImplementsOnlySlot_Unified() const;
|
||||
EVisibility ShowInheritsDecoratorsSlot_Unified() const;
|
||||
EVisibility ShowImplementsOnlySlot_Stack() const;
|
||||
EVisibility ShowInheritsDecoratorsSlot_Stack() const;
|
||||
EVisibility ShowAllDecorators() const;
|
||||
EVisibility ShowDecoratorsBottomPadding() const;
|
||||
|
||||
FSlateColor GetImplementsRowColor() const;
|
||||
FSlateColor GetBulletPointsImagePointColor() const;
|
||||
|
||||
virtual EComboActionDecoratorsInfoStyle GetDecoratorsStyle() const;
|
||||
EVisibility GetStackVisibility() const;
|
||||
EVisibility GetUnifiedVisibility() const;
|
||||
|
||||
FText GetTooltipText() const;
|
||||
|
||||
protected:
|
||||
TSharedPtr<SBorder> NodeBody;
|
||||
TSharedPtr<SHorizontalBox> OutputPinBox;
|
||||
|
||||
class UComboActionGraphEditorSettings *GraphEditorSettings = nullptr;
|
||||
|
||||
FLinearColor NodeInnerColor;
|
||||
FLinearColor PinsDockColor;
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
|
||||
|
||||
#include "SEdComboActionGraphNodeIndex.h"
|
||||
|
||||
#include "Settings/FComboActionGraphEditorStyle.h"
|
||||
|
||||
|
||||
void SEdComboActionGraphNodeIndex::Construct(const FArguments &InArgs)
|
||||
{
|
||||
const FSlateBrush* CircleBrush = FComboActionGraphEditorStyle::GetBrush(TEXT("MDSStyleSet.Node.IndexCircle"));
|
||||
ChildSlot
|
||||
[
|
||||
SNew(SOverlay)
|
||||
+SOverlay::Slot()
|
||||
.HAlign(HAlign_Fill)
|
||||
.VAlign(VAlign_Fill)
|
||||
[
|
||||
// Add a dummy box here to make sure the widget doesnt get smaller than the brush
|
||||
SNew(SBox)
|
||||
.WidthOverride(CircleBrush->ImageSize.X)
|
||||
.HeightOverride(CircleBrush->ImageSize.Y)
|
||||
]
|
||||
|
||||
+SOverlay::Slot()
|
||||
.HAlign(HAlign_Fill)
|
||||
.VAlign(VAlign_Fill)
|
||||
[
|
||||
SNew(SBorder)
|
||||
.BorderImage(CircleBrush)
|
||||
.BorderBackgroundColor(this, &SEdComboActionGraphNodeIndex::GetBackgroundColor)
|
||||
.Padding(FMargin(4.0f))
|
||||
.VAlign(VAlign_Center)
|
||||
.HAlign(HAlign_Center)
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Widgets/DeclarativeSyntaxSupport.h"
|
||||
#include "Widgets/SCompoundWidget.h"
|
||||
|
||||
class SEdComboActionGraphNodeIndex : public SCompoundWidget
|
||||
{
|
||||
public:
|
||||
/** Delegate event fired when the hover state of this widget changes */
|
||||
DECLARE_DELEGATE_OneParam(FOnHoverStateChanged, bool /* bHovered */);
|
||||
|
||||
/** Delegate used to receive the background color of the node, depending on hover state and state of other siblings */
|
||||
DECLARE_DELEGATE_RetVal_OneParam(FSlateColor, FOnGetBackgroundColor, bool /* bHovered */);
|
||||
|
||||
SLATE_BEGIN_ARGS(SEdComboActionGraphNodeIndex) {}
|
||||
SLATE_ATTRIBUTE(TSharedPtr<SWidget>, OverlayBody)
|
||||
|
||||
// Events
|
||||
SLATE_EVENT(FOnHoverStateChanged, OnHoverStateChanged)
|
||||
SLATE_EVENT(FOnGetBackgroundColor, OnGetBackgroundColor)
|
||||
SLATE_END_ARGS()
|
||||
|
||||
void Construct(const FArguments &InArgs);
|
||||
|
||||
/** Get the color we use to display the rounded border */
|
||||
FSlateColor GetBackgroundColor() const { return FSlateColor::UseForeground(); }
|
||||
|
||||
private:
|
||||
/** The OverlayBody used for this widget*/
|
||||
TSharedPtr<SWidget> OverlayBody;
|
||||
};
|
||||
Reference in New Issue
Block a user