extends Control var config: ConfigManager = preload("res://config_manager.tres") const NativeDialogs := preload("res://addons/native_dialogs/native_dialogs.gd") 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 file_path_open_button := $"%FilePathOpenButton" as Button onready var attributions_rich_text_label := $"%AttributionsRichTextLabel" as RichTextLabel var file_path_file_dialog := NativeDialogs.SaveFile.new() var theme_path_file_dialog := NativeDialogs.OpenFile.new() func _ready() -> void: # warning-ignore:return_value_discarded config.connect("theme_changed", self, "_on_theme_changed") # warning-ignore:return_value_discarded config.connect("time_sheet_loaded", self, "_on_current_file_changed") # warning-ignore:return_value_discarded file_path_button.connect("pressed", self, "_on_file_path_button_pressed") file_path_file_dialog.filters = ["*.csv ; CSV Files"] file_path_file_dialog.force_overwrite = true add_child(file_path_file_dialog) # warning-ignore:return_value_discarded file_path_file_dialog.connect("file_selected", self, "_on_current_file_selected") # warning-ignore:return_value_discarded file_path_line_edit.connect("text_entered", self, "_on_current_file_selected") # warning-ignore:return_value_discarded theme_path_button.connect("pressed", self, "_on_theme_path_button_pressed") theme_path_file_dialog.filters = ["*.theme ; Theme Files"] add_child(theme_path_file_dialog) # warning-ignore:return_value_discarded theme_path_file_dialog.connect("files_selected", self, "_on_new_theme_selected") theme_path_file_dialog.hide() file_path_file_dialog.hide() sound_check_box.pressed = config.sound_fx_on # warning-ignore:return_value_discarded sound_check_box.connect("toggled", self, "_on_sound_toggle") # warning-ignore:return_value_discarded attributions_rich_text_label.connect("meta_clicked", self, "_on_attributions_rich_text_label_meta_clicked") # warning-ignore:return_value_discarded open_data_dir_button.connect("pressed", self, "_on_open_data_dir_button_pressed") # warning-ignore:return_value_discarded file_path_open_button.connect("pressed", self, "_on_file_path_open_button_pressed") _on_current_file_changed() func _on_current_file_changed() -> void: #file_path_file_dialog.initial_path = config.current_timesheet_file_path.get_base_dir() file_path_line_edit.text = config.current_timesheet_file_path func _on_theme_changed() -> void: theme = config.theme func _on_file_path_button_pressed() -> void: file_path_file_dialog.initial_path = config.current_timesheet_file_path file_path_file_dialog.show() func _on_current_file_selected(new_file: String) -> void: config.current_timesheet_file_path = 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.initial_path = config.theme_file_path theme_path_file_dialog.show() func _on_new_theme_selected(new_theme_path: String) -> void: config.theme_file_path = new_theme_path func _on_attributions_rich_text_label_meta_clicked(meta) -> void: if meta is String: # warning-ignore:return_value_discarded OS.shell_open(meta) func _on_open_data_dir_button_pressed() -> void: _open_path(OS.get_user_data_dir()) func _on_file_path_open_button_pressed() -> void: _open_path(config.current_timesheet_file_path.get_base_dir()) func _open_path(path: String): var canonical_path := ProjectSettings.globalize_path(path).strip_edges() # warning-ignore:return_value_discarded OS.shell_open("file://"+canonical_path)