Workaround category getting cleared after registration, and virtual nodes missing in menu.
This commit is contained in:
+11
-9
@@ -5,8 +5,8 @@ const ALWAYS_MODE = 0;
|
||||
app.registerExtension({
|
||||
name: "rgthree.Muter",
|
||||
registerCustomNodes() {
|
||||
class CustomNode extends LGraphNode {
|
||||
constructor(title = CustomNode.title) {
|
||||
class MuterNode extends LGraphNode {
|
||||
constructor(title = MuterNode.title) {
|
||||
super(title);
|
||||
this.debouncer = 0;
|
||||
this.schedulePromise = null;
|
||||
@@ -94,20 +94,22 @@ app.registerExtension({
|
||||
return size;
|
||||
}
|
||||
}
|
||||
CustomNode.title = "Fast Muter (rgthree)";
|
||||
CustomNode.collapsible = false;
|
||||
CustomNode.category = "rgthree/utils";
|
||||
addConnectionLayoutSupport(CustomNode, app, [['Left'], ['Right']]);
|
||||
addMenuItem(CustomNode, app, {
|
||||
MuterNode.title = "Fast Muter (rgthree)";
|
||||
MuterNode.category = 'rgthree';
|
||||
MuterNode._category = 'rgthree';
|
||||
MuterNode.collapsible = false;
|
||||
addConnectionLayoutSupport(MuterNode, app, [['Left'], ['Right']]);
|
||||
addMenuItem(MuterNode, app, {
|
||||
name: (node) => { var _a; return (`${((_a = node.properties) === null || _a === void 0 ? void 0 : _a['collapse_connections']) ? 'Show' : 'Collapse'} Connections`); },
|
||||
property: 'collapse_connections',
|
||||
prepareValue: (_value, node) => { var _a; return !((_a = node.properties) === null || _a === void 0 ? void 0 : _a['collapse_connections']); },
|
||||
callback: (_node) => { app.graph.setDirtyCanvas(true, true); }
|
||||
});
|
||||
addMenuItem(CustomNode, app, {
|
||||
addMenuItem(MuterNode, app, {
|
||||
name: 'Refresh',
|
||||
callback: (node) => { node.scheduleRefreshMutables(); }
|
||||
});
|
||||
LiteGraph.registerNodeType(CustomNode.title, CustomNode);
|
||||
LiteGraph.registerNodeType(MuterNode.title, MuterNode);
|
||||
MuterNode.category = MuterNode._category;
|
||||
},
|
||||
});
|
||||
|
||||
+3
-1
@@ -55,8 +55,10 @@ app.registerExtension({
|
||||
}
|
||||
}
|
||||
CombinerNode.title = "Node Combiner (rgthree)";
|
||||
CombinerNode.category = "rgthree";
|
||||
CombinerNode.category = 'rgthree';
|
||||
CombinerNode._category = 'rgthree';
|
||||
addConnectionLayoutSupport(CombinerNode, app, [['Left', 'Right'], ['Right', 'Left']]);
|
||||
LiteGraph.registerNodeType(CombinerNode.title, CombinerNode);
|
||||
CombinerNode.category = CombinerNode._category;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -132,6 +132,8 @@ app.registerExtension({
|
||||
}
|
||||
}
|
||||
RerouteNode.title = "Reroute (rgthree)";
|
||||
RerouteNode.category = 'rgthree';
|
||||
RerouteNode._category = 'rgthree';
|
||||
RerouteNode.title_mode = LiteGraph.NO_TITLE;
|
||||
RerouteNode.collapsable = false;
|
||||
RerouteNode.layout_slot_offset = 0;
|
||||
@@ -166,5 +168,6 @@ app.registerExtension({
|
||||
callback: (node) => node.applyNodeSize()
|
||||
});
|
||||
LiteGraph.registerNodeType(RerouteNode.title, RerouteNode);
|
||||
RerouteNode.category = RerouteNode._category;
|
||||
},
|
||||
});
|
||||
|
||||
+12
-8
@@ -14,16 +14,19 @@ const ALWAYS_MODE = 0;
|
||||
app.registerExtension({
|
||||
name: "rgthree.Muter",
|
||||
registerCustomNodes() {
|
||||
class CustomNode extends LGraphNode {
|
||||
class MuterNode extends LGraphNode {
|
||||
|
||||
static override title = "Fast Muter (rgthree)";
|
||||
// `category` seems to get reset at register, so we'll
|
||||
// re-reset it after the register call. ¯\_(ツ)_/¯
|
||||
static category = 'rgthree';
|
||||
static _category = 'rgthree';
|
||||
static collapsible = false;
|
||||
static category = "rgthree/utils";
|
||||
debouncer: number = 0;
|
||||
schedulePromise: Promise<void> | null = null;
|
||||
isVirtualNode = true;
|
||||
|
||||
constructor(title = CustomNode.title) {
|
||||
constructor(title = MuterNode.title) {
|
||||
super(title);
|
||||
this.properties = this.properties || {};
|
||||
this.connections = [];
|
||||
@@ -117,10 +120,10 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
// @ts-ignore: Fix incorrect litegraph typings.
|
||||
addConnectionLayoutSupport(CustomNode, app, [['Left'],['Right']]);
|
||||
addConnectionLayoutSupport(MuterNode, app, [['Left'],['Right']]);
|
||||
|
||||
// @ts-ignore: Fix incorrect litegraph typings.
|
||||
addMenuItem(CustomNode, app, {
|
||||
addMenuItem(MuterNode, app, {
|
||||
name: (node) => (`${node.properties?.['collapse_connections'] ? 'Show' : 'Collapse'} Connections`),
|
||||
property: 'collapse_connections',
|
||||
prepareValue: (_value, node) => !node.properties?.['collapse_connections'],
|
||||
@@ -128,11 +131,12 @@ app.registerExtension({
|
||||
});
|
||||
|
||||
// @ts-ignore: Fix incorrect litegraph typings.
|
||||
addMenuItem(CustomNode, app, {
|
||||
addMenuItem(MuterNode, app, {
|
||||
name: 'Refresh',
|
||||
callback: (node) => {(node as CustomNode).scheduleRefreshMutables()}
|
||||
callback: (node) => {(node as MuterNode).scheduleRefreshMutables()}
|
||||
});
|
||||
|
||||
LiteGraph.registerNodeType(CustomNode.title, CustomNode);
|
||||
LiteGraph.registerNodeType(MuterNode.title, MuterNode);
|
||||
MuterNode.category = MuterNode._category;
|
||||
},
|
||||
});
|
||||
|
||||
+5
-1
@@ -13,7 +13,10 @@ app.registerExtension({
|
||||
class CombinerNode extends LGraphNode {
|
||||
|
||||
static override title = "Node Combiner (rgthree)";
|
||||
static category = "rgthree"
|
||||
// `category` seems to get reset at register, so we'll
|
||||
// re-reset it after the register call. ¯\_(ツ)_/¯
|
||||
static category = 'rgthree';
|
||||
static _category = 'rgthree';
|
||||
|
||||
isVirtualNode = true;
|
||||
|
||||
@@ -76,6 +79,7 @@ app.registerExtension({
|
||||
addConnectionLayoutSupport(CombinerNode, app, [['Left','Right'],['Right','Left']]);
|
||||
|
||||
LiteGraph.registerNodeType(CombinerNode.title, CombinerNode);
|
||||
CombinerNode.category = CombinerNode._category;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ app.registerExtension({
|
||||
class RerouteNode extends LGraphNode {
|
||||
|
||||
static override title = "Reroute (rgthree)";
|
||||
// `category` seems to get reset at register, so we'll
|
||||
// re-reset it after the register call. ¯\_(ツ)_/¯
|
||||
static category = 'rgthree';
|
||||
static _category = 'rgthree';
|
||||
static readonly title_mode = LiteGraph.NO_TITLE;
|
||||
static collapsable = false;
|
||||
static layout_slot_offset = 0;
|
||||
@@ -209,6 +213,7 @@ app.registerExtension({
|
||||
});
|
||||
|
||||
LiteGraph.registerNodeType(RerouteNode.title, RerouteNode);
|
||||
RerouteNode.category = RerouteNode._category;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user