Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions addons/material_maker/engine/nodes/gen_portal.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var source : MMGenBase.OutputPort

var editable := false
var color : Color = Color.WHITE
var horizontal_label : bool = mm_globals.get_config("aperture_label_position")

func is_editable() -> bool:
return true
Expand Down Expand Up @@ -93,6 +94,7 @@ func _serialize(data : Dictionary) -> Dictionary:
data.io = io
data.port_type = port_type
data.color = MMType.serialize_value(color)
data.horizontal_label = horizontal_label

# remove unused field
data.erase("seed_int")
Expand All @@ -105,3 +107,5 @@ func _deserialize(data : Dictionary) -> void:
port_type = data.port_type
if data.has("color"):
color = MMType.deserialize_value(data.color)
if data.has("horizontal_label"):
horizontal_label = data.horizontal_label
3 changes: 3 additions & 0 deletions material_maker/doc/user_interface_shortcuts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ Graph Editor
+-------------------------------------------------------+----------------------------------------------------+
| :kbd:`F2` | :kbd:`Enter` | :kbd:`LMB` Double-click | Edit selected aperture node |
+-------------------------------------------------------+----------------------------------------------------+
| :kbd:`R` | Toggle aperture node label position |
| | (vertical/horizontal) |
+-------------------------------------------------------+----------------------------------------------------+
| :kbd:`Ctrl/Cmd-G` | Create group from selected nodes |
+-------------------------------------------------------+----------------------------------------------------+
| :kbd:`Alt-S` | Swap inputs on selected node |
Expand Down
5 changes: 3 additions & 2 deletions material_maker/globals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ const DEFAULT_CONFIG : Dictionary = {
ui_use_native_file_dialogs = true,
win_tablet_driver = 0,
dialog_dim_background = true,
node_minimize_button = true,
node_close_button = true,
node_minimize_button = false,
node_close_button = false,
aperture_label_position = 0
}


Expand Down
34 changes: 24 additions & 10 deletions material_maker/nodes/portal/portal.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var is_editing := false

var syncing_io := false

const label_y_offset : float = 35.0

func _ready() -> void:
super._ready()
get_titlebar_hbox().get_children().map(func(n): n.hide())
Expand All @@ -22,7 +24,6 @@ func update_node() -> void:

func _draw() -> void:
const label_font_size : int = 16
const label_y_offset : int = 40

# in/out arc decoration
var offset : float = PI if is_portal_out() else 0.0
Expand All @@ -31,10 +32,16 @@ func _draw() -> void:
# label
var label_pos := size * 0.5
var label_color : Color = generator.color
var label_draw_pos : Vector2 = label_pos
var label_size : Vector2 = LABEL_FONT.get_string_size(
get_link(), HORIZONTAL_ALIGNMENT_CENTER, -1, label_font_size)

var label_size = LABEL_FONT.get_string_size(get_link(), HORIZONTAL_ALIGNMENT_CENTER, -1, label_font_size)
var label_draw_pos := label_pos - Vector2(label_size.x * 0.5, label_y_offset)
if not is_editing:
if generator.horizontal_label:
label_draw_pos += Vector2(31.0 if is_portal_in() else (-label_size.x - 31.0), 5.0)
else:
label_draw_pos -= Vector2(label_size.x * 0.5, label_y_offset)

draw_string_outline(LABEL_FONT, label_draw_pos, get_link(), HORIZONTAL_ALIGNMENT_CENTER, -1, label_font_size, 5, Color.BLACK)
draw_string(LABEL_FONT, label_draw_pos, get_link(), HORIZONTAL_ALIGNMENT_CENTER, -1, label_font_size, label_color)

Expand Down Expand Up @@ -84,14 +91,16 @@ func _input(event : InputEvent) -> void:
match event.get_keycode_with_modifiers():
KEY_F2, KEY_ENTER:
setup_portal_edit()
KEY_R:
generator.horizontal_label = !generator.horizontal_label
queue_redraw()
elif event is InputEventMouseMotion:
const tip : String = "#LMB: Select node, #LMB#LMB/F2/Enter: Rename link, R: Toggle label position"
if Rect2(Vector2.ZERO, size).has_point(get_local_mouse_position()):
mm_globals.set_tip_text(tr("#LMB: Select node, #LMB#LMB/F2/Enter: Rename link"), 1.0, 2)
mm_globals.set_tip_text(tr(tip), 1.0, 2)
elif %Dragger.get_rect().has_point(get_local_mouse_position()):
if is_editing:
mm_globals.set_tip_text(tr("Enter: Rename link, Ctrl/Cmd+Enter: Batch rename links"), 1.0, 2)
else:
mm_globals.set_tip_text(tr("#LMB: Select node, #LMB#LMB: Rename link"), 1.0, 2)
mm_globals.set_tip_text(
tr("Enter: Rename link, Ctrl/Cmd+Enter: Batch rename links" if is_editing else tip))

func _on_dragger_gui_input(event : InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
Expand Down Expand Up @@ -257,14 +266,19 @@ func replace_links(new_link : String, from_link : String) -> void:
p.on_parameter_changed("link", new_link)

func edit_box_set_position(edit : LineEdit) -> void:
const y_offset : int = 61
var y_offset : float = label_y_offset + 21.0
var g : MMGraphEdit = get_parent()
if g == null:
edit.queue_free()
return
edit.scale = Vector2.ONE * g.zoom
edit.position = graph_node_center(self, g)
edit.position -= Vector2(edit.size.x * 0.5 - 0.5, y_offset) * g.zoom

if generator.horizontal_label:
edit.alignment = HORIZONTAL_ALIGNMENT_LEFT if is_portal_in() else HORIZONTAL_ALIGNMENT_RIGHT
edit.position -= Vector2(-21.0 if is_portal_in() else edit.size.x + 21.0, edit.size.y * 0.5) * g.zoom
else:
edit.position -= Vector2(edit.size.x * 0.5 - 0.5, y_offset) * g.zoom

func setup_portal_edit() -> void:
if is_editing:
Expand Down
Loading