Browse Source

Limited creation of OutputNode

flabbet 1 year ago
parent
commit
5a4cde48aa

+ 2 - 1
src/PixiEditor.ChangeableDocument/Changes/NodeGraph/CreateNode_Change.cs

@@ -25,7 +25,8 @@ internal class CreateNode_Change : Change
     
     
     public override bool InitializeAndValidate(Document target)
     public override bool InitializeAndValidate(Document target)
     {
     {
-        return nodeType.IsSubclassOf(typeof(Node)) && nodeType is { IsAbstract: false, IsInterface: false };
+        bool canCreate = nodeType.IsSubclassOf(typeof(Node)) && nodeType is { IsAbstract: false, IsInterface: false };
+        return canCreate && (!nodeType.IsAssignableTo(typeof(OutputNode)) || target.NodeGraph.OutputNode is null);
     }
     }
 
 
     public override OneOf<None, IChangeInfo, List<IChangeInfo>> Apply(Document target, bool firstApply, out bool ignoreInUndo)
     public override OneOf<None, IChangeInfo, List<IChangeInfo>> Apply(Document target, bool firstApply, out bool ignoreInUndo)

+ 1 - 1
src/PixiEditor.ChangeableDocument/Changes/NodeGraph/DeleteNode_Change.cs

@@ -21,7 +21,7 @@ internal class DeleteNode_Change : Change
     {
     {
         Node node = target.FindNode<Node>(NodeId);
         Node node = target.FindNode<Node>(NodeId);
 
 
-        if (node is null)
+        if (node is null || target.NodeGraph.OutputNode == node)
             return false;
             return false;
 
 
         originalConnections = NodeOperations.CreateConnectionsData(node);
         originalConnections = NodeOperations.CreateConnectionsData(node);