From 95cf44107416d9049b3ebfb6fc6b2a0fa50fcb1b Mon Sep 17 00:00:00 2001 From: Lubos Lenco Date: Mon, 26 Apr 2021 12:19:48 +0200 Subject: [PATCH] Fix pasting unknown node types --- Sources/arm/ui/UINodes.hx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Sources/arm/ui/UINodes.hx b/Sources/arm/ui/UINodes.hx index 05817b55..34b54f56 100644 --- a/Sources/arm/ui/UINodes.hx +++ b/Sources/arm/ui/UINodes.hx @@ -506,6 +506,33 @@ class UINodes { nodes.nodeCanvas(ui, c); ui.inputEnabled = true; + // Remove nodes with unknown id for this canvas type + if (Zui.isPaste) { + var nodeList = canvasType == CanvasMaterial ? NodesMaterial.list : NodesBrush.list; + var i = 0; + while (i++ < c.nodes.length) { + var canvasNode = c.nodes[i]; + if (Nodes.excludeRemove.indexOf(canvasNode.type) >= 0) { + continue; + } + var found = false; + for (list in nodeList) { + for (listNode in list) { + if (canvasNode.type == listNode.type) { + found = true; + break; + } + } + if (found) break; + } + if (!found) { + nodes.removeNode(canvasNode, c); + nodes.nodesSelected.remove(canvasNode); + i--; + } + } + } + // Recompile material on change if (ui.changed) { recompileMat = (ui.inputDX != 0 || ui.inputDY != 0 || !uichangedLast) && Config.raw.material_live; // Instant preview