hotfix other widget type + remove 'control_after_generate' from convetible widget

This commit is contained in:
MaraScott 2024-05-22 00:44:07 +02:00
parent aede0b91e0
commit f22dac25ef
4 changed files with 12 additions and 5 deletions

View File

@ -1335,7 +1335,7 @@ class KSampler:
{"model": ("MODEL", { "label": "model" }),
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "label": "seed"}),
"steps": ("INT", {"default": 20, "min": 1, "max": 10000, "label": "steps"}),
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "step":0.1, "round": 0.01, "label": "steps"}),
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "step":0.1, "round": 0.01, "label": "cfg"}),
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, { "label": "sampler name" } ),
"scheduler": (comfy.samplers.KSampler.SCHEDULERS, { "label": "scheduler" } ),
"positive": ("CONDITIONING", { "label": "positive" }),

View File

@ -4,6 +4,7 @@ import { applyTextReplacements } from "../../scripts/utils.js";
const CONVERTED_TYPE = "converted-widget";
const VALID_TYPES = ["STRING", "combo", "number", "BOOLEAN"];
const UNVALID_NAMES = ["control_after_generate"];
const CONFIG = Symbol();
const GET_CONFIG = Symbol();
const TARGET = Symbol(); // Used for reroutes to specify the real target widget
@ -18,7 +19,7 @@ function getConfig(widgetName) {
}
function isConvertableWidget(widget, config) {
return (VALID_TYPES.includes(widget.type) || VALID_TYPES.includes(config[0])) && !widget.options?.forceInput;
return (VALID_TYPES.includes(widget.type) || VALID_TYPES.includes(config[0])) && !UNVALID_NAMES.includes(widget.name) && !widget.options?.forceInput;
}
function hideWidget(node, widget, suffix = "") {

View File

@ -3379,7 +3379,7 @@
* @param {Object} extra_info this can be used to have special properties of an output (label, special color, position, etc)
*/
LGraphNode.prototype.addOutput = function(name, type, extra_info) {
var output = { name: name, label: extra_info.label, type: type, links: null };
var output = { name: name, label: extra_info?.label || name, type: type, links: null };
if (extra_info) {
for (var i in extra_info) {
output[i] = extra_info[i];

View File

@ -310,6 +310,8 @@ export const ComfyWidgets = {
let disable_rounding = app.ui.settings.getSettingValue("Comfy.DisableFloatRounding")
if (precision == 0) precision = undefined;
const { val, config } = getNumberDefaults(inputData, 0.5, precision, !disable_rounding);
const inputLabel = inputData[1]?.label || inputName;
Object.assign(config, { label: inputLabel });
return { widget: node.addWidget(widgetType, inputName, val,
function (v) {
if (config.round) {
@ -335,6 +337,8 @@ export const ComfyWidgets = {
if (inputData[1].label_off)
options["off"] = inputData[1].label_off;
}
const inputLabel = inputData[1]?.label || inputName;
Object.assign(options, { label: inputLabel });
return {
widget: node.addWidget(
"toggle",
@ -348,13 +352,14 @@ export const ComfyWidgets = {
STRING(node, inputName, inputData, app) {
const defaultVal = inputData[1].default || "";
const multiline = !!inputData[1].multiline;
inputData[1].placeholder = inputData[1]?.placeholder || inputData[1]?.label || inputName;
const inputLabel = inputData[1]?.label || inputName;
inputData[1].placeholder = inputData[1]?.placeholder || inputLabel;
let res;
if (multiline) {
res = addMultilineWidget(node, inputName, { defaultVal, ...inputData[1] }, app);
} else {
res = { widget: node.addWidget("text", inputName, defaultVal, () => {}, {}) };
res = { widget: node.addWidget("text", inputName, defaultVal, () => {}, { label: inputLabel }) };
}
if(inputData[1].dynamicPrompts != undefined)
@ -369,6 +374,7 @@ export const ComfyWidgets = {
defaultValue = inputData[1].default;
}
const inputLabel = inputData[1]?.label || inputName
inputData[1].label = inputLabel;
const res = { widget: node.addWidget("combo", inputName, defaultValue, () => {}, { values: type, label: inputLabel }) };
if (inputData[1]?.control_after_generate) {
res.widget.linkedWidgets = addValueControlWidgets(node, res.widget, undefined, undefined, inputData);