From 65a08b4650117f3555ea944d61dfa1e5265b0999 Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Tue, 20 Nov 2018 07:46:51 +0100 Subject: [PATCH] Added an Apply button to the node editor window --- addons/material_maker/nodes/custom/custom.gd | 2 +- .../widgets/node_editor/node_editor.gd | 3 ++ .../widgets/node_editor/node_editor.tscn | 39 ++++++++++++++++--- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/addons/material_maker/nodes/custom/custom.gd b/addons/material_maker/nodes/custom/custom.gd index 8d325a8..8879d2b 100644 --- a/addons/material_maker/nodes/custom/custom.gd +++ b/addons/material_maker/nodes/custom/custom.gd @@ -3,7 +3,7 @@ extends "res://addons/material_maker/nodes/node_generic.gd" func _on_Edit_pressed(): var edit_window = load("res://addons/material_maker/widgets/node_editor/node_editor.tscn").instance() - add_child(edit_window) + get_parent().add_child(edit_window) if model_data != null: edit_window.set_model_data(model_data) edit_window.connect("node_changed", self, "update_node") diff --git a/addons/material_maker/widgets/node_editor/node_editor.gd b/addons/material_maker/widgets/node_editor/node_editor.gd index d5ea398..54c167a 100644 --- a/addons/material_maker/widgets/node_editor/node_editor.gd +++ b/addons/material_maker/widgets/node_editor/node_editor.gd @@ -61,6 +61,9 @@ func _on_AddInput_pressed(): func _on_AddOutput_pressed(): add_item($Sizer/Tabs/Outputs/Outputs/Sizer, OutputEditor) +func _on_Apply_pressed(): + emit_signal("node_changed", get_model_data()) + func _on_OK_pressed(): emit_signal("node_changed", get_model_data()) queue_free() diff --git a/addons/material_maker/widgets/node_editor/node_editor.tscn b/addons/material_maker/widgets/node_editor/node_editor.tscn index 59ddf75..e10dc1e 100644 --- a/addons/material_maker/widgets/node_editor/node_editor.tscn +++ b/addons/material_maker/widgets/node_editor/node_editor.tscn @@ -3,7 +3,7 @@ [ext_resource path="res://addons/material_maker/widgets/node_editor/node_editor.gd" type="Script" id=1] [ext_resource path="res://addons/material_maker/icons/plus.png" type="Texture" id=2] -[node name="NodeEditor" type="WindowDialog"] +[node name="NodeEditor" type="WindowDialog" index="0"] anchor_left = 0.0 anchor_top = 0.0 @@ -482,9 +482,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_left = 344.0 +margin_left = 307.0 margin_top = 378.0 -margin_right = 488.0 +margin_right = 525.0 margin_bottom = 398.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false @@ -495,7 +495,7 @@ size_flags_vertical = 1 alignment = 0 _sections_unfolded = [ "Size Flags" ] -[node name="OK" type="Button" parent="Sizer/HBoxContainer" index="0"] +[node name="Apply" type="Button" parent="Sizer/HBoxContainer" index="0"] anchor_left = 0.0 anchor_top = 0.0 @@ -515,11 +515,11 @@ toggle_mode = false enabled_focus_mode = 2 shortcut = null group = null -text = "OK" +text = "Apply" flat = false align = 1 -[node name="Cancel" type="Button" parent="Sizer/HBoxContainer" index="1"] +[node name="OK" type="Button" parent="Sizer/HBoxContainer" index="1"] anchor_left = 0.0 anchor_top = 0.0 @@ -540,6 +540,31 @@ toggle_mode = false enabled_focus_mode = 2 shortcut = null group = null +text = "OK" +flat = false +align = 1 + +[node name="Cancel" type="Button" parent="Sizer/HBoxContainer" index="2"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 148.0 +margin_right = 218.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 70, 0 ) +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +focus_mode = 2 +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null text = "Cancel" flat = false align = 1 @@ -550,6 +575,8 @@ align = 1 [connection signal="pressed" from="Sizer/Tabs/Outputs/Outputs/Sizer/AddOutput" to="." method="_on_AddOutput_pressed"] +[connection signal="pressed" from="Sizer/HBoxContainer/Apply" to="." method="_on_Apply_pressed"] + [connection signal="pressed" from="Sizer/HBoxContainer/OK" to="." method="_on_OK_pressed"] [connection signal="pressed" from="Sizer/HBoxContainer/Cancel" to="." method="_on_Cancel_pressed"]