extends Control var config: ConfigManager = preload("res://config_manager.tres") onready var file_path_line_edit: LineEdit = $"%FilePathLineEdit" as LineEdit onready var file_path_button: Button = $"%FilePathButton" as Button onready var theme_path_button: Button = $"%ThemePathButton" as Button onready var sound_check_box: CheckBox = $"%SoundCheckBox" as CheckBox onready var open_data_dir_button: Button = $"%OpenDataDirButton" as Button onready var file_path_open_button: Button = $"%FilePathOpenButton" as Button onready var attributions_rich_text_label: RichTextLabel = $"%AttributionsRichTextLabel" as RichTextLabel onready var file_path_file_dialog: FileDialog = $"%FilePathFileDialog" as FileDialog onready var theme_path_file_dialog: FileDialog = $"%ThemePathFileDialog" as FileDialog 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") # warning-ignore:return_value_discarded file_path_file_dialog.connect("visibility_changed", self, "_resize_on_dialog", [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") # warning-ignore:return_value_discarded theme_path_file_dialog.connect("visibility_changed", self, "_resize_on_dialog", [theme_path_file_dialog]) # warning-ignore:return_value_discarded theme_path_file_dialog.connect("file_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: _set_file_dialog_file_path(file_path_file_dialog, config.current_timesheet_file_path) 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: _set_file_dialog_file_path(theme_path_file_dialog, 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) func _set_file_dialog_file_path(dialog: FileDialog, path: String) -> void: #dialog.current_path = path #dialog.current_file = path dialog.current_dir = path.get_base_dir() dialog.show() dialog.invalidate() var previous_window_size := OS.window_size func _resize_on_dialog(dialog: Control) -> void: if dialog.visible == true: previous_window_size = OS.window_size OS.window_size = file_path_file_dialog.rect_size else: OS.window_size = previous_window_size