Change to just highlight and log

This commit is contained in:
pythongosssss
2024-05-27 10:18:30 +01:00
parent b20a66dd4b
commit 0a59db3de8
+17 -1
View File
@@ -5,6 +5,7 @@ import { app } from "../../../scripts/app.js";
let replaceRegex;
const id = "pysssss.PresetText.Presets";
const MISSING = Symbol();
const getPresets = () => {
let items;
@@ -47,6 +48,19 @@ app.registerExtension({
}
},
});
const drawNodeWidgets = LGraphCanvas.prototype.drawNodeWidgets
LGraphCanvas.prototype.drawNodeWidgets = function(node) {
const c = LiteGraph.WIDGET_BGCOLOR;
try {
if(node[MISSING]) {
LiteGraph.WIDGET_BGCOLOR = "red"
}
return drawNodeWidgets.apply(this, arguments);
} finally {
LiteGraph.WIDGET_BGCOLOR = c;
}
}
},
registerCustomNodes() {
class PresetTextNode {
@@ -153,10 +167,12 @@ app.registerExtension({
if (!w) continue;
const preset = presets.find((p) => p.name === widget.value);
if (!preset) {
this[MISSING] = true;
app.graph.setDirtyCanvas(true, true);
const msg = `Preset text '${widget.value}' not found. Please fix this and queue again.`;
alert(msg);
throw new Error(msg);
}
delete this[MISSING];
w.value = preset.value;
}
}