mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
fix grouping nodes not removing incoming connections (#6)
Reviewed-on: https://codeberg.org/Eroax/Re-DotDeck/pulls/6 Co-authored-by: Lera Elvoé <yagich@poto.cafe> Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
parent
b36bdaf71c
commit
1fb71617bb
2 changed files with 16 additions and 11 deletions
|
@ -158,6 +158,11 @@ func group_nodes(nodes_to_group: Array) -> Deck:
|
||||||
if !(connection.keys()[0] in node_ids_to_keep):
|
if !(connection.keys()[0] in node_ids_to_keep):
|
||||||
disconnect_nodes(node, get_node(connection.keys()[0]), from_port, connection.values()[0])
|
disconnect_nodes(node, get_node(connection.keys()[0]), from_port, connection.values()[0])
|
||||||
|
|
||||||
|
for to_port: int in node.incoming_connections:
|
||||||
|
for from_node: String in node.incoming_connections[to_port]:
|
||||||
|
if !(from_node in node_ids_to_keep):
|
||||||
|
disconnect_nodes(get_node(from_node), node, node.incoming_connections[to_port].values()[0], to_port)
|
||||||
|
|
||||||
midpoint += node.position_as_vector2()
|
midpoint += node.position_as_vector2()
|
||||||
remove_node(node._id)
|
remove_node(node._id)
|
||||||
group.add_node_inst(node, node._id)
|
group.add_node_inst(node, node._id)
|
||||||
|
|
|
@ -3,8 +3,8 @@ class_name NodeDB_
|
||||||
|
|
||||||
## Filepath used for referencing all [DeckNode] Files from.
|
## Filepath used for referencing all [DeckNode] Files from.
|
||||||
const BASE_NODE_PATH := "res://classes/deck/nodes/"
|
const BASE_NODE_PATH := "res://classes/deck/nodes/"
|
||||||
## Filepath where an Index of [NodeDB_.NodeDescriptor]s are saved to avoid reloading
|
## Filepath where an Index of [NodeDB_.NodeDescriptor]s are saved to avoid reloading
|
||||||
## everything each run.
|
## everything each run.
|
||||||
## @experimental
|
## @experimental
|
||||||
const NODE_INDEX_CACHE_PATH := "user://nodes_index.json"
|
const NODE_INDEX_CACHE_PATH := "user://nodes_index.json"
|
||||||
## Filepath where the the list of Favorite Nodes is stored.
|
## Filepath where the the list of Favorite Nodes is stored.
|
||||||
|
@ -14,11 +14,11 @@ const FAVORITE_NODES_PATH := "user://favorite_nodes.json"
|
||||||
var favorite_nodes: Array[String]
|
var favorite_nodes: Array[String]
|
||||||
|
|
||||||
# Dictionary[node_type, NodeDescriptor]
|
# Dictionary[node_type, NodeDescriptor]
|
||||||
## [Dictionary] filled with node_type, or [String] keys. Correlating to
|
## [Dictionary] filled with node_type, or [String] keys. Correlating to
|
||||||
## [NodeDB_.NodeDescriptor]'s. Essentially where all the nodes are loaded in for data reference.
|
## [NodeDB_.NodeDescriptor]'s. Essentially where all the nodes are loaded in for data reference.
|
||||||
var nodes: Dictionary = {}
|
var nodes: Dictionary = {}
|
||||||
|
|
||||||
## Loads in all the [DeckNode]s from [member BASE_NODE_PATH]. Or if a working
|
## Loads in all the [DeckNode]s from [member BASE_NODE_PATH]. Or if a working
|
||||||
## cache exists at [member NODE_INDEX_CACHE_PATH] that takes priority
|
## cache exists at [member NODE_INDEX_CACHE_PATH] that takes priority
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
load_favorites()
|
load_favorites()
|
||||||
|
@ -69,7 +69,7 @@ func save_node_index() -> void:
|
||||||
var f := FileAccess.open(NODE_INDEX_CACHE_PATH, FileAccess.WRITE)
|
var f := FileAccess.open(NODE_INDEX_CACHE_PATH, FileAccess.WRITE)
|
||||||
f.store_string(json)
|
f.store_string(json)
|
||||||
|
|
||||||
## Loads the Node Index from [member NODE_INDEX_CACHE_PATH] adding all of the
|
## Loads the Node Index from [member NODE_INDEX_CACHE_PATH] adding all of the
|
||||||
## [NodeDB_.NodeDescriptor]s in it to the [member nodes] [Dictionary]
|
## [NodeDB_.NodeDescriptor]s in it to the [member nodes] [Dictionary]
|
||||||
func load_node_index() -> bool:
|
func load_node_index() -> bool:
|
||||||
var f := FileAccess.open(NODE_INDEX_CACHE_PATH, FileAccess.READ)
|
var f := FileAccess.open(NODE_INDEX_CACHE_PATH, FileAccess.READ)
|
||||||
|
@ -90,7 +90,7 @@ func load_node_index() -> bool:
|
||||||
print("node index file exists, loaded")
|
print("node index file exists, loaded")
|
||||||
return true
|
return true
|
||||||
|
|
||||||
## Sets a specific [member DeckNode.node_type] to be a "favorite" for use in
|
## Sets a specific [member DeckNode.node_type] to be a "favorite" for use in
|
||||||
## [AddNodeMenu]. Then stores the updated list of favorites at [member FAVORITE_NODES_PATH]
|
## [AddNodeMenu]. Then stores the updated list of favorites at [member FAVORITE_NODES_PATH]
|
||||||
func set_node_favorite(node_type: String, favorite: bool) -> void:
|
func set_node_favorite(node_type: String, favorite: bool) -> void:
|
||||||
if (favorite && node_type in favorite_nodes) || (!favorite && !(node_type in favorite_nodes)):
|
if (favorite && node_type in favorite_nodes) || (!favorite && !(node_type in favorite_nodes)):
|
||||||
|
@ -113,14 +113,14 @@ func load_favorites() -> void:
|
||||||
favorite_nodes.clear()
|
favorite_nodes.clear()
|
||||||
favorite_nodes.assign(data)
|
favorite_nodes.assign(data)
|
||||||
|
|
||||||
## Returns [code]true[/code] if the specified [member DeckNode.node_type] is marked Favorite
|
## Returns [code]true[/code] if the specified [member DeckNode.node_type] is marked Favorite
|
||||||
## by the user.
|
## by the user.
|
||||||
func is_node_favorite(node_type: String) -> bool:
|
func is_node_favorite(node_type: String) -> bool:
|
||||||
return node_type in favorite_nodes
|
return node_type in favorite_nodes
|
||||||
|
|
||||||
## Used for storing the shorthand data of a [DeckNode].
|
## Used for storing the shorthand data of a [DeckNode].
|
||||||
##
|
##
|
||||||
## Allows for more simply storing [DeckNode]s properties without needing to
|
## Allows for more simply storing [DeckNode]s properties without needing to
|
||||||
## keep an instance
|
## keep an instance
|
||||||
class NodeDescriptor:
|
class NodeDescriptor:
|
||||||
## Default Name of the [DeckNode] type this is storing properties of.
|
## Default Name of the [DeckNode] type this is storing properties of.
|
||||||
|
@ -135,10 +135,10 @@ class NodeDescriptor:
|
||||||
var category: String
|
var category: String
|
||||||
## The description of the [DeckNode] reference [member DeckNode.appears_in_search]
|
## The description of the [DeckNode] reference [member DeckNode.appears_in_search]
|
||||||
var appears_in_search: bool
|
var appears_in_search: bool
|
||||||
|
|
||||||
## Stores the path to this nodes [Script] in res:// for later instantiation.
|
## Stores the path to this nodes [Script] in res:// for later instantiation.
|
||||||
var script_path: String
|
var script_path: String
|
||||||
|
|
||||||
func _init(
|
func _init(
|
||||||
p_script_path: String,
|
p_script_path: String,
|
||||||
p_name: String,
|
p_name: String,
|
||||||
|
@ -170,7 +170,7 @@ class NodeDescriptor:
|
||||||
}
|
}
|
||||||
return d
|
return d
|
||||||
|
|
||||||
## Creates a [NodeDB_.NodeDescriptor] from a given [Dictionary] of properties.
|
## Creates a [NodeDB_.NodeDescriptor] from a given [Dictionary] of properties.
|
||||||
static func from_dictionary(data: Dictionary) -> NodeDescriptor:
|
static func from_dictionary(data: Dictionary) -> NodeDescriptor:
|
||||||
var nd := NodeDescriptor.new(
|
var nd := NodeDescriptor.new(
|
||||||
data.get("script_path", ""),
|
data.get("script_path", ""),
|
||||||
|
|
Loading…
Reference in a new issue