Skip to content

Commit

Permalink
fix: 🐛 set current_config in ModData._load_config() (#523)
Browse files Browse the repository at this point in the history
* fix: 🐛 set `current_config` in `ModData._load_config()`

Fixed an issue where `current_config` was null because it wasn't set in `ModData._load_config()`.

closes #466

* fix: 🐛 added method to check if user profiles are initialized

* fix: 🐛 `current_config` = default if no user profile
  • Loading branch information
KANAjetzt authored Jan 26, 2025
1 parent 3915bb8 commit ee15766
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions addons/mod_loader/api/profile.gd
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ static func get_all_as_array() -> Array:
return user_profiles


# Returns true if the Mod User Profiles are initialized.
# On the first execution of the game, user profiles might not yet be created.
# Use this method to check if everything is ready to interact with the ModLoaderUserProfile API.
static func is_initialized() -> bool:
return _ModLoaderFile.file_exists(FILE_PATH_USER_PROFILES)


# Internal profile functions
# =============================================================================

Expand Down
3 changes: 2 additions & 1 deletion addons/mod_loader/mod_loader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func _init() -> void:
return

# Load user profiles into ModLoaderStore
var _success_user_profile_load := ModLoaderUserProfile._load()
if ModLoaderUserProfile.is_initialized():
var _success_user_profile_load := ModLoaderUserProfile._load()

_load_mods()

Expand Down
5 changes: 4 additions & 1 deletion addons/mod_loader/resources/mod_data.gd
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ func load_configs() -> void:
_load_config(config_file_path)

# Set the current_config based on the user profile
current_config = ModLoaderConfig.get_current_config(dir_name)
if ModLoaderUserProfile.is_initialized():
current_config = ModLoaderConfig.get_current_config(dir_name)
else:
current_config = ModLoaderConfig.get_config(dir_name, ModLoaderConfig.DEFAULT_CONFIG_NAME)


# Create a new ModConfig instance for each Config JSON and add it to the configs dictionary.
Expand Down

0 comments on commit ee15766

Please sign in to comment.