mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 19:21:54 +00:00
fixed bug in getInputNode
This commit is contained in:
@@ -440,15 +440,15 @@ LGraph.prototype.clear = function()
|
|||||||
this.stop();
|
this.stop();
|
||||||
this.status = LGraph.STATUS_STOPPED;
|
this.status = LGraph.STATUS_STOPPED;
|
||||||
|
|
||||||
this.last_node_id = 0;
|
this.last_node_id = 1;
|
||||||
this.last_link_id = 0;
|
this.last_link_id = 1;
|
||||||
|
|
||||||
this._version = -1; //used to detect changes
|
this._version = -1; //used to detect changes
|
||||||
|
|
||||||
//nodes
|
//nodes
|
||||||
this._nodes = [];
|
this._nodes = [];
|
||||||
this._nodes_by_id = {};
|
this._nodes_by_id = {};
|
||||||
this._nodes_in_order = null; //nodes that are executable sorted in execution order
|
this._nodes_in_order = []; //nodes that are executable sorted in execution order
|
||||||
this._nodes_executable = null; //nodes that contain onExecute
|
this._nodes_executable = null; //nodes that contain onExecute
|
||||||
|
|
||||||
//other scene stuff
|
//other scene stuff
|
||||||
@@ -1287,7 +1287,7 @@ LGraph.prototype.changeGlobalInputType = function(name, type)
|
|||||||
if(!this.global_inputs[name])
|
if(!this.global_inputs[name])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(this.global_inputs[name].type == type || this.global_inputs[name].type.toLowerCase() == type.toLowerCase() )
|
if(this.global_inputs[name].type && this.global_inputs[name].type.toLowerCase() == type.toLowerCase() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.global_inputs[name].type = type;
|
this.global_inputs[name].type = type;
|
||||||
@@ -1413,7 +1413,7 @@ LGraph.prototype.changeGlobalOutputType = function(name, type)
|
|||||||
if(!this.global_outputs[name])
|
if(!this.global_outputs[name])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(this.global_outputs[name].type.toLowerCase() == type.toLowerCase() )
|
if(this.global_outputs[name].type && this.global_outputs[name].type.toLowerCase() == type.toLowerCase() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.global_outputs[name].type = type;
|
this.global_outputs[name].type = type;
|
||||||
@@ -2079,7 +2079,7 @@ LGraphNode.prototype.getInputNode = function( slot )
|
|||||||
if(slot >= this.inputs.length)
|
if(slot >= this.inputs.length)
|
||||||
return null;
|
return null;
|
||||||
var input = this.inputs[slot];
|
var input = this.inputs[slot];
|
||||||
if(!input || !input.link)
|
if(!input || input.link === null)
|
||||||
return null;
|
return null;
|
||||||
var link_info = this.graph.links[ input.link ];
|
var link_info = this.graph.links[ input.link ];
|
||||||
if(!link_info)
|
if(!link_info)
|
||||||
@@ -2523,8 +2523,8 @@ LGraphNode.prototype.addWidget = function( type, name, value, callback, options
|
|||||||
options: options || {}
|
options: options || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(options.y)
|
if(w.options.y !== undefined )
|
||||||
w.y = options.y;
|
w.y = w.options.y;
|
||||||
|
|
||||||
if( type == "combo" && !w.options.values )
|
if( type == "combo" && !w.options.values )
|
||||||
throw("LiteGraph addWidget('combo',...) requires to pass values in options: { values:['red','blue'] }");
|
throw("LiteGraph addWidget('combo',...) requires to pass values in options: { values:['red','blue'] }");
|
||||||
@@ -2647,6 +2647,13 @@ LGraphNode.prototype.connect = function( slot, target_node, target_slot )
|
|||||||
{
|
{
|
||||||
target_slot = target_slot || 0;
|
target_slot = target_slot || 0;
|
||||||
|
|
||||||
|
if(!this.graph) //could be connected before adding it to a graph
|
||||||
|
{
|
||||||
|
console.log("Connect: Error, node doesnt belong to any graph. Nodes must be added first to a graph before connecting them."); //due to link ids being associated with graphs
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//seek for the output slot
|
//seek for the output slot
|
||||||
if( slot.constructor === String )
|
if( slot.constructor === String )
|
||||||
{
|
{
|
||||||
@@ -2668,7 +2675,7 @@ LGraphNode.prototype.connect = function( slot, target_node, target_slot )
|
|||||||
if(target_node && target_node.constructor === Number)
|
if(target_node && target_node.constructor === Number)
|
||||||
target_node = this.graph.getNodeById( target_node );
|
target_node = this.graph.getNodeById( target_node );
|
||||||
if(!target_node)
|
if(!target_node)
|
||||||
throw("Node not found");
|
throw("target node is null");
|
||||||
|
|
||||||
//avoid loopback
|
//avoid loopback
|
||||||
if(target_node == this)
|
if(target_node == this)
|
||||||
@@ -3734,6 +3741,7 @@ LGraphCanvas.prototype.processMouseDown = function(e)
|
|||||||
var skip_dragging = false;
|
var skip_dragging = false;
|
||||||
var skip_action = false;
|
var skip_action = false;
|
||||||
var now = LiteGraph.getTime();
|
var now = LiteGraph.getTime();
|
||||||
|
var is_double_click = (now - this.last_mouseclick) < 300;
|
||||||
|
|
||||||
this.canvas_mouse[0] = e.canvasX;
|
this.canvas_mouse[0] = e.canvasX;
|
||||||
this.canvas_mouse[1] = e.canvasY;
|
this.canvas_mouse[1] = e.canvasY;
|
||||||
@@ -3829,7 +3837,7 @@ LGraphCanvas.prototype.processMouseDown = function(e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//double clicking
|
//double clicking
|
||||||
if ((now - this.last_mouseclick) < 300 && this.selected_nodes[ node.id ])
|
if (is_double_click && this.selected_nodes[ node.id ])
|
||||||
{
|
{
|
||||||
//double click node
|
//double click node
|
||||||
if( node.onDblClick)
|
if( node.onDblClick)
|
||||||
@@ -3873,6 +3881,10 @@ LGraphCanvas.prototype.processMouseDown = function(e)
|
|||||||
else
|
else
|
||||||
this.selected_group.recomputeInsideNodes();
|
this.selected_group.recomputeInsideNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( is_double_click )
|
||||||
|
this.showSearchBox( e );
|
||||||
|
|
||||||
clicking_canvas_bg = true;
|
clicking_canvas_bg = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5434,7 +5446,7 @@ LGraphCanvas.prototype.drawNodeShape = function( node, ctx, size, fgcolor, bgcol
|
|||||||
}
|
}
|
||||||
else if (shape == LiteGraph.ROUND_SHAPE || shape == LiteGraph.CARD_SHAPE)
|
else if (shape == LiteGraph.ROUND_SHAPE || shape == LiteGraph.CARD_SHAPE)
|
||||||
{
|
{
|
||||||
ctx.roundRect(0,-title_height,size[0], title_height, this.round_radius, node.flags.collapsed ? this.round_radius : 0);
|
ctx.roundRect(0,-title_height,size[0]+1, title_height, this.round_radius, node.flags.collapsed ? this.round_radius : 0);
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ function MathOperation()
|
|||||||
this.addOutput("=","number");
|
this.addOutput("=","number");
|
||||||
this.addProperty( "A", 1 );
|
this.addProperty( "A", 1 );
|
||||||
this.addProperty( "B", 1 );
|
this.addProperty( "B", 1 );
|
||||||
this.addProperty( "OP", "+", "string", { values: MathOperation.values } );
|
this.addProperty( "OP", "+", "enum", { values: MathOperation.values } );
|
||||||
}
|
}
|
||||||
|
|
||||||
MathOperation.values = ["+","-","*","/","%","^"];
|
MathOperation.values = ["+","-","*","/","%","^"];
|
||||||
@@ -472,6 +472,10 @@ MathOperation.title = "Operation";
|
|||||||
MathOperation.desc = "Easy math operators";
|
MathOperation.desc = "Easy math operators";
|
||||||
MathOperation["@OP"] = { type:"enum", title: "operation", values: MathOperation.values };
|
MathOperation["@OP"] = { type:"enum", title: "operation", values: MathOperation.values };
|
||||||
|
|
||||||
|
MathOperation.prototype.getTitle = function()
|
||||||
|
{
|
||||||
|
return "A " + this.properties.OP + " B";
|
||||||
|
}
|
||||||
|
|
||||||
MathOperation.prototype.setValue = function(v)
|
MathOperation.prototype.setValue = function(v)
|
||||||
{
|
{
|
||||||
@@ -516,9 +520,9 @@ MathOperation.prototype.onDrawBackground = function(ctx)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ctx.font = "40px Arial";
|
ctx.font = "40px Arial";
|
||||||
ctx.fillStyle = "black";
|
ctx.fillStyle = "#CCC";
|
||||||
ctx.textAlign = "center";
|
ctx.textAlign = "center";
|
||||||
ctx.fillText(this.properties.OP, this.size[0] * 0.5, this.size[1] * 0.5 + LiteGraph.NODE_TITLE_HEIGHT );
|
ctx.fillText(this.properties.OP, this.size[0] * 0.5, this.size[1] * 0.35 + LiteGraph.NODE_TITLE_HEIGHT );
|
||||||
ctx.textAlign = "left";
|
ctx.textAlign = "left";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user