This commit is contained in:
@@ -18,11 +18,15 @@ const DISPLAY = {
|
||||
"Send only not within group" : "Send only not within group",
|
||||
"Send only to same color" : "Send only to same color",
|
||||
"Send only to different color" : "Send only to different color",
|
||||
"Exact match of input names" : "Exact match of input names",
|
||||
}
|
||||
|
||||
export const REPEATED_TYPE_OPTIONS = [ i18n("Exact match of input names"), i18n("Match start of input names"), i18n("Match end of input names"), ]
|
||||
|
||||
export const GROUP_RESTRICTION_OPTIONS = [i18n("No restrictions"), i18n("Send only within group"), i18n("Send only not within group")]
|
||||
export const COLOR_RESTRICTION_OPTIONS = [i18n("No restrictions"), i18n("Send only to same color"), i18n("Send only to different color")]
|
||||
|
||||
|
||||
const toTitleCase = (phrase) => {
|
||||
return phrase
|
||||
.toLowerCase()
|
||||
|
||||
@@ -60,6 +60,7 @@ const DEFAULT_PROPERTIES = {
|
||||
input_regex : null,
|
||||
group_regex : null,
|
||||
priority : undefined,
|
||||
repeated_type_rule : 0,
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+20
-17
@@ -2,7 +2,7 @@ import { LinkRenderController } from "./use_everywhere_ui.js";
|
||||
import { i18n, default_regex } from "./i18n.js";
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { default_priority } from "./ue_properties.js";
|
||||
import { GROUP_RESTRICTION_OPTIONS, COLOR_RESTRICTION_OPTIONS } from "./i18n.js";
|
||||
import { GROUP_RESTRICTION_OPTIONS, COLOR_RESTRICTION_OPTIONS, REPEATED_TYPE_OPTIONS } from "./i18n.js";
|
||||
import { edit_window } from "./floating_window.js";
|
||||
|
||||
const REGEXES = ['title', 'input', 'group']
|
||||
@@ -84,26 +84,12 @@ function create_editor_html(node) {
|
||||
const gr_row = add_row(table, i18n("Group"))
|
||||
const gr_select = document.createElement('select')
|
||||
add_cell(gr_row,gr_select)
|
||||
GROUP_RESTRICTION_OPTIONS.forEach((gro, i)=>{
|
||||
const gr_option = document.createElement('option')
|
||||
gr_option.value = `${i}`
|
||||
gr_option.innerText = gro
|
||||
gr_select.appendChild(gr_option)
|
||||
})
|
||||
gr_select.value = `${node.properties.ue_properties.group_restricted || 0}`
|
||||
gr_select.addEventListener('input', ()=>{ changed(node, `group_restricted`, parseInt(gr_select.value))})
|
||||
add_select_options(node, gr_select, GROUP_RESTRICTION_OPTIONS, `group_restricted`)
|
||||
|
||||
const col_row = add_row(table, i18n("Color"))
|
||||
const col_select = document.createElement('select')
|
||||
add_cell(col_row,col_select)
|
||||
COLOR_RESTRICTION_OPTIONS.forEach((cro, i)=>{
|
||||
const col_option = document.createElement('option')
|
||||
col_option.value = `${i}`
|
||||
col_option.innerText = cro
|
||||
col_select.appendChild(col_option)
|
||||
})
|
||||
col_select.value = `${node.properties.ue_properties.color_restricted || 0}`
|
||||
col_select.addEventListener('input', ()=>{ changed(node, `color_restricted`, parseInt(col_select.value))})
|
||||
add_select_options(node, col_select, COLOR_RESTRICTION_OPTIONS, `color_restricted` )
|
||||
|
||||
const priority_row = add_row(table, i18n("Priority"))
|
||||
const priority_edit = document.createElement("input")
|
||||
@@ -116,5 +102,22 @@ function create_editor_html(node) {
|
||||
priority_edit.id = 'priority_value'
|
||||
if (!node.properties.ue_properties.priority) priority_edit.style.opacity = 0.5
|
||||
add_cell(priority_row,priority_edit)
|
||||
|
||||
const repeated_type_row = add_row(table, i18n("Repeated Types"))
|
||||
const repeated_type_select = document.createElement('select')
|
||||
add_cell(repeated_type_row,repeated_type_select)
|
||||
add_select_options(node, repeated_type_select, REPEATED_TYPE_OPTIONS, `repeated_type_rule`)
|
||||
|
||||
return table
|
||||
}
|
||||
|
||||
function add_select_options(node, select, OPTIONS, property) {
|
||||
OPTIONS.forEach((txt, i)=>{
|
||||
const option = document.createElement('option')
|
||||
option.value = `${i}`
|
||||
option.innerText = txt
|
||||
select.appendChild(option)
|
||||
})
|
||||
select.value = `${node.properties.ue_properties[property] || 0}`
|
||||
select.addEventListener('input', ()=>{ changed(node, property, parseInt(select.value))})
|
||||
}
|
||||
+6
-11
@@ -85,7 +85,9 @@ app.registerExtension({
|
||||
|
||||
/*
|
||||
Reject duplicated inputs for now
|
||||
*/
|
||||
|
||||
no, allow them
|
||||
|
||||
if (is_UEnode(nodeType)) {
|
||||
const onConnectInput = nodeType.prototype.onConnectInput
|
||||
nodeType.prototype.onConnectInput = function (index, type) {
|
||||
@@ -94,7 +96,7 @@ app.registerExtension({
|
||||
}
|
||||
return onConnectInput?.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/*
|
||||
@@ -115,13 +117,6 @@ app.registerExtension({
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated;
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
const r = onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined;
|
||||
/*if (!this.properties) this.properties = {}
|
||||
if (this.inputs) {
|
||||
if (!this.widgets) this.widgets = [];
|
||||
for (const input of this.inputs) {
|
||||
if (input.widget && !this.widgets.find((w) => w.name === input.widget.name)) this.widgets.push(input.widget)
|
||||
}
|
||||
}*/
|
||||
Logger.log_detail(`Node ${this.id} created`)
|
||||
setup_ue_properties_oncreate(this)
|
||||
return r;
|
||||
@@ -130,14 +125,14 @@ app.registerExtension({
|
||||
},
|
||||
|
||||
async nodeCreated(node) {
|
||||
// TODO see if we still need this
|
||||
/* TODO see if we still need this
|
||||
if (!node.__mode) {
|
||||
node.__mode = node.mode
|
||||
defineProperty(node, "mode", {
|
||||
get: ( )=>{return node.__mode},
|
||||
set: (v)=>{node.__mode = v; node.afterChangeMade?.('mode', v);}
|
||||
})
|
||||
}
|
||||
}*/
|
||||
|
||||
const original_afterChangeMade = node.afterChangeMade
|
||||
node.afterChangeMade = (p, v) => {
|
||||
|
||||
@@ -79,6 +79,8 @@ class UseEverywhere {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.additional_requirement && !this.additional_requirement(input)) return false
|
||||
|
||||
if (this.output[0] == node.id) return false;
|
||||
if (this.restrict_to && !this.restrict_to.includes(node.id)) return false;
|
||||
const input_label = input.label ? input.label : input.name;
|
||||
@@ -139,7 +141,7 @@ export class UseEverywhereList {
|
||||
return false;
|
||||
}
|
||||
|
||||
add_ue(node, control_node_input_index, type, output, input_regex_override) {
|
||||
add_ue(node, control_node_input_index, type, output, input_regex_override, additional_requirement) {
|
||||
const params = {
|
||||
controller: node,
|
||||
control_node_input_index: control_node_input_index,
|
||||
@@ -150,6 +152,7 @@ export class UseEverywhereList {
|
||||
group_regex: regex_for(node, 'group'),
|
||||
priority: node.properties.ue_properties.priority || default_priority(node),
|
||||
graph: node_graph(node),
|
||||
additional_requirement: additional_requirement,
|
||||
};
|
||||
|
||||
if (node.properties.ue_properties.group_restricted == 1) params.restrict_to = nodes_in_my_group(node);
|
||||
@@ -240,16 +243,49 @@ export class UseEverywhereList {
|
||||
}
|
||||
|
||||
add_ue_from_node(node) {
|
||||
const input_types = new Set()
|
||||
const duplicated_input_types = new Set()
|
||||
for (var i=0; i<node.inputs.length; i++) {
|
||||
const connection = get_connection(node, i);
|
||||
if (connection.link) {
|
||||
if (input_types.has(connection.type)) duplicated_input_types.add(connection.type)
|
||||
input_types.add(connection.type)
|
||||
}
|
||||
}
|
||||
if (node.properties.ue_properties.seed_inputs) {
|
||||
this.add_ue(node, -1, "INT", [node.id.toString(),0], regex_for(node, 'input'));
|
||||
} else {
|
||||
for (var i=0; i<node.inputs.length; i++) {
|
||||
node.inputs.forEach((input, i) => {
|
||||
const connection = get_connection(node, i);
|
||||
if (connection.link) {
|
||||
const input_regex = (node.properties.ue_properties.prompt_regexes) ? prompt_regex(node,i) : undefined
|
||||
this.add_ue(node, i, connection.type, [connection.link.origin_id.toString(), connection.link.origin_slot], input_regex);
|
||||
var additional_requirement = null
|
||||
if (duplicated_input_types.has(connection.type)) {
|
||||
const input_name = input.label || input.name
|
||||
if (node.properties.ue_properties?.repeated_type_rule == 0) { // 0 is exact match of input name
|
||||
additional_requirement = (target_input) => {
|
||||
const target_name = target_input.label || target_input.name
|
||||
return (target_name == input_name)
|
||||
}
|
||||
}
|
||||
if (node.properties.ue_properties?.repeated_type_rule == 1) { // 1 is match start of input name
|
||||
additional_requirement = (target_input) => {
|
||||
const target_name = target_input.label || target_input.name
|
||||
const chars = Math.min( input_name.length, target_name.length )
|
||||
return (target_name.substring(0, chars) == input_name.substring(0, chars))
|
||||
}
|
||||
}
|
||||
if (node.properties.ue_properties?.repeated_type_rule == 2) { // 2 is match end of input name
|
||||
additional_requirement = (target_input) => {
|
||||
const target_name = target_input.label || target_input.name
|
||||
const chars = Math.min( input_name.length, target_name.length )
|
||||
return (target_name.substring(target_name.length - chars) == input_name.substring(input_name.length - chars))
|
||||
}
|
||||
}
|
||||
}
|
||||
this.add_ue(node, i, connection.type, [connection.link.origin_id.toString(), connection.link.origin_slot], input_regex, additional_requirement);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ function indicate_restriction(ctx, title_height) {
|
||||
function update_input_label(node, slot, app) {
|
||||
const type = node.inputs[slot].type
|
||||
if (type) {
|
||||
node.inputs[slot].label = type;
|
||||
node.inputs[slot].label = node.inputs[slot].label || type;
|
||||
node.inputs[slot].color_on = app.canvas.default_connection_color_byType[type];
|
||||
} else {
|
||||
node.inputs[slot].label = "anything";
|
||||
|
||||
Reference in New Issue
Block a user