diff --git a/addons/mod_loader/api/deprecated.gd b/addons/mod_loader/api/deprecated.gd index d2cfca31..1ca5313f 100644 --- a/addons/mod_loader/api/deprecated.gd +++ b/addons/mod_loader/api/deprecated.gd @@ -61,7 +61,7 @@ static func deprecated_message(msg: String, since_version: String = "") -> void: # # Returns: void static func _deprecated_log(msg: String) -> void: - if ModLoaderStore.ml_options.ignore_deprecated_errors or OS.has_feature("standalone"): + if ModLoaderStore and ModLoaderStore.ml_options.ignore_deprecated_errors or OS.has_feature("standalone"): ModLoaderLog.warning(msg, LOG_NAME) else: ModLoaderLog.fatal(msg, LOG_NAME) diff --git a/addons/mod_loader/mod_loader.gd b/addons/mod_loader/mod_loader.gd index e12b7117..7cc03df0 100644 --- a/addons/mod_loader/mod_loader.gd +++ b/addons/mod_loader/mod_loader.gd @@ -83,6 +83,7 @@ func _exit_tree() -> void: func _load_mods() -> void: + ModLoaderStore.previous_mod_dirs = _ModLoaderPath.get_dir_paths_in_dir(_ModLoaderPath.get_unpacked_mods_dir_path()) # Loop over "res://mods" and add any mod zips to the unpacked virtual # directory (UNPACKED_DIR) var zip_data := _load_mod_zips() @@ -225,18 +226,17 @@ func _check_autoload_positions() -> void: var _pos_ml_core := _ModLoaderGodot.check_autoload_position("ModLoader", 1, true) -# Loop over "res://mods" and add any mod zips to the unpacked virtual directory -# (UNPACKED_DIR) +# Add any mod zips to the unpacked virtual directory func _load_mod_zips() -> Dictionary: var zip_data := {} - if not ModLoaderStore.ml_options.steam_workshop_enabled: + if ModLoaderStore.ml_options.load_from_local: var mods_folder_path := _ModLoaderPath.get_path_to_mods() - - # If we're not using Steam workshop, just loop over the mod ZIPs. + # Loop over the mod zips in the "mods" directory var loaded_zip_data := _ModLoaderFile.load_zips_in_folder(mods_folder_path) zip_data.merge(loaded_zip_data) - else: + + if ModLoaderStore.ml_options.load_from_steam_workshop or ModLoaderStore.ml_options.steam_workshop_enabled: # If we're using Steam workshop, loop over the workshop item directories var loaded_workshop_zip_data := _ModLoaderSteam.load_steam_workshop_zips() zip_data.merge(loaded_workshop_zip_data) @@ -254,7 +254,7 @@ func _setup_mods() -> int: if dir == null: ModLoaderLog.error("Can't open unpacked mods folder %s." % unpacked_mods_path, LOG_NAME) return -1 - if not dir.list_dir_begin() == OK:# TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547 + if not dir.list_dir_begin() == OK: ModLoaderLog.error("Can't read unpacked mods folder %s." % unpacked_mods_path, LOG_NAME) return -1 diff --git a/addons/mod_loader/mod_loader_store.gd b/addons/mod_loader/mod_loader_store.gd index 54775ec2..bf9622e2 100644 --- a/addons/mod_loader/mod_loader_store.gd +++ b/addons/mod_loader/mod_loader_store.gd @@ -111,6 +111,7 @@ var ml_options := { # If true, ModLoader will load mod ZIPs from the Steam workshop directory, # instead of the default location (res://mods) + # INFO: Redundant since the introduction of mod source options, kept for backwards compatibility. steam_workshop_enabled = false, # Overrides for the path mods/configs/workshop folders are loaded from. @@ -130,6 +131,12 @@ var ml_options := { # Array of mods that should be ignored when logging messages (contains mod IDs as strings) ignored_mod_names_in_log = [], + + # Mod Sources + # Indicates whether to load mods from the Steam Workshop directory, or the overridden workshop path. + load_from_steam_workshop = false, + # Indicates whether to load mods from the "mods" folder located at the game's install directory, or the overridden mods path. + load_from_local = true, } @@ -169,6 +176,8 @@ func _update_ml_options_from_options_resource() -> void: # Update from the options in the resource for key in ml_options: ml_options[key] = current_options[key] + if key == "steam_workshop_enabled" and current_options[key] == true: + ModLoaderDeprecated.deprecated_message("The Steam Workshop Enabled option has been deprecated. Please use the mod source options instead.", "6.3.0") # Get options overrides by feature tags # An override is saved as Dictionary[String: ModLoaderOptionsProfile] @@ -199,6 +208,8 @@ func _update_ml_options_from_options_resource() -> void: # Update from the options in the resource for key in ml_options: ml_options[key] = override_options[key] + if key == "steam_workshop_enabled" and override_options[key] == true: + ModLoaderDeprecated.deprecated_message("The Steam Workshop Enabled option has been deprecated. Please use the mod source options instead.", "6.3.0") # Update ModLoader's options, via CLI args diff --git a/addons/mod_loader/resources/options_profile.gd b/addons/mod_loader/resources/options_profile.gd index 0f54dbbf..619e9080 100644 --- a/addons/mod_loader/resources/options_profile.gd +++ b/addons/mod_loader/resources/options_profile.gd @@ -16,3 +16,8 @@ extends Resource @export_dir var override_path_to_workshop = "" @export var ignore_deprecated_errors: bool = false @export var ignored_mod_names_in_log: Array[String] = [] +@export_group("Mod Source") +## Indicates whether to load mods from the Steam Workshop directory, or the overridden workshop path. +@export var load_from_steam_workshop: bool = false +## Indicates whether to load mods from the "mods" folder located at the game's install directory, or the overridden mods path. +@export var load_from_local: bool = true