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
8 changes: 4 additions & 4 deletions addons/material_maker/engine/loader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const REPLACE_MULTILINE_STRINGS_PROCESS_ITEMS : Array = [ "code", "custom", "glo
const REPLACE_MULTILINE_STRINGS_WALK_ITEMS : Array = [ "shader_model", "nodes", "template", "files" ]
const REPLACE_MULTILINE_STRINGS_WALK_CHILDREN : Array = [ "exports" ]

static func replace_multiline_strings_with_arrays(data, walk_children : bool = false):
func replace_multiline_strings_with_arrays(data, walk_children : bool = false):
if data is Dictionary:
for k in data.keys():
if k in REPLACE_MULTILINE_STRINGS_PROCESS_ITEMS:
Expand All @@ -133,7 +133,7 @@ static func replace_multiline_strings_with_arrays(data, walk_children : bool = f
data[i] = replace_multiline_strings_with_arrays(data[i])
return data

static func replace_arrays_with_multiline_strings(data, walk_children : bool = false):
func replace_arrays_with_multiline_strings(data, walk_children : bool = false):
if data is Dictionary:
for k in data.keys():
if k in REPLACE_MULTILINE_STRINGS_PROCESS_ITEMS:
Expand All @@ -148,13 +148,13 @@ static func replace_arrays_with_multiline_strings(data, walk_children : bool = f
data[i] = replace_arrays_with_multiline_strings(data[i])
return data

static func string_to_dict_tree(string_data : String) -> Dictionary:
func string_to_dict_tree(string_data : String) -> Dictionary:
var test_json_conv : JSON = JSON.new()
if test_json_conv.parse(string_data) == OK and test_json_conv.data is Dictionary:
return replace_arrays_with_multiline_strings(test_json_conv.data)
return {}

static func dict_tree_to_string(data : Dictionary) -> String:
func dict_tree_to_string(data : Dictionary) -> String:
return JSON.stringify(replace_multiline_strings_with_arrays(data.duplicate(true)), "\t", true)

func load_gen(filename: String) -> MMGenBase:
Expand Down
2 changes: 1 addition & 1 deletion addons/material_maker/engine/nodes/gen_shader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ func do_edit(node, edit_window_scene : PackedScene, tab : String = "") -> void:
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.connect("close_requested", Callable(edit_window, "queue_free"))
edit_window.get_window().content_scale_factor = mm_globals.main_window.get_window().content_scale_factor
edit_window.get_window().min_size = Vector2(950, 450) * edit_window.get_window().content_scale_factor
edit_window.hide()
Expand Down
4 changes: 2 additions & 2 deletions material_maker/nodes/comment/comment.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var generator : MMGenComment:
if mm_globals.get_config("auto_size_comment"):
resize_to_selection()

var pallette_colors = [
var palette_colors = [
Color("F8B8B3"),
Color("F7FDAF"),
Color("AAF3A2"),
Expand Down Expand Up @@ -139,7 +139,7 @@ func _on_change_color_pressed():
$Popup.get_window().size = $Popup.get_window().get_contents_minimum_size() * content_scale_factor
$Popup.position = get_screen_transform() * get_local_mouse_position()
$Popup.popup()
var corrected_color = pallette_colors.duplicate(true)
var corrected_color = palette_colors.duplicate(true)
if !light_theme:
for i in corrected_color.size():
corrected_color[i] = corrected_color[i].darkened(0.5)
Expand Down
4 changes: 2 additions & 2 deletions material_maker/nodes/reroute/reroute.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func set_generator(g : MMGenBase) -> void:
await set_preview(g.get_parameter("preview"))
update_node()

func _draw_port(slot_index: int, position: Vector2i, left: bool, color: Color) -> void:
draw_circle(position, 5, color, true, -1, true)
func _draw_port(_slot_index: int, _position: Vector2i, _left: bool, color: Color) -> void:
draw_circle(_position, 5, color, true, -1, true)

#func set_theme_type(type : StringName):
#var current_theme : Theme = mm_globals.main_window.theme
Expand Down
4 changes: 2 additions & 2 deletions material_maker/panels/graph_edit/graph_edit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ func do_disconnect_node(from : String, from_slot : int, to : String, to_slot : i
return true
return false

func on_cut_connections(connections_to_cut : Array):
func on_cut_connections(target_connections : Array):
var generator_hier_name : String = generator.get_hier_name()
var conns : Array = []
for c in connections_to_cut:
for c in target_connections:
var from_gen = get_node(str(c.from_node)).generator
var to_gen = get_node(str(c.to_node)).generator
if do_disconnect_node(c.from_node, c.from_port, c.to_node, c.to_port):
Expand Down
4 changes: 2 additions & 2 deletions material_maker/panels/preview_3d/post_process_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func _ready() -> void:
restore_dof_settings()


func _on_glow_blending_item_selected(index: int) -> void:
func _on_glow_blending_item_selected(index: Environment.GlowBlendMode) -> void:
environment.glow_blend_mode = index
mm_globals.set_config(SETTING_PREVIEW_GLOW_BLEND_MODE, index)
GlowBlendMix.visible = index == Environment.GLOW_BLEND_MODE_MIX
Expand Down Expand Up @@ -313,7 +313,7 @@ func show_hide_tonemap_white(tonemapper: int) -> void:
TonemapWhite.show()


func _on_tone_map_item_selected(tonemapper: int) -> void:
func _on_tone_map_item_selected(tonemapper: Environment.ToneMapper) -> void:
environment.tonemap_mode = tonemapper
mm_globals.set_config(SETTING_PREVIEW_TONEMAP, tonemapper)
show_hide_tonemap_white(tonemapper)
Expand Down
20 changes: 10 additions & 10 deletions material_maker/projects_panel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[ext_resource type="Script" uid="uid://bos2fu0tsood3" path="res://material_maker/panels/preview_2d/simple_button.gd" id="7_qnupl"]
[ext_resource type="PackedScene" uid="uid://rflulhsuy3ax" path="res://material_maker/widgets/float_edit/float_edit.tscn" id="8_1w3oe"]
[ext_resource type="Script" uid="uid://bxwor0k6svci8" path="res://material_maker/panels/graph_edit/graph_view_menu.gd" id="8_nl2qi"]
[ext_resource type="ButtonGroup" uid="uid://biv6we3po8wbb" path="res://material_maker/line_style_btn_group.tres" id="10_lbgjg"]
[ext_resource type="ButtonGroup" path="res://material_maker/line_style_btn_group.tres" id="10_lbgjg"]

[sub_resource type="Shader" id="1"]
resource_local_to_scene = true
Expand Down Expand Up @@ -150,7 +150,7 @@ button_mask = 3
script = ExtResource("6_r5hxx")
icon_name = "zoom"

[node name="ZoomeMenuPanel" type="PanelContainer" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu"]
[node name="ZoomMenuPanel" type="PanelContainer" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu"]
top_level = true
layout_mode = 0
offset_left = 283.0
Expand All @@ -160,10 +160,10 @@ offset_bottom = -32.0
theme_type_variation = &"MM_PanelMenuSubPanel"
script = ExtResource("7_lbgjg")

[node name="VBoxContainer" type="HBoxContainer" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel"]
[node name="VBoxContainer" type="HBoxContainer" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel"]
layout_mode = 2

[node name="ZoomOut" type="Button" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel/VBoxContainer"]
[node name="ZoomOut" type="Button" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(25, 25)
layout_mode = 2
Expand All @@ -174,7 +174,7 @@ icon_alignment = 1
script = ExtResource("7_qnupl")
icon_name = "zoom_out"

[node name="ZoomIn" type="Button" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel/VBoxContainer"]
[node name="ZoomIn" type="Button" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(25, 25)
layout_mode = 2
Expand All @@ -185,7 +185,7 @@ icon_alignment = 1
script = ExtResource("7_qnupl")
icon_name = "zoom_in"

[node name="ZoomReset" type="Button" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel/VBoxContainer"]
[node name="ZoomReset" type="Button" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(25, 25)
layout_mode = 2
Expand All @@ -196,7 +196,7 @@ icon_alignment = 1
script = ExtResource("7_qnupl")
icon_name = "zoom_reset"

[node name="ZoomLabel" type="Label" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel/VBoxContainer"]
[node name="ZoomLabel" type="Label" parent="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_type_variation = &"MM_NumberLabel"
Expand Down Expand Up @@ -451,9 +451,9 @@ Scroll to zoom the 3D Preview."
[connection signal="tab_changed" from="Projects/TabBar" to="Projects" method="set_current_tab"]
[connection signal="tab_close_pressed" from="Projects/TabBar" to="Projects" method="close_tab"]
[connection signal="timeout" from="Projects/CrashRecoveryTimer" to="Projects" method="_on_CrashRecoveryTimer_timeout"]
[connection signal="pressed" from="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel/VBoxContainer/ZoomOut" to="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel" method="_on_zoom_out_pressed"]
[connection signal="pressed" from="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel/VBoxContainer/ZoomIn" to="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel" method="_on_zoom_in_pressed"]
[connection signal="pressed" from="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel/VBoxContainer/ZoomReset" to="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomeMenuPanel" method="_on_zoom_reset_pressed"]
[connection signal="pressed" from="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel/VBoxContainer/ZoomOut" to="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel" method="_on_zoom_out_pressed"]
[connection signal="pressed" from="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel/VBoxContainer/ZoomIn" to="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel" method="_on_zoom_in_pressed"]
[connection signal="pressed" from="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel/VBoxContainer/ZoomReset" to="MenuBar/HBox/MainGraphMenuBar/HBox/ZoomMenu/ZoomMenuPanel" method="_on_zoom_reset_pressed"]
[connection signal="toggled" from="MenuBar/HBox/MainGraphMenuBar/HBox/ViewMenu/ViewMenuPanel/VBoxContainer/HBoxContainer/GridVisibility" to="MenuBar/HBox/MainGraphMenuBar/HBox/ViewMenu/ViewMenuPanel" method="_on_grid_visibility_toggled"]
[connection signal="toggled" from="MenuBar/HBox/MainGraphMenuBar/HBox/ViewMenu/ViewMenuPanel/VBoxContainer/HBoxContainer/GridSnapping" to="MenuBar/HBox/MainGraphMenuBar/HBox/ViewMenu/ViewMenuPanel" method="_on_grid_snapping_toggled"]
[connection signal="value_changed" from="MenuBar/HBox/MainGraphMenuBar/HBox/ViewMenu/ViewMenuPanel/VBoxContainer/HBoxContainer/GridSize" to="MenuBar/HBox/MainGraphMenuBar/HBox/ViewMenu/ViewMenuPanel" method="_on_grid_size_value_changed"]
Expand Down
1 change: 0 additions & 1 deletion material_maker/windows/accept_dialog/accept_dialog.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[ext_resource type="Script" uid="uid://cadawccuorvkf" path="res://material_maker/windows/accept_dialog/accept_dialog.gd" id="1"]

[node name="AcceptDialog" type="AcceptDialog"]
always_on_top = true
script = ExtResource("1")

[connection signal="canceled" from="." to="." method="_on_AcceptDialog_popup_hide"]
Expand Down
5 changes: 3 additions & 2 deletions material_maker/windows/add_node_popup/add_node_popup.gd
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ func update_list(filter_text : String = "") -> void:

idx += 1

%List.select(0)
if %List.item_count:
%List.select(0)
%List.ensure_current_is_visible()

func _unhandled_input(event) -> void:
Expand All @@ -206,7 +207,7 @@ func _unhandled_input(event) -> void:


func _on_filter_gui_input(event: InputEvent) -> void:
if event.is_action("ui_down"):
if event.is_action("ui_down") and %List.item_count:
%List.grab_focus()
%List.select(1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func _ready():

hide()
popup_centered()
_on_ViewportContainer_resized()
connect_controls()
environment_manager.environment_updated.connect(self.on_environment_updated)
environment_manager.name_updated.connect(self.on_name_updated)
Expand Down Expand Up @@ -79,9 +78,6 @@ func read_environment_list(select : int = 0):
environment_list.select(select)
set_current_environment(select)

func _on_ViewportContainer_resized():
$Main/HSplitContainer/SubViewportContainer/SubViewport.size = $Main/HSplitContainer/SubViewportContainer.size

func _on_name_text_entered(new_text : String):
environment_list.set_item_text(current_environment, new_text)

Expand Down Expand Up @@ -145,7 +141,7 @@ func _on_Environments_gui_input(event):
if environment_list.is_selected(index) and ! environment_manager.is_read_only(index):
mm_globals.popup_menu(context_menu, $Main/HSplitContainer/Environments)

func _on_ContextMenu_id_pressed(id):
func _on_ContextMenu_id_pressed(_id):
var index = environment_list.get_selected_items()[0]
environment_manager.delete_environment(index)
environment_list.remove_item(index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ text = "Close"
[connection signal="item_selected" from="Main/HSplitContainer/Environments" to="." method="_on_Environments_item_selected"]
[connection signal="id_pressed" from="Main/HSplitContainer/Environments/ContextMenu" to="." method="_on_ContextMenu_id_pressed"]
[connection signal="gui_input" from="Main/HSplitContainer/SubViewportContainer" to="." method="_on_ViewportContainer_gui_input"]
[connection signal="resized" from="Main/HSplitContainer/SubViewportContainer" to="." method="_on_ViewportContainer_resized"]
[connection signal="pressed" from="Main/Buttons/Download" to="." method="_on_Download_pressed"]
[connection signal="pressed" from="Main/Buttons/Share" to="." method="_on_Share_pressed"]
[connection signal="pressed" from="Main/Buttons/Close" to="." method="queue_free"]
1 change: 0 additions & 1 deletion material_maker/windows/sdf_builder/preview_3d.gd
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func on_dep_update_value(_buffer_name, parameter_name, value) -> bool:

func _on_Preview3D_resized():
if viewport != null:
viewport.size = size
update_viewport()

func navigation_input(ev) -> bool:
Expand Down
12 changes: 6 additions & 6 deletions material_maker/windows/sdf_builder/sdf_builder.gd
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ func update_node_parameters_grid():
if button != null:
button.disabled = true

func node_parameter_exists_already(name : String, param_index : int) -> bool:
func node_parameter_exists_already(_name : String, param_index : int) -> bool:
for pi in range($GenSDF.node_parameters.size()):
if pi != param_index and $GenSDF.node_parameters[pi].name == name:
if pi != param_index and $GenSDF.node_parameters[pi].name == _name:
return true
return false

Expand Down Expand Up @@ -657,11 +657,11 @@ func duplicate_item(item : TreeItem, parent : TreeItem, index : int = -1):
duplicate_item(c, new_item)
return new_item

func move_item(item, dest, position):
func move_item(item, dest, _position):
var source_transform : Transform3D = get_item_transform_3d(item)
var dest_transform : Transform3D = get_item_transform_3d(dest)
var new_transform : Transform3D = dest_transform.affine_inverse()*source_transform
var new_item : TreeItem = duplicate_item(item, dest, position)
var new_item : TreeItem = duplicate_item(item, dest, _position)
item.get_parent().remove_child(item)
# update copy's transform parameters
rebuild_scene()
Expand All @@ -680,8 +680,8 @@ func move_item(item, dest, position):
parameters["n%d_position_z" % index] = new_transform.origin.z
set_node_parameters($GenSDF, parameters)

func _on_Tree_drop_item(item, dest, position):
move_item(item, dest, position)
func _on_Tree_drop_item(item, dest, _position):
move_item(item, dest, _position)


# OK/Apply/Cancel buttons
Expand Down
16 changes: 8 additions & 8 deletions material_maker/windows/sdf_builder/sdf_builder_tree.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func get_nearest_parent(item : TreeItem, type : String) -> TreeItem:
item = item.get_parent()
return item

func _get_drag_data(position):
var item : TreeItem = get_item_at_position(position)
func _get_drag_data(pos):
var item : TreeItem = get_item_at_position(pos)
if item == null:
return null
else:
Expand Down Expand Up @@ -62,10 +62,10 @@ func get_valid_children_types(parent : TreeItem):
valid_children_types.push_back(parent_type.item_category)
return valid_children_types

func _can_drop_data(position, data):
func _can_drop_data(_position, data):
if data is Dictionary and data.has("item") and data.item is TreeItem:
var destination : TreeItem = get_item_at_position(position)
if destination != null and get_drop_section_at_position(position) != 0:
var destination : TreeItem = get_item_at_position(_position)
if destination != null and get_drop_section_at_position(_position) != 0:
destination = destination.get_parent()
if not mm_sdf_builder.scene_get_type(data.item.get_meta("scene")).item_category in get_valid_children_types(destination):
return false
Expand All @@ -82,10 +82,10 @@ func get_item_index(item : TreeItem) -> int:
index += 1
return -1

func _drop_data(position, data):
func _drop_data(_position, data):
if data is Dictionary and data.has("item") and data.item is TreeItem:
var item = get_item_at_position(position)
match get_drop_section_at_position(position):
var item = get_item_at_position(_position)
match get_drop_section_at_position(_position):
0:
emit_signal("drop_item", data.item, item, -1)
-1:
Expand Down
7 changes: 3 additions & 4 deletions scripts/fixup.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
extends EditorScript

func _run():
var dir : Directory = Directory.new()
dir.open("res://addons/material_maker/nodes")
var dir : DirAccess = DirAccess.open("res://addons/material_maker/nodes")
dir.list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547
var file_name = dir.get_next()
var loader = load("res://addons/material_maker/engine/loader.gd").new()
var _loader = load("res://addons/material_maker/engine/loader.gd").new()
while file_name != "":
if file_name.ends_with('.mmg'):
print("converting "+file_name)
var file_path : String = "res://addons/material_maker/nodes".path_join(file_name)
var g = mm_loader.load_gen(file_path)
var g = await mm_loader.load_gen(file_path)
mm_loader.save_gen(file_path, g)
file_name = dir.get_next()