diff --git a/objects/o_dialog_add_node/Create_0.gml b/objects/o_dialog_add_node/Create_0.gml index bbbbca3ac..814e293a1 100644 --- a/objects/o_dialog_add_node/Create_0.gml +++ b/objects/o_dialog_add_node/Create_0.gml @@ -155,11 +155,15 @@ event_inherited(); } var _new_node = noone; - var _inputs = 0, _outputs = 0; + var _inputs = ds_list_create(); + var _outputs = ds_list_create(); if(is_instanceof(_node, NodeObject)) { _new_node = _node.build(node_target_x, node_target_y,, _param); - if(!_new_node) return; + if(!_new_node) { + ds_list_destroy(_inputs); ds_list_destroy(_outputs); + return; + } if(category == NODE_CATEGORY && _node.show_in_recent) { array_remove(global.RECENT_NODES, _node.node); @@ -171,24 +175,35 @@ event_inherited(); if(is_instanceof(context, Node_Collection_Inline)) context.addNode(_new_node); - _inputs = _new_node.inputs; - _outputs = _new_node.outputs; - } else if(is_instanceof(_node, NodeAction)) { + for( var i = 0, n = ds_list_size(_new_node.inputs); i < n; i++ ) + ds_list_add(_inputs, _new_node.inputs[| i]); + + if(_new_node.dummy_input) + ds_list_add(_inputs, _new_node.dummy_input); + + for( var i = 0, n = ds_list_size(_new_node.outputs); i < n; i++ ) + ds_list_add(_outputs, _new_node.outputs[| i]); + + } else if(is_instanceof(_node, NodeAction)) { ////////////////////////////////////////// NOT IMPLEMENTED var res = _node.build(node_target_x, node_target_y,, _param); - if(_node.inputNode != noone) - _inputs = res[$ _node.inputNode].inputs; + // if(_node.inputNode != noone) { + // _inputs = res[$ _node.inputNode].inputs; + // } - if(_node.outputNode != noone) - _outputs = res[$ _node.outputNode].outputs; + // if(_node.outputNode != noone) { + // _outputs = res[$ _node.outputNode].outputs; + // } + ds_list_destroy(_inputs); ds_list_destroy(_outputs); return; + } else { var _new_list = APPEND(_node.path); - if(_new_list == noone) return; - - _inputs = ds_list_create(); - _outputs = ds_list_create(); + if(_new_list == noone) { + ds_list_destroy(_inputs); ds_list_destroy(_outputs); + return; + } var tx = 99999; var ty = 99999; @@ -232,13 +247,13 @@ event_inherited(); var _target = _junc_list[| i]; if(!_target.auto_connect) continue; - if(_call_input && node_called.isConnectable(_junc_list[| i]) == 1) { + if(_call_input && node_called.isConnectableStrict(_junc_list[| i]) == 1) { node_called.setFrom(_junc_list[| i]); _new_node.x -= _new_node.w; break; } - if(!_call_input && _junc_list[| i].isConnectable(node_called) == 1) { + if(!_call_input && _junc_list[| i].isConnectableStrict(node_called) == 1) { _junc_list[| i].setFrom(node_called); break; } @@ -250,7 +265,7 @@ event_inherited(); for( var i = 0; i < ds_list_size(_inputs); i++ ) { var _in = _inputs[| i]; - if(_in.auto_connect && _in.isConnectable(from)) { + if(_in.auto_connect && _in.isConnectableStrict(from)) { _in.setFrom(from); break; } @@ -258,7 +273,7 @@ event_inherited(); for( var i = 0; i < ds_list_size(_outputs); i++ ) { var _ot = _outputs[| i]; - if(to.isConnectable(_ot)) { + if(to.isConnectableStrict(_ot)) { to.setFrom(_ot); break; } @@ -280,6 +295,9 @@ event_inherited(); } } } + + ds_list_destroy(_inputs); + ds_list_destroy(_outputs); } catagory_pane = new scrollPane(category_width, dialog_h - ui(66), function(_y, _m) { #region catagory_pane diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index afd61fa1d..407b1aa6b 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -197,15 +197,15 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc managedRenderOrder = false; draw_dummy = false; - input_dummy = nodeValue("Add to group", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0); + dummy_input = nodeValue("Add to group", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0); - input_dummy.setDummy(function() /*=>*/ { var input = nodeBuild("Node_Group_Input", 0, 0, self); return input.inParent; }, + dummy_input.setDummy(function() /*=>*/ { var input = nodeBuild("Node_Group_Input", 0, 0, self); return input.inParent; }, function(_junc) /*=>*/ { _junc.from.destroy() } ); - input_dummy.onSetFrom = function(juncFrom) { - array_remove(juncFrom.value_to, input_dummy); - input_dummy.value_from = noone; + dummy_input.onSetFrom = function(juncFrom) { + array_remove(juncFrom.value_to, dummy_input); + dummy_input.value_from = noone; var input = nodeBuild("Node_Group_Input", 0, 0, self); var _type = juncFrom.type; @@ -345,7 +345,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc return _nodes; } - static getInput = function(_y = 0, junc = noone) { return input_dummy; } + static getInput = function(_y = 0, junc = noone) { return dummy_input; } static preConnect = function() { sortIO(); @@ -515,8 +515,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc var xx = x * _s + _x; var yy = y * _s + _y; - input_dummy.x = xx; - input_dummy.y = _iny; + dummy_input.x = xx; + dummy_input.y = _iny; var _hv = PANEL_GRAPH.pHOVER && PANEL_GRAPH.node_hovering == self && (!PREFERENCES.panel_graph_group_require_shift || key_mod_press(SHIFT)); bg_spr_add = 0.1 + (0.1 * _hv); @@ -545,11 +545,11 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc } static onDrawJunctions = function(_x, _y, _mx, _my, _s) { - input_dummy.visible = false; + dummy_input.visible = false; if(draw_dummy) { - input_dummy.visible = true; - input_dummy.drawJunction(_s, _mx, _my); + dummy_input.visible = true; + dummy_input.drawJunction(_s, _mx, _my); } draw_dummy = false; diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index f0c1803c9..43285451e 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -205,7 +205,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { input_button_length = array_length(input_buttons); }); - dummy_input = noone; #endregion #region --- attributes ---- diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 884ea271d..b3c2e9dbf 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1572,7 +1572,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return self; } #endregion - static isConnectable = function(_valueFrom, checkRecur = true, _log = false) { #region + static isConnectable = function(_valueFrom, checkRecur = true, _log = false) { if(_valueFrom == -1 || _valueFrom == undefined || _valueFrom == noone) { if(_log) noti_warning($"LOAD: Cannot set node connection from {_valueFrom} to {name} of node {node.name}.",, node); @@ -1620,7 +1620,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } return 1; - } #endregion + } + + static isConnectableStrict = function(_valueFrom) { return bool(value_bit(type) & value_bit(_valueFrom.type)); } static triggerSetFrom = function() { node.valueUpdate(index); }