diff --git a/addons/mod_loader/internal/path.gd b/addons/mod_loader/internal/path.gd index 9c67928d..7935d952 100644 --- a/addons/mod_loader/internal/path.gd +++ b/addons/mod_loader/internal/path.gd @@ -8,6 +8,7 @@ extends RefCounted const LOG_NAME := "ModLoader:Path" const MOD_CONFIG_DIR_PATH := "user://mod_configs" const MOD_CONFIG_DIR_PATH_OLD := "user://configs" +const USER_MODS_DIR_PATH := "user://mods" # Get the path to a local folder. Primarily used to get the (packed) mods @@ -209,6 +210,9 @@ static func get_mod_paths_from_all_sources() -> Array[String]: if ModLoaderStore.ml_options.load_from_steam_workshop: mod_paths.append_array(_ModLoaderSteam.find_steam_workshop_zips()) + + if ModLoaderStore.ml_options.load_from_user_data_mods: + mod_paths.append_array(get_zip_paths_in(get_path_to_user_mods())) return mod_paths @@ -291,3 +295,8 @@ static func handle_mod_config_path_deprecation() -> void: ModLoaderLog.error("Failed to rename the config directory with error \"%s\"." % [error_string(error)], LOG_NAME) else: ModLoaderLog.success("Successfully renamed config directory to \"%s\"." % MOD_CONFIG_DIR_PATH, LOG_NAME) + +static func get_path_to_user_mods() -> String: + if ModLoaderStore and ModLoaderStore.ml_options.override_path_to_user_data_mods: + return ModLoaderStore.ml_options.override_path_to_user_data_mods + return USER_MODS_DIR_PATH diff --git a/addons/mod_loader/mod_loader_store.gd b/addons/mod_loader/mod_loader_store.gd index 5bc7bebd..909a9523 100644 --- a/addons/mod_loader/mod_loader_store.gd +++ b/addons/mod_loader/mod_loader_store.gd @@ -200,7 +200,13 @@ func _update_ml_options_from_cli_args() -> void: if cmd_line_mod_path: ml_options.override_path_to_mods = cmd_line_mod_path ModLoaderLog.info("The path mods are loaded from has been changed via the CLI arg `--mods-path`, to: " + cmd_line_mod_path, LOG_NAME) - + # Override paths to user data mods + # Set via: --mod-user-path + # Example: --mod-user-path="C://user/mods" + var cmd_line_mod_user_path := _ModLoaderCLI.get_cmd_line_arg_value("--mod-user-path") + if cmd_line_mod_user_path: + ml_options.override_path_to_user_data_mods = cmd_line_mod_user_path + ModLoaderLog.info("The path mod user data is loaded from has been changed via the CLI arg `--mod-user-path`, to: " + cmd_line_mod_user_path, LOG_NAME) # Override paths to configs # Set via: --configs-path # Example: --configs-path="C://path/configs" diff --git a/addons/mod_loader/options/profiles/current.tres b/addons/mod_loader/options/profiles/current.tres index 94742bb4..5b5718ad 100644 --- a/addons/mod_loader/options/profiles/current.tres +++ b/addons/mod_loader/options/profiles/current.tres @@ -11,3 +11,5 @@ steam_workshop_enabled = false override_path_to_mods = "" override_path_to_configs = "" override_path_to_workshop = "" +load_from_user_data_mods = false +override_path_to_user_data_mods = "" \ No newline at end of file diff --git a/addons/mod_loader/options/profiles/default.tres b/addons/mod_loader/options/profiles/default.tres index 07774b34..9c12cd76 100644 --- a/addons/mod_loader/options/profiles/default.tres +++ b/addons/mod_loader/options/profiles/default.tres @@ -12,3 +12,5 @@ steam_workshop_enabled = false override_path_to_mods = "" override_path_to_configs = "" override_path_to_workshop = "" +load_from_user_data_mods = false +override_path_to_user_data_mods = "" \ No newline at end of file diff --git a/addons/mod_loader/options/profiles/disable_mods.tres b/addons/mod_loader/options/profiles/disable_mods.tres index e1e30d3c..d749ef08 100644 --- a/addons/mod_loader/options/profiles/disable_mods.tres +++ b/addons/mod_loader/options/profiles/disable_mods.tres @@ -12,3 +12,5 @@ steam_workshop_enabled = false override_path_to_mods = "" override_path_to_configs = "" override_path_to_workshop = "" +load_from_user_data_mods = false +override_path_to_user_data_mods = "" \ No newline at end of file diff --git a/addons/mod_loader/options/profiles/editor.tres b/addons/mod_loader/options/profiles/editor.tres index 2183936f..4e57952c 100644 --- a/addons/mod_loader/options/profiles/editor.tres +++ b/addons/mod_loader/options/profiles/editor.tres @@ -14,4 +14,6 @@ override_path_to_mods = "" override_path_to_configs = "" override_path_to_workshop = "" ignore_deprecated_errors = true -ignored_mod_names_in_log = [ ] \ No newline at end of file +ignored_mod_names_in_log = [ ] +load_from_user_data_mods = false +override_path_to_user_data_mods = "" \ No newline at end of file diff --git a/addons/mod_loader/options/profiles/production_no_workshop.tres b/addons/mod_loader/options/profiles/production_no_workshop.tres index 7b5856c0..2ce806d8 100644 --- a/addons/mod_loader/options/profiles/production_no_workshop.tres +++ b/addons/mod_loader/options/profiles/production_no_workshop.tres @@ -17,3 +17,5 @@ ignore_deprecated_errors = false ignored_mod_names_in_log = [] load_from_steam_workshop = false load_from_local = true +load_from_user_data_mods = false +override_path_to_user_data_mods \ No newline at end of file diff --git a/addons/mod_loader/options/profiles/production_workshop.tres b/addons/mod_loader/options/profiles/production_workshop.tres index 0b610bcb..e08e9b85 100644 --- a/addons/mod_loader/options/profiles/production_workshop.tres +++ b/addons/mod_loader/options/profiles/production_workshop.tres @@ -17,3 +17,5 @@ ignore_deprecated_errors = false ignored_mod_names_in_log = [] load_from_steam_workshop = true load_from_local = true +load_from_user_data_mods = false +override_path_to_user_data_mods \ No newline at end of file diff --git a/addons/mod_loader/resources/options_profile.gd b/addons/mod_loader/resources/options_profile.gd index f1982f48..fc277f6b 100644 --- a/addons/mod_loader/resources/options_profile.gd +++ b/addons/mod_loader/resources/options_profile.gd @@ -74,6 +74,8 @@ enum VERSION_VALIDATION { @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 +## Indicates whether to load mods from the "mods" folder located in the game's user data directory (user://) +@export var load_from_user_data_mods: bool = true ## Indicates whether to load mods from [code]"res://mods-unpacked"[/code] in the exported game.[br] ## ===[br] ## [b]Note:[color=note "Load from unpacked in the editor"][/color][/b][br] @@ -83,6 +85,9 @@ enum VERSION_VALIDATION { ## Path to a folder containing mods [br] ## Mod zips should be directly in this folder @export_dir var override_path_to_mods = "" +## Alternative path to a folder containing mods (originally within user://). [br] +## Mod zips should be directly in this folder +@export_dir var override_path_to_user_data_mods := "" ## Use this option to override the default path where configs are stored. @export_dir var override_path_to_configs = "" ## Path to a folder containing workshop items.[br] @@ -117,3 +122,7 @@ var custom_game_version_validation_callable: Callable ## Stores the instance of the script specified in [member customize_script_path]. var customize_script_instance: RefCounted + + + + diff --git a/test/test_options/customize_script/custom_validation.tres b/test/test_options/customize_script/custom_validation.tres index f390d4c3..c5e40e5c 100644 --- a/test/test_options/customize_script/custom_validation.tres +++ b/test/test_options/customize_script/custom_validation.tres @@ -24,3 +24,4 @@ override_hook_pack_name = "" restart_notification_scene_path = "res://addons/mod_loader/restart_notification.tscn" disable_restart = false game_version_validation = 2 +override_path_to_user_data_mods = "" diff --git a/test/test_options/customize_script_no_callable_set/custom_validation_no_callable_set.tres b/test/test_options/customize_script_no_callable_set/custom_validation_no_callable_set.tres index 9e5b01ea..a471d77a 100644 --- a/test/test_options/customize_script_no_callable_set/custom_validation_no_callable_set.tres +++ b/test/test_options/customize_script_no_callable_set/custom_validation_no_callable_set.tres @@ -24,3 +24,4 @@ override_hook_pack_name = "" restart_notification_scene_path = "res://addons/mod_loader/restart_notification.tscn" disable_restart = false game_version_validation = 2 +override_path_to_user_data_mods = "" \ No newline at end of file diff --git a/test/test_options/game_version_validation_default/game_version_validation_default.tres b/test/test_options/game_version_validation_default/game_version_validation_default.tres index 611aea76..06b5089e 100644 --- a/test/test_options/game_version_validation_default/game_version_validation_default.tres +++ b/test/test_options/game_version_validation_default/game_version_validation_default.tres @@ -24,3 +24,4 @@ override_hook_pack_name = "" restart_notification_scene_path = "res://addons/mod_loader/restart_notification.tscn" disable_restart = false game_version_validation = 0 +override_path_to_user_data_mods = "" \ No newline at end of file diff --git a/test/test_options/game_version_validation_disabled/game_version_validation_disabled.tres b/test/test_options/game_version_validation_disabled/game_version_validation_disabled.tres index 5d9dbf34..a89c49d7 100644 --- a/test/test_options/game_version_validation_disabled/game_version_validation_disabled.tres +++ b/test/test_options/game_version_validation_disabled/game_version_validation_disabled.tres @@ -24,3 +24,4 @@ override_hook_pack_name = "" restart_notification_scene_path = "res://addons/mod_loader/restart_notification.tscn" disable_restart = false game_version_validation = 1 +override_path_to_user_data_mods = "" \ No newline at end of file