@@ -9,6 +9,8 @@ var is_editing := false
99
1010var syncing_io := false
1111
12+ var is_navigating_source : bool = false
13+
1214func _ready () -> void :
1315 super ._ready ()
1416 get_titlebar_hbox ().get_children ().map (func (n ): n .hide ())
@@ -76,22 +78,63 @@ func _exit_tree() -> void:
7678 node .reset_slot ()
7779
7880func _gui_input (event : InputEvent ) -> void :
79- if event is InputEventMouseButton and event .double_click :
81+ if event is InputEventMouseButton and event .double_click and not event . alt_pressed :
8082 setup_portal_edit ()
8183
84+ func mouse_in_node_rect () -> bool :
85+ return Rect2 (Vector2 .ZERO , size ).has_point (get_local_mouse_position ())
86+
87+ func mouse_in_label_rect () -> bool :
88+ return % Dragger .get_rect ().has_point (get_local_mouse_position ())
89+
90+ func set_link_hint (enabled : bool ) -> void :
91+ if is_portal_out ():
92+ for node : Control in [self , % Dragger ]:
93+ node .mouse_default_cursor_shape = CURSOR_POINTING_HAND if enabled else CURSOR_ARROW
94+
95+ func jump_to_source () -> void :
96+ if is_navigating_source or is_portal_in ():
97+ return
98+ is_navigating_source = true
99+ set_link_hint (false )
100+ var graph : MMGraphEdit = get_parent ()
101+ if not graph :
102+ return
103+ var source_portal : MMGraphPortal = get_link_source (get_link (), graph )
104+ if source_portal != null :
105+ graph .scroll_offset = (source_portal .position_offset
106+ + 0.5 * source_portal .size ) * graph .zoom - 0.5 * graph .size
107+
108+ var tween : Tween = get_tree ().create_tween ()
109+ tween .tween_property (source_portal , "modulate" , Color (1.5 , 1.5 , 1.5 , 1.0 ), 0.2 ).set_trans (Tween .TRANS_CUBIC )
110+ tween .tween_property (source_portal , "modulate" , Color .WHITE , 0.6 ).set_trans (Tween .TRANS_CUBIC ).set_delay (0.5 )
111+ source_portal .set_deferred ("selected" , true )
112+ await tween .finished
113+ is_navigating_source = false
114+
115+ func set_portal_tip_text () -> void :
116+ const editing_tip : String = "Enter: Rename, Ctrl/Cmd+Enter: Batch rename"
117+ var normal_tip = "%s #LMB: Select node, #LMB#LMB/F2/Enter: Rename"
118+ normal_tip = normal_tip % ["Alt + #LMB: Jump to source, " if is_portal_out () else "" ]
119+ if mouse_in_node_rect ():
120+ mm_globals .set_tip_text (tr (normal_tip ), 1.0 , 2 )
121+ elif mouse_in_label_rect ():
122+ mm_globals .set_tip_text (tr (editing_tip if is_editing else normal_tip ), 1.0 , 2 )
123+
82124func _input (event : InputEvent ) -> void :
83- if event is InputEventKey and event . pressed and selected and not is_editing :
125+ if event is InputEventKey :
84126 match event .get_keycode_with_modifiers ():
85127 KEY_F2 , KEY_ENTER :
86- setup_portal_edit ()
128+ if event .pressed and selected and not is_editing :
129+ setup_portal_edit ()
130+ KEY_ALT :
131+ set_link_hint (event .pressed )
87132 elif event is InputEventMouseMotion :
88- if Rect2 (Vector2 .ZERO , size ).has_point (get_local_mouse_position ()):
89- mm_globals .set_tip_text (tr ("#LMB: Select node, #LMB#LMB/F2/Enter: Rename link" ), 1.0 , 2 )
90- elif % Dragger .get_rect ().has_point (get_local_mouse_position ()):
91- if is_editing :
92- mm_globals .set_tip_text (tr ("Enter: Rename link, Ctrl/Cmd+Enter: Batch rename links" ), 1.0 , 2 )
93- else :
94- mm_globals .set_tip_text (tr ("#LMB: Select node, #LMB#LMB: Rename link" ), 1.0 , 2 )
133+ set_portal_tip_text ()
134+ elif event is InputEventMouseButton and event .button_index == MOUSE_BUTTON_LEFT and event .pressed :
135+ if event .alt_pressed and (mouse_in_node_rect () or mouse_in_label_rect ()):
136+ accept_event ()
137+ jump_to_source ()
95138
96139func _on_dragger_gui_input (event : InputEvent ) -> void :
97140 if event is InputEventMouseButton and event .button_index == MOUSE_BUTTON_LEFT :
0 commit comments