Skip to content

Add user:// as mod source for 4.x #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: 4.x-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions addons/mod_loader/internal/path.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
8 changes: 7 additions & 1 deletion addons/mod_loader/mod_loader_store.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions addons/mod_loader/options/profiles/current.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
2 changes: 2 additions & 0 deletions addons/mod_loader/options/profiles/default.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
2 changes: 2 additions & 0 deletions addons/mod_loader/options/profiles/disable_mods.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
4 changes: 3 additions & 1 deletion addons/mod_loader/options/profiles/editor.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [ ]
ignored_mod_names_in_log = [ ]
load_from_user_data_mods = false
override_path_to_user_data_mods = ""
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions addons/mod_loader/options/profiles/production_workshop.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions addons/mod_loader/resources/options_profile.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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




1 change: 1 addition & 0 deletions test/test_options/customize_script/custom_validation.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this added automatically by godot or manually? wondering why the = "" is missing compared to the other .tres

Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""