From ca5f1294bc2f9e7efbfcc2d221f4fe258b0955c5 Mon Sep 17 00:00:00 2001 From: daxcay Date: Wed, 1 May 2024 22:52:05 +0530 Subject: [PATCH] [JDCN_BatchCounterAdvance] Lap Issue Fixed --- classes/JDCN_BatchCounterAdvance.py | 5 +-- web/util.js | 51 ++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/classes/JDCN_BatchCounterAdvance.py b/classes/JDCN_BatchCounterAdvance.py index 142437c..2c8b20d 100644 --- a/classes/JDCN_BatchCounterAdvance.py +++ b/classes/JDCN_BatchCounterAdvance.py @@ -8,7 +8,8 @@ class JDCN_BatchCounterAdvance: return { "required": { - "Lap": ("INT", {"default": 1, "min": 1, "max": 9999}), + "Lap": ("INT", {"default": 0, "min": 0, "max": 9999}), + "LapChange": (['fixed', 'increment', 'decrement'],), "Range": ("INT", {"default": 1, "min": 1, "max": 9999}), "Overlap": ("INT", {"default": 1, "min": 1, "max": 9999}), "Frames": ("INT", {"default": 1, "min": 1, "max": 9999}), @@ -21,7 +22,7 @@ class JDCN_BatchCounterAdvance: CATEGORY = "🔵 JDCN 🔵" - def dobca(self, Lap, Range, Frames, Overlap): + def dobca(self, Lap, LapChange, Range, Frames, Overlap): try: diff --git a/web/util.js b/web/util.js index 9628c4b..043a476 100644 --- a/web/util.js +++ b/web/util.js @@ -5,6 +5,7 @@ const NODE_WIDGET_MAP = { "JDCN_AnyFileSelector": "Index", "JDCN_AnyFileListRandom": "random_seed", "JDCN_BatchCounter": "Lap", + "JDCN_BatchCounterAdvance": "Lap", }; class JDCN_BatchImageLoadFromListControl { @@ -108,6 +109,41 @@ class JDCN_BatchCounterControl { } } +class JDCN_BatchCounterAdvanceControl { + constructor(node, seedWidget, changeWidget) { + for (const [i, w] of node.widgets.entries()) { + switch (w.name) { + case seedWidget: + this.seedWidget = w + break; + case changeWidget: + this.changeWidget = w + break; + } + } + this.seedWidget.afterQueued = () => { + + let change = this.changeWidget.value + + switch (change) { + case 'increment': + this.seedWidget.value = this.seedWidget.value + 1 + break; + case 'decrement': + this.seedWidget.value = this.seedWidget.value - 1 + break; + default: + this.seedWidget.value = this.seedWidget.value + 0 + break; + } + + this.seedWidget.value = this.seedWidget.value < 0 ? 0 : this.seedWidget.value + this.seedWidget.callback(this.seedWidget.value) + + } + } +} + class JDCN_AnyFileListRandomControl { constructor(node, seedWidget, changeWidget) { for (const [i, w] of node.widgets.entries()) { @@ -183,6 +219,18 @@ const JDCN_BatchCounter = { }, }; +const JDCN_BatchCounterAdvance = { + name: "JDCN_BatchCounterAdvance", + async beforeRegisterNodeDef(nodeType, nodeData, _app) { + if (nodeData.name === "JDCN_BatchCounterAdvance") { + nodeType.prototype.onNodeCreated = function () { + this.JDCN_BatchCounterAdvanceControl = new JDCN_BatchCounterAdvanceControl(this, NODE_WIDGET_MAP[nodeData.name], "LapChange"); + this.JDCN_BatchCounterAdvanceControl.seedWidget.value = 1; + }; + } + }, +}; + const JDCN_AnyFileListRandom = { name: "JDCN_AnyFileListRandom", async beforeRegisterNodeDef(nodeType, nodeData, _app) { @@ -198,4 +246,5 @@ const JDCN_AnyFileListRandom = { // app.registerExtension(JDCN_BatchImageLoadFromList); app.registerExtension(JDCN_AnyFileSelector); app.registerExtension(JDCN_AnyFileListRandom); -app.registerExtension(JDCN_BatchCounter); \ No newline at end of file +app.registerExtension(JDCN_BatchCounter); +app.registerExtension(JDCN_BatchCounterAdvance); \ No newline at end of file