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-04-25 23:10:17 +00:00
|
|
|
const NativeDialogs := preload("res://addons/native_dialogs/native_dialogs.gd")
|
|
|
|
|
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
|
2023-04-22 20:02:31 +00:00
|
|
|
onready var file_path_open_button := $"%FilePathOpenButton" as Button
|
2023-03-09 20:26:57 +00:00
|
|
|
onready var attributions_rich_text_label := $"%AttributionsRichTextLabel" as RichTextLabel
|
2023-04-25 23:10:17 +00:00
|
|
|
var file_path_file_dialog := NativeDialogs.SaveFile.new()
|
|
|
|
var theme_path_file_dialog := NativeDialogs.OpenFile.new()
|
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
|
2023-04-22 02:04:35 +00:00
|
|
|
config.connect("time_sheet_loaded", 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-04-25 23:10:17 +00:00
|
|
|
file_path_file_dialog.filters = ["*.csv ; CSV Files"]
|
|
|
|
file_path_file_dialog.force_overwrite = true
|
|
|
|
add_child(file_path_file_dialog)
|
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")
|
2023-04-25 23:10:17 +00:00
|
|
|
|
2023-03-09 20:26:57 +00:00
|
|
|
# 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-25 23:10:17 +00:00
|
|
|
theme_path_file_dialog.filters = ["*.theme ; Theme Files"]
|
|
|
|
add_child(theme_path_file_dialog)
|
2023-04-22 01:08:05 +00:00
|
|
|
# warning-ignore:return_value_discarded
|
2023-04-25 23:10:17 +00:00
|
|
|
theme_path_file_dialog.connect("files_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 20:02:31 +00:00
|
|
|
# warning-ignore:return_value_discarded
|
|
|
|
file_path_open_button.connect("pressed", self, "_on_file_path_open_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:
|
2023-04-25 23:10:17 +00:00
|
|
|
#file_path_file_dialog.initial_path = config.current_timesheet_file_path.get_base_dir()
|
2023-04-22 02:04:35 +00:00
|
|
|
file_path_line_edit.text = config.current_timesheet_file_path
|
2023-03-09 20:26:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_theme_changed() -> void:
|
|
|
|
theme = config.theme
|
|
|
|
|
|
|
|
|
|
|
|
func _on_file_path_button_pressed() -> void:
|
2023-04-25 23:10:17 +00:00
|
|
|
file_path_file_dialog.initial_path = config.current_timesheet_file_path
|
|
|
|
file_path_file_dialog.show()
|
2023-03-09 20:26:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_current_file_selected(new_file: String) -> void:
|
2023-04-25 23:10:17 +00:00
|
|
|
config.current_timesheet_file_path = new_file
|
2023-03-09 20:26:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_sound_toggle(is_on: bool) -> void:
|
|
|
|
config.sound_fx_on = is_on
|
|
|
|
|
|
|
|
|
|
|
|
func _on_theme_path_button_pressed() -> void:
|
2023-04-25 23:10:17 +00:00
|
|
|
theme_path_file_dialog.initial_path = config.theme_file_path
|
|
|
|
theme_path_file_dialog.show()
|
2023-03-09 20:26:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_new_theme_selected(new_theme_path: String) -> void:
|
2023-04-25 23:10:17 +00:00
|
|
|
config.theme_file_path = new_theme_path
|
2023-03-09 20:26:57 +00:00
|
|
|
|
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:
|
2023-04-25 22:31:12 +00:00
|
|
|
_open_path(OS.get_user_data_dir())
|
2023-04-22 20:02:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_file_path_open_button_pressed() -> void:
|
2023-04-25 22:31:12 +00:00
|
|
|
_open_path(config.current_timesheet_file_path.get_base_dir())
|
|
|
|
|
|
|
|
|
|
|
|
func _open_path(path: String):
|
|
|
|
var canonical_path := ProjectSettings.globalize_path(path).strip_edges()
|
2023-04-22 20:02:31 +00:00
|
|
|
# warning-ignore:return_value_discarded
|
2023-04-25 22:31:12 +00:00
|
|
|
OS.shell_open("file://"+canonical_path)
|