diff --git a/js/connections.js b/js/connections.js index d08f114..bbc6259 100644 --- a/js/connections.js +++ b/js/connections.js @@ -75,7 +75,7 @@ export function input_changed(node, slot, connect, link_info) { function post_configure_fixes(node) { if (is_combo_clone(node)) reset_comboclone_on_load(node) - if (is_UEnode(node, false)) fix_inputs(node, "post_configure_fixes") + if (is_UEnode(node)) fix_inputs(node, "post_configure_fixes") } ue_callbacks.register_allnode_callback('afterConfigureGraph', post_configure_fixes) diff --git a/js/tooltip_window.js b/js/tooltip_window.js index 20b40fd..0cc6ea5 100644 --- a/js/tooltip_window.js +++ b/js/tooltip_window.js @@ -1,7 +1,7 @@ import { any_restrictions, describe_restrictions } from "./ue_properties.js"; import { app } from "../../scripts/app.js"; -import { create, is_UEnode } from "./use_everywhere_utilities.js"; +import { create } from "./use_everywhere_utilities.js"; import { edit_window } from "./floating_window.js"; import { settingsCache } from "./use_everywhere_cache.js"; diff --git a/js/ue_properties.js b/js/ue_properties.js index 3dabd01..7204975 100644 --- a/js/ue_properties.js +++ b/js/ue_properties.js @@ -93,7 +93,7 @@ Convert node properties when loaded. export function setup_ue_properties_onload(node) { if (!node.properties?.ue_properties) node.properties.ue_properties = {} if ( !version_at_least(node.properties?.ue_properties?.version, "7.0") ) { - if (is_UEnode(node, false)) { + if (is_UEnode(node)) { // convert a pre 7.0 UE node node.properties.ue_properties = { version : VERSION, @@ -123,7 +123,7 @@ export function setup_ue_properties_onload(node) { } function convert_node_types(node) { - if (!is_UEnode(node, false)) return + if (!is_UEnode(node)) return if (node.type=="Anything Everywhere?") { node.widgets.forEach((w)=>{w.hidden=true}) diff --git a/js/use_everywhere_apply.js b/js/use_everywhere_apply.js index 208e722..9695ffb 100644 --- a/js/use_everywhere_apply.js +++ b/js/use_everywhere_apply.js @@ -1,6 +1,6 @@ import { app } from "../../scripts/app.js"; import { display_name } from "./use_everywhere_classes.js"; -import { is_UEnode, get_real_node, Logger } from "./use_everywhere_utilities.js"; +import { get_real_node, Logger } from "./use_everywhere_utilities.js"; function _convert_to_links(ue, added_links, removed_links) { diff --git a/js/use_everywhere_settings.js b/js/use_everywhere_settings.js index e22f417..6cd10c4 100644 --- a/js/use_everywhere_settings.js +++ b/js/use_everywhere_settings.js @@ -1,10 +1,9 @@ import { app } from "../../scripts/app.js"; import { convert_to_links } from "./use_everywhere_apply.js"; -import { Logger } from "./use_everywhere_utilities.js"; +import { Logger, is_UEnode, node_can_broadcast } from "./use_everywhere_utilities.js"; import { settingsCache } from "./use_everywhere_cache.js"; import { visible_graph } from "./use_everywhere_subgraph_utils.js"; import { edit_restrictions } from "./ue_properties_editor.js"; -import { is_UEnode } from "./use_everywhere_utilities.js"; import { i18ify_settings } from "./i18n.js"; import { VERSION, shared } from "./shared.js"; import { for_all_graphs } from "./recursive_callbacks.js"; @@ -222,10 +221,11 @@ export function add_extra_menu_items(node_or_node_type, ioio) { node_or_node_type.getExtraMenuOptions = function(_, options) { getExtraMenuOptions?.apply(this, arguments); options.push(null); - if (is_UEnode(this, true)) { - node_menu_settings(options, this); - } else { - non_ue_menu_settings(options, this); + if (node_can_broadcast(this)) { + add_restrictions_and_convert(options, this); + } + if (!is_UEnode(node)) { + add_input_and_output_settings(options, node) } options.push(null); ioio(options,'callback',`menu option on ${this.id}`); @@ -234,76 +234,78 @@ export function add_extra_menu_items(node_or_node_type, ioio) { } -function node_menu_settings(options, node) { +function add_restrictions_and_convert(options, node) { options.push( { content: "Edit restrictions", callback: edit_restrictions, } ) - if (is_UEnode(node, true)) { - options.push( - { - content: "Convert to real links", - callback: async () => { - const ues = shared.graphAnalyser.analyse_graph(visible_graph()); - if (ues===null) { - Logger.log_problem("Convert to real links failed to get ues") - alert("Convert failed - press f12 to see the console log") - } else { - convert_to_links(ues, node); - if (is_UEnode(node)) { - visible_graph().remove(node); - } else { - node.properties.ue_convert = false - } + + options.push( + { + content: "Convert to real links", + callback: async () => { + const ues = shared.graphAnalyser.analyse_graph(visible_graph()); + if (ues===null) { + Logger.log_problem("Convert to real links failed to get ues") + alert("Convert failed - press f12 to see the console log") + } else { + convert_to_links(ues, node); + if (is_UEnode(node)) { + visible_graph().remove(node); + } else { + node.properties.ue_convert = false } } } - ) - } - if (!is_UEnode(node, false)) { - non_ue_menu_settings(options, node) - } + } + ) } -function non_ue_menu_settings(options, node) { - options.push( - { - content: node.properties.rejects_ue_links ? "Allow UE Links" : "Reject UE Links", - has_submenu: false, - callback: () => { node.properties.rejects_ue_links = !!!node.properties.rejects_ue_links }, - } - ) - if (node.widgets?.length) { +function add_input_and_output_settings(options, node) { + if (node.inputs?.length) { options.push( { - content: "UE Connectable Inputs", - has_submenu: true, - callback: widget_ue_submenu, - } + content: node.properties.rejects_ue_links ? "Allow UE Links" : "Reject UE Links", + has_submenu: false, + callback: () => { node.properties.rejects_ue_links = !!!node.properties.rejects_ue_links }, + } ) - } - options.push( - { - content: node.properties.ue_convert ? "Remove UE broadcasting" : "Add UE broadcasting", - has_submenu: false, - callback: () => { node.properties.ue_convert = !!!node.properties.ue_convert }, - } - ) - if (node.properties.ue_convert) { - options.push( + + if (!node.properties.rejects_ue_links) { + options.push( { - content: "Broadcasting Outputs", + content: "UE Connectable Inputs", has_submenu: true, - callback: output_ue_submenu, - } + callback: widget_ue_submenu, + } ) + } + } + + if (node.outputs.length) { + options.push( + { + content: node.properties.ue_convert ? "Remove UE broadcasting" : "Add UE broadcasting", + has_submenu: false, + callback: () => { node.properties.ue_convert = !!!node.properties.ue_convert }, + } + ) + if (node.properties.ue_convert) { + options.push( + { + content: "Broadcasting Outputs", + has_submenu: true, + callback: output_ue_submenu, + } + ) + } } } function remove_ue_nodes(graph) { - graph._nodes.filter((node)=>is_UEnode(node, false)).forEach((node)=>{graph.remove(node)}) + graph._nodes.filter((node)=>is_UEnode(node)).forEach((node)=>{graph.remove(node)}) } export function canvas_menu_settings(options) { diff --git a/js/use_everywhere_ui.js b/js/use_everywhere_ui.js index 4cb0fb6..904bd92 100644 --- a/js/use_everywhere_ui.js +++ b/js/use_everywhere_ui.js @@ -1,4 +1,4 @@ -import { Logger, get_real_node, Pausable, is_UEnode } from "./use_everywhere_utilities.js"; +import { Logger, get_real_node, Pausable, node_can_broadcast } from "./use_everywhere_utilities.js"; import { app } from "../../scripts/app.js"; import { settingsCache } from "./use_everywhere_cache.js"; import { in_visible_graph, visible_graph } from "./use_everywhere_subgraph_utils.js"; @@ -78,7 +78,7 @@ export function nodes_not_my_color(node, already_limited_to) { } export function title_bar_additions(node, ctx, title_height) { - if (is_UEnode(node, true)) { + if (node_can_broadcast(node)) { const restricted = any_restrictions(node); const sending = shared.linkRenderController.node_sending_anywhere(node); diff --git a/js/use_everywhere_utilities.js b/js/use_everywhere_utilities.js index 9520e26..18841be 100644 --- a/js/use_everywhere_utilities.js +++ b/js/use_everywhere_utilities.js @@ -266,12 +266,18 @@ export function is_connected(input, treat_bypassed_as_live, graph) { /* Is this a UE node? */ -export function is_UEnode(node_or_nodeType, include_converts) { - if (include_converts && node_or_nodeType.properties?.ue_convert) return true; - const title = node_or_nodeType.type || node_or_nodeType.comfyClass; - return ((title) && (title.startsWith("Anything Everywhere") || title==="Seed Everywhere" || title==="Prompts Everywhere")) +export function is_UEnode(node_or_nodeType) { + const type = node_or_nodeType.type || node_or_nodeType.comfyClass; + return ((type) && (type.startsWith("Anything Everywhere") || type==="Seed Everywhere" || type==="Prompts Everywhere")) } +export function node_can_broadcast(node_or_nodeType) { + if (node_or_nodeType.properties?.ue_convert) return true; + return is_UEnode(node_or_nodeType) +} + + + /* Inject a call into a method on object with name methodname. The injection is added at the end of the existing method (if the method didn't exist, it is created)