From 0a59db3de84db935f927abb03c16870cdeb138f2 Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Mon, 27 May 2024 10:18:30 +0100 Subject: [PATCH] Change to just highlight and log --- web/js/presetText.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/web/js/presetText.js b/web/js/presetText.js index ecb072a..51b9066 100644 --- a/web/js/presetText.js +++ b/web/js/presetText.js @@ -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; } }