@@ -40,6 +40,9 @@ var undoredo_move_node_selection_changed : bool = true
4040enum ConnectionStyle {DIRECT , BEZIER , ROUNDED , MANHATTAN , DIAGONAL }
4141var connection_line_style : int = ConnectionStyle .BEZIER
4242
43+ var active_connections : Array [Dictionary ]
44+ var should_draw_active_overlays : bool = true
45+
4346@onready var drag_cut_cursor = preload ("res://material_maker/icons/knife.png" )
4447var connections_to_cut : Array [Dictionary ]
4548var drag_cut_line : PackedVector2Array
@@ -140,6 +143,7 @@ func _gui_input(event) -> void:
140143 connections_to_cut .append_array (conns )
141144 if connections_to_cut .size ():
142145 on_cut_connections (connections_to_cut )
146+ update_active_connections ()
143147 connections_to_cut .clear ()
144148 Input .set_custom_mouse_cursor (null )
145149 drag_cut_line .clear ()
@@ -215,7 +219,11 @@ func _gui_input(event) -> void:
215219 if not (event .ctrl_pressed or event .shift_pressed or event .alt_pressed ):
216220 node_popup .position = Vector2i (get_screen_transform ()* get_local_mouse_position ())
217221 node_popup .show_popup ()
222+ elif event .button_index == MOUSE_BUTTON_MIDDLE :
223+ should_draw_active_overlays = not event .is_pressed ()
224+ queue_redraw ()
218225 else :
226+
219227 if event .button_index == MOUSE_BUTTON_LEFT :
220228 if event .double_click :
221229 if get_nodes_under_mouse ().is_empty ():
@@ -305,9 +313,7 @@ func get_padded_node_rect(graph_node:GraphNode) -> Rect2:
305313func _draw () -> void :
306314 if drag_cut_line .size () > 1 :
307315 draw_polyline (drag_cut_line , get_theme_color ("connection_knife" , "GraphEdit" ), 1.0 )
308- if lasso_points .size () > 1 :
309- draw_polyline (lasso_points + PackedVector2Array ([lasso_points [0 ]]),
310- get_theme_color ("lasso_stroke" , "GraphEdit" ), 1.0 )
316+ $ HighlightsOverlay .queue_redraw ()
311317
312318
313319# Misc. useful functions
@@ -428,6 +434,7 @@ func do_disconnect_node(from : String, from_slot : int, to : String, to_slot : i
428434 return false
429435
430436func on_cut_connections (connections_to_cut : Array ):
437+ queue_redraw ()
431438 var generator_hier_name : String = generator .get_hier_name ()
432439 var conns : Array = []
433440 for c in connections_to_cut :
@@ -1027,14 +1034,20 @@ func _on_ButtonTransmitsSeed_toggled(button_pressed) -> void:
10271034
10281035var highlighting_connections : bool = false
10291036
1037+ func update_active_connections () -> void :
1038+ active_connections .clear ()
1039+ for c in get_connection_list ():
1040+ if get_node (NodePath (c.from_node)).selected or get_node (NodePath (c.to_node)).selected :
1041+ active_connections .append (c )
1042+
10301043func highlight_connections () -> void :
10311044 if highlighting_connections :
10321045 return
10331046 highlighting_connections = true
10341047 while Input .is_mouse_button_pressed (MOUSE_BUTTON_LEFT ):
10351048 await get_tree ().process_frame
1036- for c in get_connection_list ():
1037- set_connection_activity ( c . from_node , c . from_port , c . to_node , c . to_port , 1.0 if get_node ( NodePath (c.from_node)). selected or get_node ( NodePath (c.to_node)). selected else 0.0 )
1049+ update_active_connections ()
1050+ queue_redraw ( )
10381051 highlighting_connections = false
10391052
10401053func _on_GraphEdit_node_selected (node : GraphElement ) -> void :
@@ -1274,6 +1287,7 @@ func undoredo_command(command : Dictionary) -> void:
12741287 _ :
12751288 print ("Unknown undo/redo command:" )
12761289 print (command )
1290+ $ HighlightsOverlay .queue_redraw .call_deferred ()
12771291
12781292func undoredo_move_node (node_name : String , old_pos : Vector2 , new_pos : Vector2 ):
12791293 if old_pos == new_pos :
@@ -1750,3 +1764,16 @@ func color_comment_nodes() -> void:
17501764 picker .popup_hide .connect (picker .queue_free )
17511765 picker .popup_hide .connect (undoredo .end_group )
17521766 picker .popup ()
1767+
1768+ func _on_connection_drag_started (_from_node : StringName , _from_port : int , _is_output : bool ) -> void :
1769+ active_connections .clear ()
1770+ should_draw_active_overlays = false
1771+
1772+ func _on_end_node_move () -> void :
1773+ should_draw_active_overlays = true
1774+
1775+ func _on_begin_node_move () -> void :
1776+ should_draw_active_overlays = false
1777+
1778+ func _on_connection_drag_ended () -> void :
1779+ should_draw_active_overlays = true
0 commit comments