add settings dialog (#144)

Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/144
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
Lera Elvoé 2024-04-11 15:32:13 +00:00 committed by yagich
parent a518e46b0f
commit a56280f00a
4 changed files with 101 additions and 1 deletions

View file

@ -61,6 +61,11 @@ enum HelpMenuId {
} }
@onready var about_dialog: AcceptDialog = %AboutDialog @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. ## Weak Reference to the Deck that is currently going to be saved.
var _deck_to_save: WeakRef 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]) 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. ## Adds an empty [DeckRendererGraphEdit] with a corresponding [Deck] for it's data.
func add_empty_deck() -> void: func add_empty_deck() -> void:
var deck := DeckHolder.add_empty_deck() var deck := DeckHolder.add_empty_deck()

View file

@ -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="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"] [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://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://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://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"] [sub_resource type="InputEventKey" id="InputEventKey_giamc"]
device = -1 device = -1
@ -127,6 +128,9 @@ item_7/separator = true
[node name="Edit" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"] [node name="Edit" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"]
unique_name_in_owner = true 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"] [node name="Connections" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"]
unique_name_in_owner = true unique_name_in_owner = true
@ -197,7 +201,11 @@ script = ExtResource("5_3n36q")
[node name="AboutDialog" parent="." instance=ExtResource("11_6ln7n")] [node name="AboutDialog" parent="." instance=ExtResource("11_6ln7n")]
unique_name_in_owner = true 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/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/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/Debug" to="." method="_on_debug_id_pressed"]
[connection signal="id_pressed" from="MarginContainer/VSplitContainer/VBoxContainer/MenuBar/Help" to="." method="_on_help_id_pressed"] [connection signal="id_pressed" from="MarginContainer/VSplitContainer/VBoxContainer/MenuBar/Help" to="." method="_on_help_id_pressed"]

View file

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

View file

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