samsface / godot-steam-api

Godot Steam integration using GDNative.
403 stars 16 forks source link

Order of autoloads changed by the EditorPlugin #24

Closed MrEliptik closed 2 years ago

MrEliptik commented 2 years ago

Because the steam.gd singleton is added by the EditorPlugin dynamically, it's always put at the end of the autoload list. It seems we can't decide the order when adding a singleton by code unfortunately, unless I missed something?

This is not a huge problem, it's possible to go around this limitation but I just wanted to talk about it in case someone else is having the same problem. It's frustrating to set the order in the settings and then getting it overridden.

If there's no other solution, maybe we could add a warning somewhere in the readme or in the SteamAPI project settings panel?

samsface commented 2 years ago

@MrEliptik What exactly is the problem with the autoload appearing at the bottom of the list?

MrEliptik commented 2 years ago

In my case I wanted the Steam singleton to be loaded first because I had other singletons using it to do different things. As I said in my first message, it's not a deal breaker, I can do something else. It's just that I didn't understand why it would always go back to being at the bottom of the list even though I moved it.

samsface commented 2 years ago

@MrEliptik So you have your own autoload, that during its _ready function, calls the Steam Autload before its called its _ready function?

MrEliptik commented 2 years ago

@samsface Yes exactly and I wasn't aware the Steam plugin was going to change the order of the autoload by adding the Steam.gd dynamically.

samsface commented 2 years ago

@MrEliptik Ok gotcha. Is there a way to check if a script is already autoloaded? Then we could not add the autoload automatically if it's already there.

MrEliptik commented 2 years ago

By looking at some GitHub issues, some people recommend opening the project.godot as a ConfigFile and looking at the autoload section, but I found a very simple way using ProjectSettings.

You can check if the autoload is present by doing: ProjectSettings.get("autoload/Steam") this returns the script path if present, otherwise null

samsface commented 2 years ago

Neat, added a check using this and seems to work :pray: