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

Expose settings overwrites for autoloads #4831

Closed
RoniPerson opened this issue Jul 7, 2022 · 2 comments
Closed

Expose settings overwrites for autoloads #4831

RoniPerson opened this issue Jul 7, 2022 · 2 comments

Comments

@RoniPerson
Copy link

Describe the project you are working on

An addon for background loading.

Describe the problem or limitation you are having in your project

Since godot does not support threads on all platforms I created two implementations of my plugin. They both share the same public methods but work diffrently inside.
To make exporting for diffrent platforms easier I wanted to use settings overwrites to use the threadless implementation in the web. But the AutoLoad tab in the settings has no option to do this so I thought it would not be possible.

Later I realized, that there is also an AutoLoad optionb under the general settings which indeed allows overwriting. After some testing it seems to work fine when running the game.

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

In the autoload tab add a button to support overwriting. In addition overwritten autoloads should be displayed in a diffrent color. When moving an autoload up and down the overwritten autoload should be moved with it.

I think it would also be usefull to expose this to the addon API by adding a third parameter to add_autoload_singelton which contains the overwrite and is optional. In this way a plugin could do the overwriting for the user.

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

It should be fine to reuse functionality that is used by the GeneralSettings.

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

The part with the plugin could possibly be done via ProjectSettings although I did not get it work until now.

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

This issue is about exposing an existing feature.

@KoBeWi
Copy link
Member

KoBeWi commented Jul 7, 2022

You could just do

if no_threads:
    replace_by(preload("AutoloadNoThreads").instance())
    queue_free()
    return

inside your autoload.

@RoniPerson
Copy link
Author

You could just do

if no_threads:
    replace_by(preload("AutoloadNoThreads").instance())
    queue_free()
    return

inside your autoload.

This does not seem to work, since replace_by does not replace the reference that is accessible through the autoload constant.
Something like this is possible through set_script which works in my case since the autoload has nothing inside _ready.

Actually I use a setup simular to what you proposed. But I have it inside an own script called setup because I want the implementations to be sepperated without linkage. I need the overwrites to use this setup script only on standalone builds, so that the autocompletion still works inside the editor.

I simplified the setup for the proposal because the actual point is, that the editor does not support this feature and not how one could avoid using it.

@RoniPerson RoniPerson closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants