2018-10-02 07:46:20 +02:00
|
|
|
tool
|
|
|
|
extends "res://addons/material_maker/nodes/node_generic.gd"
|
|
|
|
|
|
|
|
func _on_Edit_pressed():
|
2018-10-09 07:24:44 +02:00
|
|
|
var edit_window = load("res://addons/material_maker/widgets/node_editor/node_editor.tscn").instance()
|
|
|
|
if model_data != null:
|
|
|
|
edit_window.set_model_data(model_data)
|
|
|
|
edit_window.connect("node_changed", self, "update_node")
|
|
|
|
add_child(edit_window)
|
|
|
|
edit_window.popup_centered()
|
|
|
|
|
|
|
|
func _on_Load_pressed():
|
|
|
|
var dialog = FileDialog.new()
|
|
|
|
add_child(dialog)
|
|
|
|
dialog.rect_min_size = Vector2(500, 500)
|
|
|
|
dialog.access = FileDialog.ACCESS_FILESYSTEM
|
|
|
|
dialog.mode = FileDialog.MODE_OPEN_FILE
|
|
|
|
dialog.add_filter("*.mmn;Material Maker Node")
|
|
|
|
dialog.connect("file_selected", self, "do_load_node")
|
|
|
|
dialog.popup_centered()
|
|
|
|
|
|
|
|
func do_load_node(file_name):
|
|
|
|
set_model(file_name)
|
2018-10-02 07:46:20 +02:00
|
|
|
|
|
|
|
func _on_Save_pressed():
|
2018-10-09 07:24:44 +02:00
|
|
|
var dialog = FileDialog.new()
|
|
|
|
add_child(dialog)
|
|
|
|
dialog.rect_min_size = Vector2(500, 500)
|
|
|
|
dialog.access = FileDialog.ACCESS_FILESYSTEM
|
|
|
|
dialog.mode = FileDialog.MODE_SAVE_FILE
|
|
|
|
dialog.add_filter("*.mmn;Material Maker Node")
|
|
|
|
dialog.connect("file_selected", self, "do_save_node")
|
|
|
|
dialog.popup_centered()
|
|
|
|
|
|
|
|
func do_save_node(file_name):
|
|
|
|
var file = File.new()
|
|
|
|
if file.open(file_name, File.WRITE) == OK:
|
|
|
|
file.store_string(to_json(model_data))
|
|
|
|
file.close()
|
|
|
|
model = file_name
|
|
|
|
|
|
|
|
func deserialize(data):
|
|
|
|
if data.has("model_data"):
|
|
|
|
update_node(data.model_data)
|
|
|
|
.deserialize(data)
|
|
|
|
|
|
|
|
func serialize():
|
|
|
|
var file = model
|
|
|
|
model = "custom"
|
|
|
|
var return_value = .serialize()
|
|
|
|
model = file
|
|
|
|
return_value.model_data = model_data
|
|
|
|
return return_value
|