fix library group saving (#161)

Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/161
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
Lera Elvoé 2024-05-20 08:54:19 +00:00 committed by yagich
parent 92ebbe5344
commit 3bb1531603
4 changed files with 31 additions and 6 deletions

View file

@ -87,7 +87,7 @@ func _post_deck_load() -> void:
var gp := _belonging_to.group_descriptors.get_input_port(port.index_of_type)
if gp.is_empty():
continue
port.label = gp.label
port.label = gp.label if not gp.label.is_empty() else "Input %s" % port.index
port.descriptor = gp.descriptor
port.type = gp.type
port.usage_type = gp.usage_type

View file

@ -14,12 +14,26 @@ var input_node_id: String
var output_node_id: String
var extra_ports: Array
var extra_port_values: Array:
get:
if extra_port_values.is_empty():
return get_all_ports().map(func(x: Port): return x.value)
else:
return extra_port_values
func _init() -> void:
name = "Group"
node_type = "group_node"
props_to_serialize = [&"group_id", &"group_instance_id", &"extra_ports", &"input_node_id", &"output_node_id", &"is_library"]
props_to_serialize = [
&"group_id",
&"group_instance_id",
&"extra_ports",
&"input_node_id",
&"output_node_id",
&"is_library",
&"extra_port_values",
]
appears_in_search = false
@ -60,25 +74,35 @@ func setup_connections() -> void:
func recalculate_ports() -> void:
var _values := extra_port_values.duplicate()
ports.clear()
for output_port: Port in output_node.get_input_ports():
add_output_port(
var port := add_output_port(
output_port.type,
output_port.label,
output_port.descriptor,
output_port.usage_type,
)
if _values.size() - 1 < port.index:
continue
port.set_value(_values[port.index])
for input_port: Port in input_node.get_output_ports():
add_input_port(
var port := add_input_port(
input_port.type,
input_port.label,
input_port.descriptor,
input_port.usage_type,
)
if _values.size() - 1 < port.index:
continue
port.set_value(_values[port.index])
extra_ports.clear()
extra_port_values.clear()
for port in ports:
extra_ports.append(port.port_type)

View file

@ -85,7 +85,7 @@ func _post_deck_load() -> void:
var gp := _belonging_to.group_descriptors.get_output_port(port.index_of_type)
if gp.is_empty():
continue
port.label = gp.label
port.label = gp.label if not gp.label.is_empty() else "Output %s" % port.index
port.descriptor = gp.descriptor
port.type = gp.type
port.usage_type = gp.usage_type

View file

@ -25,7 +25,8 @@ func set_up_from_port(port: Port, node: DeckNode, in_node: bool = true) -> void:
func(new_value: Variant):
if ignore_signal:
return
set_value(new_value)
if new_value != null:
set_value(new_value)
)
_setup(port, node)
if (port.port_type == DeckNode.PortType.VIRTUAL or port.type == DeckType.Types.ANY) or not in_node: