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

Allow using ProjectSettings.load_resource_pack() into a subfolder #7769

Open
nonchip opened this issue Sep 20, 2023 · 3 comments
Open

Allow using ProjectSettings.load_resource_pack() into a subfolder #7769

nonchip opened this issue Sep 20, 2023 · 3 comments

Comments

@nonchip
Copy link

nonchip commented Sep 20, 2023

Describe the project you are working on

multiple ones, isn't really project-specific but this would allow for anything from sandboxy keeping mods out of "core game files" to just simplifying a lot of tooling that works with packs.

Describe the problem or limitation you are having in your project

ProjectSettings.load_resource_pack can only "mount" to res://

Describe the feature / enhancement and how it helps to overcome the problem or limitation

add an optional parameter to ProjectSettings.load_resource_pack to allow mounting to any path in the virtual file system.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

essentially just need to track a single StringName across ProjectSettings.load_resource_pack, PackedData::add_pack, PackedSourcePCK::try_open_pack and prepend the String path built inside that latter function.

If this enhancement will not be used often, can it be worked around with a few lines of script?

no, none of the required functionality are exposed to GDScript nor GDExtension

Is there a reason why this should be core and not an add-on in the asset library?

because it would require a (non-compat-breaking) small api change to core functionality.

@nonchip
Copy link
Author

nonchip commented Sep 20, 2023

note this is kinda related to #2689 and #389, but instead of implementing whole apis to interact with individual pack files and sandboxed scripting environments it would be a way simpler change that covers most use cases and honestly just "makes sense". every mount so far had a 2nd parameter ;)

@nonchip
Copy link
Author

nonchip commented Sep 21, 2023

ok i appear too dumb to do the "autolink mention" right, so uh, my implementation attempt: godotengine/godot#82035

@Calinou Calinou changed the title load_resource_pack into a subfolder Allow using load_resource_pack into a subfolder Sep 21, 2023
@Calinou Calinou changed the title Allow using load_resource_pack into a subfolder Allow using ProjectSettings.load_resource_pack() into a subfolder Sep 21, 2023
@Jade-TheCat
Copy link

Jade-TheCat commented Sep 29, 2023

Following up on some discussion in the PR and moving my comment at godotengine/godot#82035 (comment) here:

Perhaps instead of mangling res:// calls by prefixing them, we could have a separate location for those resources that acts like res:// for loaded packs?
So in the pack you would use pack:// for all pack-internal references and res:// for all of the base game resources. Then in project settings there could be a setting for where to load non-overriding packs by default (let's say it defaults to res://packs/<pack_file_name>), and there could be an alternative to load_resource_pack() (say, load_resource_pack_no_override() although that is quite long) that would load the pack to the path set in project settings. The engine would have to keep track of what pack a file is in, but I think that could be easy by checking if the file location relative to res:// was in the packs folder.
Of course, this would still allow for packs to be loaded into res://, say for updates or texture packs, but there would be the option to put the pack contents somewhere it doesn't mangle stuff for mods. I believe there's a way to specify what types of files get loaded by load_resource_pack() but if not that may be something to consider as well. That way you can specify per-pack whether it should override stuff and what it should override.

I'm not really sure how one would implement this as I have only looked at the engine code a little, but I might take a look into it when I have more time and if someone else doesn't pick up this or the linked PR doesn't get approved.

This is a larger proposed change than this original proposal, so if I need to move it to its own proposal I will, but since these are covering the same topic I figured putting it in the existing discussion would be better than having a bunch of issues opened

EDIT: I think this may also be useful for the people asking for GDScript sandboxing, as the engine keeping track of whether a script is in a pack could be used to automatically sandbox the script if that were an option to enable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants