make createWidget subtype aware

-> if (widget.name === "seed") is not necessary anymore
This commit is contained in:
flyingshutter 2023-03-31 19:20:47 +02:00
parent 6cc52b42bb
commit 3fe76483fb

View File

@ -275,9 +275,7 @@ app.registerExtension({
}
*/
this.#createWidget(widget.config, theirNode, widget.name);
if (widget.name === "seed") {
addSeedControlWidget(this, this.widget, "randomize");
}
}
#createWidget(inputData, node, widgetName) {
@ -289,12 +287,25 @@ app.registerExtension({
let widget;
if (type in ComfyWidgets) {
widget = (ComfyWidgets[type](this, widgetName/*"value*"*/, inputData, app) || {}).widget;
// ComfyWidgets allows a subtype of widgets which is defined by "<type>:<widgetName>"
// 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;
} 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, () => { }, {});
}
// if (widget.type === "number") {
// addSeedControlWidget(this, this.widget, "randomize");
// }
}
if (node?.widgets && widget) {