Skip to content

Commit 020c143

Browse files
committed
fix: 🐛 improved set current_config
1 parent 0038c46 commit 020c143

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

addons/mod_loader/resources/mod_data.gd

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ func load_configs() -> void:
8888
_load_config(config_file_path)
8989

9090
# Set the current_config based on the user profile
91-
current_config = ModLoaderConfig.get_current_config(dir_name)
91+
var current_config_user_profile = ModLoaderConfig.get_current_config(dir_name)
92+
93+
# If we cannot get the current_config from the user profile, set the config to default.
94+
# This should only happen on the first run because the user profile is generated in _ready(), or if the
95+
# user profile JSON file was deleted manually.
96+
current_config = current_config_user_profile if current_config_user_profile else ModLoaderConfig.get_default_config(dir_name)
9297

9398

9499
# Create a new ModConfig instance for each Config JSON and add it to the configs dictionary.
@@ -104,10 +109,6 @@ func _load_config(config_file_path: String) -> void:
104109
# Add the config to the configs dictionary
105110
configs[mod_config.name] = mod_config
106111

107-
# Set it as the current_config if there is none
108-
if not current_config:
109-
current_config = mod_config
110-
111112

112113
# Update the mod_list of the current user profile
113114
func _set_current_config(new_current_config: ModConfig) -> void:

0 commit comments

Comments
 (0)