Ouput convert

This commit is contained in:
shanexi
2024-10-27 09:33:06 +08:00
parent 15c7d7f60c
commit d2cfd99a33
+80 -12
View File
@@ -176,22 +176,40 @@ app.registerExtension({
addMenuHandler(nodeType, function (_, options) {
if (this.widgets) {
let toInput = [];
for (const w of this.widgets) {
// todo: combo need to remove and convert back
// if (w.type === 'combo' && w.name === 'image') {
// toInput.push({
// content: `${w.name} <- Input Image`,
// callback: () => {
// this.convertWidgetToInput(w);
// const node = addNode("ShellAgentPluginInputImage", this, { before: true });
// const dvn = node.widgets.find(w => w.name === 'default_value')
// dvn.value = w.value;
// node.connect(0, this, 0);
// }
// })
// }
if (["customtext"].indexOf(w.type) > -1) {
toInput.push({
content: `${w.name} <- Input Text`,
callback: () => {
this.convertWidgetToInput(w);
const node = addNode("ShellAgentPluginInputText", this, { before: true });
const dvn = node.widgets.find(w => w.name === 'default_value')
dvn.value = w.value;
node.connect(0, this, this.inputs.length - 1);
}
content: w.name,
submenu: {
options: [
{
content: 'Input Text',
callback: () => {
this.convertWidgetToInput(w);
const node = addNode("ShellAgentPluginInputText", this, { before: true });
const dvn = node.widgets.find(w => w.name === 'default_value')
dvn.value = w.value;
node.connect(0, this, this.inputs.length - 1);
}
}
]
},
})
}
if (["number"].indexOf(w.type) > -1) {
toInput.push({
content: w.name,
submenu: {
@@ -221,16 +239,66 @@ app.registerExtension({
})
}
}
if (toInput.length) {
options.unshift({
content: "Convert to ShellAgent",
content: "Convert to ShellAgent (Input)",
submenu: {
options: toInput
}
})
}
}
if (this.outputs) {
let toOutput = [];
for (const o of this.outputs) {
if (o.type === 'IMAGE') {
toOutput.push({
content: o.name,
submenu: {
options: [
{
content: 'Save Image',
callback: () => {
const node = addNode("ShellAgentPluginSaveImage", this);
this.connect(0, node, 0);
}
},
{
content: 'Save Images',
callback: () => {
const node = addNode("ShellAgentPluginSaveImages", this);
this.connect(0, node, 0);
}
}
]
}
})
}
if (o.type === 'STRING') {
toOutput.push({
content: `${o.name} -> Output Text`,
callback: () => {
const node = addNode("ShellAgentPluginOutputText", this);
this.connect(0, node, 0);
}
})
}
}
if (toOutput.length) {
options.unshift({
content: "Convert to ShellAgent (Output)",
submenu: {
options: toOutput
}
})
}
}
})
}
},