refactor
This commit is contained in:
@ -5,23 +5,58 @@ const CONFIG_PATH := "user://settings.cfg"
|
||||
var _config := ConfigFile.new()
|
||||
|
||||
|
||||
var timesheet: TimeSheet:
|
||||
get:
|
||||
if timesheet == null:
|
||||
timesheet = TimeSheet.restore(current_file)
|
||||
return timesheet
|
||||
|
||||
signal file_changed
|
||||
var current_file: String = "":
|
||||
set(value):
|
||||
current_file = value
|
||||
_config.set_value("MAIN", "file", value)
|
||||
save()
|
||||
set = set_current_file,
|
||||
get = get_current_file
|
||||
|
||||
|
||||
func set_current_file(value: String) -> void:
|
||||
timesheet = TimeSheet.restore(value)
|
||||
if timesheet == null:
|
||||
return
|
||||
current_file = value
|
||||
_config.set_value("MAIN", "file", value)
|
||||
file_changed.emit()
|
||||
save()
|
||||
|
||||
|
||||
func get_current_file() -> String:
|
||||
var _default_path := OS.get_system_dir(OS.SYSTEM_DIR_DOCUMENTS, true).path_join("mouse_timer.csv")
|
||||
return _config.get_value("MAIN", "file", _default_path)
|
||||
|
||||
|
||||
var theme: Theme:
|
||||
get:
|
||||
var _default_path := OS.get_system_dir(OS.SYSTEM_DIR_DOCUMENTS, true).path_join("mouse_timer.csv")
|
||||
return _config.get_value("MAIN", "file", _default_path)
|
||||
if theme == null:
|
||||
theme = ResourceLoader.load(theme_path, "Theme")
|
||||
return theme
|
||||
|
||||
|
||||
signal theme_changed
|
||||
var theme_path: String = "":
|
||||
set(value):
|
||||
theme_path = value
|
||||
_config.set_value("MAIN", "theme", value)
|
||||
save()
|
||||
get:
|
||||
return _config.get_value("MAIN", "theme", preload("res://assets/default_theme.theme").resource_path)
|
||||
set = set_theme_path,
|
||||
get = get_theme_path
|
||||
|
||||
|
||||
func set_theme_path(value: String) -> void:
|
||||
var new_theme: Theme = ResourceLoader.load(value, "Theme")
|
||||
if new_theme != null:
|
||||
theme = new_theme
|
||||
theme_path = value
|
||||
_config.set_value("MAIN", "theme", value)
|
||||
theme_changed.emit()
|
||||
save()
|
||||
|
||||
|
||||
func get_theme_path() -> String:
|
||||
return _config.get_value("MAIN", "theme", preload("res://assets/default_theme.theme").resource_path)
|
||||
|
||||
|
||||
var last_task_name: String = "":
|
||||
@ -42,7 +77,6 @@ var sound_fx_on: bool = true:
|
||||
return _config.get_value("MAIN", "sound_fx", true)
|
||||
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_config.load(CONFIG_PATH)
|
||||
|
||||
|
Reference in New Issue
Block a user