Cut/Copy/Paste fix

Fixed cut, copy and paste behavior when Material is selected (that node should not be deleted or copied, but connections should be pasted).
This commit is contained in:
Rodolphe Suescun 2018-08-27 12:15:57 +02:00
parent 0d2225d997
commit 5184f6375e

View File

@ -134,7 +134,7 @@ func create_nodes(data, position = null):
names[c.name] = node.name names[c.name] = node.name
node.selected = true node.selected = true
for c in data.connections: for c in data.connections:
connect_node(names[c.from], c.from_port, names[c.to], c.to_port) connect_node(names[c.from], c.from_port, "Material" if c.to == "Material" else names[c.to], c.to_port)
return null return null
func load_file(): func load_file():
@ -202,14 +202,14 @@ func export_textures(size = null):
func remove_selection(): func remove_selection():
for c in get_children(): for c in get_children():
if c is GraphNode and c.selected: if c is GraphNode and c.selected && c.name != "Material":
remove_node(c) remove_node(c)
func serialize_selection(): func serialize_selection():
var data = { nodes = [], connections = [] } var data = { nodes = [], connections = [] }
var nodes = [] var nodes = []
for c in get_children(): for c in get_children():
if c is GraphNode and c.selected: if c is GraphNode and c.selected && c.name != "Material":
nodes.append(c) nodes.append(c)
if nodes.empty(): if nodes.empty():
return null return null
@ -229,6 +229,12 @@ func serialize_selection():
data.connections.append(c) data.connections.append(c)
return data return data
func can_copy():
for c in get_children():
if c is GraphNode and c.selected && c.name != "Material":
return true
return false
func cut(): func cut():
copy() copy()
remove_selection() remove_selection()