mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
close groups belonging to deck when closing deck
This commit is contained in:
parent
7a95121330
commit
0027ca5d1a
2 changed files with 22 additions and 0 deletions
|
@ -349,6 +349,19 @@ func send_event(event_name: StringName, event_data: Dictionary = {}) -> void:
|
||||||
node._event_received(event_name, event_data)
|
node._event_received(event_name, event_data)
|
||||||
|
|
||||||
|
|
||||||
|
func get_referenced_groups() -> Array[String]:
|
||||||
|
# this is expensive
|
||||||
|
# recursively returns a list of all groups referenced by this deck
|
||||||
|
var res: Array[String] = []
|
||||||
|
for node_id: String in nodes:
|
||||||
|
var node := get_node(node_id)
|
||||||
|
if node.node_type != "group_node":
|
||||||
|
continue
|
||||||
|
res.append(node.group_id)
|
||||||
|
res.append_array(DeckHolder.get_deck(node.group_id).get_referenced_groups())
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
## Returns a [Dictionary] representation of this deck.
|
## Returns a [Dictionary] representation of this deck.
|
||||||
func to_dict(with_meta: bool = true, group_ids: Array = []) -> Dictionary:
|
func to_dict(with_meta: bool = true, group_ids: Array = []) -> Dictionary:
|
||||||
var inner := {
|
var inner := {
|
||||||
|
|
|
@ -98,9 +98,18 @@ static func close_group_instance(group_id: String, instance_id: String) -> void:
|
||||||
decks.erase(group_id)
|
decks.erase(group_id)
|
||||||
|
|
||||||
|
|
||||||
|
static func close_all_group_instances(group_id: String) -> void:
|
||||||
|
if decks.get(group_id) is Dictionary:
|
||||||
|
decks.erase(group_id)
|
||||||
|
|
||||||
|
|
||||||
## Unloads a deck.
|
## Unloads a deck.
|
||||||
static func close_deck(deck_id: String) -> void:
|
static func close_deck(deck_id: String) -> void:
|
||||||
if decks.get(deck_id) is Deck:
|
if decks.get(deck_id) is Deck:
|
||||||
|
var deck: Deck = decks[deck_id] as Deck
|
||||||
|
var groups := deck.get_referenced_groups()
|
||||||
|
for group in groups:
|
||||||
|
close_all_group_instances(group)
|
||||||
decks.erase(deck_id)
|
decks.erase(deck_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue