mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-01-23 15:24:29 +08:00
Fix condmulticombine
This commit is contained in:
parent
ca73cb8e8e
commit
69422c9ea9
25
nodes.py
25
nodes.py
@ -112,22 +112,27 @@ class PlotNode:
|
||||
class ConditioningMultiCombine:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"conditioning_1": ("CONDITIONING", ),
|
||||
"conditioning_2": ("CONDITIONING", ),
|
||||
}}
|
||||
return {
|
||||
"required": {
|
||||
"inputcount": ("INT", {"default": 2, "min": 2, "max": 20, "step": 1}),
|
||||
"conditioning_1": ("CONDITIONING", ),
|
||||
"conditioning_2": ("CONDITIONING", ),
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("CONDITIONING",)
|
||||
RETURN_TYPES = ("CONDITIONING", "INT")
|
||||
RETURN_NAMES = ("combined", "inputcount")
|
||||
FUNCTION = "combine"
|
||||
CATEGORY = "KJNodes"
|
||||
|
||||
def combine(self, combine, **kwargs):
|
||||
def combine(self, inputcount, **kwargs):
|
||||
cond_combine_node = nodes.ConditioningCombine()
|
||||
cond = kwargs["c1"]
|
||||
for c in range(1, combine):
|
||||
new_cond = kwargs[f"c{c + 1}"]
|
||||
cond = kwargs["conditioning_1"]
|
||||
for c in range(1, inputcount):
|
||||
new_cond = kwargs[f"conditioning_{c + 1}"]
|
||||
cond = cond_combine_node.combine(new_cond, cond)[0]
|
||||
return (cond,)
|
||||
return (cond, inputcount,)
|
||||
|
||||
class ConditioningSetMaskAndCombine:
|
||||
@classmethod
|
||||
|
||||
@ -9,22 +9,24 @@ app.registerExtension({
|
||||
console.log(this.pos[0])
|
||||
}
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
this.inputs_offset = nodeData.name.includes("selective")?1:0
|
||||
//this.inputs_offset = nodeData.name.includes("selective")?1:0
|
||||
this.cond_type = "CONDITIONING"
|
||||
this.addWidget("button", "Add", null, () => {
|
||||
this.inputs_offset = nodeData.name.includes("selective")?1:0
|
||||
this.addWidget("button", "Update inputs", null, () => {
|
||||
if (!this.inputs) {
|
||||
this.inputs = [];
|
||||
}
|
||||
if (this.inputs.length < 20) {
|
||||
const newInputName = `conditioning_${this.inputs.length + 1}`;
|
||||
this.addInput(newInputName, this.cond_type);
|
||||
}
|
||||
});
|
||||
this.addWidget("button", "Remove", null, () => {
|
||||
if (this.inputs.length > 2) {
|
||||
const lastInputIndex = this.inputs.length - 1;
|
||||
this.removeInput(lastInputIndex);
|
||||
}
|
||||
const target_number_of_inputs = this.widgets.find(w => w.name === "inputcount")["value"];
|
||||
if(target_number_of_inputs===this.inputs.length)return; // already set, do nothing
|
||||
|
||||
if(target_number_of_inputs < this.inputs.length){
|
||||
for(let i = this.inputs.length; i>=this.inputs_offset+target_number_of_inputs; i--)
|
||||
this.removeInput(i)
|
||||
}
|
||||
else{
|
||||
for(let i = this.inputs.length+1-this.inputs_offset; i <= target_number_of_inputs; ++i)
|
||||
this.addInput(`conditioning_${i}`, this.cond_type)
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
@ -150,7 +150,6 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
this.clone = function () {
|
||||
console.log("CLONE");
|
||||
const cloned = SetNode.prototype.clone.apply(this);
|
||||
cloned.inputs[0].name = '*';
|
||||
cloned.inputs[0].type = '*';
|
||||
@ -203,9 +202,9 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
onRemoved() {
|
||||
console.log("onRemove");
|
||||
console.log(this);
|
||||
console.log(this.flags);
|
||||
// console.log("onRemove");
|
||||
// console.log(this);
|
||||
// console.log(this.flags);
|
||||
const allGetters = this.graph._nodes.filter((otherNode) => otherNode.type == "GetNode");
|
||||
allGetters.forEach((otherNode) => {
|
||||
if (otherNode.setComboValues) {
|
||||
@ -330,13 +329,13 @@ app.registerExtension({
|
||||
};
|
||||
|
||||
this.validateLinks = function() {
|
||||
console.log("validating links");
|
||||
//console.log("validating links");
|
||||
if (this.outputs[0].type != '*' && this.outputs[0].links) {
|
||||
console.log("in");
|
||||
//console.log("in");
|
||||
this.outputs[0].links.forEach((linkId) => {
|
||||
const link = node.graph.links[linkId];
|
||||
if (link && link.type != this.outputs[0].type && link.type != '*') {
|
||||
console.log("removing link");
|
||||
//console.log("removing link");
|
||||
node.graph.removeLink(linkId)
|
||||
}
|
||||
})
|
||||
@ -369,16 +368,16 @@ app.registerExtension({
|
||||
|
||||
if (setter) {
|
||||
const slot_info = setter.inputs[slot];
|
||||
console.log("slot info");
|
||||
console.log(slot_info);
|
||||
console.log(this.graph.links);
|
||||
//console.log("slot info");
|
||||
//console.log(slot_info);
|
||||
//console.log(this.graph.links);
|
||||
const link = this.graph.links[ slot_info.link ];
|
||||
console.log("link:");
|
||||
console.log(link);
|
||||
//console.log("link:");
|
||||
//console.log(link);
|
||||
return link;
|
||||
} else {
|
||||
console.log(this.widgets[0]);
|
||||
console.log(this.widgets[0].value);
|
||||
//console.log(this.widgets[0]);
|
||||
//console.log(this.widgets[0].value);
|
||||
alert("No SetNode found for " + this.widgets[0].value + "(" + this.type + ")");
|
||||
throw new Error("No SetNode found for " + this.widgets[0].value + "(" + this.type + ")");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user