-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: ✨ Add user profiles #214
feat: ✨ Add user profiles #214
Conversation
Saves the user profiles and `current_profile` to `user://mod_user_profiles.json`
Added `_create_new_profile(name: String, mod_list: Dictionary)` - used to create new profiles now.
and swapped hardcoded file path with `FILE_PATH_USER_PROFILES`
Added `_handle_mod_state()` for this and use it in `enable_mod()` and `disable_mod()`
Updates the mod lists of all user profiles with newly loaded mods that are not already present.
Deletes a mod from a user profiles mod_list. Also added `_is_mod_id_in_mod_list()` to keep things dry.
Update the global list of disabled mods based on the current user profile
Returns an array containing all user profiles stored in ModLoaderStore
An error was caused in the `_update_disabled_mods()` function due to the potential non-existence of the `default` profile at this stage.
Allows to specify mandatory mods in the `ml_options`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice stuff, good work 👍
i think the user profiles mod is such a central thing that we might want to pick it up as an organisation repo
also: This seems awesome for implementing mod packs in the future. just create a profile and provide an api to download all of those from the steam workshop
I integrated it into the `_update_mod_lists()` function, so that any mods that are no longer installed will automatically be deleted from the user's profile mod lists.
`create()` -> `create_profile()` | `delete()` -> `delete_profile()`
With this a mod can be locked in the current profile state and can't be disabled or enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work!
Add User Profiles -
ModLoaderUserProfile
Inner Class
Profile
Stores the data for each User Profile
New API Methods
enable_mod(mod_id: String, profile_name := ModLoaderStore.current_user_profile)
Enables a mod - it will be loaded on the next game start
disable_mod(mod_id: String, profile_name := ModLoaderStore.current_user_profile)
Disables a mod - it will not be loaded on the next game start
delete_mod(mod_id: String, profile_name := ModLoaderStore.current_user_profile)
Delete a mod from a user profiles mod_list
create(profile_name: String)
Creates a new user profile with the given name, using the currently loaded mods as the mod list.
set_profile(profile_name: String)
Sets the current user profile to the specified profile_name.
delete(profile_name: String)
Deletes a user profile with the given profile_name.
get_current()
Returns the current user profile
get_profile(profile_name: String)
Return the user profile with the given name
get_all_as_array()
Returns an array containing all user profiles stored in ModLoaderStore
New Internal Methods
_update_disabled_mods()
Update the global list of disabled mods based on the current user profile. The user profile will override the
disabled_mods
property that can be set via the options resource in the editor.Example: If
Mod-TestMod
is set indisabled_mods
via the editor, the mod will appear disabled in the user profile. If the user then enables the mod in the profile the entry indisabled_mods
will be removed.Used in mod_loader.gd
_init()
before loading mods._update_mod_lists()
This function updates the mod lists of all user profiles with newly loaded mods that are not already present. It does so by comparing the current set of loaded mods with the mod list of each user profile, and adding any missing mods.
Used in mod_loader.gd
_ready()
after all mods are loaded._handle_mod_state(mod_id: String, profile_name: String, activate: bool)
Handles the activation or deactivation of a mod in a user profile.
_is_mod_id_in_mod_list(mod_id: String, profile_name: String)
Checks whether a given mod_id is present in the mod_list of the specified user profile.
Returns True if the mod_id is present, False otherwise.
_create_new_profile(profile_name: String, mod_list: Dictionary)
Creates a new Profile with the given name and mod list.
Returns the newly created Profile object.
_load()
Loads user profiles from the JSON file and adds them to ModLoaderStore.
Path to JSON file stored in
const FILE_PATH_USER_PROFILES
_save()
Saves the user profiles in the ModLoaderStore to the user profiles JSON file.
Path to JSON file stored in
const FILE_PATH_USER_PROFILES
Locked mods
Renamed from
mandatory_mods
ModData
-is_locked
The
is_locked
flag indicates whether a mod'sactive
state can be changed in a user profile, effectively preventing the user from disabling or enabling the mod.locked_mods
to options_profile.gdlocked_mods
toModLoaderStore.ml_options
Test / Example Mod:
Download KANA-UserProfile.zip
closes #109