mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
minor changes and fixes
- Added an option to duplicate nodes - Creating a subgraph will now show the contents of the subgraph (so it can be easily renamed) - Fixed node preview updtae when the node's seed is modified
This commit is contained in:
parent
cfca689e3f
commit
3ff862f446
@ -87,8 +87,7 @@ func init_parameters() -> void:
|
|||||||
func set_position(p) -> void:
|
func set_position(p) -> void:
|
||||||
position = p
|
position = p
|
||||||
if has_randomness() and !is_seed_locked():
|
if has_randomness() and !is_seed_locked():
|
||||||
for i in range(get_output_defs().size()):
|
source_changed(0)
|
||||||
notify_output_change(i)
|
|
||||||
|
|
||||||
func get_type() -> String:
|
func get_type() -> String:
|
||||||
return "generic"
|
return "generic"
|
||||||
|
@ -220,7 +220,7 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext) -
|
|||||||
func edit(node) -> void:
|
func edit(node) -> void:
|
||||||
node.get_parent().call_deferred("update_view", self)
|
node.get_parent().call_deferred("update_view", self)
|
||||||
|
|
||||||
func create_subgraph(gens : Array) -> void:
|
func create_subgraph(gens : Array) -> MMGenGraph:
|
||||||
# Remove material, gen_inputs and gen_outputs nodes
|
# Remove material, gen_inputs and gen_outputs nodes
|
||||||
var generators = []
|
var generators = []
|
||||||
var center = Vector2(0, 0)
|
var center = Vector2(0, 0)
|
||||||
@ -239,7 +239,7 @@ func create_subgraph(gens : Array) -> void:
|
|||||||
if right_bound < p.x: right_bound = p.x
|
if right_bound < p.x: right_bound = p.x
|
||||||
if upper_bound > p.y: upper_bound = p.y
|
if upper_bound > p.y: upper_bound = p.y
|
||||||
if count == 0:
|
if count == 0:
|
||||||
return
|
return null
|
||||||
center /= count
|
center /= count
|
||||||
# Create a new graph and add it to the current one
|
# Create a new graph and add it to the current one
|
||||||
var new_graph = get_script().new()
|
var new_graph = get_script().new()
|
||||||
@ -306,6 +306,7 @@ func create_subgraph(gens : Array) -> void:
|
|||||||
new_graph.add_child(gen_parameters)
|
new_graph.add_child(gen_parameters)
|
||||||
fix_remotes()
|
fix_remotes()
|
||||||
new_graph.fix_remotes()
|
new_graph.fix_remotes()
|
||||||
|
return new_graph
|
||||||
|
|
||||||
|
|
||||||
func _serialize(data: Dictionary) -> Dictionary:
|
func _serialize(data: Dictionary) -> Dictionary:
|
||||||
|
@ -163,7 +163,7 @@ func update_spatial_material(m, file_prefix = null) -> void:
|
|||||||
if m is SpatialMaterial:
|
if m is SpatialMaterial:
|
||||||
# Make the material double-sided for better visiblity in the preview
|
# Make the material double-sided for better visiblity in the preview
|
||||||
m.params_cull_mode = SpatialMaterial.CULL_DISABLED
|
m.params_cull_mode = SpatialMaterial.CULL_DISABLED
|
||||||
# Albedo
|
# Albedo
|
||||||
m.albedo_color = parameters.albedo_color
|
m.albedo_color = parameters.albedo_color
|
||||||
m.albedo_texture = get_generated_texture("albedo", file_prefix)
|
m.albedo_texture = get_generated_texture("albedo", file_prefix)
|
||||||
m.metallic = parameters.metallic
|
m.metallic = parameters.metallic
|
||||||
|
@ -220,7 +220,7 @@ func export_textures() -> void:
|
|||||||
if g.has_method("export_textures"):
|
if g.has_method("export_textures"):
|
||||||
g.export_textures(prefix, editor_interface)
|
g.export_textures(prefix, editor_interface)
|
||||||
|
|
||||||
# Cut / copy / paste
|
# Cut / copy / paste / duplicate
|
||||||
|
|
||||||
func get_selected_nodes() -> Array:
|
func get_selected_nodes() -> Array:
|
||||||
var selected_nodes = []
|
var selected_nodes = []
|
||||||
@ -285,6 +285,16 @@ func paste(pos = Vector2(0, 0)) -> void:
|
|||||||
for c in new_nodes:
|
for c in new_nodes:
|
||||||
c.selected = true
|
c.selected = true
|
||||||
|
|
||||||
|
func duplicate_selected() -> void:
|
||||||
|
var data = serialize_selection()
|
||||||
|
for c in get_children():
|
||||||
|
if c is GraphNode:
|
||||||
|
c.selected = false
|
||||||
|
var new_nodes = create_nodes(data, scroll_offset+0.5*rect_size)
|
||||||
|
if new_nodes != null:
|
||||||
|
for c in new_nodes:
|
||||||
|
c.selected = true
|
||||||
|
|
||||||
# Delay after graph update
|
# Delay after graph update
|
||||||
|
|
||||||
func send_changed_signal() -> void:
|
func send_changed_signal() -> void:
|
||||||
@ -319,8 +329,9 @@ func create_subgraph() -> void:
|
|||||||
var generators = []
|
var generators = []
|
||||||
for n in get_selected_nodes():
|
for n in get_selected_nodes():
|
||||||
generators.push_back(n.generator)
|
generators.push_back(n.generator)
|
||||||
generator.create_subgraph(generators)
|
var subgraph = generator.create_subgraph(generators)
|
||||||
update_view(generator)
|
if subgraph != null:
|
||||||
|
update_view(subgraph)
|
||||||
|
|
||||||
func _on_ButtonShowTree_pressed() -> void:
|
func _on_ButtonShowTree_pressed() -> void:
|
||||||
var graph_tree : Popup = preload("res://addons/material_maker/widgets/graph_tree/graph_tree.tscn").instance()
|
var graph_tree : Popup = preload("res://addons/material_maker/widgets/graph_tree/graph_tree.tscn").instance()
|
||||||
|
@ -78,6 +78,7 @@ hint_tooltip = "Show hierarchy"
|
|||||||
icon = SubResource( 4 )
|
icon = SubResource( 4 )
|
||||||
[connection signal="connection_request" from="." to="." method="connect_node"]
|
[connection signal="connection_request" from="." to="." method="connect_node"]
|
||||||
[connection signal="disconnection_request" from="." to="." method="disconnect_node"]
|
[connection signal="disconnection_request" from="." to="." method="disconnect_node"]
|
||||||
|
[connection signal="duplicate_nodes_request" from="." to="." method="duplicate_selected"]
|
||||||
[connection signal="timeout" from="Timer" to="." method="do_send_changed_signal"]
|
[connection signal="timeout" from="Timer" to="." method="do_send_changed_signal"]
|
||||||
[connection signal="text_changed" from="GraphUI/SubGraphUI/Label" to="." method="_on_Label_text_changed"]
|
[connection signal="text_changed" from="GraphUI/SubGraphUI/Label" to="." method="_on_Label_text_changed"]
|
||||||
[connection signal="toggled" from="GraphUI/SubGraphUI/ButtonTransmitsSeed" to="." method="_on_ButtonTransmitsSeed_toggled"]
|
[connection signal="toggled" from="GraphUI/SubGraphUI/ButtonTransmitsSeed" to="." method="_on_ButtonTransmitsSeed_toggled"]
|
||||||
|
@ -12,6 +12,8 @@ var need_update : bool = false
|
|||||||
onready var projects = $VBoxContainer/HBoxContainer/ProjectsPane/Projects
|
onready var projects = $VBoxContainer/HBoxContainer/ProjectsPane/Projects
|
||||||
onready var library = $VBoxContainer/HBoxContainer/VBoxContainer/Library
|
onready var library = $VBoxContainer/HBoxContainer/VBoxContainer/Library
|
||||||
|
|
||||||
|
const RECENT_FILES_COUNT = 15
|
||||||
|
|
||||||
const MENU = [
|
const MENU = [
|
||||||
{ menu="File", command="new_material", description="New material" },
|
{ menu="File", command="new_material", description="New material" },
|
||||||
{ menu="File", command="load_material", shortcut="Control+O", description="Load material" },
|
{ menu="File", command="load_material", shortcut="Control+O", description="Load material" },
|
||||||
@ -29,13 +31,14 @@ const MENU = [
|
|||||||
{ menu="Edit", command="edit_cut", shortcut="Control+X", description="Cut" },
|
{ menu="Edit", command="edit_cut", shortcut="Control+X", description="Cut" },
|
||||||
{ menu="Edit", command="edit_copy", shortcut="Control+C", description="Copy" },
|
{ menu="Edit", command="edit_copy", shortcut="Control+C", description="Copy" },
|
||||||
{ menu="Edit", command="edit_paste", shortcut="Control+V", description="Paste" },
|
{ menu="Edit", command="edit_paste", shortcut="Control+V", description="Paste" },
|
||||||
|
{ menu="Edit", command="edit_duplicate", shortcut="Control+D", description="Duplicate" },
|
||||||
|
|
||||||
{ menu="View", command="view_center", shortcut="C", description="Center view" },
|
{ menu="View", command="view_center", shortcut="C", description="Center view" },
|
||||||
{ menu="View", command="view_reset_zoom", shortcut="Control+0", description="Reset zoom" },
|
{ menu="View", command="view_reset_zoom", shortcut="Control+0", description="Reset zoom" },
|
||||||
|
|
||||||
{ menu="Tools", submenu="create", description="Create" },
|
{ menu="Tools", submenu="create", description="Create" },
|
||||||
{ menu="Tools", command="create_subgraph", shortcut="Control+G", description="Create group" },
|
{ menu="Tools", command="create_subgraph", shortcut="Control+G", description="Create group" },
|
||||||
{ menu="Tools", command="make_selected_nodes_editable", shortcut="Control+E", description="Make selected nodes editable" },
|
{ menu="Tools", command="make_selected_nodes_editable", shortcut="Control+W", description="Make selected nodes editable" },
|
||||||
{ menu="Tools" },
|
{ menu="Tools" },
|
||||||
{ menu="Tools", command="add_to_user_library", description="Add selected node to user library" },
|
{ menu="Tools", command="add_to_user_library", description="Add selected node to user library" },
|
||||||
{ menu="Tools", command="export_library", description="Export the nodes library" },
|
{ menu="Tools", command="export_library", description="Export the nodes library" },
|
||||||
@ -160,6 +163,8 @@ func add_recent(path) -> void:
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
recent_files.push_front(path)
|
recent_files.push_front(path)
|
||||||
|
while recent_files.size() > RECENT_FILES_COUNT:
|
||||||
|
recent_files.pop_back()
|
||||||
var f = File.new()
|
var f = File.new()
|
||||||
f.open("user://recent_files.bin", File.WRITE)
|
f.open("user://recent_files.bin", File.WRITE)
|
||||||
f.store_string(to_json(recent_files))
|
f.store_string(to_json(recent_files))
|
||||||
@ -297,6 +302,14 @@ func edit_paste_is_disabled() -> bool:
|
|||||||
var data = parse_json(OS.clipboard)
|
var data = parse_json(OS.clipboard)
|
||||||
return data == null
|
return data == null
|
||||||
|
|
||||||
|
func edit_duplicate() -> void:
|
||||||
|
var graph_edit : MMGraphEdit = get_current_graph_edit()
|
||||||
|
if graph_edit != null:
|
||||||
|
graph_edit.duplicate_selected()
|
||||||
|
|
||||||
|
func edit_duplicate_is_disabled() -> bool:
|
||||||
|
return edit_cut_is_disabled()
|
||||||
|
|
||||||
func view_center() -> void:
|
func view_center() -> void:
|
||||||
var graph_edit : MMGraphEdit = get_current_graph_edit()
|
var graph_edit : MMGraphEdit = get_current_graph_edit()
|
||||||
graph_edit.center_view()
|
graph_edit.center_view()
|
||||||
|
@ -52,28 +52,28 @@ margin_left = 39.0
|
|||||||
margin_right = 75.0
|
margin_right = 75.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
text = "Edit"
|
text = "Edit"
|
||||||
items = [ "Cut", null, 0, false, false, 12, 268435544, null, "", false, "Copy", null, 0, false, false, 13, 268435523, null, "", false, "Paste", null, 0, false, false, 14, 268435542, null, "", false ]
|
items = [ "Cut", null, 0, false, false, 12, 268435544, null, "", false, "Copy", null, 0, false, false, 13, 268435523, null, "", false, "Paste", null, 0, false, false, 14, 268435542, null, "", false, "Duplicate", null, 0, false, false, 15, 268435524, null, "", false ]
|
||||||
|
|
||||||
[node name="View" type="MenuButton" parent="VBoxContainer/Menu"]
|
[node name="View" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||||
margin_left = 79.0
|
margin_left = 79.0
|
||||||
margin_right = 121.0
|
margin_right = 121.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
text = "View"
|
text = "View"
|
||||||
items = [ "Center view", null, 0, false, false, 15, 67, null, "", false, "Reset zoom", null, 0, false, false, 16, 268435504, null, "", false ]
|
items = [ "Center view", null, 0, false, false, 16, 67, null, "", false, "Reset zoom", null, 0, false, false, 17, 268435504, null, "", false ]
|
||||||
|
|
||||||
[node name="Tools" type="MenuButton" parent="VBoxContainer/Menu"]
|
[node name="Tools" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||||
margin_left = 125.0
|
margin_left = 125.0
|
||||||
margin_right = 171.0
|
margin_right = 171.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
text = "Tools"
|
text = "Tools"
|
||||||
items = [ "Create", null, 0, false, false, -1, 0, null, "PopupMenu", false, "Create group", null, 0, false, false, 18, 268435527, null, "", false, "Make selected nodes editable", null, 0, false, false, 19, 268435525, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Add selected node to user library", null, 0, false, false, 21, 0, null, "", false, "Export the nodes library", null, 0, false, false, 22, 0, null, "", false ]
|
items = [ "Create", null, 0, false, false, -1, 0, null, "PopupMenu", false, "Create group", null, 0, false, false, 19, 268435527, null, "", false, "Make selected nodes editable", null, 0, false, false, 20, 268435543, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Add selected node to user library", null, 0, false, false, 22, 0, null, "", false, "Export the nodes library", null, 0, false, false, 23, 0, null, "", false ]
|
||||||
|
|
||||||
[node name="Help" type="MenuButton" parent="VBoxContainer/Menu"]
|
[node name="Help" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||||
margin_left = 175.0
|
margin_left = 175.0
|
||||||
margin_right = 217.0
|
margin_right = 217.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
text = "Help"
|
text = "Help"
|
||||||
items = [ "User manual", null, 0, false, false, 23, 16777244, null, "", false, "Show selected library item documentation", null, 0, false, false, 24, 285212700, null, "", false, "Report a bug", null, 0, false, false, 25, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "About", null, 0, false, false, 27, 0, null, "", false ]
|
items = [ "User manual", null, 0, false, false, 24, 16777244, null, "", false, "Show selected library item documentation", null, 0, false, false, 25, 285212700, null, "", false, "Report a bug", null, 0, false, false, 26, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "About", null, 0, false, false, 28, 0, null, "", false ]
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HSplitContainer" parent="VBoxContainer"]
|
[node name="HBoxContainer" type="HSplitContainer" parent="VBoxContainer"]
|
||||||
margin_top = 24.0
|
margin_top = 24.0
|
||||||
@ -152,6 +152,7 @@ script = ExtResource( 6 )
|
|||||||
[connection signal="tab_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects" to="." method="_on_Projects_tab_changed"]
|
[connection signal="tab_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects" to="." method="_on_Projects_tab_changed"]
|
||||||
[connection signal="connection_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" method="connect_node"]
|
[connection signal="connection_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" method="connect_node"]
|
||||||
[connection signal="disconnection_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" method="disconnect_node"]
|
[connection signal="disconnection_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" method="disconnect_node"]
|
||||||
|
[connection signal="duplicate_nodes_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" method="duplicate_selected"]
|
||||||
[connection signal="focus_exited" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="_on_LineEdit_focus_exited"]
|
[connection signal="focus_exited" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="_on_LineEdit_focus_exited"]
|
||||||
[connection signal="gui_input" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="_on_LineEdit_gui_input"]
|
[connection signal="gui_input" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="_on_LineEdit_gui_input"]
|
||||||
[connection signal="resized" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="do_update"]
|
[connection signal="resized" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="do_update"]
|
||||||
|
Loading…
Reference in New Issue
Block a user