rat-times/ui/settings.gd
2023-03-04 17:31:27 +04:00

60 lines
1.7 KiB
GDScript

extends PanelContainer
var config: ConfigManager = preload("res://config_manager.tres")
@onready var file_path_file_dialog: FileDialog = %FilePathFileDialog
@onready var file_path_line_edit: LineEdit = %FilePathLineEdit
@onready var file_path_button: Button = %FilePathButton
@onready var theme_path_file_dialog: FileDialog = %ThemePathFileDialog
@onready var theme_path_button: Button = %ThemePathButton
@onready var sound_check_box: CheckBox = %SoundCheckBox
@onready var attributions_rich_text_label: RichTextLabel = %AttributionsRichTextLabel
@onready var open_data_dir_button: Button = %OpenDataDirButton
func _ready() -> void:
config.theme_changed.connect(
func set_current_theme() -> void:
theme = config.theme
)
config.file_changed.connect(
func set_current_file() -> void:
file_path_file_dialog.current_path = config.current_file
file_path_file_dialog.current_dir = config.current_file.get_base_dir()
file_path_line_edit.text = config.current_file
)
file_path_button.pressed.connect(
file_path_file_dialog.popup_centered
)
file_path_file_dialog.file_selected.connect(config.set_current_file)
file_path_line_edit.text_submitted.connect(config.set_current_file)
theme_path_button.pressed.connect(
theme_path_file_dialog.popup_centered
)
theme_path_file_dialog.file_selected.connect(config.set_theme_path)
theme_path_file_dialog.hide()
file_path_file_dialog.hide()
sound_check_box.button_pressed = config.sound_fx_on
sound_check_box.toggled.connect(
func sound_toggle(is_on: bool) -> void:
config.sound_fx_on = is_on
)
attributions_rich_text_label.meta_clicked.connect(OS.shell_open)
open_data_dir_button.pressed.connect(
OS.shell_open.bind(OS.get_user_data_dir())
)