feat: display live boolean values on BinaryIndexDecoder outputs
Returns ui values alongside result so JS onExecuted can update the output slot labels with the actual true/false values after execution, matching the KJNodes style inline display. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-5
@@ -393,11 +393,11 @@ class BinaryIndexDecoder:
|
|||||||
OUTPUT_NODE = False
|
OUTPUT_NODE = False
|
||||||
|
|
||||||
def decode(self, index: int):
|
def decode(self, index: int):
|
||||||
return (
|
f0 = bool((index >> 0) & 1)
|
||||||
bool((index >> 0) & 1),
|
f1 = bool((index >> 1) & 1)
|
||||||
bool((index >> 1) & 1),
|
f2 = bool((index >> 2) & 1)
|
||||||
bool((index >> 2) & 1),
|
return {"ui": {"values": [str(f0).lower(), str(f1).lower(), str(f2).lower()]},
|
||||||
)
|
"result": (f0, f1, f2)}
|
||||||
|
|
||||||
|
|
||||||
# --- Mappings ---
|
# --- Mappings ---
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { app } from "../../scripts/app.js";
|
||||||
|
|
||||||
|
app.registerExtension({
|
||||||
|
name: "json.manager.binary_index_decoder",
|
||||||
|
|
||||||
|
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||||
|
if (nodeData.name !== "BinaryIndexDecoder") return;
|
||||||
|
|
||||||
|
nodeType.prototype.onExecuted = function (output) {
|
||||||
|
if (!output?.values) return;
|
||||||
|
for (let i = 0; i < Math.min(output.values.length, this.outputs.length); i++) {
|
||||||
|
this.outputs[i].label = `${this.outputs[i].name} ${output.values[i]}`;
|
||||||
|
}
|
||||||
|
app.graph?.setDirtyCanvas(true, true);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user