From 3be669da28f5936b1f86af3efa68a86a0d6f99fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Mon, 4 Dec 2023 17:27:31 +0300 Subject: [PATCH] add file menu shortcuts to deck holder renderer --- graph_node_renderer/deck_holder_renderer.gd | 14 +++++ graph_node_renderer/deck_holder_renderer.tscn | 56 ++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/graph_node_renderer/deck_holder_renderer.gd b/graph_node_renderer/deck_holder_renderer.gd index 9ef6d9b..687dff2 100644 --- a/graph_node_renderer/deck_holder_renderer.gd +++ b/graph_node_renderer/deck_holder_renderer.gd @@ -13,6 +13,12 @@ const DECK_SCENE := preload("res://graph_node_renderer/deck_renderer_graph_edit. ## Reference to the [FileDialog] used for File operations through the program. @onready var file_dialog: FileDialog = $FileDialog +@export var new_deck_shortcut: Shortcut +@export var open_deck_shortcut: Shortcut +@export var save_deck_shortcut: Shortcut +@export var save_deck_as_shortcut: Shortcut +@export var close_deck_shortcut: Shortcut + ## Enum for storing the Options in the "File" PopupMenu. enum FileMenuId { NEW, @@ -21,6 +27,8 @@ enum FileMenuId { SAVE_AS, CLOSE = 6, } +@onready var file_popup_menu: PopupMenu = %File as PopupMenu + enum ConnectionsMenuId { OBS, @@ -46,6 +54,12 @@ func _ready() -> void: file_dialog.canceled.connect(disconnect_file_dialog_signals) Connections.obs_websocket = no_obsws + file_popup_menu.set_item_shortcut(FileMenuId.NEW, new_deck_shortcut) + file_popup_menu.set_item_shortcut(FileMenuId.OPEN, open_deck_shortcut) + file_popup_menu.set_item_shortcut(FileMenuId.SAVE, save_deck_shortcut) + file_popup_menu.set_item_shortcut(FileMenuId.SAVE_AS, save_deck_as_shortcut) + file_popup_menu.set_item_shortcut(FileMenuId.CLOSE, close_deck_shortcut) + ## Called when the File button in the [MenuBar] is pressed with the [param id] ## of the button within it that was pressed. diff --git a/graph_node_renderer/deck_holder_renderer.tscn b/graph_node_renderer/deck_holder_renderer.tscn index 68e7064..492ddaa 100644 --- a/graph_node_renderer/deck_holder_renderer.tscn +++ b/graph_node_renderer/deck_holder_renderer.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=3 uid="uid://duaah5x0jhkn6"] +[gd_scene load_steps=16 format=3 uid="uid://duaah5x0jhkn6"] [ext_resource type="Script" path="res://graph_node_renderer/deck_holder_renderer.gd" id="1_67g2g"] [ext_resource type="PackedScene" uid="uid://b84f2ngtcm5b8" path="res://graph_node_renderer/tab_container_custom.tscn" id="1_s3ug2"] @@ -6,6 +6,52 @@ [ext_resource type="Script" path="res://addons/no-obs-ws/NoOBSWS.gd" id="4_nu72u"] [ext_resource type="PackedScene" uid="uid://eioso6jb42jy" path="res://graph_node_renderer/obs_websocket_setup_dialog.tscn" id="5_uo2gj"] +[sub_resource type="InputEventKey" id="InputEventKey_giamc"] +device = -1 +ctrl_pressed = true +keycode = 78 +unicode = 110 + +[sub_resource type="Shortcut" id="Shortcut_30rq6"] +events = [SubResource("InputEventKey_giamc")] + +[sub_resource type="InputEventKey" id="InputEventKey_cyjf4"] +device = -1 +ctrl_pressed = true +keycode = 79 +unicode = 111 + +[sub_resource type="Shortcut" id="Shortcut_m48tj"] +events = [SubResource("InputEventKey_cyjf4")] + +[sub_resource type="InputEventKey" id="InputEventKey_jgr3p"] +device = -1 +ctrl_pressed = true +keycode = 83 +unicode = 115 + +[sub_resource type="Shortcut" id="Shortcut_xr6s4"] +events = [SubResource("InputEventKey_jgr3p")] + +[sub_resource type="InputEventKey" id="InputEventKey_762xj"] +device = -1 +shift_pressed = true +ctrl_pressed = true +keycode = 83 +unicode = 83 + +[sub_resource type="Shortcut" id="Shortcut_myxuq"] +events = [SubResource("InputEventKey_762xj")] + +[sub_resource type="InputEventKey" id="InputEventKey_exx3o"] +device = -1 +ctrl_pressed = true +keycode = 87 +unicode = 119 + +[sub_resource type="Shortcut" id="Shortcut_46v8y"] +events = [SubResource("InputEventKey_exx3o")] + [node name="DeckHolderRenderer" type="Control"] layout_mode = 3 anchors_preset = 15 @@ -15,6 +61,11 @@ grow_horizontal = 2 grow_vertical = 2 theme = ExtResource("1_tgul2") script = ExtResource("1_67g2g") +new_deck_shortcut = SubResource("Shortcut_30rq6") +open_deck_shortcut = SubResource("Shortcut_m48tj") +save_deck_shortcut = SubResource("Shortcut_xr6s4") +save_deck_as_shortcut = SubResource("Shortcut_myxuq") +close_deck_shortcut = SubResource("Shortcut_46v8y") [node name="MarginContainer" type="MarginContainer" parent="."] layout_mode = 1 @@ -39,6 +90,7 @@ layout_mode = 2 layout_mode = 2 [node name="File" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"] +unique_name_in_owner = true item_count = 7 item_0/text = "New Deck" item_0/id = 0 @@ -58,8 +110,10 @@ item_6/text = "Close Deck" item_6/id = 6 [node name="Edit" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"] +unique_name_in_owner = true [node name="Connections" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"] +unique_name_in_owner = true item_count = 1 item_0/text = "OBS..." item_0/id = 0