@@ -9,6 +9,8 @@ var is_editing := false
99
1010var syncing_io := false
1111
12+ const label_y_offset : int = 35
13+
1214func _ready () -> void :
1315 super ._ready ()
1416 get_titlebar_hbox ().get_children ().map (func (n ): n .hide ())
@@ -22,7 +24,6 @@ func update_node() -> void:
2224
2325func _draw () -> void :
2426 const label_font_size : int = 16
25- const label_y_offset : int = 40
2627
2728 # in/out arc decoration
2829 var offset : float = PI if is_portal_out () else 0.0
@@ -31,10 +32,16 @@ func _draw() -> void:
3132 # label
3233 var label_pos := size * 0.5
3334 var label_color : Color = generator .color
35+ var label_draw_pos : Vector2 = label_pos
36+ var label_size : Vector2 = LABEL_FONT .get_string_size (
37+ get_link (), HORIZONTAL_ALIGNMENT_CENTER , - 1 , label_font_size )
3438
35- var label_size = LABEL_FONT .get_string_size (get_link (), HORIZONTAL_ALIGNMENT_CENTER , - 1 , label_font_size )
36- var label_draw_pos := label_pos - Vector2 (label_size .x * 0.5 , label_y_offset )
3739 if not is_editing :
40+ if generator .horizontal_label :
41+ label_draw_pos += Vector2 (31.0 , 5.0 ) if is_portal_in () else Vector2 (- label_size .x - 31.0 , 5.0 )
42+ else :
43+ label_draw_pos -= Vector2 (label_size .x * 0.5 , label_y_offset )
44+
3845 draw_string_outline (LABEL_FONT , label_draw_pos , get_link (), HORIZONTAL_ALIGNMENT_CENTER , - 1 , label_font_size , 5 , Color .BLACK )
3946 draw_string (LABEL_FONT , label_draw_pos , get_link (), HORIZONTAL_ALIGNMENT_CENTER , - 1 , label_font_size , label_color )
4047
@@ -84,14 +91,16 @@ func _input(event : InputEvent) -> void:
8491 match event .get_keycode_with_modifiers ():
8592 KEY_F2 , KEY_ENTER :
8693 setup_portal_edit ()
94+ KEY_R :
95+ generator .horizontal_label = ! generator .horizontal_label
96+ queue_redraw ()
8797 elif event is InputEventMouseMotion :
98+ const tip : String = "#LMB: Select node, #LMB#LMB/F2/Enter: Rename link, R: Toggle label position"
8899 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 )
100+ mm_globals .set_tip_text (tr (tip ), 1.0 , 2 )
90101 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 )
102+ mm_globals .set_tip_text (
103+ tr ("Enter: Rename link, Ctrl/Cmd+Enter: Batch rename links" if is_editing else tip ))
95104
96105func _on_dragger_gui_input (event : InputEvent ) -> void :
97106 if event is InputEventMouseButton and event .button_index == MOUSE_BUTTON_LEFT :
@@ -257,14 +266,23 @@ func replace_links(new_link : String, from_link : String) -> void:
257266 p .on_parameter_changed ("link" , new_link )
258267
259268func edit_box_set_position (edit : LineEdit ) -> void :
260- const y_offset : int = 61
269+ var y_offset : int = label_y_offset + 21
261270 var g : MMGraphEdit = get_parent ()
262271 if g == null :
263272 edit .queue_free ()
264273 return
265274 edit .scale = Vector2 .ONE * g .zoom
266275 edit .position = graph_node_center (self , g )
267- edit .position -= Vector2 (edit .size .x * 0.5 - 0.5 , y_offset ) * g .zoom
276+
277+ if generator .horizontal_label :
278+ if is_portal_in ():
279+ edit .alignment = HORIZONTAL_ALIGNMENT_LEFT
280+ edit .position -= Vector2 (- 21 , edit .size .y * 0.5 ) * g .zoom
281+ else :
282+ edit .alignment = HORIZONTAL_ALIGNMENT_RIGHT
283+ edit .position -= Vector2 (edit .size .x + 21 , edit .size .y * 0.5 ) * g .zoom
284+ else :
285+ edit .position -= Vector2 (edit .size .x * 0.5 - 0.5 , y_offset ) * g .zoom
268286
269287func setup_portal_edit () -> void :
270288 if is_editing :
0 commit comments