Fixed export node

This commit is contained in:
RodZill4 2020-02-24 23:29:33 +01:00
parent 88dd22a0d4
commit a323f095b5
4 changed files with 18 additions and 39 deletions

View File

@ -34,19 +34,11 @@ func get_parameter_defs() -> Array:
func get_input_defs() -> Array: func get_input_defs() -> Array:
return [ { name="in", type="rgba" } ] return [ { name="in", type="rgba" } ]
func render_textures() -> void: func export_material(prefix, _profile) -> void:
var source = get_source(0) var source = get_source(0)
if source != null: if source != null:
var result = source.generator.render(source.output_index, get_image_size()) var result = source.generator.render(source.output_index, get_image_size())
while result is GDScriptFunctionState: while result is GDScriptFunctionState:
result = yield(result, "completed") result = yield(result, "completed")
texture = ImageTexture.new() result.save_to_file("%s_%s.png" % [ prefix, parameters.suffix])
result.copy_to_texture(texture)
result.release() result.release()
else:
texture = null
func export_textures(prefix, __ = null) -> void:
if texture != null:
var image = texture.get_data()
image.save_png("%s_%s.png" % [ prefix, parameters.suffix])

View File

@ -237,14 +237,10 @@ func get_material_node() -> MMGenMaterial:
return g return g
return null return null
func export_textures() -> void: func export_material(export_prefix, profile) -> void:
if save_path != null:
var prefix = save_path.left(save_path.rfind("."))
for g in top_generator.get_children(): for g in top_generator.get_children():
if g.has_method("render_textures"): if g.has_method("export_material"):
g.render_textures() g.export_material(export_prefix, profile)
if g.has_method("export_textures"):
g.export_textures(prefix, editor_interface)
# Cut / copy / paste / duplicate # Cut / copy / paste / duplicate

View File

@ -224,10 +224,8 @@ func export_material(file_path : String, profile : String) -> void:
var graph_edit : MMGraphEdit = get_current_graph_edit() var graph_edit : MMGraphEdit = get_current_graph_edit()
if graph_edit == null: if graph_edit == null:
return return
var material_node = graph_edit.get_material_node() var export_prefix = file_path.trim_suffix("."+file_path.get_extension())
if material_node == null: graph_edit.export_material(export_prefix, profile)
return
material_node.export_material(file_path.trim_suffix("."+file_path.get_extension()), profile)
func _on_ExportMaterial_id_pressed(id) -> void: func _on_ExportMaterial_id_pressed(id) -> void:
var graph_edit : MMGraphEdit = get_current_graph_edit() var graph_edit : MMGraphEdit = get_current_graph_edit()
@ -238,14 +236,11 @@ func _on_ExportMaterial_id_pressed(id) -> void:
return return
var profile = material_node.get_export_profiles()[id] var profile = material_node.get_export_profiles()[id]
var dialog : FileDialog = FileDialog.new() var dialog : FileDialog = FileDialog.new()
add_child(dialog)
dialog.rect_min_size = Vector2(500, 500) dialog.rect_min_size = Vector2(500, 500)
dialog.access = FileDialog.ACCESS_FILESYSTEM dialog.access = FileDialog.ACCESS_FILESYSTEM
dialog.mode = FileDialog.MODE_SAVE_FILE dialog.mode = FileDialog.MODE_SAVE_FILE
dialog.add_filter("*."+material_node.get_export_extension(profile)+";"+profile+" Material") dialog.add_filter("*."+material_node.get_export_extension(profile)+";"+profile+" Material")
var export_path = material_node.get_export_path(profile) add_child(dialog)
if export_path != "":
dialog.current_path = export_path
dialog.connect("file_selected", self, "export_material", [ profile ]) dialog.connect("file_selected", self, "export_material", [ profile ])
dialog.popup_centered() dialog.popup_centered()
@ -356,10 +351,6 @@ func save_material_as() -> void:
func close_material() -> void: func close_material() -> void:
projects.close_tab() projects.close_tab()
func export_material_is_disabled() -> bool:
var graph_edit : MMGraphEdit = get_current_graph_edit()
return graph_edit == null or graph_edit.save_path == null
func quit() -> void: func quit() -> void:
dim_window() dim_window()
get_tree().quit() get_tree().quit()

View File

@ -94,39 +94,39 @@ margin_right = 1268.0
margin_bottom = 22.0 margin_bottom = 22.0
[node name="File" type="MenuButton" parent="VBoxContainer/Menu"] [node name="File" type="MenuButton" parent="VBoxContainer/Menu"]
margin_right = 35.0 margin_right = 31.0
margin_bottom = 22.0 margin_bottom = 22.0
text = "File" text = "File"
items = [ "New material", null, 0, false, false, 0, 0, null, "", false, "Load material", null, 0, false, false, 1, 268435535, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Save material", null, 0, false, false, 4, 268435539, null, "", false, "Save material as...", null, 0, false, false, 5, 301989971, null, "", false, "Save all materials...", null, 0, false, false, 6, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Export material", null, 0, false, false, 8, 268435525, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Close material", null, 0, false, false, 10, 0, null, "", false, "Quit", null, 0, false, false, 11, 268435537, null, "", false ] items = [ "New material", null, 0, false, false, 0, 0, null, "", false, "Load material", null, 0, false, false, 1, 268435535, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Save material", null, 0, false, false, 4, 268435539, null, "", false, "Save material as...", null, 0, false, false, 5, 301989971, null, "", false, "Save all materials...", null, 0, false, false, 6, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Export material", null, 0, false, false, 8, 268435525, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Close material", null, 0, false, false, 10, 0, null, "", false, "Quit", null, 0, false, false, 11, 268435537, null, "", false ]
switch_on_hover = true switch_on_hover = true
[node name="Edit" type="MenuButton" parent="VBoxContainer/Menu"] [node name="Edit" type="MenuButton" parent="VBoxContainer/Menu"]
margin_left = 39.0 margin_left = 35.0
margin_right = 75.0 margin_right = 67.0
margin_bottom = 22.0 margin_bottom = 22.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, "Duplicate", null, 0, false, false, 15, 268435524, 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 ]
switch_on_hover = true switch_on_hover = true
[node name="View" type="MenuButton" parent="VBoxContainer/Menu"] [node name="View" type="MenuButton" parent="VBoxContainer/Menu"]
margin_left = 79.0 margin_left = 71.0
margin_right = 121.0 margin_right = 109.0
margin_bottom = 22.0 margin_bottom = 22.0
text = "View" text = "View"
items = [ "Center view", null, 0, false, false, 16, 67, null, "", false, "Reset zoom", null, 0, false, false, 17, 268435504, null, "", false ] items = [ "Center view", null, 0, false, false, 16, 67, null, "", false, "Reset zoom", null, 0, false, false, 17, 268435504, null, "", false ]
switch_on_hover = true switch_on_hover = true
[node name="Tools" type="MenuButton" parent="VBoxContainer/Menu"] [node name="Tools" type="MenuButton" parent="VBoxContainer/Menu"]
margin_left = 125.0 margin_left = 113.0
margin_right = 171.0 margin_right = 155.0
margin_bottom = 22.0 margin_bottom = 22.0
text = "Tools" text = "Tools"
items = [ "Create", null, 0, false, false, 0, 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 ] items = [ "Create", null, 0, false, false, 0, 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 ]
switch_on_hover = true switch_on_hover = true
[node name="Help" type="MenuButton" parent="VBoxContainer/Menu"] [node name="Help" type="MenuButton" parent="VBoxContainer/Menu"]
margin_left = 175.0 margin_left = 159.0
margin_right = 217.0 margin_right = 197.0
margin_bottom = 22.0 margin_bottom = 22.0
text = "Help" text = "Help"
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 ] 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 ]