mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
make group io nodes 'optional' (#167)
Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/167 Co-authored-by: Lera Elvoé <yagich@poto.cafe> Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
parent
83f6fa1fae
commit
3bff8e27e6
3 changed files with 36 additions and 7 deletions
|
@ -50,10 +50,6 @@ var _belonging_to: String = "" # for groups
|
||||||
var group_input_node: String
|
var group_input_node: String
|
||||||
## The ID of this group's input node. Used only if [member is_group] is [code]true[/code].
|
## The ID of this group's input node. Used only if [member is_group] is [code]true[/code].
|
||||||
var group_output_node: String
|
var group_output_node: String
|
||||||
## The ID of the group node this group is represented by, contained in this deck's parent deck.
|
|
||||||
## Used only if [member is_group] is [code]true[/code].
|
|
||||||
## @experimental
|
|
||||||
#var group_node: String
|
|
||||||
|
|
||||||
var emit_group_signals: bool = true
|
var emit_group_signals: bool = true
|
||||||
var emit_node_added_signal: bool = true
|
var emit_node_added_signal: bool = true
|
||||||
|
@ -97,8 +93,17 @@ func add_node_type(type: String, assign_id: String = "", assign_to_self: bool =
|
||||||
## If [param assign_id] is empty, the node will get its' ID (re-)assigned.
|
## If [param assign_id] is empty, the node will get its' ID (re-)assigned.
|
||||||
## Otherwise, it will be assigned to be that value.[br]
|
## Otherwise, it will be assigned to be that value.[br]
|
||||||
## If [param assign_to_self] is [code]true[/code], the node's
|
## If [param assign_to_self] is [code]true[/code], the node's
|
||||||
## [member DeckNode._belonging_to] property will be set to [code]self[/code].
|
## [member DeckNode._belonging_to] property will be set to [code]self[/code].[br]
|
||||||
|
## Returns [code]null[/code] if the node cannot be insantiated.
|
||||||
func add_node_inst(node: DeckNode, assign_id: String = "", assign_to_self: bool = true) -> DeckNode:
|
func add_node_inst(node: DeckNode, assign_id: String = "", assign_to_self: bool = true) -> DeckNode:
|
||||||
|
if node.node_type == "group_input" and not group_input_node.is_empty():
|
||||||
|
DeckHolder.logger.toast_error("Cannot add group input node, one already exists!")
|
||||||
|
node.free()
|
||||||
|
return null
|
||||||
|
if node.node_type == "group_output" and not group_output_node.is_empty():
|
||||||
|
DeckHolder.logger.toast_error("Cannot add group output node, one already exists!")
|
||||||
|
node.free()
|
||||||
|
return null
|
||||||
if assign_to_self:
|
if assign_to_self:
|
||||||
node._belonging_to = self
|
node._belonging_to = self
|
||||||
#node._belonging_to_instance = instance_id
|
#node._belonging_to_instance = instance_id
|
||||||
|
@ -113,9 +118,17 @@ func add_node_inst(node: DeckNode, assign_id: String = "", assign_to_self: bool
|
||||||
|
|
||||||
if node.node_type == "group_input":
|
if node.node_type == "group_input":
|
||||||
group_input_node = node._id
|
group_input_node = node._id
|
||||||
|
node.about_to_free.connect(
|
||||||
|
func():
|
||||||
|
group_input_node = ""
|
||||||
|
)
|
||||||
|
|
||||||
if node.node_type == "group_output":
|
if node.node_type == "group_output":
|
||||||
group_output_node = node._id
|
group_output_node = node._id
|
||||||
|
node.about_to_free.connect(
|
||||||
|
func():
|
||||||
|
group_output_node = ""
|
||||||
|
)
|
||||||
|
|
||||||
if emit_node_added_signal:
|
if emit_node_added_signal:
|
||||||
node_added.emit(node)
|
node_added.emit(node)
|
||||||
|
@ -702,8 +715,10 @@ static func from_dict(data: Dictionary, path: String = "") -> Deck:
|
||||||
node.group_instance_id
|
node.group_instance_id
|
||||||
)
|
)
|
||||||
|
|
||||||
group.get_node(node.input_node_id).group_node = node
|
if not node.input_node_id.is_empty():
|
||||||
group.get_node(node.output_node_id).group_node = node
|
group.get_node(node.input_node_id).group_node = node
|
||||||
|
if not node.output_node_id.is_empty():
|
||||||
|
group.get_node(node.output_node_id).group_node = node
|
||||||
node.init_io()
|
node.init_io()
|
||||||
|
|
||||||
return deck
|
return deck
|
||||||
|
|
|
@ -60,6 +60,17 @@ func init_io() -> void:
|
||||||
input_node = group.get_node(input_node_id)
|
input_node = group.get_node(input_node_id)
|
||||||
output_node = group.get_node(output_node_id)
|
output_node = group.get_node(output_node_id)
|
||||||
|
|
||||||
|
if input_node:
|
||||||
|
input_node.about_to_free.connect(
|
||||||
|
func():
|
||||||
|
input_node_id = ""
|
||||||
|
)
|
||||||
|
if output_node:
|
||||||
|
output_node.about_to_free.connect(
|
||||||
|
func():
|
||||||
|
output_node_id = ""
|
||||||
|
)
|
||||||
|
|
||||||
recalculate_ports()
|
recalculate_ports()
|
||||||
setup_connections()
|
setup_connections()
|
||||||
|
|
||||||
|
|
|
@ -344,6 +344,9 @@ func _on_add_node_menu_node_selected(type: String) -> void:
|
||||||
# var node := NodeDB.instance_node(type) as DeckNode
|
# var node := NodeDB.instance_node(type) as DeckNode
|
||||||
# deck.add_node_inst(node)
|
# deck.add_node_inst(node)
|
||||||
var node := deck.add_node_type(type)
|
var node := deck.add_node_type(type)
|
||||||
|
|
||||||
|
if node == null:
|
||||||
|
return
|
||||||
|
|
||||||
get_node_renderer(node).position_offset = node_pos
|
get_node_renderer(node).position_offset = node_pos
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue