From a56280f00aa2da22bf4f7e30408ff78cf7886277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Thu, 11 Apr 2024 15:32:13 +0000 Subject: [PATCH] add settings dialog (#144) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/144 Co-authored-by: Lera ElvoƩ Co-committed-by: Lera ElvoƩ --- graph_node_renderer/deck_holder_renderer.gd | 11 ++++ graph_node_renderer/deck_holder_renderer.tscn | 10 +++- graph_node_renderer/settings_dialog.gd | 25 +++++++++ graph_node_renderer/settings_dialog.tscn | 56 +++++++++++++++++++ 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 graph_node_renderer/settings_dialog.gd create mode 100644 graph_node_renderer/settings_dialog.tscn diff --git a/graph_node_renderer/deck_holder_renderer.gd b/graph_node_renderer/deck_holder_renderer.gd index 7335630..6deab4e 100644 --- a/graph_node_renderer/deck_holder_renderer.gd +++ b/graph_node_renderer/deck_holder_renderer.gd @@ -61,6 +61,11 @@ enum HelpMenuId { } @onready var about_dialog: AcceptDialog = %AboutDialog +enum EditMenuId { + SETTINGS, +} +@onready var settings_dialog: SettingsDialog = %SettingsDialog + ## Weak Reference to the Deck that is currently going to be saved. var _deck_to_save: WeakRef @@ -200,6 +205,12 @@ func _on_file_id_pressed(id: int) -> void: open_deck_at_path(recent_files[id - FileMenuId.RECENTS - 1]) +func _on_edit_id_pressed(id: int) -> void: + match id: + EditMenuId.SETTINGS: + settings_dialog.popup_centered() + + ## Adds an empty [DeckRendererGraphEdit] with a corresponding [Deck] for it's data. func add_empty_deck() -> void: var deck := DeckHolder.add_empty_deck() diff --git a/graph_node_renderer/deck_holder_renderer.tscn b/graph_node_renderer/deck_holder_renderer.tscn index 60070a1..cd9aa06 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=26 format=3 uid="uid://duaah5x0jhkn6"] +[gd_scene load_steps=27 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"] @@ -15,6 +15,7 @@ [ext_resource type="PackedScene" uid="uid://cvvkj138fg8jg" path="res://graph_node_renderer/unsaved_changes_dialog.tscn" id="9_4n0q6"] [ext_resource type="PackedScene" uid="uid://bu466w2w3q08c" path="res://graph_node_renderer/about_dialog.tscn" id="11_6ln7n"] [ext_resource type="PackedScene" uid="uid://brfrufvkjwcor" path="res://graph_node_renderer/rpc_setup_dialog.tscn" id="12_1xrfk"] +[ext_resource type="PackedScene" uid="uid://dodqetbke5wji" path="res://graph_node_renderer/settings_dialog.tscn" id="16_rktri"] [sub_resource type="InputEventKey" id="InputEventKey_giamc"] device = -1 @@ -127,6 +128,9 @@ item_7/separator = true [node name="Edit" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"] unique_name_in_owner = true +item_count = 1 +item_0/text = "Settings..." +item_0/id = 0 [node name="Connections" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"] unique_name_in_owner = true @@ -197,7 +201,11 @@ script = ExtResource("5_3n36q") [node name="AboutDialog" parent="." instance=ExtResource("11_6ln7n")] unique_name_in_owner = true +[node name="SettingsDialog" parent="." instance=ExtResource("16_rktri")] +unique_name_in_owner = true + [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/Edit" to="." method="_on_edit_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="id_pressed" from="MarginContainer/VSplitContainer/VBoxContainer/MenuBar/Help" to="." method="_on_help_id_pressed"] diff --git a/graph_node_renderer/settings_dialog.gd b/graph_node_renderer/settings_dialog.gd new file mode 100644 index 0000000..7fb88a4 --- /dev/null +++ b/graph_node_renderer/settings_dialog.gd @@ -0,0 +1,25 @@ +# (c) 2023-present Eroax +# (c) 2023-present Yagich +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +extends AcceptDialog +class_name SettingsDialog + +@onready var category_tree: Tree = %CategoryTree +@onready var category_content: Control = %CategoryContent +@onready var shortcuts_tree: Tree = %Shortcuts + + +func _ready() -> void: + var cr := category_tree.create_item() + for i in category_content.get_children(): + var item := category_tree.create_item(cr) + item.set_text(0, i.name) + + category_tree.item_selected.connect( + func(): + var item := category_tree.get_selected() + for i: Control in category_content.get_children(): + i.visible = i.get_index() == item.get_index() + ) + + category_tree.set_selected(cr.get_child(0), 0) diff --git a/graph_node_renderer/settings_dialog.tscn b/graph_node_renderer/settings_dialog.tscn new file mode 100644 index 0000000..a53ad3c --- /dev/null +++ b/graph_node_renderer/settings_dialog.tscn @@ -0,0 +1,56 @@ +[gd_scene load_steps=2 format=3 uid="uid://dodqetbke5wji"] + +[ext_resource type="Script" path="res://graph_node_renderer/settings_dialog.gd" id="1_lh25g"] + +[node name="SettingsDialog" type="AcceptDialog"] +title = "Settings" +initial_position = 1 +size = Vector2i(705, 370) +min_size = Vector2i(500, 250) +ok_button_text = "Close" +script = ExtResource("1_lh25g") + +[node name="HSplitContainer" type="HSplitContainer" parent="."] +offset_left = 8.0 +offset_top = 8.0 +offset_right = 697.0 +offset_bottom = 321.0 + +[node name="CategoryTree" type="Tree" parent="HSplitContainer"] +unique_name_in_owner = true +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 +hide_root = true + +[node name="CategoryContent" type="Control" parent="HSplitContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="General" type="VBoxContainer" parent="HSplitContainer/CategoryContent"] +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Label" type="Label" parent="HSplitContainer/CategoryContent/General"] +layout_mode = 2 +text = "Library Group Search Paths" + +[node name="LibraryGroupPaths" type="PanelContainer" parent="HSplitContainer/CategoryContent/General"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="Shortcuts" type="Tree" parent="HSplitContainer/CategoryContent"] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +hide_root = true