Merge pull request #2 from flyingshutter/fizzle296

Fizzle296
This commit is contained in:
FizzleDorf 2023-03-31 19:28:58 -04:00 committed by GitHub
commit 5dcbadea0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 20 deletions

View File

@ -266,15 +266,7 @@ app.registerExtension({
this.outputs[0].name = type; this.outputs[0].name = type;
this.outputs[0].widget = widget; this.outputs[0].widget = widget;
//make sure the seedControl is added to the correct Primitive node labelled "seed" this.#createWidget(widget.config, theirNode, widget.name);
if (widget.name === "seed") {
const seed = this.#createWidget(widget.config, theirNode, widget.name);
const seedControl = addSeedControlWidget(this, seed, "randomize");
//this.widgets[0].link = [seedControl];//tried using all different links, not just link
this.title = "seed";
}
else
this.#createWidget(widget.config, theirNode, widget.name);
} }
#createWidget(inputData, node, widgetName) { #createWidget(inputData, node, widgetName) {
@ -286,12 +278,27 @@ app.registerExtension({
let widget; let widget;
if (type in ComfyWidgets) { // ComfyWidgets allows a subtype of widgets which is defined by "<type>:<widgetName>"
widget = (ComfyWidgets[type](this, widgetName/*"value*"*/, inputData, app) || {}).widget; // common example is "INT:seed"
// so let's check for those first
let combinedWidgetType = type + ":" + widgetName;
if (combinedWidgetType in ComfyWidgets) {
// widget = (ComfyWidgets[combinedWidgetType](this, "value", inputData, app) || {}).widget;
widget = (ComfyWidgets[combinedWidgetType](this, widgetName, inputData, app) || {}).widget;
} else { } else {
widget = this.addWidget(type, widgetName /*"value"*/, null, () => { }, {}); // we did not find a subtype, so proceed with "<type>" only
if (type in ComfyWidgets) {
widget = (ComfyWidgets[type](this, widgetName/*"value*"*/, inputData, app) || {}).widget;
} else {
widget = this.addWidget(type, widgetName /*"value"*/, null, () => { }, {});
}
// addSeedControlWidget(node, seed.widget, "randomize");
if (widget.type === "number") {
addSeedControlWidget(this, widget, "fixed seed");
}
} }
if (node?.widgets && widget) { if (node?.widgets && widget) {
@ -301,10 +308,6 @@ app.registerExtension({
} }
} }
if (widget.type === "combo") {
addSeedControlWidget(this, widget, "randomize");
}
// When our value changes, update other widgets to reflect our changes // When our value changes, update other widgets to reflect our changes
// e.g. so LoadImage shows correct image // e.g. so LoadImage shows correct image
const callback = widget.callback; const callback = widget.callback;

View File

@ -11,8 +11,9 @@ function getNumberDefaults(inputData, defaultStep) {
} }
export function addSeedControlWidget(node, targetWidget, defaultValue = "randomize", values) { export function addSeedControlWidget(node, targetWidget, defaultValue = "randomize", values) {
const seedControl = node.addWidget("combo", "seed control after generating", "randomize", function (v) { }, { const seedControl = node.addWidget("combo", "seed control after generating", defaultValue, function (v) { }, {
values: ["fixed seed", "increment", "decrement", "randomize"] values: ["fixed seed", "increment", "decrement", "randomize"],
serialize: false, // Don't include this in prompt.
}) })
seedControl.afterQueued = () => { seedControl.afterQueued = () => {
@ -59,7 +60,7 @@ function seedWidget(node, inputName, inputData) {
const seedControl = addSeedControlWidget(node, seed.widget, "randomize"); const seedControl = addSeedControlWidget(node, seed.widget, "randomize");
seed.widget.linkedWidgets = [seedControl]; seed.widget.linkedWidgets = [seedControl];
return { widget: seed, seedControl }; return seed;
} }
const MultilineSymbol = Symbol(); const MultilineSymbol = Symbol();