Make set/get node automatic coloring optional

This commit is contained in:
kijai 2023-12-11 14:26:43 +02:00
parent 2665f00db9
commit f6354e7850
2 changed files with 20 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import { app } from "../../../scripts/app.js";
var nodeAutoColor = true
// Adds context menu entries, code partly from pyssssscustom-scripts
function addMenuHandler(nodeType, cb) {
@ -114,5 +114,17 @@ app.registerExtension({
LiteGraph.middle_click_slot_add_default_node = value;
},
});
app.ui.settings.addSetting({
id: "KJNodes.nodeAutoColor",
name: "Automatically set node colors",
defaultValue: false,
type: "boolean",
options: (value) => [
{ value: true, text: "On", selected: value === true },
{ value: false, text: "Off", selected: value === false },
],
// onChange: (value) => {
// },
});
}
});

View File

@ -25,6 +25,7 @@ function setColorAndBgColor(type) {
// Handle the default case if needed
}
}
app.registerExtension({
name: "SetNode",
registerCustomNodes() {
@ -97,7 +98,9 @@ app.registerExtension({
this.inputs[0].type = type;
this.inputs[0].name = type;
if (app.ui.settings.getSettingValue("KJNodes.nodeAutoColor")){
setColorAndBgColor.call(this, type);
}
} else {
alert("Error: Set node input undefined. Most likely you're missing custom nodes");
}
@ -269,7 +272,9 @@ app.registerExtension({
this.setType(linkType);
this.title = "Get_" + setter.widgets[0].value;
setColorAndBgColor.call(this, linkType);
if (app.ui.settings.getSettingValue("KJNodes.nodeAutoColor")){
setColorAndBgColor.call(this, type);
}
} else {
this.setType('*');