improve: lazy type assign - ImpactCompare, ImpactConditionalBranch, ImpactControlBridge

This commit is contained in:
Dr.Lt.Data
2023-12-10 09:55:34 +09:00
parent 177ec41177
commit f0d3bd9d29
2 changed files with 63 additions and 1 deletions
+62
View File
@@ -213,6 +213,68 @@ app.registerExtension({
impactProgressBadge.addStatusHandler(nodeType);
}
if(nodeData.name == "ImpactControlBridge") {
const onConnectionsChange = nodeType.prototype.onConnectionsChange;
nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
if(!link_info || this.inputs[0].type != '*')
return;
// assign type
let slot_type = '*';
if(type == 2) {
slot_type = link_info.type;
}
else {
const node = app.graph.getNodeById(link_info.origin_id);
slot_type = node.outputs[link_info.origin_slot].type;
}
this.inputs[0].type = slot_type;
this.outputs[0].type = slot_type;
this.outputs[0].label = slot_type;
}
}
if(nodeData.name == "ImpactConditionalBranch") {
const onConnectionsChange = nodeType.prototype.onConnectionsChange;
nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
if(!link_info || this.inputs[0].type != '*')
return;
// assign type
let slot_type = '*';
if(type == 2) {
slot_type = link_info.type;
}
else {
const node = app.graph.getNodeById(link_info.origin_id);
slot_type = node.outputs[link_info.origin_slot].type;
}
this.inputs[0].type = slot_type;
this.inputs[1].type = slot_type;
this.outputs[0].type = slot_type;
this.outputs[0].label = slot_type;
}
}
if(nodeData.name == "ImpactCompare") {
const onConnectionsChange = nodeType.prototype.onConnectionsChange;
nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
if(!link_info || this.inputs[0].type != '*' || type == 2)
return;
// assign type
const node = app.graph.getNodeById(link_info.origin_id);
let slot_type = node.outputs[link_info.origin_slot].type;
this.inputs[0].type = slot_type;
this.inputs[1].type = slot_type;
}
}
if(nodeData.name === 'ImpactInversedSwitch') {
nodeData.output = ['*'];
nodeData.output_is_list = [false];
+1 -1
View File
@@ -2,7 +2,7 @@ import configparser
import os
version = "V4.42"
version = "V4.42.1"
dependency_version = 19