Skip to content

Commit

Permalink
Updated node editor and error link to open directly the correct tab
Browse files Browse the repository at this point in the history
  • Loading branch information
RodZill4 committed Jun 1, 2024
1 parent 7d12ac6 commit 489958d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
4 changes: 2 additions & 2 deletions addons/material_maker/engine/nodes/gen_material.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
2 changes: 1 addition & 1 deletion addons/material_maker/engine/nodes/gen_sdf.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions addons/material_maker/engine/nodes/gen_shader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -789,14 +789,16 @@ 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)
edit_window.set_model_data(get_shader_model_for_edit())
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)
2 changes: 1 addition & 1 deletion material_maker/console.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions material_maker/windows/node_editor/node_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions material_maker/windows/node_editor/node_editor.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 489958d

Please sign in to comment.