From 49efd3f10617445a7da79d006b4387f22693a4ab Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 22 Jan 2022 01:25:50 +0100 Subject: [PATCH] Fix dragging nodes in mat_maker_gd after recent changes. Also implemented undo redo support for node drag events. --- game/addons/mat_maker_gd/editor/mm_graph_node.gd | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/game/addons/mat_maker_gd/editor/mm_graph_node.gd b/game/addons/mat_maker_gd/editor/mm_graph_node.gd index 36732057..ae262027 100644 --- a/game/addons/mat_maker_gd/editor/mm_graph_node.gd +++ b/game/addons/mat_maker_gd/editor/mm_graph_node.gd @@ -17,7 +17,7 @@ var _ignore_change_event : bool = false func _init(): show_close = true - connect("offset_changed", self, "on_offset_changed") + connect("dragged", self, "on_dragged") connect("close_request", self, "on_close_request") func set_editor(editor_node) -> void: @@ -547,9 +547,17 @@ func set_node(material : MMMateial, node : MMNode) -> void: func propagate_node_change() -> void: pass -func on_offset_changed(): +func on_dragged(from : Vector2, to : Vector2): if _node: - _node.set_graph_position(offset) + ignore_changes(true) + #_node.set_graph_position(offset) + + _undo_redo.create_action("MMGD: value changed") + _undo_redo.add_do_method(_node, "set_graph_position", to) + _undo_redo.add_undo_method(_node, "set_graph_position", from) + _undo_redo.commit_action() + + ignore_changes(false) #func on_node_changed(): # if _ignore_change_event: