From b1b422d79bbc468f710e617f65e564e80417154f Mon Sep 17 00:00:00 2001 From: MakhamDev Date: Mon, 16 Oct 2023 18:54:31 +0700 Subject: [PATCH] - [Graph] Hold ctrl while dragging output junction to disconnect multiple connections at once. --- scripts/node_value/node_value.gml | 65 ++++++++++--------------- scripts/panel_graph/panel_graph.gml | 74 ++++++++++++++++++----------- 2 files changed, 71 insertions(+), 68 deletions(-) diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 2edc4c7ca..373de5c8e 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -2147,28 +2147,20 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru switch(PREF_MAP[? "curve_connection_line"]) { case 0 : - if(ty == LINE_STYLE.solid) - draw_line_width_color(jx, jy, frx, fry, th, c1, c0); - else - draw_line_dashed_color(jx, jy, frx, fry, th, c1, c0, 12 * ss); + if(ty == LINE_STYLE.solid) draw_line_width_color(jx, jy, frx, fry, th, c1, c0); + else draw_line_dashed_color(jx, jy, frx, fry, th, c1, c0, 12 * ss); break; case 1 : - if(downDirection) - draw_line_curve_corner(jx, jy, frx, fry, ss, th, c0, c1); - else - draw_line_curve_color(jx, jy, frx, fry, cx, cy, ss, th, c0, c1, ty); + if(downDirection) draw_line_curve_corner(jx, jy, frx, fry, ss, th, c0, c1); + else draw_line_curve_color(jx, jy, frx, fry, cx, cy, ss, th, c0, c1, ty); break; case 2 : - if(downDirection) - draw_line_elbow_corner(frx, fry, jx, jy, ss, th, c0, c1, corner, fromIndex, toIndex, ty); - else - draw_line_elbow_color(frx, fry, jx, jy, cx, cy, ss, th, c0, c1, corner, fromIndex, toIndex, ty); + if(downDirection) draw_line_elbow_corner(frx, fry, jx, jy, ss, th, c0, c1, corner, fromIndex, toIndex, ty); + else draw_line_elbow_color(frx, fry, jx, jy, cx, cy, ss, th, c0, c1, corner, fromIndex, toIndex, ty); break; case 3 : - if(downDirection) - draw_line_elbow_diag_corner(frx, fry, jx, jy, ss, th, c0, c1, corner, fromIndex, toIndex, ty); - else - draw_line_elbow_diag_color(frx, fry, jx, jy, cx, cy, ss, th, c0, c1, corner, fromIndex, toIndex, ty); + if(downDirection) draw_line_elbow_diag_corner(frx, fry, jx, jy, ss, th, c0, c1, corner, fromIndex, toIndex, ty); + else draw_line_elbow_diag_color(frx, fry, jx, jy, cx, cy, ss, th, c0, c1, corner, fromIndex, toIndex, ty); break; } @@ -2181,52 +2173,43 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru drawCorner |= target.type == VALUE_TYPE.action; var corner = PREF_MAP[? "connection_line_corner"] * ss; - var th = PREF_MAP[? "connection_line_width"] * ss; + var th = max(1, PREF_MAP[? "connection_line_width"] * ss); var col = color_display; draw_set_color(col); + var _action = type == VALUE_TYPE.action; + var _output = connect_type == JUNCTION_CONNECT.output; + switch(PREF_MAP[? "curve_connection_line"]) { case 0 : draw_line_width(x, y, _mx, _my, th); break; case 1 : if(drawCorner) { - if(type == VALUE_TYPE.action) - draw_line_curve_corner(_mx, _my, x, y, ss, th, col, col); - else - draw_line_curve_corner(x, y, _mx, _my, ss, th, col, col); + if(_action) draw_line_curve_corner(_mx, _my, x, y, ss, th, col, col); + else draw_line_curve_corner(x, y, _mx, _my, ss, th, col, col); } else { - if(connect_type == JUNCTION_CONNECT.output) - draw_line_curve_color(_mx, _my, x, y,,, ss, th, col, col); - else - draw_line_curve_color(x, y, _mx, _my,,, ss, th, col, col); + if(_output) draw_line_curve_color(_mx, _my, x, y,,, ss, th, col, col); + else draw_line_curve_color(x, y, _mx, _my,,, ss, th, col, col); } break; case 2 : if(drawCorner) { - if(type == VALUE_TYPE.action) - draw_line_elbow_corner(_mx, _my, x, y, ss, th, col, col, corner); - else - draw_line_elbow_corner(x, y, _mx, _my, ss, th, col, col, corner); + if(_action) draw_line_elbow_corner(_mx, _my, x, y, ss, th, col, col, corner); + else draw_line_elbow_corner(x, y, _mx, _my, ss, th, col, col, corner); } else { - if(connect_type == JUNCTION_CONNECT.output) - draw_line_elbow_color(x, y, _mx, _my,,, ss, th, col, col, corner); - else - draw_line_elbow_color(_mx, _my, x, y,,, ss, th, col, col, corner); + if(_output) draw_line_elbow_color(x, y, _mx, _my,,, ss, th, col, col, corner); + else draw_line_elbow_color(_mx, _my, x, y,,, ss, th, col, col, corner); } break; case 3 : if(drawCorner) { - if(type == VALUE_TYPE.action) - draw_line_elbow_diag_corner(_mx, _my, x, y, ss, th, col, col, corner); - else - draw_line_elbow_diag_corner(x, y, _mx, _my, ss, th, col, col, corner); + if(_action) draw_line_elbow_diag_corner(_mx, _my, x, y, ss, th, col, col, corner); + else draw_line_elbow_diag_corner(x, y, _mx, _my, ss, th, col, col, corner); } else { - if(connect_type == JUNCTION_CONNECT.output) - draw_line_elbow_diag_color(x, y, _mx, _my,,, ss, th, col, col, corner); - else - draw_line_elbow_diag_color(_mx, _my, x, y,,, ss, th, col, col, corner); + if(_output) draw_line_elbow_diag_color(x, y, _mx, _my,,, ss, th, col, col, corner); + else draw_line_elbow_diag_color(_mx, _my, x, y,,, ss, th, col, col, corner); } break; } diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index a377dbc17..2527df11a 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -948,13 +948,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { if(val) { if(key_mod_press(SHIFT)) TOOLTIP = [ val.getValue(), val.type ]; - - if(key_mod_press(CTRL) && val.value_from != noone) { - value_focus = val.value_from; - if(mouse_press(mb_left)) - val.removeFrom(); - } else - value_focus = val; + value_focus = val; } } @@ -1132,6 +1126,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { if(value_focus && value_focus != value_dragging && value_focus.connect_type != value_dragging.connect_type) target = value_focus; + if(key_mod_press(CTRL) && node_hovering != noone) { if(value_dragging.connect_type == JUNCTION_CONNECT.input) { target = node_hovering.getOutput(value_dragging); @@ -1157,7 +1152,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { for( var i = 0, n = array_length(value_draggings); i < n; i++ ) { var _dmx = _mmx; - var _dmy = _mmy + (i - _stIndex) * 24 * graph_s; + var _dmy = value_draggings[i].connect_type == JUNCTION_CONNECT.output? _mmy + (i - _stIndex) * 24 * graph_s : _mmy; value_draggings[i].drawConnectionMouse(_dmx, _dmy, graph_s, target); } @@ -1169,11 +1164,16 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { if(mouse_release(mb_left)) { // CONNECT junction if(target != noone) { - if(value_dragging.connect_type == JUNCTION_CONNECT.input) - value_dragging.setFrom(target); - else if(!_addInput) + if(value_dragging.connect_type == JUNCTION_CONNECT.input) { + if(array_empty(value_draggings)) + value_dragging.setFrom(target); + else { + for( var i = 0, n = array_length(value_draggings); i < n; i++ ) + value_draggings[i].setFrom(target); + } + } else if(!_addInput) { target.setFrom(value_dragging); - else { //addInput + } else { //addInput if(array_empty(value_draggings)) target.node.addInput(value_dragging); else { @@ -1204,24 +1204,44 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { value_draggings = []; if(value_dragging.connect_type == JUNCTION_CONNECT.output) { - var _jlist = ds_priority_create(); - - for( var i = 0, n = ds_list_size(nodes_select_list); i < n; i++ ) { - var _node = nodes_select_list[| i]; - - for( var j = 0, m = ds_list_size(_node.outputs); j < m; j++ ) { - var _junction = _node.outputs[| j]; - if(!_junction.visible) continue; - if(value_bit(_junction.type) & value_bit(value_dragging.type) == 0) continue; + if(key_mod_press(CTRL)) { + var _to = value_dragging.getJunctionTo(); - ds_priority_add(_jlist, _junction, _junction.y); + if(array_length(_to)) { + value_dragging = _to[0]; + value_draggings = array_create(array_length(_to)); + + for( var i = 0, n = array_length(_to); i < n; i++ ) { + value_draggings[i] = _to[i]; + _to[i].removeFrom(); + } } + } else { + var _jlist = ds_priority_create(); + + for( var i = 0, n = ds_list_size(nodes_select_list); i < n; i++ ) { + var _node = nodes_select_list[| i]; + + for( var j = 0, m = ds_list_size(_node.outputs); j < m; j++ ) { + var _junction = _node.outputs[| j]; + if(!_junction.visible) continue; + if(value_bit(_junction.type) & value_bit(value_dragging.type) == 0) continue; + + ds_priority_add(_jlist, _junction, _junction.y); + } + } + + while(!ds_priority_empty(_jlist)) + array_push(value_draggings, ds_priority_delete_min(_jlist)); + + ds_priority_destroy(_jlist); + } + } else { + if(key_mod_press(CTRL) && value_dragging.value_from) { + var fr = value_dragging.value_from; + value_dragging.removeFrom(); + value_dragging = fr; } - - while(!ds_priority_empty(_jlist)) - array_push(value_draggings, ds_priority_delete_min(_jlist)); - - ds_priority_destroy(_jlist); } }