Skip to content

Revamp autoload creation#91124

Merged
akien-mga merged 1 commit into
godotengine:masterfrom
KoBeWi:auutoload_revampire🧛
Mar 5, 2026

Hidden character warning

The head ref may contain hidden characters: "auutoload_revampire\ud83e\udddb"
Merged

Revamp autoload creation#91124
akien-mga merged 1 commit into
godotengine:masterfrom
KoBeWi:auutoload_revampire🧛

Conversation

@KoBeWi

@KoBeWi KoBeWi commented Apr 24, 2024

Copy link
Copy Markdown
Member

Closes #17110
Closes godotengine/godot-proposals#10691

  • Text fields are replaced with buttons:
    • Select Existing Script/Scene - select a scene or script that will be added as autoload. This is the previous browse option, except the autoload is added immediately
    • Create Script Autoload - creates a new script and adds as autoload. This already existed btw, the script dialog was opening when you tried to Add autoload without a path
    • Create Scene Autoload - same as above, but creates a scene. The UX is a bit awkward, because you need to go through 2 dialogs, but maybe it's fine

Autoload name is assigned automatically from file name (or root name in case of scene) and there is basic validation to create valid identifier, as otherwise you'll be met with an error dialog. Hopefully it won't be a big problem. If you don't like auto-generated name, you can rename the autoload by double-clicking it in Tree (although the default name is fine in most cases, hence the text inputs were mostly useless).

godot.windows.editor.dev.x86_64_3O8K4gmvOh.mp4

I'm getting some errors about exclusive children™, though they already existed with the script dialog. Not sure how to fix.

@KoBeWi KoBeWi added this to the 4.x milestone Apr 24, 2024
@KoBeWi KoBeWi requested a review from a team April 24, 2024 20:41
@KoBeWi KoBeWi force-pushed the auutoload_revampire branch from d7033b3 to e4436ff Compare April 24, 2024 20:42
@KoBeWi KoBeWi changed the title Revamp autoload settings Apr 24, 2024
@KoBeWi KoBeWi requested a review from a team April 24, 2024 20:43
@KoBeWi KoBeWi force-pushed the auutoload_revampire branch 2 times, most recently from 194a488 to a477790 Compare April 24, 2024 21:00
@passivestar

Copy link
Copy Markdown
Contributor

A nitpick: so much text on the buttons is a bit overwhelming, no? "existing" and "autoload" are obvious from context

@YeldhamDev

Copy link
Copy Markdown
Member

Why are the buttons centered?

@KoBeWi

KoBeWi commented Apr 24, 2024

Copy link
Copy Markdown
Member Author

Why are the buttons centered?

There is an awkward empty space when they are aligned to one side.

@YeldhamDev

Copy link
Copy Markdown
Member

There is an awkward empty space when they are aligned to one side.

Still odd to have them like this, since everywhere else in the editor buttons tend to be aligned to one side when on the top.

@KoBeWi KoBeWi force-pushed the auutoload_revampire branch from a477790 to 14a5b3d Compare April 25, 2024 09:19
@KoBeWi

KoBeWi commented Apr 25, 2024

Copy link
Copy Markdown
Member Author

Less text and left align:
image

@tokengamedev

Copy link
Copy Markdown

Just want to check there was this scenario while selecting a script you can change the name of the node, which does not have to be the same name as the script (Ignore case)
I hope you can still edit the name of the Node.

Now couple of issues I found in 4.3:

  1. Double clicking on the path of the Autoload or the directory icon in the list -> closes the window.
  2. You should not be allowed to create two autoload variables with the same script file. Is there a use case to load the same script twice, then I may be wrong.

Also agree with @passivestar comments, I think Create Script and Create Scene will be fine as you are already under the autoload context

@KoBeWi

KoBeWi commented Sep 9, 2024

Copy link
Copy Markdown
Member Author

Double clicking on the path of the Autoload or the directory icon in the list -> closes the window.

That's intended. It opens the script in script editor.

You should not be allowed to create two autoload variables with the same script file. Is there a use case to load the same script twice, then I may be wrong.

There is no obvious use-case, but it's not wrong either. No reason to prevent that I think.

Also agree with passivestar comments, I think Create Script and Create Scene will be fine as you are already under the autoload context

image

@KoBeWi KoBeWi force-pushed the auutoload_revampire branch from 14a5b3d to fff7880 Compare September 9, 2024 14:15
@KoBeWi

KoBeWi commented Sep 9, 2024

Copy link
Copy Markdown
Member Author

Rebased and fixed some errors. Autoload dialog now uses its own SceneCreateDialog and no longer open the scene when created.

@KoBeWi KoBeWi force-pushed the auutoload_revampire branch from fff7880 to 4e4d155 Compare September 9, 2024 14:17
@tokengamedev

Copy link
Copy Markdown

Thanks @KoBeWi for the update.

@Zshandi

Zshandi commented Jun 15, 2025

Copy link
Copy Markdown
Contributor

I would love to see this in the next release of Godot! Let me know if there's anything I could do to help make that a reality 🙂

I especially like the change to have it use its own dialog for both the scene and script, rather than re-using the filesystem dock one as it was previously doing! It still behaves weirdly in that you can click out of the pop-up and it goes behind the project settings, though I think that's a much larger problem than just this (which I'm guessing already has it's own Issue somewhere, unless it's already fixed on latest master?).

@KoBeWi KoBeWi force-pushed the auutoload_revampire branch from 8acdea4 to 0da50d4 Compare June 18, 2025 09:44
@KoBeWi

KoBeWi commented Jun 18, 2025

Copy link
Copy Markdown
Member Author

Rebased.
I also deleted the Open button on the right, because you can double-click the path to do the same.
image

@Zshandi

Zshandi commented Jun 21, 2025

Copy link
Copy Markdown
Contributor

Rebased. I also deleted the Open button on the right, because you can double-click the path to do the same.

Nice, hope it gets in soon then!

I'm personally partial to having more than one way to do things in UIs (more likely users will discover it), however in this case I feel it was also counter-intuitive that a folder icon opened the file itself (rather than just revealing it in the file system dock). Great work overall!

@KoBeWi KoBeWi force-pushed the auutoload_revampire branch from 0da50d4 to 022448a Compare November 8, 2025 12:04
@Repiteo Repiteo requested a review from a team as a code owner February 17, 2026 20:11
@AdriaandeJongh AdriaandeJongh self-requested a review March 4, 2026 19:45
@Calinou

Calinou commented Mar 4, 2026

Copy link
Copy Markdown
Member

This fails to compile when rebased on top of master on my end:

In file included from ./editor/settings/action_map_editor.cpp:33,
                 from editor/settings/.scu/scu_editor_settings.gen.cpp:1:
./editor/settings/editor_autoload_settings.cpp: In constructor 'EditorAutoloadSettings::EditorAutoloadSettings()':
./core/object/callable_mp.h:216:66: error: no matching function for call to 'create_custom_callable_function_pointer(EditorFileDialog*&, const char [37], void (FileDialog::*)())'
  216 | #define callable_mp(I, M) create_custom_callable_function_pointer(I, #M, M)
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
./editor/settings/editor_autoload_settings.cpp:889:58: note: in expansion of macro 'callable_mp'
  889 |         browse_button->connect(SceneStringName(pressed), callable_mp(autoload_file_dialog, &EditorFileDialog::popup_file_dialog));
      |                                                          ^~~~~~~~~~~
./core/object/callable_mp.h:216:66: note: there are 4 candidates
  216 | #define callable_mp(I, M) create_custom_callable_function_pointer(I, #M, M)
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
./editor/settings/editor_autoload_settings.cpp:889:58: note: in expansion of macro 'callable_mp'
  889 |         browse_button->connect(SceneStringName(pressed), callable_mp(autoload_file_dialog, &EditorFileDialog::popup_file_dialog));
      |                                                          ^~~~~~~~~~~
./core/object/callable_mp.h:119:10: note: candidate 1: 'template<class T, class ... P> Callable create_custom_callable_function_pointer(T*, const char*, void (T::*)(P ...))'
  119 | Callable create_custom_callable_function_pointer(T *p_instance,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./core/object/callable_mp.h:119:10: note: template argument deduction/substitution failed:
./core/object/callable_mp.h:216:66: note:   deduced conflicting types for parameter 'T' ('EditorFileDialog' and 'FileDialog')
  216 | #define callable_mp(I, M) create_custom_callable_function_pointer(I, #M, M)
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
./editor/settings/editor_autoload_settings.cpp:889:58: note: in expansion of macro 'callable_mp'
  889 |         browse_button->connect(SceneStringName(pressed), callable_mp(autoload_file_dialog, &EditorFileDialog::popup_file_dialog));
      |                                                          ^~~~~~~~~~~
./core/object/callable_mp.h:133:10: note: candidate 2: 'template<class T, class R, class ... P> Callable create_custom_callable_function_pointer(T*, const char*, R (T::*)(P ...))'
  133 | Callable create_custom_callable_function_pointer(T *p_instance,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./core/object/callable_mp.h:133:10: note: template argument deduction/substitution failed:
./core/object/callable_mp.h:216:66: note:   deduced conflicting types for parameter 'T' ('EditorFileDialog' and 'FileDialog')
  216 | #define callable_mp(I, M) create_custom_callable_function_pointer(I, #M, M)
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
./editor/settings/editor_autoload_settings.cpp:889:58: note: in expansion of macro 'callable_mp'
  889 |         browse_button->connect(SceneStringName(pressed), callable_mp(autoload_file_dialog, &EditorFileDialog::popup_file_dialog));
      |                                                          ^~~~~~~~~~~
./core/object/callable_mp.h:188:10: note: candidate 3: 'template<class T, class ... P> Callable create_custom_callable_function_pointer(T*, const char*, void (T::*)(P ...) const)'
  188 | Callable create_custom_callable_function_pointer(T *p_instance,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./core/object/callable_mp.h:188:10: note: template argument deduction/substitution failed:
./core/object/callable_mp.h:216:66: note:   types 'void (T::)(P ...) const' and 'void (FileDialog::)()' have incompatible cv-qualifiers
  216 | #define callable_mp(I, M) create_custom_callable_function_pointer(I, #M, M)
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
./editor/settings/editor_autoload_settings.cpp:889:58: note: in expansion of macro 'callable_mp'
  889 |         browse_button->connect(SceneStringName(pressed), callable_mp(autoload_file_dialog, &EditorFileDialog::popup_file_dialog));
      |                                                          ^~~~~~~~~~~
./core/object/callable_mp.h:202:10: note: candidate 4: 'template<class T, class R, class ... P> Callable create_custom_callable_function_pointer(T*, const char*, R (T::*)(P ...) const)'
  202 | Callable create_custom_callable_function_pointer(T *p_instance,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./core/object/callable_mp.h:202:10: note: template argument deduction/substitution failed:
./core/object/callable_mp.h:216:66: note:   types 'R (T::)(P ...) const' and 'void (FileDialog::)()' have incompatible cv-qualifiers
  216 | #define callable_mp(I, M) create_custom_callable_function_pointer(I, #M, M)
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
./editor/settings/editor_autoload_settings.cpp:889:58: note: in expansion of macro 'callable_mp'
  889 |         browse_button->connect(SceneStringName(pressed), callable_mp(autoload_file_dialog, &EditorFileDialog::popup_file_dialog));
      |                                                          ^~~~~~~~~~~
scons: *** [bin/obj/editor/settings/.scu/scu_editor_settings.gen.linuxbsd.editor.x86_64.o] Error 1
scons: building terminated because of errors.
@KoBeWi KoBeWi force-pushed the auutoload_revampire branch 2 times, most recently from de05250 to a08c4e4 Compare March 4, 2026 22:35
@KoBeWi

KoBeWi commented Mar 4, 2026

Copy link
Copy Markdown
Member Author

Try now.

@passivestar passivestar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, works as expected and the UX is a clear improvement over the previous one

@AdriaandeJongh AdriaandeJongh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also tested this and found this little icon on hover (it doesn't do anything):
Screenshot 2026-03-05 at 09 42 11

And while we're at it: would be nice to give the headers a tooltip. Especially the Global Variable could use something along the lines of "If enabled, this autoload can be accessed by scripts through $Name where 'Name' is replaced with the name of the autoload".

@passivestar

passivestar commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Also tested this and found this little icon on hover (it doesn't do anything)

It's not an icon but the main tree cell that the buttons are attached to. I looked briefly into getting rid of it while working on the UI for 4.6 but afair there's no easy way to get rid of it. Ideally we should allow adding any control nodes to tree cells (or allow custom drawing/input logic in cells) because this system with icon buttons on the right is very limiting. Either way this issue is unrelated to this PR

Comment thread editor/settings/editor_autoload_settings.cpp Outdated
@KoBeWi KoBeWi force-pushed the auutoload_revampire branch from a08c4e4 to 52c2628 Compare March 5, 2026 11:20
@AdriaandeJongh AdriaandeJongh self-requested a review March 5, 2026 11:24
@KoBeWi

KoBeWi commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

Added tooltips.
image

@AdriaandeJongh AdriaandeJongh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the bug I mentioned above isn't in the scope of this PR, then the rest looks good to me.

@dagarsar

dagarsar commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

It's not an icon but the main tree cell that the buttons are attached to. I looked briefly into getting rid of it while working on the UI for 4.6 but afair there's no easy way to get rid of it. Ideally we should allow adding any control nodes to tree cells (or allow custom drawing/input logic in cells) because this system with icon buttons on the right is very limiting. Either way this issue is unrelated to this PR

You can already set a tree cell to CELL_MODE_CUSTOM and draw whatever you want, and get the clicks through the custom_item_clicked signal. I think it would not be aware of hover and pressed states though, and maybe that's enough to not change it and leave it as it is.

@KoBeWi

KoBeWi commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

CELL_MODE_CUSTOM still draws regular TreeItem elements (text, hover), the custom drawing only replaces the background.

@dagarsar

dagarsar commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

CELL_MODE_CUSTOM still draws regular TreeItem elements (text, hover), the custom drawing only replaces the background.

Oh right, then I'd say drawing the background using the tree's button stylebox and make this cell with 3 buttons 3 cells with that behaviour would fall under this PR's scope

@KoBeWi

KoBeWi commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

This is a pre-existing problem and does not affect creating autoloads, so IMO it is out of scope. Feel free to open an issue, so it's tracked properly.

@akien-mga akien-mga modified the milestones: 4.x, 4.7 Mar 5, 2026
@akien-mga akien-mga merged commit b12b7bc into godotengine:master Mar 5, 2026
20 checks passed
@akien-mga

Copy link
Copy Markdown
Member

Thanks!

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