diff --git a/graph_node_renderer/debug_decks_list.gd b/graph_node_renderer/debug_decks_list.gd new file mode 100644 index 0000000..440754e --- /dev/null +++ b/graph_node_renderer/debug_decks_list.gd @@ -0,0 +1,26 @@ +extends VBoxContainer +class_name DebugDecksList + +signal item_pressed(deck_id: String, instance_id: String) + + +func _ready() -> void: + for i in get_children(): + i.queue_free() + + for deck_id: String in DeckHolder.decks: + if DeckHolder.decks[deck_id] is Deck: + var b := Button.new() + b.text = deck_id + b.pressed.connect(func(): + item_pressed.emit(deck_id, "") + ) + add_child(b) + else: + for instance_id: String in DeckHolder.decks[deck_id]: + var b := Button.new() + b.text = "%s::%s" % [deck_id, instance_id] + b.pressed.connect(func(): + item_pressed.emit(deck_id, instance_id) + ) + add_child(b) diff --git a/graph_node_renderer/debug_decks_list.tscn b/graph_node_renderer/debug_decks_list.tscn new file mode 100644 index 0000000..ef38b89 --- /dev/null +++ b/graph_node_renderer/debug_decks_list.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dm7sc6364j84i"] + +[ext_resource type="Script" path="res://graph_node_renderer/debug_decks_list.gd" id="1_etp6v"] + +[node name="DebugDecksList" type="VBoxContainer"] +script = ExtResource("1_etp6v") diff --git a/graph_node_renderer/deck_holder_renderer.gd b/graph_node_renderer/deck_holder_renderer.gd index 458aff2..15008b7 100644 --- a/graph_node_renderer/deck_holder_renderer.gd +++ b/graph_node_renderer/deck_holder_renderer.gd @@ -7,6 +7,7 @@ class_name DeckHolderRenderer ## Reference to the base scene for [DeckRendererGraphEdit] const DECK_SCENE := preload("res://graph_node_renderer/deck_renderer_graph_edit.tscn") +const DEBUG_DECKS_LIST := preload("res://graph_node_renderer/debug_decks_list.tscn") ## Reference to the main windows [TabContainerCustom] @onready var tab_container: TabContainerCustom = %TabContainerCustom as TabContainerCustom @@ -196,3 +197,33 @@ func _on_obs_websocket_setup_dialog_connect_button_pressed(state: OBSWebsocketSe func _process(delta: float) -> void: DeckHolder.send_event(&"process", {"delta": delta}) + + +func _on_debug_id_pressed(id: int) -> void: + var d := AcceptDialog.new() + var debug_decks: DebugDecksList = DEBUG_DECKS_LIST.instantiate() + d.add_child(debug_decks) + d.canceled.connect(d.queue_free) + d.confirmed.connect(d.queue_free) + debug_decks.item_pressed.connect(_on_debug_decks_viewer_item_pressed) + add_child(d) + d.popup_centered() + + +func _on_debug_decks_viewer_item_pressed(deck_id: String, instance_id: String) -> void: + if instance_id == "": + var deck := DeckHolder.get_deck(deck_id) + var inst: DeckRendererGraphEdit = DECK_SCENE.instantiate() + inst.deck = deck + tab_container.add_content(inst, "" % [deck_id.left(8)]) + tab_container.set_tab_metadata(tab_container.get_current_tab(), deck.id) + inst.initialize_from_deck() + inst.group_enter_requested.connect(_on_deck_renderer_group_enter_requested) + else: + var deck := DeckHolder.get_group_instance(deck_id, instance_id) + var inst: DeckRendererGraphEdit = DECK_SCENE.instantiate() + inst.deck = deck + tab_container.add_content(inst, "" % [deck_id.left(8), instance_id.left(8)]) + tab_container.set_tab_metadata(tab_container.get_current_tab(), deck.id) + inst.initialize_from_deck() + inst.group_enter_requested.connect(_on_deck_renderer_group_enter_requested) diff --git a/graph_node_renderer/deck_holder_renderer.tscn b/graph_node_renderer/deck_holder_renderer.tscn index ab3e0e4..0b66c03 100644 --- a/graph_node_renderer/deck_holder_renderer.tscn +++ b/graph_node_renderer/deck_holder_renderer.tscn @@ -122,6 +122,11 @@ item_0/id = 0 item_1/text = "Twitch.." item_1/id = 1 +[node name="Debug" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"] +item_count = 1 +item_0/text = "Decks..." +item_0/id = 0 + [node name="TabContainerCustom" parent="MarginContainer/VSplitContainer/VBoxContainer" instance=ExtResource("1_s3ug2")] unique_name_in_owner = true layout_mode = 2 @@ -153,4 +158,5 @@ visible = false [connection signal="id_pressed" from="MarginContainer/VSplitContainer/VBoxContainer/MenuBar/File" to="." method="_on_file_id_pressed"] [connection signal="id_pressed" from="MarginContainer/VSplitContainer/VBoxContainer/MenuBar/Connections" to="." method="_on_connections_id_pressed"] +[connection signal="id_pressed" from="MarginContainer/VSplitContainer/VBoxContainer/MenuBar/Debug" to="." method="_on_debug_id_pressed"] [connection signal="connect_button_pressed" from="OBSWebsocketSetupDialog" to="." method="_on_obs_websocket_setup_dialog_connect_button_pressed"]