Skip to content

Commit

Permalink
5.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgoringe committed Nov 5, 2024
1 parent b5638a5 commit aeb7d8e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 33 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .use_everywhere import SeedEverywhere, AnythingEverywherePrompts

UE_VERSION = "5.0.3"
UE_VERSION = "5.0.4"

NODE_CLASS_MAPPINGS = { "Seed Everywhere": SeedEverywhere }

Expand Down
57 changes: 26 additions & 31 deletions js/use_everywhere.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,6 @@ function inject_outdating_into_object_method(object, methodname, tracetext) {
if (object) inject(object, methodname, tracetext, linkRenderController.mark_link_list_outdated, linkRenderController);
}

/*
In order to capture certain changes to nodes, we create a proxy for them which passes
all property set calls through this handler. It checks the old value, calls the setter,
and then outdates the link list if there has been a change to one of the properties that matter
*/
const nodeHandler = {
set: function(obj, property, value) {
const oldValue = Reflect.get(obj, property, this);
const result = Reflect.set(...arguments);
if (oldValue!=value) {
if (property==='bgcolor') {
if (obj.mode!=4) linkRenderController.mark_link_list_outdated();
}
if (property==='mode') {
linkRenderController.mark_link_list_outdated();
obj.widgets?.forEach((widget) => {widget.onModeChange?.(value)});
}
}
return result;
},
}

app.registerExtension({
name: "cg.customnodes.use_everywhere",

Expand Down Expand Up @@ -118,6 +96,32 @@ app.registerExtension({
},

async nodeCreated(node) {
if (!node._mode) {
node._mode = node.mode
Object.defineProperty(node, "mode", {
get: ( )=>{return node._mode},
set: (v)=>{node._mode = v; node.afterChangeMade?.('mode', v);}
})
}
if (!node._bgcolor) {
node._bgcolor = node._bgcolor
Object.defineProperty(node,"bgcolor", {
get: ( )=>{return node._bgcolor},
set: (v)=>{node._bgcolor = v; node.afterChangeMade?.('bgcolor', v);}
})
}
const acm = node.afterChangeMade
node.afterChangeMade = (p, v) => {
acm?.apply(node,arguments)
if (p==='bgcolor') {
if (node.mode!=4) linkRenderController.mark_link_list_outdated();
}
if (p==='mode') {
linkRenderController.mark_link_list_outdated();
node.widgets?.forEach((widget) => {widget.onModeChange?.(v)});
}
}

node.IS_UE = is_UEnode(node);
if (node.IS_UE) {
node.input_type = [undefined, undefined, undefined]; // for dynamic input types
Expand Down Expand Up @@ -278,15 +282,6 @@ app.registerExtension({
linkRenderController = LinkRenderController.instance(graphAnalyser);

add_autoprompts();
const createNode = LiteGraph.createNode;
LiteGraph.createNode = function() {
const nd = createNode.apply(this,arguments);
if (nd && nd.IS_UE) {
return new Proxy( nd, nodeHandler );
} else {
return nd;
}
}

if (false) add_debug();

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "cg-use-everywhere"
description = "A set of nodes that allow data to be 'broadcast' to some or all unconnected inputs. Greatly reduces link spaghetti."
version = "5.0.3"
version = "5.0.4"
license = { file = "LICENSE" }

[project.urls]
Expand Down

0 comments on commit aeb7d8e

Please sign in to comment.