diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38da6d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +.vscode/ diff --git a/README.md b/README.md index e13f689..e38562d 100644 --- a/README.md +++ b/README.md @@ -1 +1,16 @@ -# ComfyUI-SimpleCounter \ No newline at end of file +# ComfyUI-SimpleCounter +## 概要 +画像の順次読み込みを補助するシンプルなカスタムノードです。
+以下のようにバッチ数を設定して使います。
+
+ +## 動作 +ノードはメニューの「utils」カテゴリーの中にいます。
+バッチ実行中「start」に設定した値からカウントアップしていきます。
+「Queue Prompt」を押すとカウントがリセットされます。
+ +## ライセンスとか +配布や改変等ご自由にどうぞ。
+ +Python側はノードの定義のみ、全部JavaScript側で処理してます。
+(バッチ開始を知る術が無かったので……)
\ No newline at end of file diff --git a/SimpleCounter.py b/SimpleCounter.py new file mode 100644 index 0000000..9d2d2c2 --- /dev/null +++ b/SimpleCounter.py @@ -0,0 +1,28 @@ +class SimpleCounter: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "start": ("INT", {"default": 0, "min": 0, "step": 1}), + "count": ("INT", {"default": 0, "min": 0, "step": 1}), + } + } + + @classmethod + def IS_CHANGED(cls, **kwargs): + return float("NaN") + + RETURN_TYPES = ("INT",) + RETURN_NAMES = ("index",) + FUNCTION = "run" + CATEGORY = "utils" + + def run(self, start, count): + return (count,) + +NODE_CLASS_MAPPINGS = { + "Simple Counter": SimpleCounter +} diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..4fb144e --- /dev/null +++ b/__init__.py @@ -0,0 +1,3 @@ +from .SimpleCounter import NODE_CLASS_MAPPINGS +WEB_DIRECTORY = "./js" +__all__ = ['NODE_CLASS_MAPPINGS','WEB_DIRECTORY'] diff --git a/js/SimpleCounter.js b/js/SimpleCounter.js new file mode 100644 index 0000000..5e400aa --- /dev/null +++ b/js/SimpleCounter.js @@ -0,0 +1,21 @@ +import { app } from "../../scripts/app.js"; +import { api } from "../../scripts/api.js"; + +app.registerExtension({ + name: "SimpleCounter", + async beforeRegisterNodeDef(nodeType, nodeData, app) { + if (nodeData.name === "Simple Counter") { + const origOnNodeCreated = nodeType.prototype.onNodeCreated; + nodeType.prototype.onNodeCreated = function () { + const r = origOnNodeCreated ? origOnNodeCreated.apply(this) : undefined; + const start = this.widgets.find((w) => w.name === "start"); + const count = this.widgets.find((w) => w.name === "count"); + let counter = start.value; + count.type = "converted-widget"; // hidden + count.serializeValue = () => { return counter++; } + api.addEventListener("promptQueued", () => { counter = start.value; }); // reset + return r; + } + } + } +}) diff --git a/sample.jpg b/sample.jpg new file mode 100644 index 0000000..7e8324b Binary files /dev/null and b/sample.jpg differ