From eb0f6b99dbed152216c022fa157d32c974963f5a Mon Sep 17 00:00:00 2001 From: teackot Date: Thu, 10 Nov 2022 17:03:38 +0300 Subject: [PATCH 01/12] Settings and game installations can now be stored separately from the executable --- scripts/Debug.gd | 4 +-- scripts/ModManager.gd | 4 +-- scripts/ReleaseInstaller.gd | 6 ++-- scripts/SoundpackManager.gd | 4 +-- scripts/SoundpacksUI.gd | 2 +- scripts/path_helper.gd | 65 +++++++++++++++++++++++++++---------- scripts/settings_manager.gd | 2 +- 7 files changed, 58 insertions(+), 29 deletions(-) diff --git a/scripts/Debug.gd b/scripts/Debug.gd index f672c20b..45f34090 100644 --- a/scripts/Debug.gd +++ b/scripts/Debug.gd @@ -41,7 +41,7 @@ func _on_Button2_pressed() -> void: func _on_Button3_pressed(): var d = Directory.new() - var dir = Paths.own_dir.plus_file("testdir") + var dir = Paths.data_dir.plus_file("testdir") d.make_dir(dir) var command_linux = { @@ -85,7 +85,7 @@ func _on_Button4_pressed() -> void: func _on_Button5_pressed() -> void: - var path = Paths.own_dir + var path = Paths.data_dir Status.post("Listing directory %s..." % path, Enums.MSG_DEBUG) yield(get_tree().create_timer(0.1), "timeout") diff --git a/scripts/ModManager.gd b/scripts/ModManager.gd index 2f138c6e..4262e034 100644 --- a/scripts/ModManager.gd +++ b/scripts/ModManager.gd @@ -264,10 +264,10 @@ func retrieve_kenan_pack() -> void: emit_signal("modpack_retrieval_started") Status.post(tr("msg_getting_kenan_pack") % game.to_upper()) - Downloader.download_file(pack["url"], Paths.own_dir, pack["filename"]) + Downloader.download_file(pack["url"], Paths.data_dir, pack["filename"]) yield(Downloader, "download_finished") - var archive = Paths.own_dir.plus_file(pack["filename"]) + var archive = Paths.data_dir.plus_file(pack["filename"]) if Directory.new().file_exists(archive): FS.extract(archive, Paths.tmp_dir) yield(FS, "extract_done") diff --git a/scripts/ReleaseInstaller.gd b/scripts/ReleaseInstaller.gd index 174ec0d4..df7f1404 100644 --- a/scripts/ReleaseInstaller.gd +++ b/scripts/ReleaseInstaller.gd @@ -14,10 +14,10 @@ func install_release(release_info: Dictionary, game: String, update_in: String = else: Status.post(tr("msg_installing_game") % release_info["name"]) - Downloader.download_file(release_info["url"], Paths.own_dir, release_info["filename"]) + Downloader.download_file(release_info["url"], Paths.data_dir, release_info["filename"]) yield(Downloader, "download_finished") - var archive: String = Paths.own_dir.plus_file(release_info["filename"]) + var archive: String = Paths.data_dir.plus_file(release_info["filename"]) if Directory.new().file_exists(archive): FS.extract(archive, Paths.tmp_dir) @@ -41,7 +41,7 @@ func install_release(release_info: Dictionary, game: String, update_in: String = FS.rm_dir(target_dir) yield(FS, "rm_dir_done") else: - target_dir = Paths.next_install_dir + target_dir = Paths.next_data_dir FS.move_dir(extracted_root, target_dir) yield(FS, "move_dir_done") diff --git a/scripts/SoundpackManager.gd b/scripts/SoundpackManager.gd index a1bf869d..e6ac291a 100644 --- a/scripts/SoundpackManager.gd +++ b/scripts/SoundpackManager.gd @@ -141,9 +141,9 @@ func install_pack(soundpack_index: int, from_file = null, reinstall = false, kee if from_file: archive = from_file else: - Downloader.download_file(pack["url"], Paths.own_dir, pack["filename"]) + Downloader.download_file(pack["url"], Paths.data_dir, pack["filename"]) yield(Downloader, "download_finished") - archive = Paths.own_dir.plus_file(pack["filename"]) + archive = Paths.data_dir.plus_file(pack["filename"]) if not Directory.new().file_exists(archive): Status.post(tr("msg_sound_download_failed"), Enums.MSG_ERROR) emit_signal("soundpack_installation_finished") diff --git a/scripts/SoundpacksUI.gd b/scripts/SoundpacksUI.gd index 502a48e1..26965507 100644 --- a/scripts/SoundpacksUI.gd +++ b/scripts/SoundpacksUI.gd @@ -149,7 +149,7 @@ func _on_ConfirmManualDownload_confirmed() -> void: var pack = _sound.SOUNDPACKS[_available_list.get_selected_items()[0]] OS.shell_open(pack["url"]) - _dlg_file.current_dir = Paths.own_dir + _dlg_file.current_dir = Paths.data_dir _dlg_file.popup_centered_ratio(0.9) diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index 7ccd4f6c..3a6178c7 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -4,10 +4,10 @@ extends Node signal status_message -var own_dir: String setget , _get_own_dir +var data_dir: String setget , _get_data_dir var installs_summary: Dictionary setget , _get_installs_summary var game_dir: String setget , _get_game_dir -var next_install_dir: String setget , _get_next_install_dir +var next_data_dir: String setget , _get_next_data_dir var userdata: String setget , _get_userdata_dir var config: String setget , _get_config_dir var savegames: String setget , _get_savegame_dir @@ -26,15 +26,44 @@ var tmp_dir: String setget , _get_tmp_dir var utils_dir: String setget , _get_utils_dir var save_backups: String setget , _get_save_backups_dir +var _data_dir := _determine_data_dir() var _last_active_install_name := "" -var _last_active_install_dir := "" - - -func _get_own_dir() -> String: +var _last_active_data_dir := "" + + +func _determine_data_dir() -> String: + + for arg in OS.get_cmdline_args(): + if arg.find("=") > -1: # if arg is a key-value pair + var arg_pair = arg.split("=") + if arg_pair[0] == "--data_dir_abs": + var dirname = arg_pair[1] + + if not dirname.begins_with("/"): + # relative paths are not supported, fallback to executable path + Status.post(tr("msg_path_not_absolute"), Enums.MSG_ERROR) + break + + # Ensure that data_dir_abs exists + var d = Directory.new() + if not d.dir_exists(dirname): + var error = d.make_dir_recursive(dirname) + if error: + # something went wrong, fallback to executable path + # todo: error message + Status.post(tr("msg_cannot_create_target_dir") % [dirname, error], Enums.MSG_ERROR) + break + + return dirname return OS.get_executable_path().get_base_dir() +func _get_data_dir() -> String: + + return _data_dir + + func _get_installs_summary() -> Dictionary: var result = {} @@ -42,7 +71,7 @@ func _get_installs_summary() -> Dictionary: for game in ["dda", "bn"]: var installs = {} - var base_dir = Paths.own_dir.plus_file(game) + var base_dir = Paths.data_dir.plus_file(game) for subdir in FS.list_dir(base_dir): var info_file = base_dir.plus_file(subdir).plus_file(Helpers.INFO_FILENAME) if d.file_exists(info_file): @@ -66,9 +95,9 @@ func _get_game_dir() -> String: var active_name = Settings.read("active_install_" + Settings.read("game")) if active_name == "": - return _get_next_install_dir() + return _get_next_data_dir() elif active_name == _last_active_install_name: - return _last_active_install_dir + return _last_active_data_dir else: return _find_active_game_dir() @@ -76,24 +105,24 @@ func _get_game_dir() -> String: func _find_active_game_dir() -> String: var d = Directory.new() - var base_dir = _get_own_dir().plus_file(Settings.read("game")) + var base_dir = _get_data_dir().plus_file(Settings.read("game")) for subdir in FS.list_dir(base_dir): var curr_dir = base_dir.plus_file(subdir) var info_file = curr_dir.plus_file("catapult_install_info.json") if d.file_exists(info_file): var info = Helpers.load_json_file(info_file) if ("name" in info) and (info["name"] == Settings.read("active_install_" + Settings.read("game"))): - _last_active_install_dir = curr_dir + _last_active_data_dir = curr_dir return curr_dir return "" -func _get_next_install_dir() -> String: +func _get_next_data_dir() -> String: # Finds a suitable directory name for a new game installation in the # multi-install system. The names follow the pattern "game0, game1, ..." - var base_dir := _get_own_dir().plus_file(Settings.read("game")) + var base_dir := _get_data_dir().plus_file(Settings.read("game")) var dir_number := 0 var d := Directory.new() while d.dir_exists(base_dir.plus_file("game" + str(dir_number))): @@ -103,7 +132,7 @@ func _get_next_install_dir() -> String: func _get_userdata_dir() -> String: - return _get_own_dir().plus_file(Settings.read("game")).plus_file("userdata") + return _get_data_dir().plus_file(Settings.read("game")).plus_file("userdata") func _get_config_dir() -> String: @@ -168,19 +197,19 @@ func _get_graveyard_dir() -> String: func _get_modrepo_dir() -> String: - return _get_own_dir().plus_file(Settings.read("game")).plus_file("mod_repo") + return _get_data_dir().plus_file(Settings.read("game")).plus_file("mod_repo") func _get_tmp_dir() -> String: - return _get_own_dir().plus_file(Settings.read("game")).plus_file("tmp") + return _get_data_dir().plus_file(Settings.read("game")).plus_file("tmp") func _get_utils_dir() -> String: - return _get_own_dir().plus_file("utils") + return _get_data_dir().plus_file("utils") func _get_save_backups_dir() -> String: - return _get_own_dir().plus_file(Settings.read("game")).plus_file("save_backups") + return _get_data_dir().plus_file(Settings.read("game")).plus_file("save_backups") diff --git a/scripts/settings_manager.gd b/scripts/settings_manager.gd index 748e003f..21f1fecd 100644 --- a/scripts/settings_manager.gd +++ b/scripts/settings_manager.gd @@ -41,7 +41,7 @@ func _exit_tree() -> void: func _load() -> void: - _settings_file = Paths.own_dir.plus_file(_SETTINGS_FILENAME) + _settings_file = Paths.data_dir.plus_file(_SETTINGS_FILENAME) if File.new().file_exists(_settings_file): _current = _read_from_file(_settings_file) From 49aa2f90dd05e582f820874ee8537d131db3ecbf Mon Sep 17 00:00:00 2001 From: teackot Date: Thu, 10 Nov 2022 17:05:42 +0300 Subject: [PATCH 02/12] Remove a todo --- scripts/path_helper.gd | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index 3a6178c7..f61bb76d 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -50,7 +50,6 @@ func _determine_data_dir() -> String: var error = d.make_dir_recursive(dirname) if error: # something went wrong, fallback to executable path - # todo: error message Status.post(tr("msg_cannot_create_target_dir") % [dirname, error], Enums.MSG_ERROR) break From e6756dfb5dff681107642ff6b70fd0c74ac6c560 Mon Sep 17 00:00:00 2001 From: teackot Date: Fri, 11 Nov 2022 11:03:47 +0300 Subject: [PATCH 03/12] Added new translation strings (not translated) --- project.godot | 2 +- scripts/path_helper.gd | 2 +- text/cs/path_helper.csv | 3 +++ text/cs/path_helper.csv.import | 16 ++++++++++++++++ text/en/path_helper.csv | 3 +++ text/en/path_helper.csv.import | 16 ++++++++++++++++ text/es/path_helper.csv | 3 +++ text/es/path_helper.csv.import | 16 ++++++++++++++++ text/fr/path_helper.csv | 3 +++ text/fr/path_helper.csv.import | 16 ++++++++++++++++ text/pl/path_helper.csv | 3 +++ text/pl/path_helper.csv.import | 16 ++++++++++++++++ text/ru/path_helper.csv | 3 +++ text/ru/path_helper.csv.import | 16 ++++++++++++++++ text/tr/path_helper.csv | 3 +++ text/tr/path_helper.csv.import | 16 ++++++++++++++++ text/zh/path_helper.csv | 3 +++ text/zh/path_helper.csv.import | 16 ++++++++++++++++ 18 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 text/cs/path_helper.csv create mode 100644 text/cs/path_helper.csv.import create mode 100644 text/en/path_helper.csv create mode 100644 text/en/path_helper.csv.import create mode 100644 text/es/path_helper.csv create mode 100644 text/es/path_helper.csv.import create mode 100644 text/fr/path_helper.csv create mode 100644 text/fr/path_helper.csv.import create mode 100644 text/pl/path_helper.csv create mode 100644 text/pl/path_helper.csv.import create mode 100644 text/ru/path_helper.csv create mode 100644 text/ru/path_helper.csv.import create mode 100644 text/tr/path_helper.csv create mode 100644 text/tr/path_helper.csv.import create mode 100644 text/zh/path_helper.csv create mode 100644 text/zh/path_helper.csv.import diff --git a/project.godot b/project.godot index cdbd6a25..19ef9340 100644 --- a/project.godot +++ b/project.godot @@ -130,7 +130,7 @@ ui_down={ [locale] -translations=PoolStringArray( "res://text/en/backups_tab.en.translation", "res://text/en/backup_manager.en.translation", "res://text/en/changelog_dialog.en.translation", "res://text/en/dialog_buttons.en.translation", "res://text/en/download_manager.en.translation", "res://text/en/easter_egg.en.translation", "res://text/en/filesystem_helper.en.translation", "res://text/en/fonts_tab.en.translation", "res://text/en/font_help_dialog.en.translation", "res://text/en/font_info.en.translation", "res://text/en/font_manager.en.translation", "res://text/en/game_tab.en.translation", "res://text/en/general.en.translation", "res://text/en/install_probe.en.translation", "res://text/en/mods_tab.en.translation", "res://text/en/mod_manager.en.translation", "res://text/en/mod_reinstall_dialog.en.translation", "res://text/en/release_installer.en.translation", "res://text/en/release_manager.en.translation", "res://text/en/settings_manager.en.translation", "res://text/en/settings_tab.en.translation", "res://text/en/soundpacks_tab.en.translation", "res://text/en/soundpack_manager.en.translation", "res://text/en/tips.en.translation", "res://text/ru/backups_tab.ru.translation", "res://text/ru/backup_manager.ru.translation", "res://text/ru/changelog_dialog.ru.translation", "res://text/ru/dialog_buttons.ru.translation", "res://text/ru/download_manager.ru.translation", "res://text/ru/easter_egg.ru.translation", "res://text/ru/filesystem_helper.ru.translation", "res://text/ru/fonts_tab.ru.translation", "res://text/ru/font_help_dialog.ru.translation", "res://text/ru/font_info.ru.translation", "res://text/ru/font_manager.ru.translation", "res://text/ru/game_tab.ru.translation", "res://text/ru/general.ru.translation", "res://text/ru/install_probe.ru.translation", "res://text/ru/mods_tab.ru.translation", "res://text/ru/mod_manager.ru.translation", "res://text/ru/mod_reinstall_dialog.ru.translation", "res://text/ru/release_installer.ru.translation", "res://text/ru/release_manager.ru.translation", "res://text/ru/settings_manager.ru.translation", "res://text/ru/settings_tab.ru.translation", "res://text/ru/soundpacks_tab.ru.translation", "res://text/ru/soundpack_manager.ru.translation", "res://text/ru/tips.ru.translation", "res://text/zh/backups_tab.zh.translation", "res://text/zh/backup_manager.zh.translation", "res://text/zh/changelog_dialog.zh.translation", "res://text/zh/dialog_buttons.zh.translation", "res://text/zh/download_manager.zh.translation", "res://text/zh/easter_egg.zh.translation", "res://text/zh/filesystem_helper.zh.translation", "res://text/zh/fonts_tab.zh.translation", "res://text/zh/font_help_dialog.zh.translation", "res://text/zh/font_info.zh.translation", "res://text/zh/font_manager.zh.translation", "res://text/zh/game_tab.zh.translation", "res://text/zh/general.zh.translation", "res://text/zh/install_probe.zh.translation", "res://text/zh/mods_tab.zh.translation", "res://text/zh/mod_manager.zh.translation", "res://text/zh/mod_reinstall_dialog.zh.translation", "res://text/zh/release_installer.zh.translation", "res://text/zh/release_manager.zh.translation", "res://text/zh/settings_manager.zh.translation", "res://text/zh/settings_tab.zh.translation", "res://text/zh/soundpacks_tab.zh.translation", "res://text/zh/soundpack_manager.zh.translation", "res://text/zh/tips.zh.translation", "res://text/fr/backups_tab.fr.translation", "res://text/fr/backup_manager.fr.translation", "res://text/fr/changelog_dialog.fr.translation", "res://text/fr/dialog_buttons.fr.translation", "res://text/fr/download_manager.fr.translation", "res://text/fr/easter_egg.fr.translation", "res://text/fr/filesystem_helper.fr.translation", "res://text/fr/fonts_tab.fr.translation", "res://text/fr/font_help_dialog.fr.translation", "res://text/fr/font_info.fr.translation", "res://text/fr/font_manager.fr.translation", "res://text/fr/game_tab.fr.translation", "res://text/fr/general.fr.translation", "res://text/fr/install_probe.fr.translation", "res://text/fr/mods_tab.fr.translation", "res://text/fr/mod_manager.fr.translation", "res://text/fr/mod_reinstall_dialog.fr.translation", "res://text/fr/release_installer.fr.translation", "res://text/fr/release_manager.fr.translation", "res://text/fr/settings_manager.fr.translation", "res://text/fr/settings_tab.fr.translation", "res://text/fr/soundpacks_tab.fr.translation", "res://text/fr/soundpack_manager.fr.translation", "res://text/fr/tips.fr.translation", "res://text/en/helpers.en.translation", "res://text/fr/helpers.fr.translation", "res://text/ru/helpers.ru.translation", "res://text/zh/helpers.zh.translation", "res://text/cs/backups_tab.cs.translation", "res://text/cs/backup_manager.cs.translation", "res://text/cs/changelog_dialog.cs.translation", "res://text/cs/dialog_buttons.cs.translation", "res://text/cs/download_manager.cs.translation", "res://text/cs/easter_egg.cs.translation", "res://text/cs/filesystem_helper.cs.translation", "res://text/cs/fonts_tab.cs.translation", "res://text/cs/font_help_dialog.cs.translation", "res://text/cs/font_info.cs.translation", "res://text/cs/font_manager.cs.translation", "res://text/cs/game_tab.cs.translation", "res://text/cs/general.cs.translation", "res://text/cs/helpers.cs.translation", "res://text/cs/install_probe.cs.translation", "res://text/cs/mods_tab.cs.translation", "res://text/cs/mod_manager.cs.translation", "res://text/cs/mod_reinstall_dialog.cs.translation", "res://text/cs/release_installer.cs.translation", "res://text/cs/release_manager.cs.translation", "res://text/cs/settings_manager.cs.translation", "res://text/cs/settings_tab.cs.translation", "res://text/cs/soundpacks_tab.cs.translation", "res://text/cs/soundpack_manager.cs.translation", "res://text/cs/tips.cs.translation", "res://text/es/backups_tab.es.translation", "res://text/es/backup_manager.es.translation", "res://text/es/changelog_dialog.es.translation", "res://text/es/dialog_buttons.es.translation", "res://text/es/download_manager.es.translation", "res://text/es/easter_egg.es.translation", "res://text/es/filesystem_helper.es.translation", "res://text/es/helpers.es.translation", "res://text/es/general.es.translation", "res://text/es/game_tab.es.translation", "res://text/es/font_manager.es.translation", "res://text/es/font_info.es.translation", "res://text/es/font_help_dialog.es.translation", "res://text/es/fonts_tab.es.translation", "res://text/es/install_probe.es.translation", "res://text/es/mods_tab.es.translation", "res://text/es/mod_manager.es.translation", "res://text/es/mod_reinstall_dialog.es.translation", "res://text/es/release_installer.es.translation", "res://text/es/release_manager.es.translation", "res://text/es/settings_manager.es.translation", "res://text/es/settings_tab.es.translation", "res://text/es/soundpacks_tab.es.translation", "res://text/es/soundpack_manager.es.translation", "res://text/es/tips.es.translation", "res://text/pl/backups_tab.pl.translation", "res://text/pl/backup_manager.pl.translation", "res://text/pl/changelog_dialog.pl.translation", "res://text/pl/dialog_buttons.pl.translation", "res://text/pl/download_manager.pl.translation", "res://text/pl/easter_egg.pl.translation", "res://text/pl/filesystem_helper.pl.translation", "res://text/pl/fonts_tab.pl.translation", "res://text/pl/font_help_dialog.pl.translation", "res://text/pl/font_info.pl.translation", "res://text/pl/font_manager.pl.translation", "res://text/pl/game_tab.pl.translation", "res://text/pl/general.pl.translation", "res://text/pl/helpers.pl.translation", "res://text/pl/install_probe.pl.translation", "res://text/pl/mods_tab.pl.translation", "res://text/pl/mod_manager.pl.translation", "res://text/pl/mod_reinstall_dialog.pl.translation", "res://text/pl/release_installer.pl.translation", "res://text/pl/release_manager.pl.translation", "res://text/pl/settings_manager.pl.translation", "res://text/pl/settings_tab.pl.translation", "res://text/pl/soundpacks_tab.pl.translation", "res://text/pl/soundpack_manager.pl.translation", "res://text/pl/tips.pl.translation", "res://text/tr/backups_tab.tr.translation", "res://text/tr/backup_manager.tr.translation", "res://text/tr/changelog_dialog.tr.translation", "res://text/tr/dialog_buttons.tr.translation", "res://text/tr/download_manager.tr.translation", "res://text/tr/easter_egg.tr.translation", "res://text/tr/filesystem_helper.tr.translation", "res://text/tr/fonts_tab.tr.translation", "res://text/tr/font_help_dialog.tr.translation", "res://text/tr/font_info.tr.translation", "res://text/tr/font_manager.tr.translation", "res://text/tr/game_tab.tr.translation", "res://text/tr/general.tr.translation", "res://text/tr/helpers.tr.translation", "res://text/tr/install_probe.tr.translation", "res://text/tr/mods_tab.tr.translation", "res://text/tr/mod_manager.tr.translation", "res://text/tr/mod_reinstall_dialog.tr.translation", "res://text/tr/release_installer.tr.translation", "res://text/tr/release_manager.tr.translation", "res://text/tr/settings_manager.tr.translation", "res://text/tr/settings_tab.tr.translation", "res://text/tr/soundpacks_tab.tr.translation", "res://text/tr/soundpack_manager.tr.translation", "res://text/tr/tips.tr.translation" ) +translations=PoolStringArray( "res://text/en/backups_tab.en.translation", "res://text/en/backup_manager.en.translation", "res://text/en/changelog_dialog.en.translation", "res://text/en/dialog_buttons.en.translation", "res://text/en/download_manager.en.translation", "res://text/en/easter_egg.en.translation", "res://text/en/filesystem_helper.en.translation", "res://text/en/fonts_tab.en.translation", "res://text/en/font_help_dialog.en.translation", "res://text/en/font_info.en.translation", "res://text/en/font_manager.en.translation", "res://text/en/game_tab.en.translation", "res://text/en/general.en.translation", "res://text/en/install_probe.en.translation", "res://text/en/mods_tab.en.translation", "res://text/en/mod_manager.en.translation", "res://text/en/mod_reinstall_dialog.en.translation", "res://text/en/release_installer.en.translation", "res://text/en/release_manager.en.translation", "res://text/en/settings_manager.en.translation", "res://text/en/settings_tab.en.translation", "res://text/en/soundpacks_tab.en.translation", "res://text/en/soundpack_manager.en.translation", "res://text/en/tips.en.translation", "res://text/ru/backups_tab.ru.translation", "res://text/ru/backup_manager.ru.translation", "res://text/ru/changelog_dialog.ru.translation", "res://text/ru/dialog_buttons.ru.translation", "res://text/ru/download_manager.ru.translation", "res://text/ru/easter_egg.ru.translation", "res://text/ru/filesystem_helper.ru.translation", "res://text/ru/fonts_tab.ru.translation", "res://text/ru/font_help_dialog.ru.translation", "res://text/ru/font_info.ru.translation", "res://text/ru/font_manager.ru.translation", "res://text/ru/game_tab.ru.translation", "res://text/ru/general.ru.translation", "res://text/ru/install_probe.ru.translation", "res://text/ru/mods_tab.ru.translation", "res://text/ru/mod_manager.ru.translation", "res://text/ru/mod_reinstall_dialog.ru.translation", "res://text/ru/release_installer.ru.translation", "res://text/ru/release_manager.ru.translation", "res://text/ru/settings_manager.ru.translation", "res://text/ru/settings_tab.ru.translation", "res://text/ru/soundpacks_tab.ru.translation", "res://text/ru/soundpack_manager.ru.translation", "res://text/ru/tips.ru.translation", "res://text/zh/backups_tab.zh.translation", "res://text/zh/backup_manager.zh.translation", "res://text/zh/changelog_dialog.zh.translation", "res://text/zh/dialog_buttons.zh.translation", "res://text/zh/download_manager.zh.translation", "res://text/zh/easter_egg.zh.translation", "res://text/zh/filesystem_helper.zh.translation", "res://text/zh/fonts_tab.zh.translation", "res://text/zh/font_help_dialog.zh.translation", "res://text/zh/font_info.zh.translation", "res://text/zh/font_manager.zh.translation", "res://text/zh/game_tab.zh.translation", "res://text/zh/general.zh.translation", "res://text/zh/install_probe.zh.translation", "res://text/zh/mods_tab.zh.translation", "res://text/zh/mod_manager.zh.translation", "res://text/zh/mod_reinstall_dialog.zh.translation", "res://text/zh/release_installer.zh.translation", "res://text/zh/release_manager.zh.translation", "res://text/zh/settings_manager.zh.translation", "res://text/zh/settings_tab.zh.translation", "res://text/zh/soundpacks_tab.zh.translation", "res://text/zh/soundpack_manager.zh.translation", "res://text/zh/tips.zh.translation", "res://text/fr/backups_tab.fr.translation", "res://text/fr/backup_manager.fr.translation", "res://text/fr/changelog_dialog.fr.translation", "res://text/fr/dialog_buttons.fr.translation", "res://text/fr/download_manager.fr.translation", "res://text/fr/easter_egg.fr.translation", "res://text/fr/filesystem_helper.fr.translation", "res://text/fr/fonts_tab.fr.translation", "res://text/fr/font_help_dialog.fr.translation", "res://text/fr/font_info.fr.translation", "res://text/fr/font_manager.fr.translation", "res://text/fr/game_tab.fr.translation", "res://text/fr/general.fr.translation", "res://text/fr/install_probe.fr.translation", "res://text/fr/mods_tab.fr.translation", "res://text/fr/mod_manager.fr.translation", "res://text/fr/mod_reinstall_dialog.fr.translation", "res://text/fr/release_installer.fr.translation", "res://text/fr/release_manager.fr.translation", "res://text/fr/settings_manager.fr.translation", "res://text/fr/settings_tab.fr.translation", "res://text/fr/soundpacks_tab.fr.translation", "res://text/fr/soundpack_manager.fr.translation", "res://text/fr/tips.fr.translation", "res://text/en/helpers.en.translation", "res://text/fr/helpers.fr.translation", "res://text/ru/helpers.ru.translation", "res://text/zh/helpers.zh.translation", "res://text/cs/backups_tab.cs.translation", "res://text/cs/backup_manager.cs.translation", "res://text/cs/changelog_dialog.cs.translation", "res://text/cs/dialog_buttons.cs.translation", "res://text/cs/download_manager.cs.translation", "res://text/cs/easter_egg.cs.translation", "res://text/cs/filesystem_helper.cs.translation", "res://text/cs/fonts_tab.cs.translation", "res://text/cs/font_help_dialog.cs.translation", "res://text/cs/font_info.cs.translation", "res://text/cs/font_manager.cs.translation", "res://text/cs/game_tab.cs.translation", "res://text/cs/general.cs.translation", "res://text/cs/helpers.cs.translation", "res://text/cs/install_probe.cs.translation", "res://text/cs/mods_tab.cs.translation", "res://text/cs/mod_manager.cs.translation", "res://text/cs/mod_reinstall_dialog.cs.translation", "res://text/cs/release_installer.cs.translation", "res://text/cs/release_manager.cs.translation", "res://text/cs/settings_manager.cs.translation", "res://text/cs/settings_tab.cs.translation", "res://text/cs/soundpacks_tab.cs.translation", "res://text/cs/soundpack_manager.cs.translation", "res://text/cs/tips.cs.translation", "res://text/es/backups_tab.es.translation", "res://text/es/backup_manager.es.translation", "res://text/es/changelog_dialog.es.translation", "res://text/es/dialog_buttons.es.translation", "res://text/es/download_manager.es.translation", "res://text/es/easter_egg.es.translation", "res://text/es/filesystem_helper.es.translation", "res://text/es/helpers.es.translation", "res://text/es/general.es.translation", "res://text/es/game_tab.es.translation", "res://text/es/font_manager.es.translation", "res://text/es/font_info.es.translation", "res://text/es/font_help_dialog.es.translation", "res://text/es/fonts_tab.es.translation", "res://text/es/install_probe.es.translation", "res://text/es/mods_tab.es.translation", "res://text/es/mod_manager.es.translation", "res://text/es/mod_reinstall_dialog.es.translation", "res://text/es/release_installer.es.translation", "res://text/es/release_manager.es.translation", "res://text/es/settings_manager.es.translation", "res://text/es/settings_tab.es.translation", "res://text/es/soundpacks_tab.es.translation", "res://text/es/soundpack_manager.es.translation", "res://text/es/tips.es.translation", "res://text/pl/backups_tab.pl.translation", "res://text/pl/backup_manager.pl.translation", "res://text/pl/changelog_dialog.pl.translation", "res://text/pl/dialog_buttons.pl.translation", "res://text/pl/download_manager.pl.translation", "res://text/pl/easter_egg.pl.translation", "res://text/pl/filesystem_helper.pl.translation", "res://text/pl/fonts_tab.pl.translation", "res://text/pl/font_help_dialog.pl.translation", "res://text/pl/font_info.pl.translation", "res://text/pl/font_manager.pl.translation", "res://text/pl/game_tab.pl.translation", "res://text/pl/general.pl.translation", "res://text/pl/helpers.pl.translation", "res://text/pl/install_probe.pl.translation", "res://text/pl/mods_tab.pl.translation", "res://text/pl/mod_manager.pl.translation", "res://text/pl/mod_reinstall_dialog.pl.translation", "res://text/pl/release_installer.pl.translation", "res://text/pl/release_manager.pl.translation", "res://text/pl/settings_manager.pl.translation", "res://text/pl/settings_tab.pl.translation", "res://text/pl/soundpacks_tab.pl.translation", "res://text/pl/soundpack_manager.pl.translation", "res://text/pl/tips.pl.translation", "res://text/tr/backups_tab.tr.translation", "res://text/tr/backup_manager.tr.translation", "res://text/tr/changelog_dialog.tr.translation", "res://text/tr/dialog_buttons.tr.translation", "res://text/tr/download_manager.tr.translation", "res://text/tr/easter_egg.tr.translation", "res://text/tr/filesystem_helper.tr.translation", "res://text/tr/fonts_tab.tr.translation", "res://text/tr/font_help_dialog.tr.translation", "res://text/tr/font_info.tr.translation", "res://text/tr/font_manager.tr.translation", "res://text/tr/game_tab.tr.translation", "res://text/tr/general.tr.translation", "res://text/tr/helpers.tr.translation", "res://text/tr/install_probe.tr.translation", "res://text/tr/mods_tab.tr.translation", "res://text/tr/mod_manager.tr.translation", "res://text/tr/mod_reinstall_dialog.tr.translation", "res://text/tr/release_installer.tr.translation", "res://text/tr/release_manager.tr.translation", "res://text/tr/settings_manager.tr.translation", "res://text/tr/settings_tab.tr.translation", "res://text/tr/soundpacks_tab.tr.translation", "res://text/tr/soundpack_manager.tr.translation", "res://text/tr/tips.tr.translation", "res://text/cs/path_helper.en.translation", "res://text/en/path_helper.en.translation", "res://text/es/path_helper.en.translation", "res://text/fr/path_helper.en.translation", "res://text/pl/path_helper.en.translation", "res://text/ru/path_helper.en.translation", "res://text/tr/path_helper.en.translation", "res://text/zh/path_helper.en.translation" ) locale_filter=[ 0, [ "en", "ru", "zh" ] ] [physics] diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index f61bb76d..362dd771 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -41,7 +41,7 @@ func _determine_data_dir() -> String: if not dirname.begins_with("/"): # relative paths are not supported, fallback to executable path - Status.post(tr("msg_path_not_absolute"), Enums.MSG_ERROR) + Status.post(tr("msg_path_not_absolute") % dirname, Enums.MSG_ERROR) break # Ensure that data_dir_abs exists diff --git a/text/cs/path_helper.csv b/text/cs/path_helper.csv new file mode 100644 index 00000000..f0b47c17 --- /dev/null +++ b/text/cs/path_helper.csv @@ -0,0 +1,3 @@ +"keys","en" +, +"msg_path_not_absolute","%s is not an absolute path. Falling back to executable path" diff --git a/text/cs/path_helper.csv.import b/text/cs/path_helper.csv.import new file mode 100644 index 00000000..a3fe1230 --- /dev/null +++ b/text/cs/path_helper.csv.import @@ -0,0 +1,16 @@ +[remap] + +importer="csv_translation" +type="Translation" + +[deps] + +files=[ "res://text/cs/path_helper.en.translation" ] + +source_file="res://text/cs/path_helper.csv" +dest_files=[ "res://text/cs/path_helper.en.translation" ] + +[params] + +compress=true +delimiter=0 diff --git a/text/en/path_helper.csv b/text/en/path_helper.csv new file mode 100644 index 00000000..f0b47c17 --- /dev/null +++ b/text/en/path_helper.csv @@ -0,0 +1,3 @@ +"keys","en" +, +"msg_path_not_absolute","%s is not an absolute path. Falling back to executable path" diff --git a/text/en/path_helper.csv.import b/text/en/path_helper.csv.import new file mode 100644 index 00000000..9640ef45 --- /dev/null +++ b/text/en/path_helper.csv.import @@ -0,0 +1,16 @@ +[remap] + +importer="csv_translation" +type="Translation" + +[deps] + +files=[ "res://text/en/path_helper.en.translation" ] + +source_file="res://text/en/path_helper.csv" +dest_files=[ "res://text/en/path_helper.en.translation" ] + +[params] + +compress=true +delimiter=0 diff --git a/text/es/path_helper.csv b/text/es/path_helper.csv new file mode 100644 index 00000000..f0b47c17 --- /dev/null +++ b/text/es/path_helper.csv @@ -0,0 +1,3 @@ +"keys","en" +, +"msg_path_not_absolute","%s is not an absolute path. Falling back to executable path" diff --git a/text/es/path_helper.csv.import b/text/es/path_helper.csv.import new file mode 100644 index 00000000..778ecca3 --- /dev/null +++ b/text/es/path_helper.csv.import @@ -0,0 +1,16 @@ +[remap] + +importer="csv_translation" +type="Translation" + +[deps] + +files=[ "res://text/es/path_helper.en.translation" ] + +source_file="res://text/es/path_helper.csv" +dest_files=[ "res://text/es/path_helper.en.translation" ] + +[params] + +compress=true +delimiter=0 diff --git a/text/fr/path_helper.csv b/text/fr/path_helper.csv new file mode 100644 index 00000000..f0b47c17 --- /dev/null +++ b/text/fr/path_helper.csv @@ -0,0 +1,3 @@ +"keys","en" +, +"msg_path_not_absolute","%s is not an absolute path. Falling back to executable path" diff --git a/text/fr/path_helper.csv.import b/text/fr/path_helper.csv.import new file mode 100644 index 00000000..d860ad3e --- /dev/null +++ b/text/fr/path_helper.csv.import @@ -0,0 +1,16 @@ +[remap] + +importer="csv_translation" +type="Translation" + +[deps] + +files=[ "res://text/fr/path_helper.en.translation" ] + +source_file="res://text/fr/path_helper.csv" +dest_files=[ "res://text/fr/path_helper.en.translation" ] + +[params] + +compress=true +delimiter=0 diff --git a/text/pl/path_helper.csv b/text/pl/path_helper.csv new file mode 100644 index 00000000..f0b47c17 --- /dev/null +++ b/text/pl/path_helper.csv @@ -0,0 +1,3 @@ +"keys","en" +, +"msg_path_not_absolute","%s is not an absolute path. Falling back to executable path" diff --git a/text/pl/path_helper.csv.import b/text/pl/path_helper.csv.import new file mode 100644 index 00000000..c04f9992 --- /dev/null +++ b/text/pl/path_helper.csv.import @@ -0,0 +1,16 @@ +[remap] + +importer="csv_translation" +type="Translation" + +[deps] + +files=[ "res://text/pl/path_helper.en.translation" ] + +source_file="res://text/pl/path_helper.csv" +dest_files=[ "res://text/pl/path_helper.en.translation" ] + +[params] + +compress=true +delimiter=0 diff --git a/text/ru/path_helper.csv b/text/ru/path_helper.csv new file mode 100644 index 00000000..f0b47c17 --- /dev/null +++ b/text/ru/path_helper.csv @@ -0,0 +1,3 @@ +"keys","en" +, +"msg_path_not_absolute","%s is not an absolute path. Falling back to executable path" diff --git a/text/ru/path_helper.csv.import b/text/ru/path_helper.csv.import new file mode 100644 index 00000000..f400c45b --- /dev/null +++ b/text/ru/path_helper.csv.import @@ -0,0 +1,16 @@ +[remap] + +importer="csv_translation" +type="Translation" + +[deps] + +files=[ "res://text/ru/path_helper.en.translation" ] + +source_file="res://text/ru/path_helper.csv" +dest_files=[ "res://text/ru/path_helper.en.translation" ] + +[params] + +compress=true +delimiter=0 diff --git a/text/tr/path_helper.csv b/text/tr/path_helper.csv new file mode 100644 index 00000000..f0b47c17 --- /dev/null +++ b/text/tr/path_helper.csv @@ -0,0 +1,3 @@ +"keys","en" +, +"msg_path_not_absolute","%s is not an absolute path. Falling back to executable path" diff --git a/text/tr/path_helper.csv.import b/text/tr/path_helper.csv.import new file mode 100644 index 00000000..b1b74e32 --- /dev/null +++ b/text/tr/path_helper.csv.import @@ -0,0 +1,16 @@ +[remap] + +importer="csv_translation" +type="Translation" + +[deps] + +files=[ "res://text/tr/path_helper.en.translation" ] + +source_file="res://text/tr/path_helper.csv" +dest_files=[ "res://text/tr/path_helper.en.translation" ] + +[params] + +compress=true +delimiter=0 diff --git a/text/zh/path_helper.csv b/text/zh/path_helper.csv new file mode 100644 index 00000000..f0b47c17 --- /dev/null +++ b/text/zh/path_helper.csv @@ -0,0 +1,3 @@ +"keys","en" +, +"msg_path_not_absolute","%s is not an absolute path. Falling back to executable path" diff --git a/text/zh/path_helper.csv.import b/text/zh/path_helper.csv.import new file mode 100644 index 00000000..9ed7d9e5 --- /dev/null +++ b/text/zh/path_helper.csv.import @@ -0,0 +1,16 @@ +[remap] + +importer="csv_translation" +type="Translation" + +[deps] + +files=[ "res://text/zh/path_helper.en.translation" ] + +source_file="res://text/zh/path_helper.csv" +dest_files=[ "res://text/zh/path_helper.en.translation" ] + +[params] + +compress=true +delimiter=0 From ef8282b8f172e335f12d7d72ba31847221493b8a Mon Sep 17 00:00:00 2001 From: teackot Date: Fri, 11 Nov 2022 13:23:54 +0300 Subject: [PATCH 04/12] Changed naming --- scripts/Debug.gd | 4 ++-- scripts/ModManager.gd | 4 ++-- scripts/ReleaseInstaller.gd | 4 ++-- scripts/SoundpackManager.gd | 4 ++-- scripts/SoundpacksUI.gd | 2 +- scripts/path_helper.gd | 36 ++++++++++++++++++------------------ scripts/settings_manager.gd | 2 +- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/scripts/Debug.gd b/scripts/Debug.gd index 45f34090..12dbd9b1 100644 --- a/scripts/Debug.gd +++ b/scripts/Debug.gd @@ -41,7 +41,7 @@ func _on_Button2_pressed() -> void: func _on_Button3_pressed(): var d = Directory.new() - var dir = Paths.data_dir.plus_file("testdir") + var dir = Paths.catapult_dir.plus_file("testdir") d.make_dir(dir) var command_linux = { @@ -85,7 +85,7 @@ func _on_Button4_pressed() -> void: func _on_Button5_pressed() -> void: - var path = Paths.data_dir + var path = Paths.catapult_dir Status.post("Listing directory %s..." % path, Enums.MSG_DEBUG) yield(get_tree().create_timer(0.1), "timeout") diff --git a/scripts/ModManager.gd b/scripts/ModManager.gd index 4262e034..e16f20da 100644 --- a/scripts/ModManager.gd +++ b/scripts/ModManager.gd @@ -264,10 +264,10 @@ func retrieve_kenan_pack() -> void: emit_signal("modpack_retrieval_started") Status.post(tr("msg_getting_kenan_pack") % game.to_upper()) - Downloader.download_file(pack["url"], Paths.data_dir, pack["filename"]) + Downloader.download_file(pack["url"], Paths.catapult_dir, pack["filename"]) yield(Downloader, "download_finished") - var archive = Paths.data_dir.plus_file(pack["filename"]) + var archive = Paths.catapult_dir.plus_file(pack["filename"]) if Directory.new().file_exists(archive): FS.extract(archive, Paths.tmp_dir) yield(FS, "extract_done") diff --git a/scripts/ReleaseInstaller.gd b/scripts/ReleaseInstaller.gd index df7f1404..94dc03d4 100644 --- a/scripts/ReleaseInstaller.gd +++ b/scripts/ReleaseInstaller.gd @@ -14,10 +14,10 @@ func install_release(release_info: Dictionary, game: String, update_in: String = else: Status.post(tr("msg_installing_game") % release_info["name"]) - Downloader.download_file(release_info["url"], Paths.data_dir, release_info["filename"]) + Downloader.download_file(release_info["url"], Paths.catapult_dir, release_info["filename"]) yield(Downloader, "download_finished") - var archive: String = Paths.data_dir.plus_file(release_info["filename"]) + var archive: String = Paths.catapult_dir.plus_file(release_info["filename"]) if Directory.new().file_exists(archive): FS.extract(archive, Paths.tmp_dir) diff --git a/scripts/SoundpackManager.gd b/scripts/SoundpackManager.gd index e6ac291a..d64071c9 100644 --- a/scripts/SoundpackManager.gd +++ b/scripts/SoundpackManager.gd @@ -141,9 +141,9 @@ func install_pack(soundpack_index: int, from_file = null, reinstall = false, kee if from_file: archive = from_file else: - Downloader.download_file(pack["url"], Paths.data_dir, pack["filename"]) + Downloader.download_file(pack["url"], Paths.catapult_dir, pack["filename"]) yield(Downloader, "download_finished") - archive = Paths.data_dir.plus_file(pack["filename"]) + archive = Paths.catapult_dir.plus_file(pack["filename"]) if not Directory.new().file_exists(archive): Status.post(tr("msg_sound_download_failed"), Enums.MSG_ERROR) emit_signal("soundpack_installation_finished") diff --git a/scripts/SoundpacksUI.gd b/scripts/SoundpacksUI.gd index 26965507..2d114158 100644 --- a/scripts/SoundpacksUI.gd +++ b/scripts/SoundpacksUI.gd @@ -149,7 +149,7 @@ func _on_ConfirmManualDownload_confirmed() -> void: var pack = _sound.SOUNDPACKS[_available_list.get_selected_items()[0]] OS.shell_open(pack["url"]) - _dlg_file.current_dir = Paths.data_dir + _dlg_file.current_dir = Paths.catapult_dir _dlg_file.popup_centered_ratio(0.9) diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index 362dd771..96c2e0d7 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -4,7 +4,7 @@ extends Node signal status_message -var data_dir: String setget , _get_data_dir +var catapult_dir: String setget , _get_catapult_dir var installs_summary: Dictionary setget , _get_installs_summary var game_dir: String setget , _get_game_dir var next_data_dir: String setget , _get_next_data_dir @@ -26,17 +26,17 @@ var tmp_dir: String setget , _get_tmp_dir var utils_dir: String setget , _get_utils_dir var save_backups: String setget , _get_save_backups_dir -var _data_dir := _determine_data_dir() +var _catapult_dir := _determine_catapult_dir() var _last_active_install_name := "" -var _last_active_data_dir := "" +var _last_active_install_dir := "" -func _determine_data_dir() -> String: +func _determine_catapult_dir() -> String: for arg in OS.get_cmdline_args(): if arg.find("=") > -1: # if arg is a key-value pair var arg_pair = arg.split("=") - if arg_pair[0] == "--data_dir_abs": + if arg_pair[0] == "--catapult_dir_abs": var dirname = arg_pair[1] if not dirname.begins_with("/"): @@ -44,7 +44,7 @@ func _determine_data_dir() -> String: Status.post(tr("msg_path_not_absolute") % dirname, Enums.MSG_ERROR) break - # Ensure that data_dir_abs exists + # Ensure that catapult_dir_abs exists var d = Directory.new() if not d.dir_exists(dirname): var error = d.make_dir_recursive(dirname) @@ -58,9 +58,9 @@ func _determine_data_dir() -> String: return OS.get_executable_path().get_base_dir() -func _get_data_dir() -> String: +func _get_catapult_dir() -> String: - return _data_dir + return _catapult_dir func _get_installs_summary() -> Dictionary: @@ -70,7 +70,7 @@ func _get_installs_summary() -> Dictionary: for game in ["dda", "bn"]: var installs = {} - var base_dir = Paths.data_dir.plus_file(game) + var base_dir = Paths.catapult_dir.plus_file(game) for subdir in FS.list_dir(base_dir): var info_file = base_dir.plus_file(subdir).plus_file(Helpers.INFO_FILENAME) if d.file_exists(info_file): @@ -96,7 +96,7 @@ func _get_game_dir() -> String: if active_name == "": return _get_next_data_dir() elif active_name == _last_active_install_name: - return _last_active_data_dir + return _last_active_install_dir else: return _find_active_game_dir() @@ -104,14 +104,14 @@ func _get_game_dir() -> String: func _find_active_game_dir() -> String: var d = Directory.new() - var base_dir = _get_data_dir().plus_file(Settings.read("game")) + var base_dir = _get_catapult_dir().plus_file(Settings.read("game")) for subdir in FS.list_dir(base_dir): var curr_dir = base_dir.plus_file(subdir) var info_file = curr_dir.plus_file("catapult_install_info.json") if d.file_exists(info_file): var info = Helpers.load_json_file(info_file) if ("name" in info) and (info["name"] == Settings.read("active_install_" + Settings.read("game"))): - _last_active_data_dir = curr_dir + _last_active_install_dir = curr_dir return curr_dir return "" @@ -121,7 +121,7 @@ func _get_next_data_dir() -> String: # Finds a suitable directory name for a new game installation in the # multi-install system. The names follow the pattern "game0, game1, ..." - var base_dir := _get_data_dir().plus_file(Settings.read("game")) + var base_dir := _get_catapult_dir().plus_file(Settings.read("game")) var dir_number := 0 var d := Directory.new() while d.dir_exists(base_dir.plus_file("game" + str(dir_number))): @@ -131,7 +131,7 @@ func _get_next_data_dir() -> String: func _get_userdata_dir() -> String: - return _get_data_dir().plus_file(Settings.read("game")).plus_file("userdata") + return _get_catapult_dir().plus_file(Settings.read("game")).plus_file("userdata") func _get_config_dir() -> String: @@ -196,19 +196,19 @@ func _get_graveyard_dir() -> String: func _get_modrepo_dir() -> String: - return _get_data_dir().plus_file(Settings.read("game")).plus_file("mod_repo") + return _get_catapult_dir().plus_file(Settings.read("game")).plus_file("mod_repo") func _get_tmp_dir() -> String: - return _get_data_dir().plus_file(Settings.read("game")).plus_file("tmp") + return _get_catapult_dir().plus_file(Settings.read("game")).plus_file("tmp") func _get_utils_dir() -> String: - return _get_data_dir().plus_file("utils") + return _get_catapult_dir().plus_file("utils") func _get_save_backups_dir() -> String: - return _get_data_dir().plus_file(Settings.read("game")).plus_file("save_backups") + return _get_catapult_dir().plus_file(Settings.read("game")).plus_file("save_backups") diff --git a/scripts/settings_manager.gd b/scripts/settings_manager.gd index 21f1fecd..30279b01 100644 --- a/scripts/settings_manager.gd +++ b/scripts/settings_manager.gd @@ -41,7 +41,7 @@ func _exit_tree() -> void: func _load() -> void: - _settings_file = Paths.data_dir.plus_file(_SETTINGS_FILENAME) + _settings_file = Paths.catapult_dir.plus_file(_SETTINGS_FILENAME) if File.new().file_exists(_settings_file): _current = _read_from_file(_settings_file) From c4677f10e59eaf95aa5068224bc3e2fdb0e2e663 Mon Sep 17 00:00:00 2001 From: teackot Date: Fri, 11 Nov 2022 14:07:53 +0300 Subject: [PATCH 05/12] Cleaner catapult_dir initialization --- scripts/Catapult.gd | 2 +- scripts/path_helper.gd | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/Catapult.gd b/scripts/Catapult.gd index d3762e98..b4e2d36f 100644 --- a/scripts/Catapult.gd +++ b/scripts/Catapult.gd @@ -524,6 +524,6 @@ func _activate_easter_egg() -> void: Status.rainbow_text = true - for i in range(20): + for _i in range(20): Status.post(tr("msg_easter_egg_activated")) yield(get_tree().create_timer(0.1), "timeout") diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index 96c2e0d7..d4f8d79a 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -4,7 +4,7 @@ extends Node signal status_message -var catapult_dir: String setget , _get_catapult_dir +var catapult_dir: String setget _set_catapult_dir , _get_catapult_dir var installs_summary: Dictionary setget , _get_installs_summary var game_dir: String setget , _get_game_dir var next_data_dir: String setget , _get_next_data_dir @@ -26,11 +26,15 @@ var tmp_dir: String setget , _get_tmp_dir var utils_dir: String setget , _get_utils_dir var save_backups: String setget , _get_save_backups_dir -var _catapult_dir := _determine_catapult_dir() var _last_active_install_name := "" var _last_active_install_dir := "" +func _init() -> void: + + catapult_dir = _determine_catapult_dir() + + func _determine_catapult_dir() -> String: for arg in OS.get_cmdline_args(): @@ -58,9 +62,14 @@ func _determine_catapult_dir() -> String: return OS.get_executable_path().get_base_dir() +func _set_catapult_dir(path: String) -> void: + + catapult_dir = path + + func _get_catapult_dir() -> String: - return _catapult_dir + return catapult_dir func _get_installs_summary() -> Dictionary: From 0b44e1970983dbf73a8dd052f1b2e180a6035a93 Mon Sep 17 00:00:00 2001 From: teackot Date: Fri, 11 Nov 2022 15:37:02 +0300 Subject: [PATCH 06/12] Implement global config --- scripts/path_helper.gd | 30 ++++++++++++++++++++++++++++++ scripts/settings_manager.gd | 11 +++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index d4f8d79a..485727fc 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -5,6 +5,7 @@ extends Node signal status_message var catapult_dir: String setget _set_catapult_dir , _get_catapult_dir +var settings_dir: String setget _set_settings_dir , _get_settings_dir var installs_summary: Dictionary setget , _get_installs_summary var game_dir: String setget , _get_game_dir var next_data_dir: String setget , _get_next_data_dir @@ -33,6 +34,7 @@ var _last_active_install_dir := "" func _init() -> void: catapult_dir = _determine_catapult_dir() + settings_dir = _determine_settings_dir() func _determine_catapult_dir() -> String: @@ -62,6 +64,24 @@ func _determine_catapult_dir() -> String: return OS.get_executable_path().get_base_dir() +func _determine_settings_dir() -> String: + + var global_settings_dir: String + + match OS.get_name(): + "X11": + global_settings_dir = OS.get_environment("HOME").plus_file(".config/catapult/") + "Windows": + global_settings_dir = OS.get_environment("USERPROFILE").plus_file("AppData/Local/Catapult/") + _: + return catapult_dir + + if Settings.dir_contains_settings(global_settings_dir): + return global_settings_dir + else: + return catapult_dir + + func _set_catapult_dir(path: String) -> void: catapult_dir = path @@ -72,6 +92,16 @@ func _get_catapult_dir() -> String: return catapult_dir +func _set_settings_dir(path: String) -> void: + + settings_dir = path + + +func _get_settings_dir() -> String: + + return settings_dir + + func _get_installs_summary() -> Dictionary: var result = {} diff --git a/scripts/settings_manager.gd b/scripts/settings_manager.gd index 30279b01..6a3155cb 100644 --- a/scripts/settings_manager.gd +++ b/scripts/settings_manager.gd @@ -41,11 +41,10 @@ func _exit_tree() -> void: func _load() -> void: - _settings_file = Paths.catapult_dir.plus_file(_SETTINGS_FILENAME) + _settings_file = Paths.settings_dir.plus_file(_SETTINGS_FILENAME) if File.new().file_exists(_settings_file): _current = _read_from_file(_settings_file) - else: _current = _HARDCODED_DEFAULTS Status.post(tr("msg_creating_settings") % _SETTINGS_FILENAME) @@ -82,6 +81,14 @@ func _write_to_file(data: Dictionary, path: String) -> void: f.close() +func dir_contains_settings(path: String) ->bool: + + var d = Directory.new() + d.open(path) + + return d.file_exists(_SETTINGS_FILENAME) + + func read(setting_name: String): if len(_current) == 0: From 01d7e2dcc81ec7564be521a2b079364786e4e949 Mon Sep 17 00:00:00 2001 From: teackot Date: Fri, 11 Nov 2022 17:18:34 +0300 Subject: [PATCH 07/12] Added installation directory input field in settings --- scenes/Catapult.tscn | 25 +++++++++++++++++++++++-- scripts/SettingsUI.gd | 7 +++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/scenes/Catapult.tscn b/scenes/Catapult.tscn index ffd8d1b8..3316d1a2 100644 --- a/scenes/Catapult.tscn +++ b/scenes/Catapult.tscn @@ -125,7 +125,7 @@ margin_bottom = 100.0 [node name="Tabs" type="TabContainer" parent="Main" groups=["disable_during_backup_operations", "disable_during_mod_operations", "disable_during_release_operations", "disable_during_soundpack_operations", "disable_while_fetching_releases"]] margin_top = 104.0 margin_right = 592.0 -margin_bottom = 547.0 +margin_bottom = 573.0 tab_align = 0 script = ExtResource( 16 ) @@ -1194,6 +1194,26 @@ value = 100.0 editable = false suffix = "%" +[node name="InstDir" type="HBoxContainer" parent="Main/Tabs/Settings"] +margin_top = 404.0 +margin_right = 577.0 +margin_bottom = 428.0 +hint_tooltip = "tooltip_num_prs_to_request" + +[node name="Label" type="Label" parent="Main/Tabs/Settings/InstDir"] +margin_right = 120.0 +margin_bottom = 24.0 +text = "lbl_installation_dir" + +[node name="leInstDir" type="LineEdit" parent="Main/Tabs/Settings/InstDir"] +margin_left = 493.0 +margin_right = 577.0 +margin_bottom = 24.0 +size_flags_horizontal = 10 +middle_mouse_paste_enabled = false +placeholder_text = "placeholder_installation_dir" +caret_blink = true + [node name="Debug" type="VBoxContainer" parent="Main/Tabs"] visible = false anchor_right = 1.0 @@ -1284,7 +1304,7 @@ size_flags_horizontal = 4 text = "Print screen info" [node name="Log" type="RichTextLabel" parent="Main"] -margin_top = 551.0 +margin_top = 577.0 margin_right = 592.0 margin_bottom = 692.0 focus_mode = 2 @@ -1400,6 +1420,7 @@ __meta__ = { [connection signal="value_changed" from="Main/Tabs/Settings/NumPrs/sbNumPRs" to="Main/Tabs/Settings" method="_on_sbNumPRs_value_changed"] [connection signal="toggled" from="Main/Tabs/Settings/ScaleOverride/cbScaleOverrideEnable" to="Main/Tabs/Settings" method="_on_cbScaleOverrideEnable_toggled"] [connection signal="value_changed" from="Main/Tabs/Settings/ScaleOverride/sbScaleOverride" to="Main/Tabs/Settings" method="_on_sbScaleOverride_value_changed"] +[connection signal="text_changed" from="Main/Tabs/Settings/InstDir/leInstDir" to="Main/Tabs/Settings" method="_on_leInstDir_text_changed"] [connection signal="pressed" from="Main/Tabs/Debug/Button" to="Main/Tabs/Debug" method="_on_Button_pressed"] [connection signal="pressed" from="Main/Tabs/Debug/Button2" to="Main/Tabs/Debug" method="_on_Button2_pressed"] [connection signal="pressed" from="Main/Tabs/Debug/Button3" to="Main/Tabs/Debug" method="_on_Button3_pressed"] diff --git a/scripts/SettingsUI.gd b/scripts/SettingsUI.gd index 06132923..9d028bc9 100644 --- a/scripts/SettingsUI.gd +++ b/scripts/SettingsUI.gd @@ -44,6 +44,8 @@ func _ready() -> void: $ShowDebug.pressed = Settings.read("debug_mode") $NumReleases/sbNumReleases.value = Settings.read("num_releases_to_request") as int $NumPrs/sbNumPRs.value = Settings.read("num_prs_to_request") as int + var inst_dir = Settings.read("installation_dir") + $InstDir/leInstDir.text = inst_dir if inst_dir else "" $ScaleOverride/cbScaleOverrideEnable.pressed = Settings.read("ui_scale_override_enabled") $ScaleOverride/sbScaleOverride.editable = Settings.read("ui_scale_override_enabled") @@ -123,6 +125,11 @@ func _on_sbNumPRs_value_changed(value: float) -> void: Settings.store("num_prs_to_request", str(value)) +func _on_leInstDir_text_changed(new_text: String) -> void: + + Settings.store("installation_dir", new_text) + + func _on_cbScaleOverrideEnable_toggled(button_pressed: bool) -> void: Settings.store("ui_scale_override_enabled", button_pressed) From 0736ccae42373e6693a2eae36fd5b62edda4f58f Mon Sep 17 00:00:00 2001 From: teackot Date: Sun, 13 Nov 2022 14:33:56 +0300 Subject: [PATCH 08/12] Implemented installation_dir setting --- scripts/path_helper.gd | 15 ++++++++++++++- scripts/settings_manager.gd | 6 +++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index 485727fc..a0030128 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -36,6 +36,19 @@ func _init() -> void: catapult_dir = _determine_catapult_dir() settings_dir = _determine_settings_dir() + Settings.load_settings(settings_dir) + var inst_dir_setting = Settings.read("installation_dir") + if inst_dir_setting != null and inst_dir_setting.is_abs_path(): + var d = Directory.new() + if not d.dir_exists(inst_dir_setting): + var error = d.make_dir_recursive(inst_dir_setting) + if error: + # something went wrong, use basic catapult_dir + Status.post(tr("msg_cannot_create_target_dir") % [inst_dir_setting, error], Enums.MSG_ERROR) + return + + catapult_dir = inst_dir_setting + func _determine_catapult_dir() -> String: @@ -45,7 +58,7 @@ func _determine_catapult_dir() -> String: if arg_pair[0] == "--catapult_dir_abs": var dirname = arg_pair[1] - if not dirname.begins_with("/"): + if not dirname.is_abs_path(): # relative paths are not supported, fallback to executable path Status.post(tr("msg_path_not_absolute") % dirname, Enums.MSG_ERROR) break diff --git a/scripts/settings_manager.gd b/scripts/settings_manager.gd index 6a3155cb..d8eb25ee 100644 --- a/scripts/settings_manager.gd +++ b/scripts/settings_manager.gd @@ -39,9 +39,9 @@ func _exit_tree() -> void: _write_to_file(_current, _settings_file) -func _load() -> void: +func load_settings(path: String = Paths.settings_dir) -> void: - _settings_file = Paths.settings_dir.plus_file(_SETTINGS_FILENAME) + _settings_file = path.plus_file(_SETTINGS_FILENAME) if File.new().file_exists(_settings_file): _current = _read_from_file(_settings_file) @@ -92,7 +92,7 @@ func dir_contains_settings(path: String) ->bool: func read(setting_name: String): if len(_current) == 0: - _load() + load_settings() if not setting_name in _current: if setting_name in _HARDCODED_DEFAULTS: From e484a6dbdfebe001cbdb5d21c3d45a6cb5fa80ee Mon Sep 17 00:00:00 2001 From: teackot Date: Sun, 13 Nov 2022 15:32:13 +0300 Subject: [PATCH 09/12] Use XDG config directory if possible --- scripts/path_helper.gd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index a0030128..dd292357 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -83,7 +83,9 @@ func _determine_settings_dir() -> String: match OS.get_name(): "X11": - global_settings_dir = OS.get_environment("HOME").plus_file(".config/catapult/") + var xdg_config_home = OS.get_environment("XDG_CONFIG_HOME") + var config_home = xdg_config_home if not xdg_config_home.empty() else OS.get_environment("HOME").plus_file(".config") + global_settings_dir = config_home.plus_file("catapult/") "Windows": global_settings_dir = OS.get_environment("USERPROFILE").plus_file("AppData/Local/Catapult/") _: From 6df96448e590be6d6b814af5097f388b077db652 Mon Sep 17 00:00:00 2001 From: teackot Date: Sun, 13 Nov 2022 16:58:43 +0300 Subject: [PATCH 10/12] Fix installation_dir not using env variables --- scripts/path_helper.gd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index dd292357..a5121fd1 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -47,7 +47,8 @@ func _init() -> void: Status.post(tr("msg_cannot_create_target_dir") % [inst_dir_setting, error], Enums.MSG_ERROR) return - catapult_dir = inst_dir_setting + d.open(inst_dir_setting) + catapult_dir = d.get_current_dir() func _determine_catapult_dir() -> String: From 6a9f711ee9054126aac93b074d3e9c4944032218 Mon Sep 17 00:00:00 2001 From: teackot Date: Sun, 13 Nov 2022 17:32:22 +0300 Subject: [PATCH 11/12] Revert last fix with only replacing '~' --- scripts/path_helper.gd | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index a5121fd1..b0937338 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -38,17 +38,15 @@ func _init() -> void: Settings.load_settings(settings_dir) var inst_dir_setting = Settings.read("installation_dir") - if inst_dir_setting != null and inst_dir_setting.is_abs_path(): + inst_dir_setting = inst_dir_setting.replace("~", OS.get_environment("HOME")) + + if inst_dir_setting != null: var d = Directory.new() + if not d.dir_exists(inst_dir_setting): - var error = d.make_dir_recursive(inst_dir_setting) - if error: - # something went wrong, use basic catapult_dir - Status.post(tr("msg_cannot_create_target_dir") % [inst_dir_setting, error], Enums.MSG_ERROR) - return - - d.open(inst_dir_setting) - catapult_dir = d.get_current_dir() + d.make_dir_recursive(inst_dir_setting) + + catapult_dir = inst_dir_setting func _determine_catapult_dir() -> String: From d16fc59f0dc85182e369d8fea0812a912115a97c Mon Sep 17 00:00:00 2001 From: teackot Date: Sun, 13 Nov 2022 17:45:58 +0300 Subject: [PATCH 12/12] Check if dir creation was successful --- scripts/path_helper.gd | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/path_helper.gd b/scripts/path_helper.gd index b0937338..68a0c5a4 100644 --- a/scripts/path_helper.gd +++ b/scripts/path_helper.gd @@ -43,10 +43,12 @@ func _init() -> void: if inst_dir_setting != null: var d = Directory.new() + var error = 0 if not d.dir_exists(inst_dir_setting): - d.make_dir_recursive(inst_dir_setting) + error = d.make_dir_recursive(inst_dir_setting) - catapult_dir = inst_dir_setting + if not error: + catapult_dir = inst_dir_setting func _determine_catapult_dir() -> String: