From 489958d93191c940645e7dbadd99123f1ba93e4a Mon Sep 17 00:00:00 2001 From: Rodz Labs Date: Sat, 1 Jun 2024 16:53:25 +0200 Subject: [PATCH] Updated node editor and error link to open directly the correct tab --- addons/material_maker/engine/nodes/gen_material.gd | 4 ++-- addons/material_maker/engine/nodes/gen_sdf.gd | 2 +- addons/material_maker/engine/nodes/gen_shader.gd | 8 +++++--- material_maker/console.gd | 2 +- material_maker/windows/node_editor/node_editor.gd | 10 ++++++++++ material_maker/windows/node_editor/node_editor.tscn | 6 ++++++ 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/addons/material_maker/engine/nodes/gen_material.gd b/addons/material_maker/engine/nodes/gen_material.gd index 01e086ab2..6c5df5aec 100644 --- a/addons/material_maker/engine/nodes/gen_material.gd +++ b/addons/material_maker/engine/nodes/gen_material.gd @@ -770,8 +770,8 @@ func get_shader_model_for_edit(): edit_shader_model.exports[e].external = true return edit_shader_model -func edit(node) -> void: - do_edit(node, load("res://material_maker/windows/material_editor/material_editor.tscn")) +func edit(node, tab : String = "") -> void: + do_edit(node, load("res://material_maker/windows/material_editor/material_editor.tscn"), tab) func edit_export_targets(node) -> void: do_edit(node, load("res://material_maker/windows/material_editor/export_editor.tscn")) diff --git a/addons/material_maker/engine/nodes/gen_sdf.gd b/addons/material_maker/engine/nodes/gen_sdf.gd index ca276d2ff..2ea916c7d 100644 --- a/addons/material_maker/engine/nodes/gen_sdf.gd +++ b/addons/material_maker/engine/nodes/gen_sdf.gd @@ -186,7 +186,7 @@ func _deserialize(data : Dictionary) -> void: if data.has("sdf_scene"): set_sdf_scene(mm_sdf_builder.deserialize_scene(data.sdf_scene)) -func edit(node) -> void: +func edit(node, tab : String = "") -> void: if scene != null: var edit_window = load("res://material_maker/windows/sdf_builder/sdf_builder.tscn").instantiate() node.get_parent().add_child(edit_window) diff --git a/addons/material_maker/engine/nodes/gen_shader.gd b/addons/material_maker/engine/nodes/gen_shader.gd index 8c8dabc38..951c1decd 100644 --- a/addons/material_maker/engine/nodes/gen_shader.gd +++ b/addons/material_maker/engine/nodes/gen_shader.gd @@ -789,7 +789,7 @@ func _deserialize(data : Dictionary) -> void: func get_shader_model_for_edit(): return shader_model -func do_edit(node, edit_window_scene : PackedScene) -> void: +func do_edit(node, edit_window_scene : PackedScene, tab : String = "") -> void: if shader_model != null: var edit_window = edit_window_scene.instantiate() mm_globals.main_window.add_dialog(edit_window) @@ -797,6 +797,8 @@ func do_edit(node, edit_window_scene : PackedScene) -> void: edit_window.connect("node_changed", Callable(node, "update_shader_generator")) edit_window.connect("popup_hide", Callable(edit_window, "queue_free")) edit_window.popup_centered() + if tab != "": + edit_window.show_tab(tab) -func edit(node) -> void: - do_edit(node, load("res://material_maker/windows/node_editor/node_editor.tscn")) +func edit(node, tab : String = "") -> void: + do_edit(node, load("res://material_maker/windows/node_editor/node_editor.tscn"), tab) diff --git a/material_maker/console.gd b/material_maker/console.gd index f83f80c7f..b15980fb5 100644 --- a/material_maker/console.gd +++ b/material_maker/console.gd @@ -48,7 +48,7 @@ func _on_rich_text_label_meta_clicked(meta): match data.type: "nodesection": generator = instance_from_id(data.nodeid.right(-1).to_int()) - generator.edit(self) + generator.edit(self, data.section) func update_shader_generator(shader_model) -> void: generator.set_shader_model(shader_model) diff --git a/material_maker/windows/node_editor/node_editor.gd b/material_maker/windows/node_editor/node_editor.gd index 471179260..6ce66997d 100644 --- a/material_maker/windows/node_editor/node_editor.gd +++ b/material_maker/windows/node_editor/node_editor.gd @@ -97,6 +97,16 @@ func get_model_data() -> Dictionary: data.outputs.append(o.get_model_data()) return data +func show_tab(tab : String): + if tab.left(6) == "output": + $Sizer/TabBar.current_tab = 1 + elif tab == "main": + $Sizer/TabBar.current_tab = 2 + elif tab == "instance": + $Sizer/TabBar.current_tab = 3 + elif tab == "globals": + $Sizer/TabBar.current_tab = 4 + func _on_AddParameter_pressed() -> void: add_item(parameter_list, ParameterEditor) parameter_list.update_up_down_buttons() diff --git a/material_maker/windows/node_editor/node_editor.tscn b/material_maker/windows/node_editor/node_editor.tscn index c111fff6b..3427695dc 100644 --- a/material_maker/windows/node_editor/node_editor.tscn +++ b/material_maker/windows/node_editor/node_editor.tscn @@ -40,9 +40,11 @@ size_flags_vertical = 3 layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 +current_tab = 0 [node name="General" type="VBoxContainer" parent="Sizer/TabBar"] layout_mode = 2 +metadata/_tab_index = 0 [node name="Name" type="HBoxContainer" parent="Sizer/TabBar/General"] layout_mode = 2 @@ -103,6 +105,7 @@ flat = true [node name="Outputs" type="VBoxContainer" parent="Sizer/TabBar"] visible = false layout_mode = 2 +metadata/_tab_index = 1 [node name="LabelOutputs" type="Label" parent="Sizer/TabBar/Outputs"] layout_mode = 2 @@ -127,15 +130,18 @@ flat = true [node name="Main Code" parent="Sizer/TabBar" instance=ExtResource("5_l5uxq")] visible = false layout_mode = 2 +metadata/_tab_index = 2 [node name="Instance Functions" parent="Sizer/TabBar" instance=ExtResource("5_l5uxq")] visible = false layout_mode = 2 syntax_highlighter = SubResource("CodeHighlighter_g2tsy") +metadata/_tab_index = 3 [node name="Global Functions" type="VBoxContainer" parent="Sizer/TabBar"] visible = false layout_mode = 2 +metadata/_tab_index = 4 [node name="Includes" type="HBoxContainer" parent="Sizer/TabBar/Global Functions"] layout_mode = 2