| import { app } from "../../../scripts/app.js"; |
| import { addMenuHandler, addNode } from "./common/utils.js"; |
|
|
| const nodePxOffsets = 80; |
|
|
| function getXYInputNodes() { |
| return [ |
| "XY Input: Seeds++ Batch", |
| "XY Input: Add/Return Noise", |
| "XY Input: Steps", |
| "XY Input: CFG Scale", |
| "XY Input: Sampler/Scheduler", |
| "XY Input: Denoise", |
| "XY Input: VAE", |
| "XY Input: Prompt S/R", |
| "XY Input: Aesthetic Score", |
| "XY Input: Refiner On/Off", |
| "XY Input: Checkpoint", |
| "XY Input: Clip Skip", |
| "XY Input: LoRA", |
| "XY Input: LoRA Plot", |
| "XY Input: LoRA Stacks", |
| "XY Input: Control Net", |
| "XY Input: Control Net Plot", |
| "XY Input: Manual XY Entry" |
| ]; |
| } |
|
|
| function showAddXYInputMenu(type, e, menu, node) { |
| const specialNodes = [ |
| "XY Input: LoRA Plot", |
| "XY Input: Control Net Plot", |
| "XY Input: Manual XY Entry" |
| ]; |
| |
| const values = getXYInputNodes().map(nodeType => { |
| return { |
| content: nodeType, |
| callback: function() { |
| const newNode = addNode(nodeType, node); |
|
|
| |
| const shiftX = -(newNode.size[0] + 35); |
| newNode.pos[0] += shiftX; |
|
|
| if (specialNodes.includes(nodeType)) { |
| newNode.pos[1] += 20; |
| |
| newNode.connect(0, node, 1); |
| newNode.connect(1, node, 2); |
| } else if (type === 'X') { |
| newNode.pos[1] += 20; |
| newNode.connect(0, node, 1); |
| } else { |
| newNode.pos[1] += node.size[1] + 45; |
| newNode.connect(0, node, 2); |
| } |
| } |
| }; |
| }); |
|
|
| new LiteGraph.ContextMenu(values, { |
| event: e, |
| callback: null, |
| parentMenu: menu, |
| node: node |
| }); |
| return false; |
| } |
|
|
| app.registerExtension({ |
| name: "efficiency.addXYinputs", |
| async beforeRegisterNodeDef(nodeType, nodeData, app) { |
| if (nodeData.name === "XY Plot") { |
| addMenuHandler(nodeType, function(insertOption) { |
| insertOption({ |
| content: "โ๏ธ Add ๐ input...", |
| has_submenu: true, |
| callback: (value, options, e, menu, node) => showAddXYInputMenu('X', e, menu, node) |
| }); |
| insertOption({ |
| content: "โ๏ธ Add ๐ input...", |
| has_submenu: true, |
| callback: (value, options, e, menu, node) => showAddXYInputMenu('Y', e, menu, node) |
| }); |
| }); |
| } |
| }, |
| }); |
|
|