add debug option to embed subwindows

This commit is contained in:
Lera Elvoé 2023-12-15 00:50:42 +03:00
parent ca0fc15103
commit e405b921d5
No known key found for this signature in database
2 changed files with 34 additions and 9 deletions

View file

@ -43,6 +43,12 @@ enum ConnectionsMenuId {
TWITCH, TWITCH,
} }
enum DebugMenuId{
DECKS,
EMBED_SUBWINDOWS,
}
@onready var debug_popup_menu: PopupMenu = %Debug
## Weak Reference to the Deck that is currently going to be saved. ## Weak Reference to the Deck that is currently going to be saved.
var _deck_to_save: WeakRef var _deck_to_save: WeakRef
@ -58,6 +64,13 @@ func _ready() -> void:
tab_container.add_button_pressed.connect(add_empty_deck) tab_container.add_button_pressed.connect(add_empty_deck)
RendererPersistence.init_namespace(PERSISTENCE_NAMESPACE) RendererPersistence.init_namespace(PERSISTENCE_NAMESPACE)
debug_popup_menu.set_item_checked(
DebugMenuId.EMBED_SUBWINDOWS,
RendererPersistence.get_or_create(PERSISTENCE_NAMESPACE, "config", "embed_subwindows", true)
)
get_tree().get_root().gui_embed_subwindows = RendererPersistence.get_value(PERSISTENCE_NAMESPACE, "config", "embed_subwindows")
recent_files = RendererPersistence.get_or_create( recent_files = RendererPersistence.get_or_create(
PERSISTENCE_NAMESPACE, "config", PERSISTENCE_NAMESPACE, "config",
"recent_files", [] "recent_files", []
@ -281,6 +294,8 @@ func _process(delta: float) -> void:
func _on_debug_id_pressed(id: int) -> void: func _on_debug_id_pressed(id: int) -> void:
match id:
DebugMenuId.DECKS:
var d := AcceptDialog.new() var d := AcceptDialog.new()
var debug_decks: DebugDecksList = DEBUG_DECKS_LIST.instantiate() var debug_decks: DebugDecksList = DEBUG_DECKS_LIST.instantiate()
d.add_child(debug_decks) d.add_child(debug_decks)
@ -289,6 +304,11 @@ func _on_debug_id_pressed(id: int) -> void:
debug_decks.item_pressed.connect(_on_debug_decks_viewer_item_pressed) debug_decks.item_pressed.connect(_on_debug_decks_viewer_item_pressed)
add_child(d) add_child(d)
d.popup_centered() d.popup_centered()
DebugMenuId.EMBED_SUBWINDOWS:
var c := debug_popup_menu.is_item_checked(id)
debug_popup_menu.set_item_checked(id, !c)
get_tree().get_root().gui_embed_subwindows = !c
RendererPersistence.set_value(PERSISTENCE_NAMESPACE, "config", "embed_subwindows", !c)
func _on_debug_decks_viewer_item_pressed(deck_id: String, instance_id: String) -> void: func _on_debug_decks_viewer_item_pressed(deck_id: String, instance_id: String) -> void:

View file

@ -129,9 +129,14 @@ item_1/text = "Twitch.."
item_1/id = 1 item_1/id = 1
[node name="Debug" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"] [node name="Debug" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"]
item_count = 1 unique_name_in_owner = true
item_count = 2
item_0/text = "Decks..." item_0/text = "Decks..."
item_0/id = 0 item_0/id = 0
item_1/text = "Embed subwindows"
item_1/checkable = 1
item_1/checked = true
item_1/id = 1
[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