From bdea885a91743c68f6879435bc784e82e13eba88 Mon Sep 17 00:00:00 2001 From: stmSi Date: Sun, 28 May 2023 00:02:12 +0630 Subject: [PATCH] Fixed: Progress not saving in exported binaries --- src/Autoload/DisplaySettings.gd | 2 ++ src/Autoload/GeneralSettings.gd | 1 + src/Autoload/SoundSettings.gd | 1 + src/Autoload/UserProfileManager.gd | 1 + src/Autoload/Utils.gd | 12 ++++++++++++ 5 files changed, 17 insertions(+) diff --git a/src/Autoload/DisplaySettings.gd b/src/Autoload/DisplaySettings.gd index 0855921..a361424 100644 --- a/src/Autoload/DisplaySettings.gd +++ b/src/Autoload/DisplaySettings.gd @@ -39,6 +39,8 @@ signal renderer_changed(new_renderer: String) signal resolution_try_changing(original: Vector2i, new: Vector2i) signal max_fps_changed(fps: int) func _ready() -> void: + Utils.check_and_create_user_dir() + # Settings Config Setup config = ConfigFile.new() var err = config.load(display_settings_file) diff --git a/src/Autoload/GeneralSettings.gd b/src/Autoload/GeneralSettings.gd index be626a9..0f405eb 100644 --- a/src/Autoload/GeneralSettings.gd +++ b/src/Autoload/GeneralSettings.gd @@ -11,6 +11,7 @@ signal prevent_typing_pass_error_char_changed(prevent: bool) func _ready() -> void: + Utils.check_and_create_user_dir() # Settings Config Setup config = ConfigFile.new() var err = config.load(general_settings_path) diff --git a/src/Autoload/SoundSettings.gd b/src/Autoload/SoundSettings.gd index 556cc51..9c160f0 100644 --- a/src/Autoload/SoundSettings.gd +++ b/src/Autoload/SoundSettings.gd @@ -10,6 +10,7 @@ var config: ConfigFile = null func _ready() -> void: + Utils.check_and_create_user_dir() # Settings Config Setup config = ConfigFile.new() var err = config.load(settings_path) diff --git a/src/Autoload/UserProfileManager.gd b/src/Autoload/UserProfileManager.gd index 2d8ede2..cc7b84c 100644 --- a/src/Autoload/UserProfileManager.gd +++ b/src/Autoload/UserProfileManager.gd @@ -14,6 +14,7 @@ var corrected_chars_frequency = [] func _ready() -> void: + Utils.check_and_create_user_dir() if not FileAccess.file_exists(profile_data_file): save_file = ConfigFile.new() # save Default data diff --git a/src/Autoload/Utils.gd b/src/Autoload/Utils.gd index eb4425b..a8a9735 100644 --- a/src/Autoload/Utils.gd +++ b/src/Autoload/Utils.gd @@ -1,5 +1,17 @@ extends Node +func _ready() -> void: + # Just in case. + check_and_create_user_dir() + pass + +func check_and_create_user_dir(): + var dir = DirAccess.open(OS.get_user_data_dir()) + print("Checking User Dir: ", OS.get_user_data_dir()) + if dir == null: + print("User Dir Not Found.") + print("Making: ", OS.get_user_data_dir()) + dir.make_dir_recursive(OS.get_user_data_dir()) func randomize_packed_array(packed_array: PackedStringArray): # PackedStringArray doesn't support shuffle()