add a debug tool to view open decks to deck holder renderer

This commit is contained in:
Lera Elvoé 2023-12-08 08:41:32 +03:00
parent 58842437b6
commit 08e6bb2a17
No known key found for this signature in database
4 changed files with 69 additions and 0 deletions

View file

@ -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)

View file

@ -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")

View file

@ -7,6 +7,7 @@ class_name DeckHolderRenderer
## Reference to the base scene for [DeckRendererGraphEdit] ## Reference to the base scene for [DeckRendererGraphEdit]
const DECK_SCENE := preload("res://graph_node_renderer/deck_renderer_graph_edit.tscn") 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] ## Reference to the main windows [TabContainerCustom]
@onready var tab_container: TabContainerCustom = %TabContainerCustom as 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: func _process(delta: float) -> void:
DeckHolder.send_event(&"process", {"delta": delta}) 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 %s>" % [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, "<Group %s::%s>" % [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)

View file

@ -122,6 +122,11 @@ item_0/id = 0
item_1/text = "Twitch.." item_1/text = "Twitch.."
item_1/id = 1 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")] [node name="TabContainerCustom" parent="MarginContainer/VSplitContainer/VBoxContainer" instance=ExtResource("1_s3ug2")]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 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/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/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"] [connection signal="connect_button_pressed" from="OBSWebsocketSetupDialog" to="." method="_on_obs_websocket_setup_dialog_connect_button_pressed"]