Start seed node as -1 when newly created.

This commit is contained in:
rgthree
2023-12-06 21:49:10 -05:00
parent 423d59c311
commit 3d276f3d64
2 changed files with 8 additions and 0 deletions
+5
View File
@@ -15,6 +15,7 @@ import type {
import type { ComfyApp, ComfyObjectInfo, ComfyWidget, ComfyGraphNode } from "./typings/comfy.js";
import { RgthreeBaseNode } from "./base_node.js";
import { rgthree } from "./rgthree.js";
import { addConnectionLayoutSupport } from "./utils.js";
declare const LiteGraph: typeof TLiteGraph;
declare const LGraphNode: typeof TLGraphNode;
@@ -57,12 +58,15 @@ class SeedControl {
}
};
// (this.node as any).widgets_values = (this.node as any).widgets_values || [];
this.node.properties = this.node.properties || {};
// Grab the already available widgets, and remove the built-in control_after_generate
for (const [i, w] of this.node.widgets.entries()) {
if (w.name === "seed") {
this.seedWidget = w as ComfyWidget;
this.seedWidget.value = SPECIAL_SEED_RANDOM;
} else if (w.name === "control_after_generate") {
this.node.widgets.splice(i, 1);
}
@@ -256,6 +260,7 @@ app.registerExtension({
onNodeCreated ? onNodeCreated.apply(this, []) : undefined;
(this as any).seedControl = new SeedControl(this as ComfyGraphNode);
};
addConnectionLayoutSupport(nodeType, app, [["Left", "Right"], ["Right", "Left"]]);
}
},
});
+3
View File
@@ -1,6 +1,7 @@
import { app } from "../../scripts/app.js";
import { ComfyWidgets } from "../../scripts/widgets.js";
import { rgthree } from "./rgthree.js";
import { addConnectionLayoutSupport } from "./utils.js";
const LAST_SEED_BUTTON_LABEL = "♻️ (Use Last Queued Seed)";
const SPECIAL_SEED_RANDOM = -1;
const SPECIAL_SEED_INCREMENT = -2;
@@ -29,6 +30,7 @@ class SeedControl {
for (const [i, w] of this.node.widgets.entries()) {
if (w.name === "seed") {
this.seedWidget = w;
this.seedWidget.value = SPECIAL_SEED_RANDOM;
}
else if (w.name === "control_after_generate") {
this.node.widgets.splice(i, 1);
@@ -162,6 +164,7 @@ app.registerExtension({
onNodeCreated ? onNodeCreated.apply(this, []) : undefined;
this.seedControl = new SeedControl(this);
};
addConnectionLayoutSupport(nodeType, app, [["Left", "Right"], ["Right", "Left"]]);
}
},
});