From 31cd4abcdcd97f9ca237f89510e2767da296adf9 Mon Sep 17 00:00:00 2001 From: Kai Roth Date: Mon, 5 Jun 2023 13:38:17 +0200 Subject: [PATCH 1/3] fix: :bug: added deprecation for `mod_data` --- addons/mod_loader/mod_loader.gd | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/mod_loader/mod_loader.gd b/addons/mod_loader/mod_loader.gd index d03e24a8..dcd82dc8 100644 --- a/addons/mod_loader/mod_loader.gd +++ b/addons/mod_loader/mod_loader.gd @@ -28,9 +28,13 @@ const LOG_NAME := "ModLoader" # --- DEPRECATED --- # UNPACKED_DIR was moved to ModLoaderStore. -# However, many Brotato mods use this const directly, which is why the deprecation warning was added. +# However, many mods use this const directly, which is why the deprecation warning was added. var UNPACKED_DIR := "res://mods-unpacked/" setget ,deprecated_direct_access_UNPACKED_DIR +# mod_data was moved to ModLoaderStore. +# However, many mods use this const directly, which is why the deprecation warning was added. +var mod_data := {} setget , deprecated_direct_access_mod_data + # Main # ============================================================================= @@ -374,3 +378,8 @@ func get_mod_config(mod_dir_name: String = "", key: String = "") -> ModConfig: func deprecated_direct_access_UNPACKED_DIR() -> String: ModLoaderDeprecated.deprecated_message("The const \"UNPACKED_DIR\" was removed, use \"ModLoaderMod.get_unpacked_dir()\" instead", "6.0.0") return _ModLoaderPath.get_unpacked_mods_dir_path() + + +func deprecated_direct_access_mod_data() -> Dictionary: + ModLoaderDeprecated.deprecated_message("The var \"mod_data\" was removed, use \"ModLoaderMod.get_mod_data_from_mod_id()\" instead", "6.0.0") + return ModLoaderStore.mod_data \ No newline at end of file From 0cb3ec4e9230c71c1ab0f98e01b8969c8a56aaec Mon Sep 17 00:00:00 2001 From: Kai Roth Date: Mon, 5 Jun 2023 13:40:53 +0200 Subject: [PATCH 2/3] refactor: :pencil2: `get_mod_data_from_mod_id` -> `get_mod_data` --- addons/mod_loader/api/mod.gd | 6 +++--- addons/mod_loader/mod_loader.gd | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/mod_loader/api/mod.gd b/addons/mod_loader/api/mod.gd index b258f557..dafe2eab 100644 --- a/addons/mod_loader/api/mod.gd +++ b/addons/mod_loader/api/mod.gd @@ -15,7 +15,7 @@ const LOG_NAME := "ModLoader:Mod" static func install_script_extension(child_script_path: String) -> void: var mod_id: String = ModLoaderUtils.get_string_in_between(child_script_path, "res://mods-unpacked/", "/") - var mod_data: ModData = get_mod_data_from_mod_id(mod_id) + var mod_data: ModData = get_mod_data(mod_id) if not ModLoaderStore.saved_extension_paths.has(mod_data.manifest.get_mod_id()): ModLoaderStore.saved_extension_paths[mod_data.manifest.get_mod_id()] = [] ModLoaderStore.saved_extension_paths[mod_data.manifest.get_mod_id()].append(child_script_path) @@ -102,7 +102,7 @@ static func add_translation_from_resource(resource_path: String) -> void: # Gets the ModData from the provided namespace -static func get_mod_data_from_mod_id(mod_id: String) -> ModData: +static func get_mod_data(mod_id: String) -> ModData: if not ModLoaderStore.mod_data.has(mod_id): ModLoaderLog.error("%s is an invalid mod_id" % mod_id, LOG_NAME) return null @@ -116,7 +116,7 @@ static func is_mod_loaded(mod_id: String) -> bool: ModLoaderLog.warning( "The ModLoader is not fully initialized. " + "Calling \"is_mod_loaded()\" in \"_init()\" may result in an unexpected return value as mods are still loading.", - LOG_NAME + LOG_NAME ) # If the mod is not present in the mod_data dictionary or the mod is flagged as not loadable. diff --git a/addons/mod_loader/mod_loader.gd b/addons/mod_loader/mod_loader.gd index dcd82dc8..cf73688d 100644 --- a/addons/mod_loader/mod_loader.gd +++ b/addons/mod_loader/mod_loader.gd @@ -381,5 +381,5 @@ func deprecated_direct_access_UNPACKED_DIR() -> String: func deprecated_direct_access_mod_data() -> Dictionary: - ModLoaderDeprecated.deprecated_message("The var \"mod_data\" was removed, use \"ModLoaderMod.get_mod_data_from_mod_id()\" instead", "6.0.0") + ModLoaderDeprecated.deprecated_message("The var \"mod_data\" was removed, use \"ModLoaderMod.get_mod_data()\" instead", "6.0.0") return ModLoaderStore.mod_data \ No newline at end of file From ed7206c9a6cbe6c99d0b3700674887b5f221fabd Mon Sep 17 00:00:00 2001 From: Kai Roth Date: Mon, 5 Jun 2023 13:48:36 +0200 Subject: [PATCH 3/3] style: :art: added lost whitespace --- addons/mod_loader/mod_loader.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mod_loader/mod_loader.gd b/addons/mod_loader/mod_loader.gd index cf73688d..dd3c6476 100644 --- a/addons/mod_loader/mod_loader.gd +++ b/addons/mod_loader/mod_loader.gd @@ -382,4 +382,4 @@ func deprecated_direct_access_UNPACKED_DIR() -> String: func deprecated_direct_access_mod_data() -> Dictionary: ModLoaderDeprecated.deprecated_message("The var \"mod_data\" was removed, use \"ModLoaderMod.get_mod_data()\" instead", "6.0.0") - return ModLoaderStore.mod_data \ No newline at end of file + return ModLoaderStore.mod_data