2025-11-17 15:11:34 +08:00
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
2025-11-18 15:37:21 +08:00
|
|
|
#include "ConnectionDrawingPolicy.h"
|
2025-11-17 15:11:34 +08:00
|
|
|
#include "EdGraph/EdGraphSchema.h"
|
|
|
|
|
#include "DialogueGraphSchema.generated.h"
|
|
|
|
|
|
2025-11-18 15:37:21 +08:00
|
|
|
struct FConnectionParams;
|
2025-11-17 15:11:34 +08:00
|
|
|
/**
|
|
|
|
|
* 创建节点的Action
|
|
|
|
|
*/
|
|
|
|
|
USTRUCT()
|
|
|
|
|
struct FDialogueGraphSchemaAction_NewNode : public FEdGraphSchemaAction
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FDialogueGraphSchemaAction_NewNode() : FEdGraphSchemaAction() {}
|
|
|
|
|
|
|
|
|
|
FDialogueGraphSchemaAction_NewNode(UClass* InClassTemplate, FText InNodeCategory, FText InMenuDesc, FText InToolTip)
|
|
|
|
|
: FEdGraphSchemaAction(InNodeCategory, InMenuDesc, InToolTip, 0), ClassTemplate(InClassTemplate) {}
|
|
|
|
|
|
|
|
|
|
virtual UEdGraphNode* PerformAction(UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode = true) override;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
UClass* ClassTemplate = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-18 15:37:21 +08:00
|
|
|
//自定义连线绘制方式
|
|
|
|
|
class FVerticalConnectionDrawingPolicy : public FConnectionDrawingPolicy
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FVerticalConnectionDrawingPolicy(int32 InBackLayerID, int32 InFrontLayerID, float InZoomFactor, const FSlateRect& InClippingRect, FSlateWindowElementList& InDrawElements);
|
|
|
|
|
virtual void DrawSplineWithArrow(const FVector2D& StartPoint, const FVector2D& EndPoint, const FConnectionParams& Params) override;
|
|
|
|
|
virtual void DrawSplineWithArrow(const FGeometry& StartGeom, const FGeometry& EndGeom, const FConnectionParams& Params) override;
|
|
|
|
|
//virtual void DrawConnection(int32 LayerId, const FVector2D& Start, const FVector2D& End, const FConnectionParams& Params) override;
|
|
|
|
|
virtual FVector2D ComputeSplineTangent(const FVector2D& Start, const FVector2D& End) const override;
|
|
|
|
|
//virtual FVector2D GetCorrectedPinPosition(const FVector2D& OriginalPosition, UEdGraphPin* Pin, EEdGraphPinDirection Direction);
|
|
|
|
|
virtual FVector2D GetPinPos(const UEdGraphPin* Pin) const;
|
|
|
|
|
};
|
2025-11-17 15:11:34 +08:00
|
|
|
/**
|
|
|
|
|
* 对话图表规则
|
|
|
|
|
*/
|
|
|
|
|
UCLASS()
|
|
|
|
|
class DIALOGUEEDITOR_API UDialogueGraphSchema : public UEdGraphSchema
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/** UEdGraphSchema */
|
|
|
|
|
virtual void CreateDefaultNodesForGraph(UEdGraph& Graph) const override;
|
|
|
|
|
// 右键菜单创建节点
|
|
|
|
|
virtual void GetGraphContextActions(FGraphContextMenuBuilder& ContextMenuBuilder) const override;
|
|
|
|
|
|
|
|
|
|
// 连接规则
|
|
|
|
|
virtual const FPinConnectionResponse CanCreateConnection(const UEdGraphPin* A, const UEdGraphPin* B) const override;
|
2025-11-18 15:37:21 +08:00
|
|
|
//修改连线的绘制方式
|
|
|
|
|
virtual FConnectionDrawingPolicy* CreateConnectionDrawingPolicy(int32 InBackLayerID, int32 InFrontLayerID, float InZoomFactor, const FSlateRect& InClippingRect, FSlateWindowElementList& InDrawElements, class UEdGraph* InGraphObj) const override;
|
2025-11-17 15:11:34 +08:00
|
|
|
};
|