From f0d3bd9d29e9d4fe3ea307745094cccff4bc2dd5 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sun, 10 Dec 2023 09:55:34 +0900 Subject: [PATCH] improve: lazy type assign - ImpactCompare, ImpactConditionalBranch, ImpactControlBridge --- js/impact-pack.js | 62 ++++++++++++++++++++++++++++++++++++++++ modules/impact/config.py | 2 +- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/js/impact-pack.js b/js/impact-pack.js index a5bf132..546c042 100644 --- a/js/impact-pack.js +++ b/js/impact-pack.js @@ -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]; diff --git a/modules/impact/config.py b/modules/impact/config.py index 4c7169b..6d0e085 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -2,7 +2,7 @@ import configparser import os -version = "V4.42" +version = "V4.42.1" dependency_version = 19