@@ -80,12 +80,12 @@ static func create_profile(profile_name: String) -> bool:
80
80
if not new_profile :
81
81
return false
82
82
83
- # Set it as the current profile
84
- ModLoaderStore .current_user_profile = new_profile
85
-
86
83
# Store the new profile in the ModLoaderStore
87
84
ModLoaderStore .user_profiles [profile_name ] = new_profile
88
85
86
+ # Set it as the current profile
87
+ ModLoaderStore .current_user_profile = ModLoaderStore .user_profiles [profile_name ]
88
+
89
89
# Store the new profile in the json file
90
90
var is_save_success := _save ()
91
91
@@ -108,7 +108,7 @@ static func set_profile(user_profile: ModUserProfile) -> bool:
108
108
return false
109
109
110
110
# Update the current_user_profile in the ModLoaderStore
111
- ModLoaderStore .current_user_profile = user_profile
111
+ ModLoaderStore .current_user_profile = ModLoaderStore . user_profiles [ user_profile . name ]
112
112
113
113
# Save changes in the json file
114
114
var is_save_success := _save ()
@@ -390,12 +390,6 @@ static func _load() -> bool:
390
390
ModLoaderLog .error ("No profile file found at \" %s \" " % FILE_PATH_USER_PROFILES , LOG_NAME )
391
391
return false
392
392
393
- # Set the current user profile to the one specified in the data
394
- var current_user_profile : ModUserProfile = ModUserProfile .new ()
395
- current_user_profile .name = data .current_profile
396
- current_user_profile .mod_list = data .profiles [data .current_profile ].mod_list
397
- ModLoaderStore .current_user_profile = current_user_profile
398
-
399
393
# Loop through each profile in the data and add them to ModLoaderStore
400
394
for profile_name in data .profiles .keys ():
401
395
# Get the profile data from the JSON object
@@ -405,6 +399,9 @@ static func _load() -> bool:
405
399
var new_profile := _create_new_profile (profile_name , profile_data .mod_list )
406
400
ModLoaderStore .user_profiles [profile_name ] = new_profile
407
401
402
+ # Set the current user profile to the one specified in the data
403
+ ModLoaderStore .current_user_profile = ModLoaderStore .user_profiles [data .current_profile ]
404
+
408
405
return true
409
406
410
407
0 commit comments