mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Implement restoring node connections on opening an MMMaterian in mat_maker_gd's editor.
This commit is contained in:
parent
da126d1d45
commit
c07ca3d8d8
@ -61,9 +61,31 @@ func recreate() -> void:
|
||||
_graph_edit.add_child(gn)
|
||||
|
||||
#connect them
|
||||
for n in _material.nodes:
|
||||
if n:
|
||||
for ip in n.input_properties:
|
||||
if ip.input_property:
|
||||
var input_node : Node = find_graph_node_for(n)
|
||||
var output_node : Node = find_graph_node_for(ip.input_property.owner)
|
||||
|
||||
var to_slot : int = input_node.get_input_property_graph_node_slot_index(ip)
|
||||
var from_slot : int = output_node.get_output_property_graph_node_slot_index(ip.input_property)
|
||||
|
||||
_graph_edit.connect_node(output_node.name, from_slot, input_node.name, to_slot)
|
||||
|
||||
_material.render()
|
||||
|
||||
func find_graph_node_for(nnode) -> Node:
|
||||
for c in _graph_edit.get_children():
|
||||
if c is GraphNode:
|
||||
if c.has_method("get_material_node"):
|
||||
var n = c.get_material_node()
|
||||
|
||||
if n == nnode:
|
||||
return c
|
||||
|
||||
return null
|
||||
|
||||
func set_mmmaterial(object : MMMateial):
|
||||
_material = object
|
||||
|
||||
|
@ -325,6 +325,30 @@ func disconnect_slot(slot_idx : int, to_node : Node, to_slot_idx : int) -> bool:
|
||||
|
||||
return true
|
||||
|
||||
func get_input_property_graph_node_slot_index(property) -> int:
|
||||
var property_index : int = -1
|
||||
|
||||
for i in range(properties.size()):
|
||||
if properties[i][1] != -1:
|
||||
property_index += 1
|
||||
|
||||
if properties[i][6] == property:
|
||||
break
|
||||
|
||||
return property_index
|
||||
|
||||
func get_output_property_graph_node_slot_index(property) -> int:
|
||||
var property_index : int = -1
|
||||
|
||||
for i in range(properties.size()):
|
||||
if properties[i][2] != -1:
|
||||
property_index += 1
|
||||
|
||||
if properties[i][6] == property:
|
||||
break
|
||||
|
||||
return property_index
|
||||
|
||||
func get_property_control(slot_idx : int) -> Node:
|
||||
return properties[slot_idx][5]
|
||||
|
||||
@ -397,3 +421,6 @@ func on_universal_texture_changed(slot_idx : int) -> void:
|
||||
|
||||
func on_slot_line_edit_text_entered(text : String, slot_idx : int) -> void:
|
||||
_node.call(properties[slot_idx][4], text)
|
||||
|
||||
func get_material_node() -> MMNode:
|
||||
return _node
|
||||
|
@ -39,6 +39,15 @@ default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=10]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=4]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
@ -47,10 +56,11 @@ default_float = 0.65
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 10 )
|
||||
|
||||
[sub_resource type="Resource" id=5]
|
||||
script = ExtResource( 4 )
|
||||
graph_position = Vector2( -340, -340 )
|
||||
graph_position = Vector2( -360, -340 )
|
||||
image = SubResource( 7 )
|
||||
shape_type = 4
|
||||
sides = 11
|
||||
@ -68,7 +78,7 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=6]
|
||||
script = ExtResource( 6 )
|
||||
graph_position = Vector2( -20, -340 )
|
||||
graph_position = Vector2( -20, -320 )
|
||||
image = SubResource( 13 )
|
||||
postfix = "-test"
|
||||
|
||||
@ -81,15 +91,6 @@ default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=10]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=11]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
@ -101,7 +102,7 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=12]
|
||||
script = ExtResource( 4 )
|
||||
graph_position = Vector2( -720, -60 )
|
||||
graph_position = Vector2( -760, -60 )
|
||||
image = SubResource( 10 )
|
||||
shape_type = 3
|
||||
sides = 6
|
||||
|
Loading…
Reference in New Issue
Block a user