From b4480e0ccce40d31e45ac1d82c3280b5903a1668 Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:25:35 +0300 Subject: [PATCH] Update setgetnodes.js --- web/js/setgetnodes.js | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/web/js/setgetnodes.js b/web/js/setgetnodes.js index 1601445..ac35f23 100644 --- a/web/js/setgetnodes.js +++ b/web/js/setgetnodes.js @@ -43,6 +43,7 @@ app.registerExtension({ currentGetters = null; slotColor = "#FFF"; canvas = app.canvas; + menuEntry = "Show connections"; constructor() { if (!this.properties) { @@ -219,20 +220,49 @@ app.registerExtension({ }) } getExtraMenuOptions(_, options) { - let menuEntry = this.drawConnection ? "Hide connections" : "Show connections"; + this.menuEntry = this.drawConnection ? "Hide connections" : "Show connections"; options.unshift( { - content: menuEntry, + content: this.menuEntry, callback: () => { this.currentGetters = this.findGetters(this.graph); if (this.currentGetters.length == 0) return; let linkType = (this.currentGetters[0].outputs[0].type); this.slotColor = this.canvas.default_connection_color_byType[linkType] - menuEntry = this.drawConnection ? "Hide connections" : "Show connections"; + this.menuEntry = this.drawConnection ? "Hide connections" : "Show connections"; this.drawConnection = !this.drawConnection; this.canvas.setDirty(true, true); }, + has_submenu: true, + submenu: { + title: "Color", + options: [ + { + content: "Highlight", + callback: () => { + this.slotColor = "orange" + this.canvas.setDirty(true, true); + } + } + ], + }, + }, + { + content: "Hide all connections", + callback: () => { + const allGetters = this.graph._nodes.filter(otherNode => otherNode.type === "GetNode" || otherNode.type === "SetNode"); + allGetters.forEach(otherNode => { + otherNode.drawConnection = false; + console.log(otherNode); + }); + + this.menuEntry = "Show connections"; + this.drawConnection = false + this.canvas.setDirty(true, true); + + }, + }, ); // Dynamically add a submenu for all getters