@@ -40,6 +40,8 @@ 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+
4345@onready var drag_cut_cursor = preload ("res://material_maker/icons/knife.png" )
4446var connections_to_cut : Array [Dictionary ]
4547var drag_cut_line : PackedVector2Array
@@ -139,6 +141,7 @@ func _gui_input(event) -> void:
139141 if connections_to_cut .size ():
140142 on_cut_connections (connections_to_cut )
141143 connections_to_cut .clear ()
144+ update_active_connections ()
142145 Input .set_custom_mouse_cursor (null )
143146 drag_cut_line .clear ()
144147 conns .clear ()
@@ -272,6 +275,7 @@ func get_padded_node_rect(graph_node:GraphNode) -> Rect2:
272275func _draw () -> void :
273276 if drag_cut_line .size () > 1 :
274277 draw_polyline (drag_cut_line , get_theme_color ("connection_knife" , "GraphEdit" ), 1.0 )
278+ $ OutlineOverlay .queue_redraw ()
275279
276280
277281# Misc. useful functions
@@ -360,6 +364,7 @@ func on_cut_connections(connections_to_cut : Array):
360364 var from_gen = get_node (str (c .from_node )).generator
361365 var to_gen = get_node (str (c .to_node )).generator
362366 if do_disconnect_node (c .from_node , c .from_port , c .to_node , c .to_port ):
367+ remove_active_connection (c .from_node , c .from_port , c .to_node , c .to_port )
363368 conns .append ({from = from_gen .name ,from_port = c .from_port , to = to_gen .name , to_port = c .to_port })
364369 var undo_actions = [
365370 { type = "add_to_graph" , parent = generator_hier_name , generators = [], connections = conns }
@@ -369,7 +374,6 @@ func on_cut_connections(connections_to_cut : Array):
369374 ]
370375 undoredo .add ("Cut node connections" , undo_actions , redo_actions )
371376
372-
373377func on_disconnect_node (from : String , from_slot : int , to : String , to_slot : int ) -> void :
374378 var from_gen = get_node (from ).generator
375379 var to_gen = get_node (to ).generator
@@ -383,6 +387,7 @@ func on_disconnect_node(from : String, from_slot : int, to : String, to_slot : i
383387 { type = "remove_connections" , parent = generator_hier_name , connections = [connection ] }
384388 ]
385389 undoredo .add ("Disconnect nodes" , undo_actions , redo_actions )
390+ remove_active_connection (from , from_slot , to , to_slot )
386391
387392func on_connections_changed (removed_connections : Array , added_connections : Array ) -> void :
388393 for c in removed_connections :
@@ -950,14 +955,20 @@ func _on_ButtonTransmitsSeed_toggled(button_pressed) -> void:
950955
951956var highlighting_connections : bool = false
952957
958+ func update_active_connections () -> void :
959+ active_connections .clear ()
960+ for c in get_connection_list ():
961+ if get_node (NodePath (c.from_node)).selected or get_node (NodePath (c.to_node)).selected :
962+ active_connections .append (c )
963+ $ OutlineOverlay .queue_redraw ()
964+
953965func highlight_connections () -> void :
954966 if highlighting_connections :
955967 return
956968 highlighting_connections = true
957969 while Input .is_mouse_button_pressed (MOUSE_BUTTON_LEFT ):
958970 await get_tree ().process_frame
959- for c in get_connection_list ():
960- 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 )
971+ update_active_connections ()
961972 highlighting_connections = false
962973
963974func _on_GraphEdit_node_selected (node : GraphElement ) -> void :
@@ -1197,6 +1208,8 @@ func undoredo_command(command : Dictionary) -> void:
11971208 _ :
11981209 print ("Unknown undo/redo command:" )
11991210 print (command )
1211+ await get_tree ().process_frame
1212+ update_active_connections ()
12001213
12011214func undoredo_move_node (node_name : String , old_pos : Vector2 , new_pos : Vector2 ):
12021215 if old_pos == new_pos :
@@ -1673,3 +1686,12 @@ func color_comment_nodes() -> void:
16731686 picker .popup_hide .connect (picker .queue_free )
16741687 picker .popup_hide .connect (undoredo .end_group )
16751688 picker .popup ()
1689+
1690+ func remove_active_connection (from : String , from_slot : int , to : String , to_slot : int ) -> void :
1691+ for c in len (active_connections ):
1692+ var connection : Dictionary = active_connections [c ]
1693+ if (connection .from_node == from and connection .from_port == from_slot
1694+ and connection .to_node == to and connection .to_port == to_slot ):
1695+ active_connections .remove_at (c )
1696+ break
1697+ $ OutlineOverlay .queue_redraw ()
0 commit comments