rat-times/ui/settings.gd

93 lines
3.0 KiB
GDScript3
Raw Normal View History

2023-04-22 01:08:05 +00:00
extends Control
2023-03-04 13:31:27 +00:00
var config: ConfigManager = preload("res://config_manager.tres")
2023-03-09 20:26:57 +00:00
onready var file_path_line_edit := $"%FilePathLineEdit" as LineEdit
onready var file_path_button := $"%FilePathButton" as Button
onready var theme_path_button := $"%ThemePathButton" as Button
onready var sound_check_box := $"%SoundCheckBox" as CheckBox
onready var open_data_dir_button := $"%OpenDataDirButton" as Button
onready var attributions_rich_text_label := $"%AttributionsRichTextLabel" as RichTextLabel
onready var file_path_file_dialog := $"%FilePathFileDialog" as FileDialog
onready var theme_path_file_dialog := $"%ThemePathFileDialog" as FileDialog
2023-03-04 13:31:27 +00:00
func _ready() -> void:
2023-03-09 20:26:57 +00:00
# warning-ignore:return_value_discarded
config.connect("theme_changed", self, "_on_theme_changed")
# warning-ignore:return_value_discarded
config.connect("file_changed", self, "_on_current_file_changed")
2023-03-04 13:31:27 +00:00
2023-03-09 20:26:57 +00:00
# warning-ignore:return_value_discarded
file_path_button.connect("pressed", self, "_on_file_path_button_pressed")
2023-03-04 13:31:27 +00:00
2023-03-09 20:26:57 +00:00
# warning-ignore:return_value_discarded
file_path_file_dialog.connect("file_selected", self, "_on_current_file_selected")
# warning-ignore:return_value_discarded
2023-04-22 01:08:05 +00:00
file_path_line_edit.connect("text_entered", self, "_on_current_file_selected")
2023-03-04 13:31:27 +00:00
2023-04-22 01:08:05 +00:00
# warning-ignore:return_value_discarded
theme_path_button.connect("pressed", self, "_on_theme_path_button_pressed")
2023-03-04 13:31:27 +00:00
2023-04-22 01:08:05 +00:00
# warning-ignore:return_value_discarded
theme_path_file_dialog.connect("file_selected", self, "_on_new_theme_selected")
2023-03-04 13:31:27 +00:00
theme_path_file_dialog.hide()
file_path_file_dialog.hide()
2023-03-09 20:26:57 +00:00
sound_check_box.pressed = config.sound_fx_on
# warning-ignore:return_value_discarded
sound_check_box.connect("toggled", self, "_on_sound_toggle")
2023-03-04 13:31:27 +00:00
2023-03-09 20:26:57 +00:00
# warning-ignore:return_value_discarded
attributions_rich_text_label.connect("meta_clicked", self, "_on_attributions_rich_text_label_meta_clicked")
2023-03-04 13:31:27 +00:00
2023-03-09 20:26:57 +00:00
# warning-ignore:return_value_discarded
open_data_dir_button.connect("pressed", self, "_on_open_data_dir_button_pressed")
2023-04-22 01:08:05 +00:00
_on_current_file_changed()
2023-03-09 20:26:57 +00:00
func _on_current_file_changed() -> 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
func _on_theme_changed() -> void:
theme = config.theme
func _on_file_path_button_pressed() -> void:
file_path_file_dialog.popup_centered()
func _on_current_file_selected(new_file: String) -> void:
config.set_current_file = new_file
func _on_sound_toggle(is_on: bool) -> void:
config.sound_fx_on = is_on
func _on_theme_path_button_pressed() -> void:
theme_path_file_dialog.popup_centered()
func _on_new_theme_selected(new_theme_path: String) -> void:
config.set_theme_path = new_theme_path
2023-03-04 13:31:27 +00:00
2023-03-09 20:26:57 +00:00
func _on_attributions_rich_text_label_meta_clicked(meta) -> void:
if meta is String:
# warning-ignore:return_value_discarded
OS.shell_open(meta)
2023-03-04 13:31:27 +00:00
2023-03-09 20:26:57 +00:00
func _on_open_data_dir_button_pressed() -> void:
# warning-ignore:return_value_discarded
OS.shell_open(OS.get_user_data_dir())