Made node non collapsable

Fixed color of first input link
This commit is contained in:
pythongosssss 2023-03-16 14:08:11 +00:00
parent 97f3c23036
commit 37b70d7987

View File

@ -34,6 +34,7 @@ app.registerExtension({
let currentNode = this; let currentNode = this;
let updateNodes = []; let updateNodes = [];
let inputType = null; let inputType = null;
let inputNode = null;
while (currentNode) { while (currentNode) {
updateNodes.unshift(currentNode); updateNodes.unshift(currentNode);
const linkId = currentNode.inputs[0].link; const linkId = currentNode.inputs[0].link;
@ -46,6 +47,7 @@ app.registerExtension({
currentNode = node; currentNode = node;
} else { } else {
// We've found the end // We've found the end
inputNode = currentNode;
inputType = node.outputs[link.origin_slot].type; inputType = node.outputs[link.origin_slot].type;
break; break;
} }
@ -93,6 +95,7 @@ app.registerExtension({
} }
const displayType = inputType || outputType || "*"; const displayType = inputType || outputType || "*";
const color = LGraphCanvas.link_type_colors[displayType];
// Update the types of each node // Update the types of each node
for (const node of updateNodes) { for (const node of updateNodes) {
@ -103,11 +106,14 @@ app.registerExtension({
node.outputs[0].name = node.properties.showOutputText ? displayType : ""; node.outputs[0].name = node.properties.showOutputText ? displayType : "";
node.size = node.computeSize(); node.size = node.computeSize();
const color = LGraphCanvas.link_type_colors[displayType];
for (const l of node.outputs[0].links || []) { for (const l of node.outputs[0].links || []) {
app.graph.links[l].color = color; app.graph.links[l].color = color;
} }
} }
if (inputNode) {
app.graph.links[inputNode.inputs[0].link].color = color;
}
}; };
this.clone = function () { this.clone = function () {
@ -173,6 +179,7 @@ app.registerExtension({
Object.assign(RerouteNode, { Object.assign(RerouteNode, {
title_mode: LiteGraph.NO_TITLE, title_mode: LiteGraph.NO_TITLE,
title: "Reroute", title: "Reroute",
collapsable: false,
}) })
); );