Skip to content
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

ModLoaderUserProfile - Mods are getting deleted from the mod_list when they are disabled and Steam Workshop support is enabled. #288

Closed
KANAjetzt opened this issue Jun 20, 2023 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@KANAjetzt
Copy link
Member

KANAjetzt commented Jun 20, 2023

# Check if the mod_dir for the mod-id exists
if not _ModLoaderFile.dir_exists(_ModLoaderPath.get_unpacked_mods_dir_path() + mod_id):
# If the mod directory doesn't exist,
# the mod is no longer installed and can be removed from the mod list
updated_mod_list.erase(mod_id)
continue

https://clips.twitch.tv/EmpathicAdventurousClintHotPokket-H7a59LUuNBrzUDNy


The current approach of using _ModLoaderFile.dir_exists(_ModLoaderPath.get_unpacked_mods_dir_path() + mod_id) to remove mods from the mod_list is not suitable outside of the development environment. This is because mods are only present in the mods-unpacked directory once they are loaded. Therefore, we need to find an alternative way to check if the mods are still installed.

One option is to store the path to the mod zip when the mod is added to the mod_list inside the user profile. This way, we can check if the actual zip file is still present. However, we should be cautious about false positives, as renaming a zip file could lead to incorrect results.

Currently the name of the ZIP file is arbitrary and can include additional information such as a version string:

The name of the ZIP is arbitrary. This gives you freedom to, for example, append it with a version string, eg. AuthorName-ModName-v1.1.2.zip.
https://github.com/GodotModding/godot-mod-loader/wiki/Mod-Structure#zips

Therefore, we cannot assume a consistent naming convention like we do for the mods-unpacked directory, where the directory name follows the pattern namespace-modname.

@KANAjetzt
Copy link
Member Author

KANAjetzt commented Jun 21, 2023

Notes:

  • ModData is initialized with the umpacked_dir in _init() -> _load_mods() -> _setup_mods() -> _init_mod_data()
  • The zip path is accessible in _ModLoaderFile.load_zips_in_folder(folder_path: String) used by ModLoader._load_mod_zips() and _ModLoaderSteam.load_steam_workshop_zips() in _init() -> _load_mods() -> _load_mod_zips
  • Keep in mind that in dev, there will usually be no zip files, only unpacked mods in the mods-unpacked directory.
    • So I have to check if the current env is the editor, in that case don't delete anything from the mod_list
  • Maybe we don't delete mods from the mod_list and just indicate them as "no longer present"? That way, players can choose to remove the mod from the list.
  • When a player uninstalls a mod, there's usually no need to keep it in the profile. The profile only stores the active state and the current configuration. The configuration is stored and not deleted, so if the mod is installed again, we can simply use the default configuration.
Possible Flow for initing `ModData` early

image

  • Added the zip_path to ModData KANAjetzt@924f783

  • Now I can save the zip_path to the mod_list in mod_user_profiles.json

  • Check if the file exists ( if not in the editor? ) and if not delete the mod from the mod_list

KANAjetzt added a commit to KANAjetzt/godot-mod-loader that referenced this issue Jun 24, 2023
This allows to verify if the mod is still installed by confirming the existence of the zip file. However, this check is only performed when the mod is not loaded and a path to the zip file exists. This ensures that mods are not deleted from the profile when running in the editor. It's important to note that this new check may cause mods to appear in user profiles even if they are currently not loaded. To determine if a mod is actually loaded, you should also check `ModLoaderStore.mod_data` or use `ModLoaderMod.is_mod_loaded()`.

closes GodotModding#288
KANAjetzt added a commit to KANAjetzt/godot-mod-loader that referenced this issue Jun 24, 2023
This allows to verify if the mod is still installed by confirming the existence of the zip file. However, this check is only performed when the mod is not loaded and a path to the zip file exists. This ensures that mods are not deleted from the profile when running in the editor. It's important to note that this new check may cause mods to appear in user profiles even if they are currently not loaded. To determine if a mod is actually loaded, you should also check `ModLoaderStore.mod_data` or use `ModLoaderMod.is_mod_loaded()`.

closes GodotModding#288
KANAjetzt added a commit to KANAjetzt/godot-mod-loader that referenced this issue Jun 24, 2023
This allows to verify if the mod is still installed by confirming the existence of the zip file. However, this check is only performed when the mod is not loaded and a path to the zip file exists. This ensures that mods are not deleted from the profile when running in the editor. It's important to note that this new check may cause mods to appear in user profiles even if they are currently not loaded. To determine if a mod is actually loaded, you should also check `ModLoaderStore.mod_data` or use `ModLoaderMod.is_mod_loaded()`.

closes GodotModding#288
github-merge-queue bot pushed a commit that referenced this issue Jun 27, 2023
* feat: ✨ added ` get_dir_paths_in_dir()`

* feat: ✨ added `zip_name` and `zip_path` to `ModData`

* refactor: ♻️ added `zip_path` to user profiles

This allows to verify if the mod is still installed by confirming the existence of the zip file. However, this check is only performed when the mod is not loaded and a path to the zip file exists. This ensures that mods are not deleted from the profile when running in the editor. It's important to note that this new check may cause mods to appear in user profiles even if they are currently not loaded. To determine if a mod is actually loaded, you should also check `ModLoaderStore.mod_data` or use `ModLoaderMod.is_mod_loaded()`.

closes #288
@KANAjetzt
Copy link
Member Author

closed by #298

@KANAjetzt KANAjetzt mentioned this issue Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant